From patchwork Tue Oct 25 16:39:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 618123 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp3518777pvb; Tue, 25 Oct 2022 09:46:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Lag4LpNaWz7S7drvctCNrAPjMcO2nypw8f6OSFCy0ICLKyVjn36sAafVG6IMjNSZhKmJF X-Received: by 2002:a05:622a:5d1:b0:39a:b847:a645 with SMTP id d17-20020a05622a05d100b0039ab847a645mr32744172qtb.410.1666716390207; Tue, 25 Oct 2022 09:46:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666716390; cv=none; d=google.com; s=arc-20160816; b=OtFee/8uI+JRhJPL73vxqulyBIVcxfUzLcvngCJ1G5/lAkJeQQQbnPGpAw0Iau2DMl b4/YaI+qaDItOSvLhk03i8uYjxcFoEDfPRaK7Qa60yhFNk8Vtr3OKxn6+P4QQhbAc9vv Be3Xpkvu5il+hZZFI8b9ITfMCN7DR1PtEpx7Carl1S6+EVqESx7e/+2cR2jVV/sosIJ+ TmvMDSDHIHEpvVZuLzXL3g1gJj3zTabkYOTMp0A6hR2K7cFdCV2FVhTuWg996gVys4rY /4/uO0c6RUtYsv+iclc4vjR9ggIcH091z1JxpZ/VJYwkmorUaA052EE3uOQKL33WAPCF 4EcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=gxu0mniabCTeOPg3dGH8ocxPQsfgLf2PZIHByV3HkDY=; b=SiHbtr96sptlTqGsTbsFKEi+7SkZz2wQHi21K8uZcB5akzoNSSWTyJ7nB7tPcWlRV9 cm+QtYNp5UD1zU3eF/Zie3h8lK1EpNxnpP7uAyN9h1JKKy73pPe//8/0W6inB+6ggAmK ALQNwoOUcw/RHT1YAx3ZQ+A6QhioCsUwePnu+iJSP5C0BN4+bdLXxidyUaLtFyEqec+n oTMyM3kAJawrwk9TfR37FqSaUP7g64JB25NhldkrkGiM/MDqpelkStryYNPF1YneW5RS IldgvbbUn+vZdF0ilsUzouuauH6R5Bahj7adzSWZwP0mrp1BiV+XD43xdpMrQdl7zVRb EN7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jEBZSTpl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r15-20020a05620a298f00b006ce1c3e8439si2374798qkp.584.2022.10.25.09.46.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Oct 2022 09:46:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jEBZSTpl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMyq-0006Th-6k; Tue, 25 Oct 2022 12:40:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1onMyg-0006Ck-1f for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:34 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyO-0001dB-RO for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:25 -0400 Received: by mail-wr1-x429.google.com with SMTP id bk15so22061269wrb.13 for ; Tue, 25 Oct 2022 09:40:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=gxu0mniabCTeOPg3dGH8ocxPQsfgLf2PZIHByV3HkDY=; b=jEBZSTplR+MxR0uq6vfPiEC2Z3YGy0W8YQWv50NrBCs1GdelKLz+2k2xmjoqEamjGG R8Qr5YjjfNbUIJtU9bVFmdYD0xA6+TdwDJabeJ5zqlGx/y7qhueTNRkSxI/dxBhj/wr2 0fKzYK+vQxDV7RpJAHvpFCQ2faT0/bs7BEpEd274M2+BuVhoS6jmTYoI+aVXuKEqQzt0 z219BJEXK8qJ5bdSOFXbaA1xajA9aEAl1vEP3BL1ShHAxADPDQ6lFfcdrvFGT3HgYXeh hbwjOtXef2tEK4MAsoCrI6OtY2Pvw4xu8GnL8BjK5+O/ZBpx5xPYYZBywdPagC7L+H62 K0pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gxu0mniabCTeOPg3dGH8ocxPQsfgLf2PZIHByV3HkDY=; b=P+IzX3QgBAhwaUJ8nWDvEfKaLQNziq8Wd/aXPr8kr5u5z+FSQQCgfbi04D88pWuCSp GvIyZjR+SrrZHLcxmifU/r1pRm1W4yJ1ejWX1reqAvBBXZJ1pMtEoTz2zq6Yznk7SYXn XXh6+7WdLKcCWqBH1DEPcXbgwvwIPK/U2ib7QHbNBCuyB47g6tLAl/haEdoB9JzGvitc +krHCVE83Lm5cLbXMToLJQh1YLPjC4LW9W/Ea3mmORJkYrnqKG9xCti6nb75KA9sIs7f tt1W3pEOtHHz1E4G8PYZgUHhzjVEajBuo8caEtHM5lkMnrPokoF9p69W1FzhI2365eLn hpUQ== X-Gm-Message-State: ACrzQf0Sc+CEv+nsq3tGZdTeDZKTb/1bcpNvg3Ihj4cNGJLPAzEkdbxa LmqMQnQ7kCbX9+z/U6oqDiqb1d37yZYoNw== X-Received: by 2002:a05:6000:16c3:b0:22e:c6fd:2676 with SMTP id h3-20020a05600016c300b0022ec6fd2676mr25899358wrf.141.1666716015395; Tue, 25 Oct 2022 09:40:15 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z12-20020a05600c220c00b003cd9c26a0basm2971084wml.40.2022.10.25.09.40.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:14 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 17/30] target/arm: Tidy merging of attributes from descriptor and table Date: Tue, 25 Oct 2022 17:39:39 +0100 Message-Id: <20221025163952.4131046-18-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221025163952.4131046-1-peter.maydell@linaro.org> References: <20221025163952.4131046-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson Replace some gotos with some nested if statements. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée Message-id: 20221024051851.3074715-12-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/ptw.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 79a0ef45c79..73b3c37b23f 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1322,27 +1322,25 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, page_size = (1ULL << ((stride * (4 - level)) + 3)); descaddr &= ~(hwaddr)(page_size - 1); descaddr |= (address & (page_size - 1)); - /* Extract attributes from the descriptor */ - attrs = descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 14)); - if (regime_is_stage2(mmu_idx)) { - /* Stage 2 table descriptors do not include any attribute fields */ - goto skip_attrs; - } - /* Merge in attributes from table descriptors */ - attrs |= nstable << 5; /* NS */ - if (param.hpd) { - /* HPD disables all the table attributes except NSTable. */ - goto skip_attrs; - } - attrs |= extract64(tableattrs, 0, 2) << 53; /* XN, PXN */ /* - * The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1 - * means "force PL1 access only", which means forcing AP[1] to 0. + * Extract attributes from the descriptor, and apply table descriptors. + * Stage 2 table descriptors do not include any attribute fields. + * HPD disables all the table attributes except NSTable. */ - attrs &= ~(extract64(tableattrs, 2, 1) << 6); /* !APT[0] => AP[1] */ - attrs |= extract32(tableattrs, 3, 1) << 7; /* APT[1] => AP[2] */ - skip_attrs: + attrs = descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 14)); + if (!regime_is_stage2(mmu_idx)) { + attrs |= nstable << 5; /* NS */ + if (!param.hpd) { + attrs |= extract64(tableattrs, 0, 2) << 53; /* XN, PXN */ + /* + * The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1 + * means "force PL1 access only", which means forcing AP[1] to 0. + */ + attrs &= ~(extract64(tableattrs, 2, 1) << 6); /* !APT[0] => AP[1] */ + attrs |= extract32(tableattrs, 3, 1) << 7; /* APT[1] => AP[2] */ + } + } /* * Here descaddr is the final physical address, and attributes