Skip to contentSkip to conversation

KVM: x86: Drop WARN on INIT/SIPI being blocked when vCPU is in Wait-For-SIPI

PATCH Applied Sean Christopherson 1 participant 2 messages Jan 23 – Feb 4

Subsystems (3)
lore
Share & tools
lore

Sean Christopherson

author maintainer
#0 lore raw

PATCH 1/1 KVM: x86: Drop WARN on INIT/SIPI being blocked when vCPU is in Wait-For-SIPI

Drop the sanity check in kvm_apic_accept_events() that attempts to detect KVM bugs by asserting that a vCPU isn't in Wait-For-SIPI if INIT/SIPI are blocked, because if INIT is blocked, then it should be impossible for a vCPU to get into WFS in the first place. Unfortunately, syzbot is smarter than KVM (and its maintainers), and circumvented the guards put in place by commit 0fe3e8d804fd ("KVM: x86: Move INIT_RECEIVED vs. INIT/SIPI blocked check to KVM_RUN") by swapping the order and stuffing VMXON after INIT, and then triggering kvm_apic_accept_events() by way of KVM_GET_MP_STATE.

Simply drop the WARN as it hasn't detected any meaningful KVM bugs in years (if ever?), and preventing userspace from clobbering guest state is generally a non-goal. More importantly, fully closing the hole would likely require enforcing some amount of ordering in KVM's ioctls, which is a much bigger risk than simply deleting the WARN.

---
 arch/x86/kvm/lapic.c | 1 -
 1 file changed, 1 deletion(-)
arch/x86/kvm/lapic.c +0 -1
index 2e513f1c8988..46ba9df3b81d 100644
@@ -3487,7 +3487,6 @@ int kvm_apic_accept_events(struct kvm_vcpu *vcpu)
 	 * wait-for-SIPI (WFS).
 	 */
 	if (!kvm_apic_init_sipi_allowed(vcpu)) {
-		WARN_ON_ONCE(vcpu->arch.mp_state == KVM_MP_STATE_INIT_RECEIVED);
 		clear_bit(KVM_APIC_SIPI, &apic->pending_events);
 		return 0;
 	}

base-commit: acdc5446135932ca974b82d9d9a17762c7a82493

Signature · 1 line
2.52.0.457.g6b5491de43-goog
author maintainer Applied
#1 lore raw
Quoted 10 lines · Sean Christopherson

Drop the sanity check in kvm_apic_accept_events() that attempts to detect KVM bugs by asserting that a vCPU isn't in Wait-For-SIPI if INIT/SIPI are blocked, because if INIT is blocked, then it should be impossible for a vCPU to get into WFS in the first place. Unfortunately, syzbot is smarter than KVM (and its maintainers), and circumvented the guards put in place by commit 0fe3e8d804fd ("KVM: x86: Move INIT_RECEIVED vs. INIT/SIPI blocked check to KVM_RUN") by swapping the order and stuffing VMXON after INIT, and then triggering kvm_apic_accept_events() by way of KVM_GET_MP_STATE.

[...]

Applied to kvm-x86 misc.

[1/1] KVM: x86: Drop WARN on INIT/SIPI being blocked when vCPU is in Wait-For-SIPI

      https://github.com/kvm-x86/linux/commit/c4a365cd4a4e

--
https://github.com/kvm-x86/linux/tree/next