From patchwork Mon Oct 10 14:27:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 613731 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2010881pvb; Mon, 10 Oct 2022 07:28:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7XzhzAyQ4qSrfNHnDLj+B1z6SIizvZ3gDHSNK+N4ZSyFLafSQmhCaAeTl8IirO2uXlhi0m X-Received: by 2002:a05:622a:11d1:b0:394:60a0:4a41 with SMTP id n17-20020a05622a11d100b0039460a04a41mr14823712qtk.571.1665412129066; Mon, 10 Oct 2022 07:28:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665412129; cv=none; d=google.com; s=arc-20160816; b=K1t07u1u89MtxO1ztDqicTFzxwqsLWIRZ4KsoMHI0KnJXABZJenrZypLAkmnOlJf8o 4zPWuz4427Lmk7n/H5QTSP8KG0UI4xGBXXPNlCfYUnjkCODpv1IAFjf5qoLHjZ9R18aK r4F3L49R99gaJVQxtn4/aNL2Br/NRef5yFIuCZQru5G2MZOI5janZGaN4qKBpJ8use4z 9+ucBD75cFYEAp0y991eS85FgMwQQWWAYobyOrPOJWrEJ2TT7MVKdyONAIR6acTrIfH5 UDbU2fpgRg+BibXAfN8UYNg2URCyHdgLIxtWKMu+59das3p0U7XmVQr/QbpOsmknARQa eR5w== 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:to:from :dkim-signature; bh=UhrnEzupfDW4VUrWZYS+8MEh7LjRrlG3/gLMwULTgSk=; b=alsOlBsoBj8bpe34d+0zamr3rCFa+m9ofXUz3skWdU2q/4TWJzr5mCSck1kBitI1HN bO6cw/JrodNAKfG/i+JidF1XEn/3M4PM536KzVmaXhwkKovdA1JxXy+U4LWgeoFL+kgC zAP0Lmf/IeobkYWYTPBhE4eb/+0YuFiPHyFzcQl/mE8wXnAzH8So+K66Uca0RfrXmMJw t551IKroQS0amHPa7nT6R9LmbbdFgxTEuoWTcB35vofvTva0zEGubQluRsHzu0LBCJZV 5D2Z/pjoiwIukQNvy2iXjYz4ZMTF+wiMscFw/bKNWD4Ar6eaQsrf8/Lc5dgVu2YqBZb0 qHbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kZeEGwuz; 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 ck15-20020a05622a230f00b00342f844e320si5724219qtb.259.2022.10.10.07.28.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 07:28: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=kZeEGwuz; 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]:57948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohtlw-0005x1-Ht for patch@linaro.org; Mon, 10 Oct 2022 10:28:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55762) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohtkq-0005v0-Ki for qemu-devel@nongnu.org; Mon, 10 Oct 2022 10:27:40 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:34388) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ohtkp-0005Xn-13 for qemu-devel@nongnu.org; Mon, 10 Oct 2022 10:27:40 -0400 Received: by mail-wr1-x429.google.com with SMTP id b4so17334114wrs.1 for ; Mon, 10 Oct 2022 07:27:38 -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=UhrnEzupfDW4VUrWZYS+8MEh7LjRrlG3/gLMwULTgSk=; b=kZeEGwuz74XaSMz02YTAoSWNHvRdc1H83RRD/mRiZayT+5Ry+ggOWnCzCp0wkwcGRh 3qvYz8Z88dNf0mV2v7ZQI7s/j/o8xdI7SCzbzVc0SkH0WpyeshzeqNJes4eZUgA2x8XZ GYrkEX5rlk1cpMjNPQWJ03Y114p9qmmjOgrRPcZilrPjNGgKBqLxJuJ4b7IRtmAvlmdg ncjcrXFx/XB9TkgN6p2iU4+Phslu3sGwXPydwp9m+0jV6C2mHpUWGffJsIlh2l5lKwsO A4ziI0PdsGamte6P4pjVOzqzEfH4vbxKEmr8QjY9E/uS550uSnidird1USiEWbbqo+mW XfbA== 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=UhrnEzupfDW4VUrWZYS+8MEh7LjRrlG3/gLMwULTgSk=; b=w7X4ftel/onMaXgaJo7yBO4YYmdEct1rHn+ugsoRjhoyfEz3gNu6O2IYc0ixwa4FNM kXZbeaepEVNj6S6Hl4JxfSPZcxTwtbmnEjFnAFmIbrhMzbTgfUcYQCs0dBOHVY+CQlVh 9IX8FTUtcT/yDes6Ou5ELRQ3gmQpILQh2mVxXvHuDmWjwWvYJ9rdgkcbpI9LKlPtmX6m ZiCK2Tdw+24T+8+u9syIWyojnfIV+SSmtAfA6ym4KVBJqLj3L1hBm4U+U2EUdkSSfDK8 LdWXjClq4iKJOZBg2XcfJuRJ8L6Y8z9/oyDggATAphH6zsvT3GBFonI74WEN8/DE365U ko7Q== X-Gm-Message-State: ACrzQf04HKo6YMaZdRVQgBBh1YsEmnD+NKYmPRxhKXVkphVU34M8QIkm Ac73M19J4/OkrK8BsFqM4h6l0Ji5kBu/sg== X-Received: by 2002:a05:6000:18a1:b0:230:f9fb:c83 with SMTP id b1-20020a05600018a100b00230f9fb0c83mr1640439wri.329.1665412057398; Mon, 10 Oct 2022 07:27:37 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id u6-20020adfed46000000b0022e04bfa661sm9037054wro.59.2022.10.10.07.27.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 07:27:36 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 04/28] target/arm: Split s2walk_secure from ipa_secure in get_phys_addr Date: Mon, 10 Oct 2022 15:27:06 +0100 Message-Id: <20221010142730.502083-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221010142730.502083-1-peter.maydell@linaro.org> References: <20221010142730.502083-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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson The starting security state comes with the translation regime, not the current state of arm_is_secure_below_el3(). Create a new local variable, s2walk_secure, which does not need to be written back to result->attrs.secure -- we compute that value later, after the S2 walk is complete. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Message-id: 20221001162318.153420-2-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/ptw.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 2ddfc028abb..b8c494ad9f0 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -2298,7 +2298,7 @@ bool get_phys_addr(CPUARMState *env, target_ulong address, hwaddr ipa; int s1_prot; int ret; - bool ipa_secure; + bool ipa_secure, s2walk_secure; ARMCacheAttrs cacheattrs1; ARMMMUIdx s2_mmu_idx; bool is_el0; @@ -2313,17 +2313,17 @@ bool get_phys_addr(CPUARMState *env, target_ulong address, ipa = result->phys; ipa_secure = result->attrs.secure; - if (arm_is_secure_below_el3(env)) { - if (ipa_secure) { - result->attrs.secure = !(env->cp15.vstcr_el2 & VSTCR_SW); - } else { - result->attrs.secure = !(env->cp15.vtcr_el2 & VTCR_NSW); - } + if (is_secure) { + /* Select TCR based on the NS bit from the S1 walk. */ + s2walk_secure = !(ipa_secure + ? env->cp15.vstcr_el2 & VSTCR_SW + : env->cp15.vtcr_el2 & VTCR_NSW); } else { assert(!ipa_secure); + s2walk_secure = false; } - s2_mmu_idx = (result->attrs.secure + s2_mmu_idx = (s2walk_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2); is_el0 = mmu_idx == ARMMMUIdx_E10_0 || mmu_idx == ARMMMUIdx_SE10_0; @@ -2366,7 +2366,7 @@ bool get_phys_addr(CPUARMState *env, target_ulong address, result->cacheattrs); /* Check if IPA translates to secure or non-secure PA space. */ - if (arm_is_secure_below_el3(env)) { + if (is_secure) { if (ipa_secure) { result->attrs.secure = !(env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW));