From patchwork Mon Oct 10 14:27:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 613749 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2024554pvb; Mon, 10 Oct 2022 07:52:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5P03OUy8tVMoFYybOsqJX2FglNux9TB9SQpeBIJlsagRFJ09blFuyQtI6LB7tJksGZgobF X-Received: by 2002:a05:620a:2989:b0:6ee:1a5a:f8c3 with SMTP id r9-20020a05620a298900b006ee1a5af8c3mr1279319qkp.703.1665413551894; Mon, 10 Oct 2022 07:52:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665413551; cv=none; d=google.com; s=arc-20160816; b=f5VPOX8bgatrZ795fHM5+GqRF9LGYOnwLUEeX5/rv7bchmvlJkid7MN42xJg2flr55 LQQBvO/+q9u0O3RowOKwgwVTktbPxkq6C8V1sx7UUMm7FafVR3fCA8XZoTMw71m/KKW5 jf7z0X81f0xugK29fepuABSyUecevECds7dBCnStv80Hsot0qTklVuZUvEMqxg/4qtMO xxb8oDuUlSNu9k3+dyD2qo5t1QX5pfsxpHisNv0Ps63WNA+EC8/Cb2pDoJxJcfWgRNhd Ra8vGo1Egywz+7WYeFtWB9/b0e5GM6eACck8+uKV4upK5Efpuv3vemFeRjcaXQ2gzrYO 8IYA== 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=I9U26+V5C/CkK7B8UL55/rDbIxkmkXtApVD0MXqZAlI=; b=wSCJdC6bDK1v91eWHyM5GjrZt91UMqGTKyUm+gMpNfxB+n0DUsxy5X3Nm+DzLjo3+5 4cKeD4QGuN4w0ZhxvkpWQ5hBFvA/t5DdZNBs/DN9GjyBwLrW3paWoMU+EZLYDviL/BOT c26IXmxDxVyx/KLLO9HK5LkV0+TnxKz22wB1pBp3fuVa/TrIQyJS/MEoAlADyARfdlKc ueQd4AZTatXi9sc+mkJiJULSDDPaqlWtVvwHKpGNYRD+w46JrqCrgbTWXmgZBz0hlMdy YIgTKU2Q8NoJsqJI9GwXHmq9zRmEwZQKC/DnPrll2qL2XMNDFDX2J1srdufZsB8Ijr8T xO5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KnFvsa0H; 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 d17-20020ac85451000000b003973bf578dasi4319084qtq.361.2022.10.10.07.52.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 07:52:31 -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=KnFvsa0H; 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]:53038 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohu8s-0001QR-C5 for patch@linaro.org; Mon, 10 Oct 2022 10:52:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohtl4-0006Ox-NM for qemu-devel@nongnu.org; Mon, 10 Oct 2022 10:27:54 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:43542) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ohtl3-0005aa-4v for qemu-devel@nongnu.org; Mon, 10 Oct 2022 10:27:54 -0400 Received: by mail-wr1-x433.google.com with SMTP id n12so17285157wrp.10 for ; Mon, 10 Oct 2022 07:27:52 -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=I9U26+V5C/CkK7B8UL55/rDbIxkmkXtApVD0MXqZAlI=; b=KnFvsa0HE+CDYRZNIPeB5LeupDsanlgw7O/1Q7EpMLvyTs/MEktXQohZlqzVWLZdu+ gJxv/1TZHTnmHiba+ZLjM0mvR7B3Jn4NAXLl0+Em39gUdw62ZDlo7FIqB3WpDA/0Qt0m 5oMhQpR61RsmEI5u2slNu2tk/XoQtSogBaOBTkVP0A2i4WpEGLutD9snG0qonQNycD37 LJUEkwa72WH9DtZP1qIH8irv9rryRvM+S4kFo/0bsKIAYLZMndfM1yBxkpdPdrQn96iL HaGAxlu7qE0VHSNr/5EBk56s6nBnjEDVzdyxYBr0Tjb5o3ieL/cBSb+hK4b/fD5L6lJM 9pVQ== 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=I9U26+V5C/CkK7B8UL55/rDbIxkmkXtApVD0MXqZAlI=; b=fxvvQ/wVmId1Ta73o1rs64Guck5FUrn7RaDaAQ0FeF7RDo9LwzijwHgsFf5jjjBbrF dBP57RJ6UJEpIsfOTqgiftbpEfN9n0449bujMeRyUSllfCjkPxkR82cmpiCjmmvi+t5q 8cHsumw9G6gx3SEi2+3f1Di7i7MP76vl3LPZhLqiGlX/2b5lNFovtZhvUOhZtqcUnFl5 cYDmjMltAtWkpTr1o/Yg5QWkSxkZjDmIOrNGemNoxoCK3ci8iV5TRJr8mTR59TTEne7b a4G2kofn8V3G/2oVm8jHCJcPl1Q4dXcCCnYmYrff9Y42UkM3nvs3qCQslnavzQFoOzGZ QBRQ== X-Gm-Message-State: ACrzQf3coXLbnPHEKb/orVWQ7A2Ub7hYZ5uEnp9tDuvBoMzeH1XPAa7f g565229bGfIQSLKrxEMiQLCrtBDQGePJSw== X-Received: by 2002:a5d:47a6:0:b0:22e:7c73:feb2 with SMTP id 6-20020a5d47a6000000b0022e7c73feb2mr11572755wrb.715.1665412071529; Mon, 10 Oct 2022 07:27:51 -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.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 07:27:50 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 18/28] target/arm: Hoist read of *is_secure in S1_ptw_translate Date: Mon, 10 Oct 2022 15:27:20 +0100 Message-Id: <20221010142730.502083-19-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::433; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x433.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 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. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20221001162318.153420-15-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/ptw.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index b3e0db19369..b40b4586f87 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -207,24 +207,25 @@ 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) { - ARMMMUIdx s2_mmu_idx = *is_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2; + bool is_secure = *is_secure_ptr; + ARMMMUIdx s2_mmu_idx = is_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2; if (arm_mmu_idx_is_stage1_of_2(mmu_idx) && - !regime_translation_disabled(env, s2_mmu_idx, *is_secure)) { + !regime_translation_disabled(env, s2_mmu_idx, is_secure)) { 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 +238,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;