From: Xiang Zheng <xiang.zheng@linux.alibaba.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <seanjc@google.com>,
Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H . Peter Anvin" <hpa@zytor.com>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
Shuah Khan <shuah@kernel.org>
Cc: Shannon Zhao <shannon.zhao@linux.alibaba.com>,
kvm@vger.kernel.org, x86@kernel.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: [PATCH 0/2] KVM: x86: Fix stale RTC pending-EOI tracking under AVIC
Date: Tue, 20 Oct 2026 14:00:51 +0800 [thread overview]
Message-ID: <20261020060053.25011-1-xiang.zheng@linux.alibaba.com> (raw)
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)
next reply other threads:[~2026-10-20 6:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 6:00 Xiang Zheng [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261020060053.25011-1-xiang.zheng@linux.alibaba.com \
--to=xiang.zheng@linux.alibaba.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=shannon.zhao@linux.alibaba.com \
--cc=shuah@kernel.org \
--cc=suravee.suthikulpanit@amd.com \
--cc=tglx@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®