From patchwork Sat Oct 1 16:22:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 611388 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp276406pvb; Sat, 1 Oct 2022 09:35:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7PUgXWe/3Qf7VBKwEQZI6eBmci8QXJZWixQCVFLaVlM72I+KyVHXANhHiJnX8iMmd31Wuy X-Received: by 2002:a0c:aa48:0:b0:4aa:b039:35be with SMTP id e8-20020a0caa48000000b004aab03935bemr11144827qvb.57.1664642108562; Sat, 01 Oct 2022 09:35:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664642108; cv=none; d=google.com; s=arc-20160816; b=ukXo0eqOprEDXMTtQd0QwY25GTyXeFqRTAWNVDeo6DpkGhyoLw6SiCJElw38dHhVW3 JW/tboMKEbqjXANQHTum8mzwdyhr+8n/Vv2jGdTPRQK7M7I/t/pHJbvz/hdvqoOQE23M 9ACQLEfIiCccReikWv5Yt19zNonyTJ+17eSo5eHCNCXI24gLlfbzxd9N+qVqOOuXbAIt mqdJLad3f1VIZ2WqVsnOyM+AQIayV7MXELQyOoEAWVP++IGY9UTlZFKoCiJM1/WAjiFT /5TUkAY0Wt2xJD/RKhJjBx/E5pSgFiCiuGz1qtMm+QqytngCfTSL7LoaDxNNnRjz58Ag RvdA== 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=YUgoT+b6fWGQnaxpAgaCymNUj0JMoRjdbdEo3IB0Hrw=; b=jkR9hUxmXJzw/GjnlwSMrw7xW9TOZu7P0V+m6+HY+dISna09fLhXJCnpXy3WMYPiaM t1CetevO6aCYk1v4yOk0RRcf7+VGADbjKbZoob68rTB8qdZF4WJ0SnWiP+KCBF2ukEaz hir09eXApgoefIQs367H5lIDSNW1HCU4vCUThQBbTkxXEwz/9+OS1Km9du92AmmqbS+/ hhCYILWiVrHQthfKNWUbWT8tY01K82HW3me07YnC3syhDCTp+acmtiv+WErgwvpti//S ZHAb5OAJ0hJyTbzTVs2Zc54SizGqarz+wqCSxYeQeW2dYcfaSSZ/Zq7NyqdHg2T/VRey MpNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nMZYSGKj; 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 fq11-20020a056214258b00b004ad7d03fa59si2770601qvb.370.2022.10.01.09.35.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Oct 2022 09:35:08 -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=nMZYSGKj; 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]:42812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oefSG-0004Tv-2N for patch@linaro.org; Sat, 01 Oct 2022 12:35:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oefHW-0006kY-9h for qemu-devel@nongnu.org; Sat, 01 Oct 2022 12:24:05 -0400 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]:38557) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oefHO-0006Gl-DI for qemu-devel@nongnu.org; Sat, 01 Oct 2022 12:23:58 -0400 Received: by mail-qk1-x734.google.com with SMTP id 3so4547875qka.5 for ; Sat, 01 Oct 2022 09:23:50 -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; bh=YUgoT+b6fWGQnaxpAgaCymNUj0JMoRjdbdEo3IB0Hrw=; b=nMZYSGKjI7zFJxikM0HB+50DbcvuJSECCb1K5gTS3hd7piNpaXDi0aduszmqjp4CQ9 1YwSngP2WKtuRB4HEdYqc0BlD5PvyQ0BMQht6uDXYOxS3KALEhdDfu0PUpd+9N6uGViS s0b6nHozQ8bKCtX9WjXrqh4FBVgJR/o4oksrBAY4Vh1dnAWP0TQSE6qXY2z6p4t6S34m eHJvtUf6HNro2+vYHF+RHupka1YB3hsUNXQRk9eka2Yn2mQbi+QGZyjvTWv+RaadpQP9 //YClP1Lelx76oCJ+q5ozdFHF0PsBSsN2Y9LGyhrFbjfRRHFeZUKxrAlANWqGX+u9K/D 0+3w== 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; bh=YUgoT+b6fWGQnaxpAgaCymNUj0JMoRjdbdEo3IB0Hrw=; b=QrVCME/+YxkkotARIM4WJ7A04RDnJXF1WtRtuPeN0V8qvT7IKydF8stu+XlgOnbfwg 0R2dA4Keul4g7D9Pf19RPH/UMVLLp1AolRMZuQY3JqYU3cojxXrypIaTiwRQI3u2muAq 6rix1gcHnD1IxJ4uES/WrVy54q2A/gzbJOdNIOmrRxbGZjMRtyl+WjmILTk3ls1yrfxv 5P+O4/UjEqzDdrxBbSnutUW1Lh/8vwHJOeH6/T0YhJCiVMgklXGi34042VKXQm2vzNH/ j6L6fVq1q50c77E50reaE5E8w+JStQQOkaB3MD98GclnseZeSpT6jg4lpY+DmVNMwv9M M1ug== X-Gm-Message-State: ACrzQf1uKbxbQMTJ9vxZVXplLLSls2UGqNGaRD+9//0/59OHxgSfdcX0 2UmjrIVJfhZf+eXQ7PzaVSUqcwXxH6iiCg== X-Received: by 2002:a37:38d:0:b0:6cd:fd39:10e5 with SMTP id 135-20020a37038d000000b006cdfd3910e5mr9535242qkd.784.1664641430025; Sat, 01 Oct 2022 09:23:50 -0700 (PDT) Received: from stoup.. ([2605:ef80:8084:91a4:f7cb:db31:c505:b931]) by smtp.gmail.com with ESMTPSA id t4-20020a37ea04000000b006d1d8fdea8asm4387445qkj.85.2022.10.01.09.23.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Oct 2022 09:23:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v3 11/42] target/arm: Reorg regime_translation_disabled Date: Sat, 1 Oct 2022 09:22:47 -0700 Message-Id: <20221001162318.153420-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221001162318.153420-1-richard.henderson@linaro.org> References: <20221001162318.153420-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::734; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x734.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use a switch on mmu_idx for the a-profile indexes, instead of three different if's vs regime_el and arm_mmu_idx_is_stage1_of_2. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/ptw.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 9be11f1673..2875ea881c 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -148,21 +148,39 @@ static bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx, hcr_el2 = arm_hcr_el2_eff(env); - if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) { + switch (mmu_idx) { + case ARMMMUIdx_Stage2: + case ARMMMUIdx_Stage2_S: /* HCR.DC means HCR.VM behaves as 1 */ return (hcr_el2 & (HCR_DC | HCR_VM)) == 0; - } - if (hcr_el2 & HCR_TGE) { + case ARMMMUIdx_E10_0: + case ARMMMUIdx_E10_1: + case ARMMMUIdx_E10_1_PAN: /* TGE means that NS EL0/1 act as if SCTLR_EL1.M is zero */ - if (!is_secure && regime_el(env, mmu_idx) == 1) { + if (!is_secure && (hcr_el2 & HCR_TGE)) { return true; } - } + break; - if ((hcr_el2 & HCR_DC) && arm_mmu_idx_is_stage1_of_2(mmu_idx)) { + case ARMMMUIdx_Stage1_E0: + case ARMMMUIdx_Stage1_E1: + case ARMMMUIdx_Stage1_E1_PAN: /* HCR.DC means SCTLR_EL1.M behaves as 0 */ - return true; + if (hcr_el2 & HCR_DC) { + return true; + } + break; + + case ARMMMUIdx_E20_0: + case ARMMMUIdx_E20_2: + case ARMMMUIdx_E20_2_PAN: + case ARMMMUIdx_E2: + case ARMMMUIdx_E3: + break; + + default: + g_assert_not_reached(); } return (regime_sctlr(env, mmu_idx) & SCTLR_M) == 0;