Skip to contentSkip to conversation

xen/arm: gic_shutdown_irq must only disable the right IRQ

PATCH In review Julien Grall 3 participants 4 messages Jun 28, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/arm: gic_shutdown_irq must only disable the right IRQ

When GICD_ICENABLERn is read, all the 1s bit represent enabled IRQs. Currently gic_shutdown_irq:
- read GICD_ICENABLER
- set the corresping bit to 1
- write back the new value
That means, Xen will disable more IRQs than necessary.

---
 xen/arch/arm/gic.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
xen/arch/arm/gic.c +1 -3
index 177560e..cafb681 100644
@@ -117,12 +117,10 @@ static unsigned int gic_irq_startup(struct irq_desc *desc)
 
 static void gic_irq_shutdown(struct irq_desc *desc)
 {
-    uint32_t enabler;
     int irq = desc->irq;
 
     /* Disable routing */
-    enabler = GICD[GICD_ICENABLER + irq / 32];
-    GICD[GICD_ICENABLER + irq / 32] = enabler | (1u << (irq % 32));
+    GICD[GICD_ICENABLER + irq / 32] = (1u << (irq % 32));
 }
 
 static void gic_irq_enable(struct irq_desc *desc)
Signature · 1 line
1.7.10.4
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Julien Grall

When GICD_ICENABLERn is read, all the 1s bit represent enabled IRQs. Currently gic_shutdown_irq:
- read GICD_ICENABLER
- set the corresping bit to 1
- write back the new value
That means, Xen will disable more IRQs than necessary.

Doh!

Quoted 22 lines
---
 xen/arch/arm/gic.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
xen/arch/arm/gic.c +1 -3
index 177560e..cafb681 100644
@@ -117,12 +117,10 @@ static unsigned int gic_irq_startup(struct irq_desc *desc)
 
 static void gic_irq_shutdown(struct irq_desc *desc)
 {
-    uint32_t enabler;
     int irq = desc->irq;
 
     /* Disable routing */
-    enabler = GICD[GICD_ICENABLER + irq / 32];
-    GICD[GICD_ICENABLER + irq / 32] = enabler | (1u << (irq % 32));
+    GICD[GICD_ICENABLER + irq / 32] = (1u << (irq % 32));
 }
 
 static void gic_irq_enable(struct irq_desc *desc)
#2 lore raw
In reply to Julien Grall
Quoted 8 lines · Julien Grall

When GICD_ICENABLERn is read, all the 1s bit represent enabled IRQs. Currently gic_shutdown_irq:
- read GICD_ICENABLER
- set the corresping bit to 1
- write back the new value
That means, Xen will disable more IRQs than necessary.

It's impressive for how long we got this bug.

Quoted 24 lines
 xen/arch/arm/gic.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
xen/arch/arm/gic.c +1 -3
index 177560e..cafb681 100644
@@ -117,12 +117,10 @@ static unsigned int gic_irq_startup(struct irq_desc *desc)
 
 static void gic_irq_shutdown(struct irq_desc *desc)
 {
-    uint32_t enabler;
     int irq = desc->irq;
 
     /* Disable routing */
-    enabler = GICD[GICD_ICENABLER + irq / 32];
-    GICD[GICD_ICENABLER + irq / 32] = enabler | (1u << (irq % 32));
+    GICD[GICD_ICENABLER + irq / 32] = (1u << (irq % 32));
 }
 
 static void gic_irq_enable(struct irq_desc *desc)
Signature · 1 line
1.7.10.4
#3 lore raw
Quoted 8 lines · Stefano Stabellini
Quoted 7 lines · Julien Grall

When GICD_ICENABLERn is read, all the 1s bit represent enabled IRQs. Currently gic_shutdown_irq:
- read GICD_ICENABLER
- set the corresping bit to 1
- write back the new value
That means, Xen will disable more IRQs than necessary.

Quoted 5 lines
Quoted 1 line

It's impressive for how long we got this bug.

I think you meant Acked-by, so applied with both our acks.