target/arm: Fix VNCR fault detection logic
PATCH 1/1 target/arm: Fix VNCR fault detection logic
In arm_deliver_fault() we check for whether the fault is caused by a data abort due to an access to a FEAT_NV2 sysreg in the memory pointed to by the VNCR. Unfortunately part of the condition checks the wrong argument to the function, meaning that it would spuriously trigger, resulting in some instruction aborts being taken to the wrong EL and reported incorrectly.
Use the right variable in the condition.
---
In less lax languages the compiler might have pointed out that the type of the LHS and the RHS in the comparison didn't match :-)
--- target/arm/tcg/tlb_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/tcg/tlb_helper.c +1 -1
@@ -184,7 +184,7 @@ void arm_deliver_fault(ARMCPU *cpu, vaddr addr,* (and indeed syndrome does not have the EC field in it, * because we masked that out in disas_set_insn_syndrome()) */ -bool is_vncr = (mmu_idx !=MMU_INST_FETCH ) && +bool is_vncr = (access_type !=MMU_INST_FETCH ) && (env->exception.syndrome &ARM_EL_VNCR );if (is_vncr) {
Signature · 1 line
2.34.1
Quoted 7 lines · On Tue, 16 Jan 2024 16:56:05 +0000 Peter Maydell <[email protected]>…
In
arm_deliver_fault()we check for whether the fault is caused by a data abort due to an access to aFEAT_NV2sysreg in the memory pointed to by the VNCR. Unfortunately part of the condition checks the wrong argument to the function, meaning that it would spuriously trigger, resulting in some instruction aborts being taken to the wrong EL and reported incorrectly.
Quoted 5 lines
Use the right variable in the condition.
Fixes 674e5345275d425 ("target/arm: Report VNCR_EL2 based faults correctly")Reported-by Jonathan Cameron <[email protected]>Signed-off-by Peter Maydell <[email protected]>
Matches what I have locally from discussion earlier.
Thanks
Quoted 20 lines
---
In less lax languages the compiler might have pointed out that the type of the LHS and the RHS in the comparison didn't match :-)--- target/arm/tcg/tlb_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/arm/tcg/tlb_helper.c +1
-1@@ -184,7 +184,7 @@ void arm_deliver_fault(ARMCPU *cpu, vaddr addr,* (and indeed syndrome does not have the EC field in it, * because we masked that out in disas_set_insn_syndrome()) */ -bool is_vncr = (mmu_idx !=MMU_INST_FETCH ) && +bool is_vncr = (access_type !=MMU_INST_FETCH ) && (env->exception.syndrome &ARM_EL_VNCR );if (is_vncr) {
Quoted 12 lines · Peter Maydell
In
arm_deliver_fault()we check for whether the fault is caused by a data abort due to an access to aFEAT_NV2sysreg in the memory pointed to by the VNCR. Unfortunately part of the condition checks the wrong argument to the function, meaning that it would spuriously trigger, resulting in some instruction aborts being taken to the wrong EL and reported incorrectly.Use the right variable in the condition.
Fixes 674e5345275d425 ("target/arm: Report VNCR_EL2 based faults correctly")Reported-by Jonathan Cameron<[email protected]>Signed-off-by Peter Maydell<[email protected]>
Quoted 6 lines
---
In less lax languages the compiler might have pointed out that the type of the LHS and the RHS in the comparison didn't match :-)--- target/arm/tcg/tlb_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
r~