[PATCH v2 0/3] KVM: x86: Don't lose ExtINT latched while LVT0 is masked

From: Jiaming Fan

Date: Thu Nov 26 2026 - 08:48:28 EST


The in-kernel PIC kicks a vCPU only on a rising edge of its output, so
an interrupt that arrives while LVT0 is masked is never injected when the
guest later unmasks LVT0 (patch 1) or hardware-disables the APIC (patch
2), as neither path requests KVM_REQ_EVENT. Linux guests booted with
"noapic" hang this way in calibrate_delay_converge(). Patch 3 adds a
selftest for both paths.

The selftest fails at the LVT0 unmask on the base kernel, at the APIC
hardware-disable with patch 1 alone, and passes with patches 1-2. Full
KVM selftests and kvm-unit-tests show no other differences. Tested on
AMD only, nested with AVIC disabled.

v1: https://lore.kernel.org/all/20261008-lapic-extint-lvt0-unmask-fix-v1-1-db2bf68fba75@xxxxxxxxxxxxx

v1 -> v2:
- Request KVM_REQ_EVENT on any unmasked LVT write [Sean]
- Add the APIC_BASE fix and the selftest

Jiaming Fan (2):
KVM: x86: Reevaluate pending interrupts when hardware-disabling the local APIC
KVM: selftests: Add a test for ExtINT latched while LVT0 is masked

Matthew Leach (1):
KVM: x86: Reevaluate pending interrupts when unmasking an LVT entry

arch/x86/kvm/lapic.c | 3 +
tools/testing/selftests/kvm/Makefile.kvm | 1 +
.../testing/selftests/kvm/include/x86/apic.h | 1 +
.../selftests/kvm/x86/pic_lvt0_extint_test.c | 241 ++++++++++++++++++
4 files changed, 246 insertions(+)

base-commit: cbe54fc3462b3949ab27b9ae81fb9ddb509040c7
--
2.56.1