From patchwork Thu Oct 20 22:35:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 616812 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp579447pvb; Thu, 20 Oct 2022 15:55:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ZDN7LIXjRjmrWuWhWWkEJJ1VTyv29Y0lBbnqc9y378GSmjoRyhVGnfGEwPcWEqAaRnqku X-Received: by 2002:a37:be02:0:b0:6ed:1b73:a5a5 with SMTP id o2-20020a37be02000000b006ed1b73a5a5mr10942004qkf.214.1666306549472; Thu, 20 Oct 2022 15:55:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666306549; cv=none; d=google.com; s=arc-20160816; b=ZbWxqtIpbxq1Pei0bx/pJY0bzAt5QBNc9mXmUCfW+UWLrfFZhQEXcUq5bWuExlRQdm JJ+WXPfDYi5VejycZYzs3ft3Hq7ILlF8MgB5qIZvdtI+YSSvjNrSA8HMqr72Wvwbtk0c 6pWcmo3crSydiv8699fuNnEQYYSHdRMz2gd6vaOqT51QU5Lv4Ifxsasod3X+xpR5hnF7 YIfNHDEkjusxe5xTtxPINUy04XBH2Qs2+k0VamLpB+pqnjExdgZlklzARrAtbMa3S4B5 VbzV1T0TAK5xEQnbkr3SsSw2mzRN/UMbLArqNKgavMUCV2V8fU3zcfIQ33OC1w/ApdPC 8zog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=GurYN5eM5ASmrAS3IhHR+unhisIkdfoZKXFyT1rxT6E=; b=Z946Q4SFZotuTnMmkO0ecoKmZ2qD3JnaPWi17pGdkoec276ucudhEoE8JoHZiakbgR zEK9ZtJTgzjjD6Q4PiWCBmiQz89gTmCMBhHlweCXxFKWZtJoIqEXkIMVI49APy+SdRYQ dUOmhEnnJBfrho9qGSrPIZn2YPIefE4O52GlNaegH1Msob+bR4v+auXEB5OB8Twr2SLj DenAB7uM0Fvin4R1YxTLT8X1/5GFehLdGIcYihGA9XBfazE1dPoYJUcIO/YjeYokJkuB vzaaN6e1cqHkkMFaEOWUAE6Zx7hgBYDFpaMhQ6/xMZPsPhrgyKjfbkYLKOGTLm+Mfvvz Hpbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="oBObJo/S"; 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 m20-20020a05620a24d400b006b88d06dc1csi12720924qkn.565.2022.10.20.15.55.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Oct 2022 15:55:49 -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="oBObJo/S"; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oleS4-0001og-T3 for patch@linaro.org; Thu, 20 Oct 2022 18:55:48 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oleA5-0007wB-Ib for patch@linaro.org; Thu, 20 Oct 2022 18:37:13 -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 1oleA0-0007pQ-ES for qemu-devel@nongnu.org; Thu, 20 Oct 2022 18:37:08 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ole9v-00015w-RS for qemu-devel@nongnu.org; Thu, 20 Oct 2022 18:37:08 -0400 Received: by mail-pg1-x52c.google.com with SMTP id l6so860814pgu.7 for ; Thu, 20 Oct 2022 15:37:03 -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:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GurYN5eM5ASmrAS3IhHR+unhisIkdfoZKXFyT1rxT6E=; b=oBObJo/SuGrzvYu8v74JYIYpSShHPLlCRFALgt+AAAHK/VxmrPn+Gcm9uIfq3JnrP7 9H7bir4UQGYsNwmKaeSjqJ5VSIYXKiw1+p1uM1iEs+qGXjeO+1n3Sn+bz431Y0o7p+hB 1+3HsZiZj3lchECBJTx7WuLSIyz5I+Fmcss3H5mvpXEhDb8xHLAZKNsq14YRMz7db+vD izNATLNZ8Sj1E5MAAWwngxFJSeyEm5qFzWTRbx0mPkzCGk5+CZMT/5w/IV/0XSX7ixXm hq1/CQg5/5AX8dWbyU5xnkO+apixXrzrBIstuht3OR62KfWKru8pfVqb+Z1YtpA37LeY 7nnw== 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:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GurYN5eM5ASmrAS3IhHR+unhisIkdfoZKXFyT1rxT6E=; b=XPYpS76buFEvPtYpMFwSr5pMjEpen8La5G9qRPZ0GfUxLkTLOL8rjtVFiaoMj4UCKy opLtAtnj6qNx/Mk7CgafvVrSbea0szp904hYi/7XqxNpGNorHIf4EsY64x0DHj36t/mT E1VdK20F2v0xIPL6w0ewNw/UGm/WxUfFggwuTnsOokWkyiefkFhpn2qmZe+8L8vcG3+N Ll/DOHcW5BpE68XGnnHh5z0s5pEYanqP8b8/AHhS8f5/hLdAdaKneaRcwqhOnEQV2k4J Hre0Kfwicz2HvZwLfRD0Lfzw7K6vU5uKcxEn1VxYb5N8PREwh6e/lh5OLRqNV75e08Jz jNWQ== X-Gm-Message-State: ACrzQf1aSXcOVsalB07bqX+NjOBF2j2OVxvhgdfI3TdwBdCNpALCy3I8 M3d8AA6P9FOrmjqArSLktnxGQrJBn6gjjP5M X-Received: by 2002:a05:6a00:a8f:b0:563:3a3f:9d5c with SMTP id b15-20020a056a000a8f00b005633a3f9d5cmr16186633pfl.50.1666305422377; Thu, 20 Oct 2022 15:37:02 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id r10-20020aa7988a000000b0054cd16c9f6bsm13753841pfl.200.2022.10.20.15.36.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 15:37:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH v5 11/14] target/arm: Tidy merging of attributes from descriptor and table Date: Fri, 21 Oct 2022 08:35:45 +1000 Message-Id: <20221020223548.2310496-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221020223548.2310496-1-richard.henderson@linaro.org> References: <20221020223548.2310496-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52c.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=unavailable 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Replace some gotos with some nested if statements. Signed-off-by: Richard Henderson --- 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 cb2e9072ec..165e70d044 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1341,27 +1341,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