target/arm: Fix PMSAv8 shareability decode for R-profile MPU regions
PATCH 1/1 target/arm: Fix PMSAv8 shareability decode for R-profile MPU regions
In Armv8-R AArch32 the shareability field of an MPU region lives in PRBAR, not PRLAR:
PRBAR: [31:6] BASE [5] RES0 [4:3] SH [2:1] AP [0] XN
PRLAR: [31:6] LIMIT [5:4] RES0 [3:1] AttrIndx [0] EN
(Arm Cortex-R52 TRM 100026_0103_00_en: Tables 3-80 and 3-83 for HPRBAR/HPRLAR, Tables 3-124 and 3-127 for PRBAR/PRLAR.)
Without this fix, address translation instructions like ATS1HR will return wrong value for PAR.SH.
--- target/arm/ptw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/ptw.c +1 -1
@@ -3085,7 +3085,7 @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,if (!arm_feature (env,ARM_FEATURE_M )) {uint8_t attrindx =extract32 (matched_rlar,1 ,3 );uint64_t mair = env->cp15.mair_el[regime_el (mmu_idx)]; -uint8_t sh =extract32 (matched_rlar,3 ,2 ); +uint8_t sh =extract32 (matched_rbar,3 ,2 );if (regime_sctlr (env, mmu_idx) &SCTLR_WXN && result->f.prot &PAGE_WRITE && mmu_idx != ARMMMUIdx_Stage2) {
Signature · 1 line
2.34.1
Peter Maydell
AppliedQuoted 10 lines · Jean-Francois Bortolotti
In Armv8-R AArch32 the shareability field of an MPU region lives in PRBAR, not PRLAR:
PRBAR: [31:6] BASE [5] RES0 [4:3] SH [2:1] AP [0] XN
PRLAR: [31:6] LIMIT [5:4] RES0 [3:1] AttrIndx [0] EN(Arm Cortex-R52 TRM 100026_0103_00_en: Tables 3-80 and 3-83 for HPRBAR/HPRLAR, Tables 3-124 and 3-127 for PRBAR/PRLAR.)
Quoted 7 lines
Without this fix, address translation instructions like ATS1HR will return wrong value for PAR.SH.
Signed-off-by Jean-Francois Bortolotti <[email protected]>--- target/arm/ptw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Yep, this is clearly wrong, maybe a cut-and-paste mistake, since we just pulled bits [3:1] out of matched_rlar for attrindx.
Applied to target-arm.next, thanks (and added a cc:stable tag).
(I did wonder about v8M, but this whole block is not-M-profile; the register layout for RLAR and RBAR is the same, we just don't bother to fish out the SH and attr info since there's nowhere that M-profile needs to report it.)
-- PMM