Skip to contentSkip to conversation

target/arm: Fix VNCR fault detection logic

PATCH In review Peter Maydell 3 participants 3 messages Jan 16, 2024 – Jan 28, 2024

lore
Share & tools
lore
#0 lore raw

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.

Fixes 674e5345275d425 ("target/arm: Report VNCR_EL2 based faults correctly")

---
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
index dd5de74ffb7..5477c7fb7dc 100644
@@ -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
Tested-by Jonathan Cameron Reviewed-by Jonathan Cameron on v1 1/1
#1 lore raw
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 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.

Quoted 5 lines

Use the right variable in the condition.

Fixes 674e5345275d425 ("target/arm: Report VNCR_EL2 based faults correctly")

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
index dd5de74ffb7..5477c7fb7dc 100644
@@ -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) {
Reviewed-by on v1 1/1
#2 lore raw
In reply to Peter Maydell
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 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.

Fixes 674e5345275d425 ("target/arm: Report VNCR_EL2 based faults correctly")
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~