KVM: arm64: Preserve level IRQ re-pending
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest3 patches 0 repliesNew
- v1 RFC3 patches 2 repliesSuperseded
Changes in v2 from the cover letter
- Synchronize target vCPU LRs in vgic_mmio_write_spending() via vgic_access_active_prepare() and vgic_access_active_finish() under config_lock instead of tracking on-LR writes with a separate latch_written flag (Oliver Upton).
- Extend the selftest to verify that a cross-vCPU GICD_ISPENDR write before the ack merges with the initial pending state without causing a second delivery.
- Drop RFC prefix.
- Link to v1: https://lore.kernel.org/r/[email protected]
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | KVM: arm64: vgic-v2: Don't drop pending writes to active level IRQsarch/ arch/ | +50 | 0 replies | |
| 2/3 | KVM: arm64: vgic-v3: Don't drop pending writes to active level IRQsarch/ | +7 | 0 replies | |
| 3/3 | KVM: selftests: arm64: Test pending writes to active level IRQstools/ | +140 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH v2 0/3] KVM: arm64: Preserve level IRQ re-pending
A guest can set a level interrupt pending again while handling it. The GIC records Active and Pending and delivers the interrupt after deactivation. KVM instead drops the second pending state for both the GICv2 and GICv3 backends.
The VGIC keeps software pending state outside the LR because commit 67b5b673ad4d stopped placing Pending and Active together for level interrupts. When the LR is folded, KVM cannot distinguish the pending state used to populate the LR from a later ISPENDR write.
Synchronize the target vCPU's LRs in vgic_mmio_write_spending() with vgic_access_active_prepare() and vgic_access_active_finish() under config_lock before setting pending_latch, as suggested by Oliver Upton. When a vCPU writes its own GICR_ISPENDR0, this synchronization is a no-op. For shared interrupts or remote redistributor writes, stopping the guest folds any prior ack from the target vCPU's LRs before the new pending state is recorded. In the v2 and v3 fold paths, clear pending_latch when an LR populated for an inactive interrupt no longer reports a pending state, and preserve a latch written while the interrupt was active.
The last patch adds a two-vCPU GICv3 selftest covering same-vCPU and cross-vCPU re-pending while active, as well as a cross-vCPU ISPENDR write before the ack.
The issue was reproduced with Zephyr, NuttX and RT-Thread test harnesses that configure an unused SPI as level-sensitive, pend it via GICD_ISPENDR, and re-pend it once from the ISR before deactivation. On a Raspberry Pi 400 host with a GIC-400, each GICv2 guest handled the SPI once on the baseline and twice with the RFC fix. A native RT-Thread run on the same GIC-400 also delivered the re-pended interrupt.
The v2 change was A/B tested with RT-Thread's direct and mailbox-pic reproducers on Linux/KVM hosts running under QEMU TCG with GICv2 and GICv3. The baseline lost the second event and v2 delivered it. The new GICv3 selftest also passes in that setup. I do not have a physical GICv3 host, so the GICv3 testing is emulated.
Changes in v2:
- Synchronize target vCPU LRs in vgic_mmio_write_spending() via vgic_access_active_prepare() and vgic_access_active_finish() under config_lock instead of tracking on-LR writes with a separate latch_written flag (Oliver Upton).
- Extend the selftest to verify that a cross-vCPU GICD_ISPENDR write before the ack merges with the initial pending state without causing a second delivery.
- Drop RFC prefix.
- Link to v1: https://lore.kernel.org/r/[email protected]
Karl Mehltretter (3):
KVM: arm64: vgic-v2: Don't drop pending writes to active level IRQs
KVM: arm64: vgic-v3: Don't drop pending writes to active level IRQs
KVM: selftests: arm64: Test pending writes to active level IRQs
arch/arm64/kvm/vgic/vgic-mmio.c | 76 +++++----- arch/arm64/kvm/vgic/vgic-v2.c | 10 +- arch/arm64/kvm/vgic/vgic-v3.c | 10 +- tools/testing/selftests/kvm/arm64/vgic_irq.c | 140 +++++++++++++++++++ 4 files changed, 197 insertions(+), 39 deletions(-)
base-commit: dd0bc00e3e9201fd49b62ff9cc07890c89003afe
Signature · 1 line
2.39.5 (Apple Git-154)