Re: [PATCH] KVM: x86: Always sync PIR to IRR prior to scanning I/O APIC routes

From: Jim Mattson
Date: Mon Jun 10 2024 - 23:47:50 EST


On Mon, Jun 10, 2024 at 6:48 PM Sean Christopherson <seanjc@xxxxxxxxxx> wrote:
>
> 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 fceb3a36c29a ("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@xxxxxxxxxxxxxxx
> Cc: Adamos Ttofari <attofari@xxxxxxxxx>
> Cc: Raghavendra Rao Ananta <rananta@xxxxxxxxxx>
> Cc: Jim Mattson <jmattson@xxxxxxxxxx>
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
Reviewed-by: Jim Mattson <jmattson@xxxxxxxxxx>