Skip to contentSkip to conversation

arm_gicv3: Fix broken logic in ELRSR calculation

PATCH In review Peter Maydell 2 participants 2 messages Jan 24, 2017 – Jan 26, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm_gicv3: Fix broken logic in ELRSR calculation

Fix a broken expression in the calculation of ELRSR register bits: instead of "(lr & ICH_LR_EL2_HW) == 1" we want to check for != 0, because the HW bit is not bit 0 so a test for == 1 is always false.

---
 hw/intc/arm_gicv3_cpuif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/intc/arm_gicv3_cpuif.c +1 -1
index a9ee7fd..c25ee03 100644
@@ -2430,7 +2430,7 @@ static uint64_t ich_elrsr_read(CPUARMState *env, const ARMCPRegInfo *ri)
         uint64_t lr = cs->ich_lr_el2[i];
 
         if ((lr & ICH_LR_EL2_STATE_MASK) == 0 &&
-            ((lr & ICH_LR_EL2_HW) == 1 || (lr & ICH_LR_EL2_EOI) == 0)) {
+            ((lr & ICH_LR_EL2_HW) != 0 || (lr & ICH_LR_EL2_EOI) == 0)) {
             value |= (1 << i);
         }
     }
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Peter Maydell

Fix a broken expression in the calculation of ELRSR register bits: instead of "(lr & ICH_LR_EL2_HW) == 1" we want to check for != 0, because the HW bit is not bit 0 so a test for == 1 is always false.

---
 hw/intc/arm_gicv3_cpuif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/intc/arm_gicv3_cpuif.c +0 -0
index a9ee7fd..c25ee03 100644

hw/intc/arm_gicv3_cpuif.c static uint64_t ich_elrsr_read(CPUARMState *env, const ARMCPRegInfo *ri) · line 2436

Quoted 8 lines
hw/intc/arm_gicv3_cpuif.c +1 -1
@@ -2430,7 +2430,7 @@ static uint64_t ich_elrsr_read(CPUARMState *env, const ARMCPRegInfo *ri)
         uint64_t lr = cs->ich_lr_el2[i];
 
         if ((lr & ICH_LR_EL2_STATE_MASK) == 0 &&
-            ((lr & ICH_LR_EL2_HW) == 1 || (lr & ICH_LR_EL2_EOI) == 0)) {
+            ((lr & ICH_LR_EL2_HW) != 0 || (lr & ICH_LR_EL2_EOI) == 0)) {
             value |= (1 << i);
         }
     }