Skip to contentSkip to conversation

target/arm: Fix MTE access checks for disabled SEL2

PATCH Applied Idan Horowitz 3 participants 3 messages Mar 28, 2022 – Mar 31, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/arm: Fix MTE access checks for disabled SEL2

While not mentioned anywhere in the actual specification text, the HCR_EL2.ATA bit is treated as '1' when EL2 is disabled at the current security state. This can be observed in the psuedo-code implementation of AArch64.AllocationTagAccessIsEnabled().

---
 target/arm/helper.c    | 2 +-
 target/arm/internals.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
target/arm/helper.c +1 -1
index 16c2628f8f..7d14650615 100644
@@ -7176,7 +7176,7 @@ static CPAccessResult access_mte(CPUARMState *env, const ARMCPRegInfo *ri,
 {
     int el = arm_current_el(env);
 
-    if (el < 2 && arm_feature(env, ARM_FEATURE_EL2)) {
+    if (el < 2 && arm_is_el2_enabled(env)) {
         uint64_t hcr = arm_hcr_el2_eff(env);
         if (!(hcr & HCR_ATA) && (!(hcr & HCR_E2H) || !(hcr & HCR_TGE))) {
             return CP_ACCESS_TRAP_EL2;
target/arm/internals.h +1 -1
index a34be2e459..7f696cd36a 100644
@@ -1094,7 +1094,7 @@ static inline bool allocation_tag_access_enabled(CPUARMState *env, int el,
         && !(env->cp15.scr_el3 & SCR_ATA)) {
         return false;
     }
-    if (el < 2 && arm_feature(env, ARM_FEATURE_EL2)) {
+    if (el < 2 && arm_is_el2_enabled(env)) {
         uint64_t hcr = arm_hcr_el2_eff(env);
         if (!(hcr & HCR_ATA) && (!(hcr & HCR_E2H) || !(hcr & HCR_TGE))) {
             return false;
Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Idan Horowitz

While not mentioned anywhere in the actual specification text, the HCR_EL2.ATA bit is treated as '1' when EL2 is disabled at the current security state. This can be observed in the psuedo-code implementation of AArch64.AllocationTagAccessIsEnabled().

---
  target/arm/helper.c    | 2 +-
  target/arm/internals.h | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)

I was immediately thinking, didn't I just fix this? But I was patching pauth. Anyway, good catch.

r~

#2 lore raw
Quoted 13 lines · Richard Henderson
Quoted 10 lines · Idan Horowitz

While not mentioned anywhere in the actual specification text, the HCR_EL2.ATA bit is treated as '1' when EL2 is disabled at the current security state. This can be observed in the psuedo-code implementation of AArch64.AllocationTagAccessIsEnabled().

---
  target/arm/helper.c    | 2 +-
  target/arm/internals.h | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 4 lines

I was immediately thinking, didn't I just fix this? But I was patching pauth. Anyway, good catch.

Applied to target-arm.next, thanks.

-- PMM