From patchwork Sun Jul 3 08:23:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 586831 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5036:0:0:0:0 with SMTP id e22csp2927566mab; Sun, 3 Jul 2022 02:03:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tqs2YvdA3MBIwKpYHdSyK29Qrbx961syjfYPgiF2Hku68Mj72XR7qhvyTV6GJM+1D2TXLj X-Received: by 2002:a25:ec0b:0:b0:669:b376:8bf5 with SMTP id j11-20020a25ec0b000000b00669b3768bf5mr24623925ybh.111.1656839023225; Sun, 03 Jul 2022 02:03:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656839023; cv=none; d=google.com; s=arc-20160816; b=neP4MCSjIJHMGvOdee6nkhOqFaVKCZvhUYxzXVepg9zf2cx2P2+a2/WGjcQDdn7rUP b77ysSFl41VeKfAGcKz5J9KI3byhu9Sf4emi2AJufQ1hNe0MI78zZuLIhcpIhF082Kvy 1ZcN24bJ5ePS6Jkcv5rF3JeQ6zHVBy16dOHNO7sJ4UQDo5j5D4F3EusvQLPMSgPL4jYn 5lxtl0ui0XlGFEHeHmvy878ysmcfBHrfZCYXNrxG6cyqz5Fb+LSYbHKsRCkZAYDoFaSg ZNfh8fGcrxROIarmQu69oe3BAhBLguin4FIgMy6Hdv28Oi1k1zxFSfAY2tEHCEdtUN5C ySkw== 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=/RaZZc14+S6hYz1OWvaDxJGxtM/J8YX/Y05Pry77JbE=; b=XiPzDfUeEnY++6nhHHl7jf5tCKQ+k/E3+HB0aCtT2NnNMp+ohFjgUZ+p8FA2glqmS/ Ox7yb5m0uFE/gFKWkm7DHaZeBghA88oUCOFLH7QSZZaUftW1JjsVikLk4qF3k4p4tSub 00vtNqvgTI7ETrDP7eI6Pw9WLcUz5ScANBbAeQ2AYMAA70HXfQozdwS/fFEOHLGI7SO+ PMaRyMR/NY5ZARmytgo0L1u2JqqwRD3AIt3/ycHAeR78MhEMGT2Xanym/gRza8/uL0kY 0mAqlRiSiLPizNO1LPNZkdcZDxEa6FrcdEZmFMZiBiLHtNOVlJu5n+Ztjk15e8sBAMyJ hlhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F2wMatOZ; 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 205-20020a2501d6000000b0066e340a1dc2si2055564ybb.85.2022.07.03.02.03.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 03 Jul 2022 02:03:43 -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=F2wMatOZ; 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]:40970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o7vW2-0005LF-Ma for patch@linaro.org; Sun, 03 Jul 2022 05:03:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53726) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7uvj-00016K-5Y for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:26:11 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:35819) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o7uvh-0006Gc-JT for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:26:10 -0400 Received: by mail-pf1-x430.google.com with SMTP id x4so6360712pfq.2 for ; Sun, 03 Jul 2022 01:26:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/RaZZc14+S6hYz1OWvaDxJGxtM/J8YX/Y05Pry77JbE=; b=F2wMatOZDFdCuj5e7iz8uCWWLVb7MO27GNZMQeTu9MRtW0MbdNr9oYQebvyhXeTR8U ubxey3BwjLRPqoVNx/7OkfIfW5LHV/0K2WdvbCAh2GqGYz5rpW8rQO8d46kFa8Xk6iLz IKrYPUcGCy6H9Ewe7OAWHXKSU0c+ej+GDZFqolD/Ix/4rhpLkeo6xDIUZEfjdo2ujl5n MbbtZ+9gQagRgrooBBQOT39BQFRQN6eLpVLhIiEoRIRF9JB6D7vOIFMavo0x//xZ8R16 1PGkBGzkdU8k3BsP0fzv2ChNtaWnQjzMZkMKL3n13K+/BmjvUYPMEa+iWU/DK0rpT7Wm MKqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/RaZZc14+S6hYz1OWvaDxJGxtM/J8YX/Y05Pry77JbE=; b=cYV0FyTaWRDYA0guavJ+cXhns/yD43FbpI3IbGS6VpSc/2w4u+Q6IvLWFqZuUw8q+9 Qkpyuq67Y8MASCdhhF/XQZh6oAjtMEjGJEKaqyt/mWBPEu9+vdfwhNsJJyLLtgFFpDW8 dvVLpR+ik7GeRuPgYzgBq8nE+9EweU8ZVaLZ1ve2/2hlg/3tTZEJt12JhBxik/aFgKpn 0adw3B9z8XomioPnxHb691h4OXgkUZtMs+RFy7Ae21yAPwXJm/KOOranfrT6ncWNTG8R LIb+uSJmp7XaX8MFyf8PnIx9v7Vpfh+D2z5OXRpSlPgtK/qJY1KmN21jj7SSIhgEquyV 8lhQ== X-Gm-Message-State: AJIora+Gx03bh/Y4ogsmTmrvawjpdulz2WkTGEh5HUnCZQCl+Z3aA2ED avaOl1dDa+MbVWMI2DnRfHKoYbK0vBVXpcYy X-Received: by 2002:a63:e705:0:b0:3fd:fb59:bd7f with SMTP id b5-20020a63e705000000b003fdfb59bd7fmr19055667pgi.505.1656836768422; Sun, 03 Jul 2022 01:26:08 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id im22-20020a170902bb1600b0016a3f9e528asm13569112plb.57.2022.07.03.01.26.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 01:26:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 34/62] target/arm: Reorg regime_translation_disabled Date: Sun, 3 Jul 2022 13:53:51 +0530 Message-Id: <20220703082419.770989-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220703082419.770989-1-richard.henderson@linaro.org> References: <20220703082419.770989-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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, T_SCC_BODY_TEXT_LINE=-0.01 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. 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 1fb4d44600..8b80716e38 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;