target/arm: Fix MTE0_ACTIVE
PATCH 1/1 target/arm: Fix MTE0_ACTIVE
In 50244cc76abc we updated mte_check_fail to match the ARM pseudocode, using the correct EL to select the TCF field. But we failed to update MTE0_ACTIVE the same way, which led to g_assert_not_reached().
--- target/arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/helper.c +1 -1
@@ -12932,7 +12932,7 @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el,if (FIELD_EX32 (flags,TBFLAG_A64 ,UNPRIV ) && tbid && !(env->pstate &PSTATE_TCO ) - && (sctlr &SCTLR_TCF0 ) + && (sctlr &SCTLR_TCF ) &&allocation_tag_access_enabled (env,0 , sctlr)) { flags =FIELD_DP32 (flags,TBFLAG_A64 ,MTE0_ACTIVE ,1 ); }
Signature · 1 line
2.25.1
Quoted 18 lines · Richard Henderson
In
50244cc76abcwe updatedmte_check_failto match the ARM pseudocode, using the correct EL to select the TCF field. But we failed to updateMTE0_ACTIVEthe same way, which led tog_assert_not_reached().Signed-off-by Richard Henderson <[email protected]>--- target/arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/arm/helper.c +0
-0
target/arm/helper.c static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, · line 12938
Quoted 8 lines
target/arm/helper.c +1
-1@@ -12932,7 +12932,7 @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el,if (FIELD_EX32 (flags,TBFLAG_A64 ,UNPRIV ) && tbid && !(env->pstate &PSTATE_TCO ) - && (sctlr &SCTLR_TCF0 ) + && (sctlr &SCTLR_TCF ) &&allocation_tag_access_enabled (env,0 , sctlr)) { flags =FIELD_DP32 (flags,TBFLAG_A64 ,MTE0_ACTIVE ,1 ); }
I don't understand this change, could you explain a bit more? In commit 50244cc76abcac we change to looking at the TCF field corresponding to the actual current EL instead of the EL for the memory-access. But if we're doing that then why should we be looking at exclusively SCTLR_TCF0 in this for-unpriv-access code rather than doing the same thing we do for normal accesses and checking
(sctlr & (el == 0 ? SCTLR_TCF0 : SCTLR_TCF))
?
thanks
-- PMM
Quoted 11 lines · Peter Maydell
target/arm/helper.c static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, · line 12938
Quoted 5 lines
target/arm/helper.c +1
-1- && (sctlr & SCTLR_TCF0) + && (sctlr & SCTLR_TCF) && allocation_tag_access_enabled(env, 0, sctlr)) { flags =FIELD_DP32 (flags,TBFLAG_A64 ,MTE0_ACTIVE ,1 ); }I don't understand this change, could you explain a bit more? In commit
50244cc76abcacwe change to looking at the TCF field corresponding to the actual current EL instead of the EL for the memory-access.
Correct.
Quoted 5 lines
But if we're doing that then why
should we be looking at exclusivelySCTLR_TCF0in this for-unpriv-access code rather than doing the same thing we do for normal accesses and checking
(sctlr & (el == 0 ?SCTLR_TCF0:SCTLR_TCF))
Because this is for the UNPRIV instructions which are UNDEF at el == 0.
r~
Peter Maydell
AppliedQuoted 16 lines · Richard Henderson
Quoted 11 lines · Peter Maydell
target/arm/helper.c static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, · line 12938
Quoted 5 lines
target/arm/helper.c +1
-1- && (sctlr & SCTLR_TCF0) + && (sctlr & SCTLR_TCF) && allocation_tag_access_enabled(env, 0, sctlr)) { flags =FIELD_DP32 (flags,TBFLAG_A64 ,MTE0_ACTIVE ,1 ); }I don't understand this change, could you explain a bit more? In commit
50244cc76abcacwe change to looking at the TCF field corresponding to the actual current EL instead of the EL for the memory-access.Correct.
Quoted 7 lines
Quoted 5 lines
But if we're doing that then why
should we be looking at exclusivelySCTLR_TCF0in this for-unpriv-access code rather than doing the same thing we do for normal accesses and checking
(sctlr & (el == 0 ?SCTLR_TCF0:SCTLR_TCF))Because this is for the UNPRIV instructions which are UNDEF at el == 0.
Ah, right. (It didn't help that I'd read the diff backwards:
the new code looks at SCTLR_TCF, not SCTLR_TCF0.)
Further, the SCTLR_*.ATA/ATA0 checks *are* based on the privilege of the access, which is why calling allocation_tag_access_enabled(env, 0, sctlr) is still correct.
Applied to target-arm.next, thanks.
-- PMM