From patchwork Mon Aug 22 15:27:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 599167 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1835067mae; Mon, 22 Aug 2022 10:24:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR6B2yI2NRoNYLk5CyvVGXJqpUhX01XduIUYmEHQeVXz9hD6K6d5Z5HKPwNUeqNiojZrZnNM X-Received: by 2002:a0c:9d46:0:b0:476:ff07:3fe7 with SMTP id n6-20020a0c9d46000000b00476ff073fe7mr16743004qvf.15.1661189089840; Mon, 22 Aug 2022 10:24:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661189089; cv=none; d=google.com; s=arc-20160816; b=jq5PdSNH+Ml9u8r4468RAs6g7QPhQh7HlSjiWSab7O+xX1bfdA9HM8rd+I1NxQGybG mTzykxtIImh/cLErpVU4OztPNLlqS57F7Bxej2T3QXPDL7p7mjVUYBqtTOhMBRFnEr+N avOi3t40XjTatEd7dILXW32o5xnkQLwX8mUgeDoFtPsQj8FiA8YmFFNT4TveYXxhqqqZ 5anD5g8mHvRSA3cbK+PbpmV+InLYIphULYQqPAM79Hlnm7+NaIldTDj1nZz4GH5SyC7e mG6/HFp5QYdO0epajdQSLm9IAITPyVdzMkiGBp92dzX4XlbPyYwKkdbrVth35zZkue2u Vw9w== 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=HtO4LZZP477l4fezaKu9Yh3w9XE4HiCdIKoUptn6t1w=; b=u6twdptbnMAiRYonEESgDm+szlK7yNYJ+68tfZgdiRzj3rXZDgdwvS6CAeujoXW4Io aEPnLTURnac7qci1N8agF/OigZMcAQ92E/urUPWz01OcM9PkcBlboIhKvBajihqV+PgT DwdVE4FNaWuJGZoODB0pIFETjR2wCaRQWXk+Xg8BJGudso6e7H+MkYN5Bi1TFR7V7s5o jmTli4z4pLGNSf7MyaN7uOXCWm+Lo9kZxSWLiUeA7s8Wzr37VQ3yw7AZ+v1e/ZSlMv5c FfyJwE14F80IPGTqFs12dNHPsoqiZsjzJyePfhpvIFbJ3YwuQjUL2JKw0NCguKnUfClu PWWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="v/XqIg3i"; 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 f6-20020a05620a280600b006b935e981b1si5571953qkp.288.2022.08.22.10.24.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Aug 2022 10:24: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="v/XqIg3i"; 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]:52892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQBAP-00029i-DI for patch@linaro.org; Mon, 22 Aug 2022 13:24:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55028) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQ9Ll-00008x-Ln for qemu-devel@nongnu.org; Mon, 22 Aug 2022 11:28:25 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:40943) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oQ9LU-0000pc-6U for qemu-devel@nongnu.org; Mon, 22 Aug 2022 11:28:25 -0400 Received: by mail-pl1-x62e.google.com with SMTP id x23so10231570pll.7 for ; Mon, 22 Aug 2022 08:28:07 -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; bh=HtO4LZZP477l4fezaKu9Yh3w9XE4HiCdIKoUptn6t1w=; b=v/XqIg3iMI28YOFRjxKs0QoUJ7dJgPOk2cpUbZ/ivo6a6h3EW/2PPQgwQCjex1uWJI azxr1CUrYakkECCOCCiHTt+UZ1m8qzES97qGoCTtpTkMwtMmsHE4bxufuSlYxS7Wlmz4 nzkZM5no2/dNEsykoa2t3oLwfkpB3oyxFRWKA0LJyiKxC9APVcNdUTxZHp3aZYJnPCYe zVHuccDt1Ffvlu2H/mdgQJd4AhdeVMPmOYL3iKMGBNTE79i28456JgjclL+t4hoipTHu z2JB4nXGRDkJ69q8MJJ8XZnKuFp0oHPzWAbJOb+OXvMxuTV67cKej9MnuY3RUKSYc0h/ Gtzw== 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; bh=HtO4LZZP477l4fezaKu9Yh3w9XE4HiCdIKoUptn6t1w=; b=SMYL81vLUQlbjD5TRPtEYma6ZfMQszjXYgZ3BBf5OfNMjjBdnx3B1HtdGsUNHiNBkn 5mSjbkls8zQHCcI1h/DtNUIn1eotTyxOe6cpzDrZ9esYoCU6A7OPFEsKm7SMz/lBsplr K58kgkpT9SsU5gd1Ed/rj/QvSvL1BcjqZzQWLnStzJv2LbiGJBaasz2bIwrB+kFMRu8O uEusL2yYqNh7w5tyb5boKEmRZBNnm1NA5NlxLZ/8rrp76MktuW7SgGeHWHm0QU00N9kV SFTTo22QhCHUb9zrmCsW8n/4vWUAIoCkfhAEgjf/MEjpm8xlfpoLG2VWXcsoy3e6AaNK SNwg== X-Gm-Message-State: ACgBeo2BVZuaqxWYaqf54LbZ5N4IKTEpSaHuiRlJTUGOWITtc527e5k1 DAL09e8FRcA6WmEWZe2Iv0Fq/xCZmCymFw== X-Received: by 2002:a17:90b:3b41:b0:1fb:5376:fb06 with SMTP id ot1-20020a17090b3b4100b001fb5376fb06mr1590279pjb.240.1661182086809; Mon, 22 Aug 2022 08:28:06 -0700 (PDT) Received: from stoup.. ([71.212.157.236]) by smtp.gmail.com with ESMTPSA id q7-20020a17090311c700b0016bffc59718sm8665222plh.58.2022.08.22.08.28.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Aug 2022 08:28:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH v2 30/66] target/arm: Hoist read of *is_secure in S1_ptw_translate Date: Mon, 22 Aug 2022 08:27:05 -0700 Message-Id: <20220822152741.1617527-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220822152741.1617527-1-richard.henderson@linaro.org> References: <20220822152741.1617527-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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" Rename the argument to is_secure_ptr, and introduce a local variable is_secure with the value. We only write back to the pointer toward the end of the function. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/ptw.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 7c0a4316a3..dbe5852af6 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -207,24 +207,26 @@ static bool ptw_attrs_are_device(CPUARMState *env, ARMCacheAttrs cacheattrs) /* Translate a S1 pagetable walk through S2 if needed. */ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, - hwaddr addr, bool *is_secure, + hwaddr addr, bool *is_secure_ptr, ARMMMUFaultInfo *fi) { + bool is_secure = *is_secure_ptr; + if (arm_mmu_idx_is_stage1_of_2(mmu_idx) && - !regime_translation_disabled(env, ARMMMUIdx_Stage2, *is_secure)) { - ARMMMUIdx s2_mmu_idx = *is_secure ? ARMMMUIdx_Stage2_S - : ARMMMUIdx_Stage2; + !regime_translation_disabled(env, ARMMMUIdx_Stage2, is_secure)) { + ARMMMUIdx s2_mmu_idx = is_secure ? ARMMMUIdx_Stage2_S + : ARMMMUIdx_Stage2; GetPhysAddrResult s2 = {}; int ret; ret = get_phys_addr_lpae(env, addr, MMU_DATA_LOAD, s2_mmu_idx, - *is_secure, false, &s2, fi); + is_secure, false, &s2, fi); if (ret) { assert(fi->type != ARMFault_None); fi->s2addr = addr; fi->stage2 = true; fi->s1ptw = true; - fi->s1ns = !*is_secure; + fi->s1ns = !is_secure; return ~0; } if ((arm_hcr_el2_eff(env) & HCR_PTW) && @@ -237,19 +239,20 @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, fi->s2addr = addr; fi->stage2 = true; fi->s1ptw = true; - fi->s1ns = !*is_secure; + fi->s1ns = !is_secure; return ~0; } if (arm_is_secure_below_el3(env)) { /* Check if page table walk is to secure or non-secure PA space. */ - if (*is_secure) { - *is_secure = !(env->cp15.vstcr_el2 & VSTCR_SW); + if (is_secure) { + is_secure = !(env->cp15.vstcr_el2 & VSTCR_SW); } else { - *is_secure = !(env->cp15.vtcr_el2 & VTCR_NSW); + is_secure = !(env->cp15.vtcr_el2 & VTCR_NSW); } + *is_secure_ptr = is_secure; } else { - assert(!*is_secure); + assert(!is_secure); } addr = s2.phys;