[PATCH v2 1/3] KVM: x86: Reevaluate pending interrupts when unmasking an LVT entry
From: Jiaming Fan
Date: Thu Nov 26 2026 - 08:49:01 EST
From: Matthew Leach <matthew.leach@xxxxxxxxxxxxx>
The PIC kicks vCPUs only when its output rises, and the output stays
high until the interrupt is acknowledged. If it rises while LVT0 is
masked, unmasking LVT0 later makes the interrupt injectable, but nothing
sets KVM_REQ_EVENT, so it is never injected. Linux guests booted with
"noapic" hit this: setup_local_APIC() masks all LVT entries through SPIV
and later writes LVT0 as unmasked ExtINT, so a PIT tick in between hangs
the guest in calibrate_delay_converge().
Request KVM_REQ_EVENT whenever an LVT entry is written unmasked. The
trigger mode bit can't be used to filter, as the ExtINT is latched in the
PIC and Linux programs LVT0 without APIC_LVT_LEVEL_TRIGGER.
Suggested-by: Sean Christopherson <seanjc@xxxxxxxxxx>
Signed-off-by: Matthew Leach <matthew.leach@xxxxxxxxxxxxx>
[jiaming: request KVM_REQ_EVENT for any unmasked LVT write, reword changelog]
Signed-off-by: Jiaming Fan <fan.jiaming@xxxxxxxxxxx>
---
arch/x86/kvm/lapic.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index d341801b61cba..c1f819a0ab2fd 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -2524,6 +2524,8 @@ static int kvm_lapic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)
val |= APIC_LVT_MASKED;
val &= apic_lvt_mask[index];
kvm_lapic_set_reg(apic, reg, val);
+ if (!(val & APIC_LVT_MASKED))
+ kvm_make_request(KVM_REQ_EVENT, apic->vcpu);
break;
}
--
2.56.1