Skip to contentSkip to conversation

hw/intc/arm_gicv3_cpuif: Don't count a virtual EOI in EOImode 1

PATCH Applied Fuad Tabba 2 participants 2 messages Nov 19 – Nov 23

lore
Share & tools
lore

Fuad Tabba

author
#0 lore raw

PATCH 1/1 hw/intc/arm_gicv3_cpuif: Don't count a virtual EOI in EOImode 1

icv_eoir_write() increments ICH_HCR_EL2.EOIcount for a virtual EOI with no matching list register, in either EOImode. The VirtualWriteEOIR0() and VirtualWriteEOIR1() pseudocode in the GICv3 architecture specification only does so in EOImode 0 (ICH_VMCR_EL2.VEOIM clear), since in EOImode 1 the DIR write increments EOIcount instead.

In EOImode 1 an interrupt with no list register is therefore counted twice, and KVM running under TCG deactivates an interrupt that its guest has yet to deactivate.

Increment EOIcount on EOIR only when EOImode is 0.

Fixes b3b48f529fe8 ("hw/intc/arm_gicv3: Implement ICV_ registers EOIR and IAR")

---

Notes:
Tested with a local reproducer that runs a KVM guest in EOImode 1 under TCG, with more interrupts pending than list registers. Without this patch the guest sees an interrupt deactivated before its DIR, and with it the reproducer passes.

 hw/intc/arm_gicv3_cpuif.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
hw/intc/arm_gicv3_cpuif.c +3 -2
index 67a0bba4b0..02e1e7c254 100644
@@ -1617,9 +1617,10 @@ static void icv_eoir_write(CPUARMState *env, const ARMCPRegInfo *ri,
     if (idx < 0) {
         /*
          * No valid list register corresponding to EOI ID; if this is a vLPI
-         * not in the list regs then do nothing; otherwise increment EOI count
+         * not in the list regs then do nothing; otherwise increment EOI count,
+         * unless drop and deactivate are split, when the DIR write does so.
          */
-        if (irq < GICV3_LPI_INTID_START) {
+        if (irq < GICV3_LPI_INTID_START && !icv_eoi_split(env, cs)) {
             icv_increment_eoicount(cs);
         }
     } else {
Signature · 1 line
2.47.3
#1 lore raw
Quoted 18 lines · Fuad Tabba

icv_eoir_write() increments ICH_HCR_EL2.EOIcount for a virtual EOI with no matching list register, in either EOImode. The VirtualWriteEOIR0() and VirtualWriteEOIR1() pseudocode in the GICv3 architecture specification only does so in EOImode 0 (ICH_VMCR_EL2.VEOIM clear), since in EOImode 1 the DIR write increments EOIcount instead.

In EOImode 1 an interrupt with no list register is therefore counted twice, and KVM running under TCG deactivates an interrupt that its guest has yet to deactivate.

Increment EOIcount on EOIR only when EOImode is 0.

Fixes b3b48f529fe8 ("hw/intc/arm_gicv3: Implement ICV_ registers EOIR and IAR")

---

Quoted 8 lines

Notes:
Tested with a local reproducer that runs a KVM guest in EOImode 1 under TCG, with more interrupts pending than list registers. Without this patch the guest sees an interrupt deactivated before its DIR, and with it the reproducer passes.

 hw/intc/arm_gicv3_cpuif.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Applied to target-arm.next, thanks.

-- PMM