]> git.proxmox.com Git - mirror_ubuntu-impish-kernel.git/commit - arch/x86/kvm/lapic.c
KVM: x86: Properly handle APF vs disabled LAPIC situation
authorVitaly Kuznetsov <vkuznets@redhat.com>
Thu, 22 Apr 2021 09:29:48 +0000 (11:29 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 26 Apr 2021 09:19:27 +0000 (05:19 -0400)
commit2f15d027c05fac406decdb5eceb9ec0902b68f53
treedd407a143b560b468e45c5dc5ccc8fda4ecc25e9
parent462f8ddebccbb8a364b154008212052d515ac6b1
KVM: x86: Properly handle APF vs disabled LAPIC situation

Async PF 'page ready' event may happen when LAPIC is (temporary) disabled.
In particular, Sebastien reports that when Linux kernel is directly booted
by Cloud Hypervisor, LAPIC is 'software disabled' when APF mechanism is
initialized. On initialization KVM tries to inject 'wakeup all' event and
puts the corresponding token to the slot. It is, however, failing to inject
an interrupt (kvm_apic_set_irq() -> __apic_accept_irq() -> !apic_enabled())
so the guest never gets notified and the whole APF mechanism gets stuck.
The same issue is likely to happen if the guest temporary disables LAPIC
and a previously unavailable page becomes available.

Do two things to resolve the issue:
- Avoid dequeuing 'page ready' events from APF queue when LAPIC is
  disabled.
- Trigger an attempt to deliver pending 'page ready' events when LAPIC
  becomes enabled (SPIV or MSR_IA32_APICBASE).

Reported-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20210422092948.568327-1-vkuznets@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/lapic.c
arch/x86/kvm/x86.c