mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] KVM: x86: Fix stale RTC pending-EOI tracking under AVIC
@ 2026-10-20  6:00 Xiang Zheng
  2026-10-20  6:00 ` [PATCH 1/2] KVM: x86: ioapic: Clear stale RTC pending EOIs using the delivery record Xiang Zheng
  2026-10-20  6:00 ` [PATCH 2/2] KVM: selftests: x86: Add RTC EOI retargeting regression test Xiang Zheng
  0 siblings, 2 replies; 3+ messages in thread
From: Xiang Zheng @ 2026-10-20  6:00 UTC (permalink / raw)
  To: Paolo Bonzini, Sean Christopherson, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, H . Peter Anvin,
	Suravee Suthikulpanit, Shuah Khan
  Cc: Shannon Zhao, kvm, x86, linux-kernel, linux-kselftest

ioapic_lazy_update_eoi() exists because AVIC completes EOIs of
edge-triggered interrupts in hardware, without a VM exit.  It clears
the RTC pending-EOI record of vCPUs that no longer have the vector in
IRR/ISR, but identifies those vCPUs with the current redirection entry
instead of the delivery record kept in rtc_status.  A guest that
retargets the RTC after such an EOI therefore leaves the pending EOI
set, and every later RTC interrupt is dropped as coalesced.  A guest
that relies on the RTC timer interrupt to advance timekeeping, e.g. a
Windows guest without HPET and with an unused APIC timer, then loses
its timer and hangs.

Patch 1 makes the lazy update consult the delivery record.  Patch 2
adds a selftest that reproduces the bookkeeping failure without a
Windows guest: userspace injects GSI 8, the target vCPU handles it and
writes the EOI, the guest retargets the RTC, and the next injection
must still be reported as delivered by KVM_IRQ_LINE_STATUS.

Tested on an AMD host running Linux 7.3-rc7: with AVIC enabled, the
unpatched kernel fails the selftest at the second injection (status 0,
coalesced) and the patched kernel passes all 64 rounds; with AVIC
disabled both pass.  Not tested on Intel/APICv.

Thanks,
Xiang

Xiang Zheng (2):
  KVM: x86: ioapic: Clear stale RTC pending EOIs using the delivery
    record
  KVM: selftests: x86: Add RTC EOI retargeting regression test

 arch/x86/kvm/ioapic.c                         |  19 +--
 tools/testing/selftests/kvm/Makefile.kvm      |   1 +
 .../selftests/kvm/x86/rtc_eoi_retarget_test.c | 155 ++++++++++++++++++
 3 files changed, 164 insertions(+), 11 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/x86/rtc_eoi_retarget_test.c


base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-20  6:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-20  6:00 [PATCH 0/2] KVM: x86: Fix stale RTC pending-EOI tracking under AVIC Xiang Zheng
2026-10-20  6:00 ` [PATCH 1/2] KVM: x86: ioapic: Clear stale RTC pending EOIs using the delivery record Xiang Zheng
2026-10-20  6:00 ` [PATCH 2/2] KVM: selftests: x86: Add RTC EOI retargeting regression test Xiang Zheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®