From patchwork Thu Sep 22 16:35:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 608236 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp479016pvb; Thu, 22 Sep 2022 10:37:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4obK4IcmjuDCLmMqQzHrwzoBaUo3ohRnuZVfRvQjoHbVyjq9XcBO9dL0N/VsWifvcKsxwo X-Received: by 2002:a05:620a:bd4:b0:6cf:468e:e092 with SMTP id s20-20020a05620a0bd400b006cf468ee092mr2939464qki.583.1663868254806; Thu, 22 Sep 2022 10:37:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663868254; cv=none; d=google.com; s=arc-20160816; b=Sq/et0iiRhEpuJmTBRfAxKg3+hz9fimSiI/TP8Yc6RH6PtVdDKKv5zKnQ9BN+MXcsx gRhBdCKvJhcXVmRpoFsPYvKFPwpJE6YAQJ8yL7ZBTTMmcKUuS+6Nshd1VAyCadij6sfj HhRDy6zFf5S1DmHB4XoW+lPLNxH3ZwE3FNYNBqRhZP4MjmQGCwur+jmS+PgP5CXBvrMM cLGNGi0z2YZ7UYGaVX0sR2oGZVXIhXxNbt97fXorwNz+n20WP1ADhbl1cXuK2O7rI0yC p4fwYnVbbO5GtqKvn+j3e8qm2MDBWg3pcceM5yDNobpWvoM7S+PuUmAp8r6k11xKoymo XyeQ== 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=u3T0zAgMbu0p/+YyGjLWBqhH/EbkbWQ0NkCK9u4fEiQ=; b=BIMgsg1CI0bs1PUr6tvhyrd2tCCYmDQk7DBJ8BWLuPGsa3vRHq6SoIIphmEDGVeIys HiTKSRaEV3KP3hKUKyZQu+jgEkICFkGmSWlfb+F/cc/bAmpKwFtZyvLFPtHRLj5CuSk7 VGHvbDwS0+s5TvAJHXLn2rNOo9VfpREf3ajOlkAtGjIpFkFTpx922qEyx365pAB1UStO AbQR3A0wh4Lo+Y9YBhXtm6CH5BeAX8jflGDS0y4EuWsk9F8PlMep6mxG6DTq3Hi6MIwS NrEXHTFnPWMvzKGgBarsHh/aHYj+uI3oVHRYAFG+wcLctx5x/2bY12Snks+xIAQ5rA9O kNNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sXjcJ5No; 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 r11-20020a05620a298b00b006c9ab327674si4192144qkp.508.2022.09.22.10.37.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Sep 2022 10:37:34 -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=sXjcJ5No; 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]:41504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1obQ8k-0003A2-AE for patch@linaro.org; Thu, 22 Sep 2022 13:37:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obPB0-0002Ax-Eu for qemu-devel@nongnu.org; Thu, 22 Sep 2022 12:35:56 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:46004) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1obPAy-0005Pe-JZ for qemu-devel@nongnu.org; Thu, 22 Sep 2022 12:35:50 -0400 Received: by mail-wr1-x436.google.com with SMTP id n10so16377656wrw.12 for ; Thu, 22 Sep 2022 09:35:48 -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; bh=u3T0zAgMbu0p/+YyGjLWBqhH/EbkbWQ0NkCK9u4fEiQ=; b=sXjcJ5No6QiXM2ybWl2cRGICt5mla64tW3I+eEw24ZaHWEIjNidQOkepQNqNXCR+qk Nw++BlqPRkMLEg00lIx9F1rZVCwR84EH8J+3AU97LmdlSqySc3SR8U/MVI/QXRyKBzEw 59Ny0kFl7Ln70CF/BZsbNCH9VSXPtPv1rmnMD5ld66U80RafrTQmsKXgiCWRL2fgLTVl Ib+uuu/F8+DQC05ShIgeewJFRL6+WysM6EF7jTEnjTxrzEB+ObIntViQ4c998vuDC9t1 IfZixVGt+Rl+Yz7K3TW+CeagfaPWy4LWxizROw0SlsBkZaFc8BEeahk9atc5EfkZ93pV 7diQ== 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; bh=u3T0zAgMbu0p/+YyGjLWBqhH/EbkbWQ0NkCK9u4fEiQ=; b=JBrB0iCyPsPbjK++QNz6c/+mHJcV1zP1Z1UwsECTn5kT4auESskuH4QwhvIHkLpmYC Qcs1FTbmEJrtlu9AX35oCsv21PcigkTzq8tpyvzMz16BZ117BSL19PIvvwCmAhRDNLN/ AVeUhZKJvKb4/S/9WNIfh77ltW1suYxpM/uSQp3ukSfbaTMKBzzHScNjEMyZnYxbbRP/ 7Sx5P6cuPXFq0CPEe2L+Juz5JWKl4Thz8ye5jk6B1X5F3j1TwRihmYT9EOfWj1SnnOmw 6OscKwuEf1DSOQhg+mx+RT1Fd1batd9g+Y5GmULxWwiipLNvJhD777ETHs6T1J4Xknvx LmnA== X-Gm-Message-State: ACrzQf1LoT2W4UaUCtgBDMW6g3op5xjYDRWOz3XOi8B2XQGTIYd2SSxb 3GHOJc+VBFEBoTiRb9fx+qaJ6v5j4Uosvg== X-Received: by 2002:a05:6000:887:b0:21e:24a0:f302 with SMTP id ca7-20020a056000088700b0021e24a0f302mr2537644wrb.466.1663864546969; Thu, 22 Sep 2022 09:35:46 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id iw1-20020a05600c54c100b003b3401f1e24sm6452599wmb.28.2022.09.22.09.35.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Sep 2022 09:35:46 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 12/39] target/arm: Add is_secure parameter to v8m_security_lookup Date: Thu, 22 Sep 2022 17:35:09 +0100 Message-Id: <20220922163536.1096175-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220922163536.1096175-1-peter.maydell@linaro.org> References: <20220922163536.1096175-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x436.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 Remove the use of regime_is_secure from v8m_security_lookup, passing the new parameter to the lookup instead. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20220822152741.1617527-12-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/internals.h | 2 +- target/arm/m_helper.c | 9 ++++++--- target/arm/ptw.c | 9 +++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index f8b22d3ab0b..e97f5c3d47e 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1123,7 +1123,7 @@ typedef struct V8M_SAttributes { void v8m_security_lookup(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, - V8M_SAttributes *sattrs); + bool secure, V8M_SAttributes *sattrs); /* Cacheability and shareability attributes for a memory access */ typedef struct ARMCacheAttrs { diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c index 01263990dc3..45fbf195590 100644 --- a/target/arm/m_helper.c +++ b/target/arm/m_helper.c @@ -689,7 +689,8 @@ static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure, if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { V8M_SAttributes sattrs = {}; - v8m_security_lookup(env, addr, MMU_DATA_LOAD, mmu_idx, &sattrs); + v8m_security_lookup(env, addr, MMU_DATA_LOAD, mmu_idx, + targets_secure, &sattrs); if (sattrs.ns) { attrs.secure = false; } else if (!targets_secure) { @@ -2002,7 +2003,8 @@ static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx, ARMMMUFaultInfo fi = {}; MemTxResult txres; - v8m_security_lookup(env, addr, MMU_INST_FETCH, mmu_idx, &sattrs); + v8m_security_lookup(env, addr, MMU_INST_FETCH, mmu_idx, + regime_is_secure(env, mmu_idx), &sattrs); if (!sattrs.nsc || sattrs.ns) { /* * This must be the second half of the insn, and it straddles a @@ -2826,7 +2828,8 @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) } if (env->v7m.secure) { - v8m_security_lookup(env, addr, MMU_DATA_LOAD, mmu_idx, &sattrs); + v8m_security_lookup(env, addr, MMU_DATA_LOAD, mmu_idx, + targetsec, &sattrs); nsr = sattrs.ns && r; nsrw = sattrs.ns && rw; } else { diff --git a/target/arm/ptw.c b/target/arm/ptw.c index bb3c709f8f5..74d2f63359f 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1857,8 +1857,8 @@ static bool v8m_is_sau_exempt(CPUARMState *env, } void v8m_security_lookup(CPUARMState *env, uint32_t address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, - V8M_SAttributes *sattrs) + MMUAccessType access_type, ARMMMUIdx mmu_idx, + bool is_secure, V8M_SAttributes *sattrs) { /* * Look up the security attributes for this address. Compare the @@ -1886,7 +1886,7 @@ void v8m_security_lookup(CPUARMState *env, uint32_t address, } if (idau_exempt || v8m_is_sau_exempt(env, address, access_type)) { - sattrs->ns = !regime_is_secure(env, mmu_idx); + sattrs->ns = !is_secure; return; } @@ -1975,7 +1975,8 @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, bool ret; if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { - v8m_security_lookup(env, address, access_type, mmu_idx, &sattrs); + v8m_security_lookup(env, address, access_type, mmu_idx, + secure, &sattrs); if (access_type == MMU_INST_FETCH) { /* * Instruction fetches always use the MMU bank and the