Skip to content

Commit f3ced00

Browse files
sean-jcbonzini
authored andcommitted
KVM: x86: Always sync PIR to IRR prior to scanning I/O APIC routes
Sync pending posted interrupts to the IRR prior to re-scanning I/O APIC routes, irrespective of whether the I/O APIC is emulated by userspace or by KVM. If a level-triggered interrupt routed through the I/O APIC is pending or in-service for a vCPU, KVM needs to intercept EOIs on said vCPU even if the vCPU isn't the destination for the new routing, e.g. if servicing an interrupt using the old routing races with I/O APIC reconfiguration. Commit fceb3a3 ("KVM: x86: ioapic: Fix level-triggered EOI and userspace I/OAPIC reconfigure race") fixed the common cases, but kvm_apic_pending_eoi() only checks if an interrupt is in the local APIC's IRR or ISR, i.e. misses the uncommon case where an interrupt is pending in the PIR. Failure to intercept EOI can manifest as guest hangs with Windows 11 if the guest uses the RTC as its timekeeping source, e.g. if the VMM doesn't expose a more modern form of time to the guest. Cc: stable@vger.kernel.org Cc: Adamos Ttofari <attofari@amazon.de> Cc: Raghavendra Rao Ananta <rananta@google.com> Reviewed-by: Jim Mattson <jmattson@google.com> Signed-off-by: Sean Christopherson <seanjc@google.com> Message-ID: <20240611014845.82795-1-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent db574f2 commit f3ced00

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

arch/x86/kvm/x86.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10718,13 +10718,12 @@ static void vcpu_scan_ioapic(struct kvm_vcpu *vcpu)
1071810718

1071910719
bitmap_zero(vcpu->arch.ioapic_handled_vectors, 256);
1072010720

10721+
static_call_cond(kvm_x86_sync_pir_to_irr)(vcpu);
10722+
1072110723
if (irqchip_split(vcpu->kvm))
1072210724
kvm_scan_ioapic_routes(vcpu, vcpu->arch.ioapic_handled_vectors);
10723-
else {
10724-
static_call_cond(kvm_x86_sync_pir_to_irr)(vcpu);
10725-
if (ioapic_in_kernel(vcpu->kvm))
10726-
kvm_ioapic_scan_entry(vcpu, vcpu->arch.ioapic_handled_vectors);
10727-
}
10725+
else if (ioapic_in_kernel(vcpu->kvm))
10726+
kvm_ioapic_scan_entry(vcpu, vcpu->arch.ioapic_handled_vectors);
1072810727

1072910728
if (is_guest_mode(vcpu))
1073010729
vcpu->arch.load_eoi_exitmap_pending = true;

0 commit comments

Comments
 (0)