Skip to contentSkip to conversation

xen/arm: Save/Restore GICH_APR register

PATCH In review Julien Grall 3 participants 3 messages Apr 4, 2013 – Apr 11, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/arm: Save/Restore GICH_APR register

Linux uses GICC_CTLR.EOImodeNS set to 0, which means both priority drop and deactivate interrupt functionality are made when something is written in GICC_EOIR.

As the ARM manual specifies: "having an active interrupt in the List registers with a priority that is not set in the corresponding Active Priorities register" when GICV_CTLR.EOImode (ie GICC_CTLR.EOImodeNS in the guest context) result in unpredicable behavior, we need to save/restore GICH_APR.

---
 xen/arch/arm/gic.c |    2 ++
 1 file changed, 2 insertions(+)
xen/arch/arm/gic.c +2 -0
index 41abdfb..ccb90e5 100644
@@ -70,6 +70,7 @@ void gic_save_state(struct vcpu *v)
         v->arch.gic_lr[i] = GICH[GICH_LR + i];
     v->arch.lr_mask = this_cpu(lr_mask);
     spin_unlock_irq(&gic.lock);
+    v->arch.gic_apr = GICH[GICH_APR];
     /* Disable until next VCPU scheduled */
     GICH[GICH_HCR] = 0;
     isb();
@@ -87,6 +88,7 @@ void gic_restore_state(struct vcpu *v)
     for ( i=0; i<nr_lrs; i++)
         GICH[GICH_LR + i] = v->arch.gic_lr[i];
     spin_unlock_irq(&gic.lock);
+    GICH[GICH_APR] = v->arch.gic_apr;
     GICH[GICH_HCR] = GICH_HCR_EN;
     isb();
 
Signature · 1 line
1.7.10.4
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Julien Grall

Linux uses GICC_CTLR.EOImodeNS set to 0, which means both priority drop and deactivate interrupt functionality are made when something is written in GICC_EOIR.

As the ARM manual specifies: "having an active interrupt in the List registers with a priority that is not set in the corresponding Active Priorities register" when GICV_CTLR.EOImode (ie GICC_CTLR.EOImodeNS in the guest context) result in unpredicable behavior, we need to save/restore GICH_APR.

Nice catch!!

Quoted 26 lines
 xen/arch/arm/gic.c |    2 ++
 1 file changed, 2 insertions(+)
xen/arch/arm/gic.c +2 -0
index 41abdfb..ccb90e5 100644
@@ -70,6 +70,7 @@ void gic_save_state(struct vcpu *v)
         v->arch.gic_lr[i] = GICH[GICH_LR + i];
     v->arch.lr_mask = this_cpu(lr_mask);
     spin_unlock_irq(&gic.lock);
+    v->arch.gic_apr = GICH[GICH_APR];
     /* Disable until next VCPU scheduled */
     GICH[GICH_HCR] = 0;
     isb();
@@ -87,6 +88,7 @@ void gic_restore_state(struct vcpu *v)
     for ( i=0; i<nr_lrs; i++)
         GICH[GICH_LR + i] = v->arch.gic_lr[i];
     spin_unlock_irq(&gic.lock);
+    GICH[GICH_APR] = v->arch.gic_apr;
     GICH[GICH_HCR] = GICH_HCR_EN;
     isb();
 
Signature · 1 line
1.7.10.4
#2 lore raw
Quoted 5 lines · Stefano Stabellini
Quoted 4 lines · Julien Grall

Linux uses GICC_CTLR.EOImodeNS set to 0, which means both priority drop and deactivate interrupt functionality are made when something is written in GICC_EOIR.

Quoted 8 lines
Quoted 6 lines

As the ARM manual specifies: "having an active interrupt in the List registers with a priority that is not set in the corresponding Active Priorities register" when GICV_CTLR.EOImode (ie GICC_CTLR.EOImodeNS in the guest context) result in unpredicable behavior, we need to save/restore GICH_APR.

Nice catch!!

Indeed! I don't suppose you had a glance through the docs for other gic registers we've missed?

Quoted 1 line

me too + Applied.