Skip to contentSkip to conversation

xen/arm: clear UIE on hypervisor entry

PATCH Superseded Stefano Stabellini 4 participants 9 messages Nov 20, 2014 – Nov 21, 2014

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xen/arm: clear UIE on hypervisor entry

UIE being set can cause maintenance interrupts to occur when Xen writes to one or more LR registers. The effect is a busy loop around the interrupt handler in Xen
(http://marc.info/?l=xen-devel&m=141597517132682): everything gets stuck.

---

Konrad, this fixes an actual bug, at least on OMAP5. It should have no bad side effects on any other platforms as far as I can tell. It should go in 4.5.

Changes in v2:

- add an in-code comment about maintenance_interrupt not being called.

xen/arch/arm/gic.c +6 -2
index 70d10d6..c6c11d3 100644
@@ -403,6 +403,8 @@ void gic_clear_lrs(struct vcpu *v)
     if ( is_idle_vcpu(v) )
         return;
 
+    gic_hw_ops->update_hcr_status(GICH_HCR_UIE, 0);
+
     spin_lock_irqsave(&v->arch.vgic.lock, flags);
 
     while ((i = find_next_bit((const unsigned long *) &this_cpu(lr_mask),
@@ -527,8 +529,6 @@ void gic_inject(void)
 
     if ( !list_empty(&current->arch.vgic.lr_pending) && lr_all_full() )
         gic_hw_ops->update_hcr_status(GICH_HCR_UIE, 1);
-    else
-        gic_hw_ops->update_hcr_status(GICH_HCR_UIE, 0);
 }
 
 static void do_sgi(struct cpu_user_regs *regs, enum gic_sgi sgi)
@@ -598,6 +598,10 @@ static void maintenance_interrupt(int irq, void *dev_id, struct cpu_user_regs *r
      * Receiving the interrupt is going to cause gic_inject to be called
      * on return to guest that is going to clear the old LRs and inject
      * new interrupts.
+     *
+     * Do not add code here: maintenance interrupts caused by setting
+     * GICH_HCR_UIE, might read as spurious interrupts (1023). As a
+     * consequence sometimes this handler might not be called.
      */
 }
 
Signature · 1 line
1.7.10.4
#1 lore raw

Hi Stefano,

Quoted 8 lines · Stefano Stabellini

UIE being set can cause maintenance interrupts to occur when Xen writes to one or more LR registers. The effect is a busy loop around the interrupt handler in Xen
(http://marc.info/?l=xen-devel&m=141597517132682): everything gets stuck.

Quoted 7 lines

---

Konrad, this fixes an actual bug, at least on OMAP5. It should have no bad side effects on any other platforms as far as I can tell. It should go in 4.5.

From Andrii's mail, there is a bad side effect. We can receive spurious

interrupt.

On V1, you said that you tried this patch on midway. I would prefer if you give a try on platform that would really be used (such as xgene or seattle). As we know Midway won't be used in prod.

Regards,

Quoted 38 lines

Changes in v2:

- add an in-code comment about maintenance_interrupt not being called.

xen/arch/arm/gic.c +6 -2
index 70d10d6..c6c11d3 100644
@@ -403,6 +403,8 @@ void gic_clear_lrs(struct vcpu *v)
     if ( is_idle_vcpu(v) )
         return;
 
+    gic_hw_ops->update_hcr_status(GICH_HCR_UIE, 0);
+
     spin_lock_irqsave(&v->arch.vgic.lock, flags);
 
     while ((i = find_next_bit((const unsigned long *) &this_cpu(lr_mask),
@@ -527,8 +529,6 @@ void gic_inject(void)
 
     if ( !list_empty(&current->arch.vgic.lr_pending) && lr_all_full() )
         gic_hw_ops->update_hcr_status(GICH_HCR_UIE, 1);
-    else
-        gic_hw_ops->update_hcr_status(GICH_HCR_UIE, 0);
 }
 
 static void do_sgi(struct cpu_user_regs *regs, enum gic_sgi sgi)
@@ -598,6 +598,10 @@ static void maintenance_interrupt(int irq, void *dev_id, struct cpu_user_regs *r
      * Receiving the interrupt is going to cause gic_inject to be called
      * on return to guest that is going to clear the old LRs and inject
      * new interrupts.
+     *
+     * Do not add code here: maintenance interrupts caused by setting
+     * GICH_HCR_UIE, might read as spurious interrupts (1023). As a
+     * consequence sometimes this handler might not be called.
      */
 }
 
Signature · 1 line
Julien Grall
#2 lore raw
Quoted 17 lines · Julien Grall

Hi Stefano,

Quoted 5 lines · Stefano Stabellini

UIE being set can cause maintenance interrupts to occur when Xen writes to one or more LR registers. The effect is a busy loop around the interrupt handler in Xen
(http://marc.info/?l=xen-devel&m=141597517132682): everything gets stuck.

Quoted 8 lines

---

Konrad, this fixes an actual bug, at least on OMAP5. It should have no bad side effects on any other platforms as far as I can tell. It should go in 4.5.

Quoted 6 lines

From Andrii's mail, there is a bad side effect. We can receive spurious interrupt.

On V1, you said that you tried this patch on midway. I would prefer if you give a try on platform that would really be used (such as xgene or seattle). As we know Midway won't be used in prod.

And maybe give a try to gicv3 too as it's common code.

Regards,

Signature · 1 line
Julien Grall
#3 lore raw
Quoted 18 lines · Julien Grall
Quoted 17 lines · Julien Grall

Hi Stefano,

Quoted 13 lines · Stefano Stabellini

UIE being set can cause maintenance interrupts to occur when Xen writes to one or more LR registers. The effect is a busy loop around the interrupt handler in Xen
(http://marc.info/?l=xen-devel&m=141597517132682): everything gets stuck.

---

Konrad, this fixes an actual bug, at least on OMAP5. It should have no bad side effects on any other platforms as far as I can tell. It should go in 4.5.

Quoted 8 lines
Quoted 6 lines

From Andrii's mail, there is a bad side effect. We can receive spurious interrupt.

On V1, you said that you tried this patch on midway. I would prefer if you give a try on platform that would really be used (such as xgene or seattle). As we know Midway won't be used in prod.

And maybe give a try to gicv3 too as it's common code.

I don't have a gicv3 test environment ready but it works on xgene too

Reviewed-by
#4 lore raw

Hi Stefano,

Quoted 22 lines · Stefano Stabellini
Quoted 21 lines · Julien Grall
Quoted 20 lines · Julien Grall

Hi Stefano,

Quoted 5 lines · Stefano Stabellini

UIE being set can cause maintenance interrupts to occur when Xen writes to one or more LR registers. The effect is a busy loop around the interrupt handler in Xen
(http://marc.info/?l=xen-devel&m=141597517132682): everything gets stuck.

Quoted 8 lines

---

Konrad, this fixes an actual bug, at least on OMAP5. It should have no bad side effects on any other platforms as far as I can tell. It should go in 4.5.

From Andrii's mail, there is a bad side effect. We can receive spurious interrupt.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

On V1, you said that you tried this patch on midway. I would prefer if you give a try on platform that would really be used (such as xgene or seattle). As we know Midway won't be used in prod.

And maybe give a try to gicv3 too as it's common code.

I don't have a gicv3 test environment ready but it works on xgene too

Ok. I will give a quick try on the model today or tomorrow.

Aside from that, and after reading the spec. This patch looks good to me:

Regards,

Signature · 1 line
Julien Grall
Tested-by
#5 lore raw
In reply to Stefano Stabellini

Hi Stefano,

Quoted 22 lines · Stefano Stabellini
Quoted 21 lines · Julien Grall
Quoted 20 lines · Julien Grall

Hi Stefano,

Quoted 5 lines · Stefano Stabellini

UIE being set can cause maintenance interrupts to occur when Xen writes to one or more LR registers. The effect is a busy loop around the interrupt handler in Xen
(http://marc.info/?l=xen-devel&m=141597517132682): everything gets stuck.

Quoted 8 lines

---

Konrad, this fixes an actual bug, at least on OMAP5. It should have no bad side effects on any other platforms as far as I can tell. It should go in 4.5.

From Andrii's mail, there is a bad side effect. We can receive spurious
interrupt.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

On V1, you said that you tried this patch on midway. I would prefer if you give a try on platform that would really be used (such as xgene or seattle). As we know Midway won't be used in prod.

And maybe give a try to gicv3 too as it's common code.

I don't have a gicv3 test environment ready but it works on xgene too

I gave a try on the Foundation Model and didn't see any specific regression:

Regards,

Signature · 1 line
Julien Grall
#6 lore raw
In reply to Julien Grall
Quoted 13 lines · Julien Grall

Hi Stefano,

Quoted 10 lines · Stefano Stabellini

UIE being set can cause maintenance interrupts to occur when Xen writes to one or more LR registers. The effect is a busy loop around the interrupt handler in Xen
(http://marc.info/?l=xen-devel&m=141597517132682): everything gets stuck.

---

Quoted 6 lines
Quoted 5 lines

Konrad, this fixes an actual bug, at least on OMAP5. It should have no bad side effects on any other platforms as far as I can tell. It should go in 4.5.

From Andrii's mail, there is a bad side effect. We can receive spurious

interrupt.

The spurious interrupt is the maintenance interrupt.
There is not one more spurious interrupt notification in addition to the maintenance interrupt.

Quoted 3 lines

On V1, you said that you tried this patch on midway. I would prefer if you give a try on platform that would really be used (such as xgene or seattle). As we know Midway won't be used in prod.

OK

Quoted 45 lines

Regards,

Quoted 38 lines

Changes in v2:

- add an in-code comment about maintenance_interrupt not being called.

xen/arch/arm/gic.c +6 -2
index 70d10d6..c6c11d3 100644
@@ -403,6 +403,8 @@ void gic_clear_lrs(struct vcpu *v)
     if ( is_idle_vcpu(v) )
         return;
 
+    gic_hw_ops->update_hcr_status(GICH_HCR_UIE, 0);
+
     spin_lock_irqsave(&v->arch.vgic.lock, flags);
 
     while ((i = find_next_bit((const unsigned long *) &this_cpu(lr_mask),
@@ -527,8 +529,6 @@ void gic_inject(void)
 
     if ( !list_empty(&current->arch.vgic.lr_pending) && lr_all_full() )
         gic_hw_ops->update_hcr_status(GICH_HCR_UIE, 1);
-    else
-        gic_hw_ops->update_hcr_status(GICH_HCR_UIE, 0);
 }
 
 static void do_sgi(struct cpu_user_regs *regs, enum gic_sgi sgi)
@@ -598,6 +598,10 @@ static void maintenance_interrupt(int irq, void *dev_id, struct cpu_user_regs *r
      * Receiving the interrupt is going to cause gic_inject to be called
      * on return to guest that is going to clear the old LRs and inject
      * new interrupts.
+     *
+     * Do not add code here: maintenance interrupts caused by setting
+     * GICH_HCR_UIE, might read as spurious interrupts (1023). As a
+     * consequence sometimes this handler might not be called.
      */
 }
 
Signature · 1 line
Julien Grall
Acked-by on v2 1/1
#7 lore raw
In reply to Stefano Stabellini
Quoted 4 lines · Stefano Stabellini

UIE being set can cause maintenance interrupts to occur when Xen writes to one or more LR registers. The effect is a busy loop around the interrupt handler in Xen
(http://marc.info/?l=xen-devel&m=141597517132682): everything gets stuck.

I think it would be useful to explain somewhere why/how a spurious interrupt can occur, if not here then in the comment you've already added or in another one in gic_clear_lrs where you clear UIE.

The bit about clearing the LRs on entry causing UIE to become deasserted before we get as far as reading the IAR is a bit subtle.

Quoted 3 lines

With the expanded commentary:

Quoted 43 lines

---

Konrad, this fixes an actual bug, at least on OMAP5. It should have no bad side effects on any other platforms as far as I can tell. It should go in 4.5.

Changes in v2:

- add an in-code comment about maintenance_interrupt not being called.

xen/arch/arm/gic.c +6 -2
index 70d10d6..c6c11d3 100644
@@ -403,6 +403,8 @@ void gic_clear_lrs(struct vcpu *v)
     if ( is_idle_vcpu(v) )
         return;
 
+    gic_hw_ops->update_hcr_status(GICH_HCR_UIE, 0);
+
     spin_lock_irqsave(&v->arch.vgic.lock, flags);
 
     while ((i = find_next_bit((const unsigned long *) &this_cpu(lr_mask),
@@ -527,8 +529,6 @@ void gic_inject(void)
 
     if ( !list_empty(&current->arch.vgic.lr_pending) && lr_all_full() )
         gic_hw_ops->update_hcr_status(GICH_HCR_UIE, 1);
-    else
-        gic_hw_ops->update_hcr_status(GICH_HCR_UIE, 0);
 }
 
 static void do_sgi(struct cpu_user_regs *regs, enum gic_sgi sgi)
@@ -598,6 +598,10 @@ static void maintenance_interrupt(int irq, void *dev_id, struct cpu_user_regs *r
      * Receiving the interrupt is going to cause gic_inject to be called
      * on return to guest that is going to clear the old LRs and inject
      * new interrupts.
+     *
+     * Do not add code here: maintenance interrupts caused by setting
+     * GICH_HCR_UIE, might read as spurious interrupts (1023). As a
+     * consequence sometimes this handler might not be called.
      */
 }
 
#8 lore raw
Quoted 13 lines · Ian Campbell
Quoted 4 lines · Stefano Stabellini

UIE being set can cause maintenance interrupts to occur when Xen writes to one or more LR registers. The effect is a busy loop around the interrupt handler in Xen
(http://marc.info/?l=xen-devel&m=141597517132682): everything gets stuck.

I think it would be useful to explain somewhere why/how a spurious interrupt can occur, if not here then in the comment you've already added or in another one in gic_clear_lrs where you clear UIE.

The bit about clearing the LRs on entry causing UIE to become deasserted before we get as far as reading the IAR is a bit subtle.

Quoted 12 lines
Quoted 3 lines

With the expanded commentary:

Quoted 5 lines

---

Konrad, this fixes an actual bug, at least on OMAP5. It should have no bad side effects on any other platforms as far as I can tell. It should go in 4.5.

As long as the testing that Julian has asked for does not demonstrate any issues with this patch I am OK with it going in Xen 4.5.

Quoted 40 lines
Quoted 38 lines

Changes in v2:

- add an in-code comment about maintenance_interrupt not being called.

xen/arch/arm/gic.c +6 -2
index 70d10d6..c6c11d3 100644
@@ -403,6 +403,8 @@ void gic_clear_lrs(struct vcpu *v)
     if ( is_idle_vcpu(v) )
         return;
 
+    gic_hw_ops->update_hcr_status(GICH_HCR_UIE, 0);
+
     spin_lock_irqsave(&v->arch.vgic.lock, flags);
 
     while ((i = find_next_bit((const unsigned long *) &this_cpu(lr_mask),
@@ -527,8 +529,6 @@ void gic_inject(void)
 
     if ( !list_empty(&current->arch.vgic.lr_pending) && lr_all_full() )
         gic_hw_ops->update_hcr_status(GICH_HCR_UIE, 1);
-    else
-        gic_hw_ops->update_hcr_status(GICH_HCR_UIE, 0);
 }
 
 static void do_sgi(struct cpu_user_regs *regs, enum gic_sgi sgi)
@@ -598,6 +598,10 @@ static void maintenance_interrupt(int irq, void *dev_id, struct cpu_user_regs *r
      * Receiving the interrupt is going to cause gic_inject to be called
      * on return to guest that is going to clear the old LRs and inject
      * new interrupts.
+     *
+     * Do not add code here: maintenance interrupts caused by setting
+     * GICH_HCR_UIE, might read as spurious interrupts (1023). As a
+     * consequence sometimes this handler might not be called.
      */
 }