[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 11/20] target/arm: NSTable is RES0 for the RME EL3 regime
From: |
Richard Henderson |
Subject: |
[PATCH v5 11/20] target/arm: NSTable is RES0 for the RME EL3 regime |
Date: |
Tue, 20 Jun 2023 14:44:09 +0200 |
Test in_space instead of in_secure so that we don't
switch out of Root space.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/arm/ptw.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
index e1e7c9a3d2..ea0ad56f13 100644
--- a/target/arm/ptw.c
+++ b/target/arm/ptw.c
@@ -1275,7 +1275,6 @@ static bool get_phys_addr_lpae(CPUARMState *env,
S1Translate *ptw,
{
ARMCPU *cpu = env_archcpu(env);
ARMMMUIdx mmu_idx = ptw->in_mmu_idx;
- bool is_secure = ptw->in_secure;
int32_t level;
ARMVAParameters param;
uint64_t ttbr;
@@ -1291,7 +1290,6 @@ static bool get_phys_addr_lpae(CPUARMState *env,
S1Translate *ptw,
uint64_t descaddrmask;
bool aarch64 = arm_el_is_aa64(env, el);
uint64_t descriptor, new_descriptor;
- bool nstable;
/* TODO: This code does not support shareability levels. */
if (aarch64) {
@@ -1453,21 +1451,21 @@ static bool get_phys_addr_lpae(CPUARMState *env,
S1Translate *ptw,
descaddrmask = MAKE_64BIT_MASK(0, 40);
}
descaddrmask &= ~indexmask_grainsize;
-
- /*
- * Secure stage 1 accesses start with the page table in secure memory and
- * can be downgraded to non-secure at any step. Non-secure accesses
- * remain non-secure. We implement this by just ORing in the NSTable/NS
- * bits at each step.
- * Stage 2 never gets this kind of downgrade.
- */
- tableattrs = is_secure ? 0 : (1 << 4);
+ tableattrs = 0;
next_level:
descaddr |= (address >> (stride * (4 - level))) & indexmask;
descaddr &= ~7ULL;
- nstable = !regime_is_stage2(mmu_idx) && extract32(tableattrs, 4, 1);
- if (nstable && ptw->in_secure) {
+
+ /*
+ * Process the NSTable bit from the previous level. This changes
+ * the table address space and the output space from Secure to
+ * NonSecure. With RME, the EL3 translation regime does not change
+ * from Root to NonSecure.
+ */
+ if (ptw->in_space == ARMSS_Secure
+ && !regime_is_stage2(mmu_idx)
+ && extract32(tableattrs, 4, 1)) {
/*
* Stage2_S -> Stage2 or Phys_S -> Phys_NS
* Assert the relative order of the secure/non-secure indexes.
@@ -1476,7 +1474,9 @@ static bool get_phys_addr_lpae(CPUARMState *env,
S1Translate *ptw,
QEMU_BUILD_BUG_ON(ARMMMUIdx_Stage2_S + 1 != ARMMMUIdx_Stage2);
ptw->in_ptw_idx += 1;
ptw->in_secure = false;
+ ptw->in_space = ARMSS_NonSecure;
}
+
if (!S1_ptw_translate(env, ptw, descaddr, fi)) {
goto do_fault;
}
@@ -1579,7 +1579,7 @@ static bool get_phys_addr_lpae(CPUARMState *env,
S1Translate *ptw,
*/
attrs = new_descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50,
14));
if (!regime_is_stage2(mmu_idx)) {
- attrs |= nstable << 5; /* NS */
+ attrs |= !ptw->in_secure << 5; /* NS */
if (!param.hpd) {
attrs |= extract64(tableattrs, 0, 2) << 53; /* XN, PXN */
/*
--
2.34.1
- [PATCH v5 01/20] target/arm: Add isar_feature_aa64_rme, (continued)
- [PATCH v5 01/20] target/arm: Add isar_feature_aa64_rme, Richard Henderson, 2023/06/20
- [PATCH v5 04/20] target/arm: Add RME cpregs, Richard Henderson, 2023/06/20
- [PATCH v5 02/20] target/arm: Update SCR and HCR for RME, Richard Henderson, 2023/06/20
- [PATCH v5 03/20] target/arm: SCR_EL3.NS may be RES1, Richard Henderson, 2023/06/20
- [PATCH v5 05/20] target/arm: Introduce ARMSecuritySpace, Richard Henderson, 2023/06/20
- [PATCH v5 06/20] include/exec/memattrs: Add two bits of space to MemTxAttrs, Richard Henderson, 2023/06/20
- [PATCH v5 07/20] target/arm: Adjust the order of Phys and Stage2 ARMMMUIdx, Richard Henderson, 2023/06/20
- [PATCH v5 08/20] target/arm: Introduce ARMMMUIdx_Phys_{Realm,Root}, Richard Henderson, 2023/06/20
- [PATCH v5 09/20] target/arm: Remove __attribute__((nonnull)) from ptw.c, Richard Henderson, 2023/06/20
- [PATCH v5 10/20] target/arm: Pipe ARMSecuritySpace through ptw.c, Richard Henderson, 2023/06/20
- [PATCH v5 11/20] target/arm: NSTable is RES0 for the RME EL3 regime,
Richard Henderson <=
- [PATCH v5 13/20] target/arm: Handle no-execute for Realm and Root regimes, Richard Henderson, 2023/06/20
- [PATCH v5 14/20] target/arm: Use get_phys_addr_with_struct in S1_ptw_translate, Richard Henderson, 2023/06/20
- [PATCH v5 15/20] target/arm: Move s1_is_el0 into S1Translate, Richard Henderson, 2023/06/20
- [PATCH v5 16/20] target/arm: Use get_phys_addr_with_struct for stage2, Richard Henderson, 2023/06/20
- [PATCH v5 12/20] target/arm: Handle Block and Page bits for security space, Richard Henderson, 2023/06/20
- [PATCH v5 17/20] target/arm: Add GPC syndrome, Richard Henderson, 2023/06/20
- [PATCH v5 18/20] target/arm: Implement GPC exceptions, Richard Henderson, 2023/06/20
- [PATCH v5 19/20] target/arm: Implement the granule protection check, Richard Henderson, 2023/06/20
- [PATCH v5 20/20] target/arm: Add cpu properties for enabling FEAT_RME, Richard Henderson, 2023/06/20