Skip to contentSkip to conversation

hw/intc/arm_gic: Fix GIC_SET_LEVEL

PATCH In review Christoffer Dall 2 participants 3 messages Feb 22, 2014 – Feb 24, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/intc/arm_gic: Fix GIC_SET_LEVEL

The GIC_SET_LEVEL macro unfortunately overwrote the entire level bitmask instead of just or'ing on the necessary bits, causing active level PPIs on a core to clear PPIs on other cores.

I introduced this bug, sorry about that.

---
 hw/intc/gic_internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/intc/gic_internal.h +1 -1
index 92a6f7a..48a58d7 100644
@@ -40,7 +40,7 @@
 #define GIC_SET_MODEL(irq) s->irq_state[irq].model = true
 #define GIC_CLEAR_MODEL(irq) s->irq_state[irq].model = false
 #define GIC_TEST_MODEL(irq) s->irq_state[irq].model
-#define GIC_SET_LEVEL(irq, cm) s->irq_state[irq].level = (cm)
+#define GIC_SET_LEVEL(irq, cm) s->irq_state[irq].level |= (cm)
 #define GIC_CLEAR_LEVEL(irq, cm) s->irq_state[irq].level &= ~(cm)
 #define GIC_TEST_LEVEL(irq, cm) ((s->irq_state[irq].level & (cm)) != 0)
 #define GIC_SET_EDGE_TRIGGER(irq) s->irq_state[irq].edge_trigger = true
Signature · 1 line
1.8.5.2
#1 lore raw
Quoted 6 lines · Christoffer Dall

The GIC_SET_LEVEL macro unfortunately overwrote the entire level bitmask instead of just or'ing on the necessary bits, causing active level PPIs on a core to clear PPIs on other cores.

I introduced this bug, sorry about that.

Actually it turns out this was ancient, I was a little too quick to blame myself there.

-Christoffer

Reviewed-by
#2 lore raw
Quoted 9 lines · Christoffer Dall
Quoted 6 lines · Christoffer Dall

The GIC_SET_LEVEL macro unfortunately overwrote the entire level bitmask instead of just or'ing on the necessary bits, causing active level PPIs on a core to clear PPIs on other cores.

I introduced this bug, sorry about that.

Actually it turns out this was ancient, I was a little too quick to blame myself there.

Yes, it's been present since 2007 or so. Probably not noticed at that time because all the 11MPcore PPIs are edge rather than level triggered.

I'll remove the line about it being your fault when I apply this to target-arm.next :-)

thanks
-- PMM