Skip to content

Commit 16777eb

Browse files
committed
KVM: x86: WARN and reject KVM_RUN if vCPU's MP_STATE is SIPI_RECEIVED
WARN if KVM_RUN is reached with a vCPU's mp_state set to SIPI_RECEIVED, as KVM no longer uses SIPI_RECEIVED internally, and should morph SIPI_RECEIVED into INIT_RECEIVED with a pending SIPI if userspace forces SIPI_RECEIVED. See commit 66450a2 ("KVM: x86: Rework INIT and SIPI handling") for more history and details. Link: https://lore.kernel.org/r/20250605195018.539901-3-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent c4a37ac commit 16777eb

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

arch/x86/kvm/x86.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11568,6 +11568,20 @@ static void kvm_put_guest_fpu(struct kvm_vcpu *vcpu)
1156811568
trace_kvm_fpu(0);
1156911569
}
1157011570

11571+
static int kvm_x86_vcpu_pre_run(struct kvm_vcpu *vcpu)
11572+
{
11573+
/*
11574+
* SIPI_RECEIVED is obsolete; KVM leaves the vCPU in Wait-For-SIPI and
11575+
* tracks the pending SIPI separately. SIPI_RECEIVED is still accepted
11576+
* by KVM_SET_VCPU_EVENTS for backwards compatibility, but should be
11577+
* converted to INIT_RECEIVED.
11578+
*/
11579+
if (WARN_ON_ONCE(vcpu->arch.mp_state == KVM_MP_STATE_SIPI_RECEIVED))
11580+
return -EINVAL;
11581+
11582+
return kvm_x86_call(vcpu_pre_run)(vcpu);
11583+
}
11584+
1157111585
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
1157211586
{
1157311587
struct kvm_queued_exception *ex = &vcpu->arch.exception;
@@ -11670,7 +11684,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
1167011684
goto out;
1167111685
}
1167211686

11673-
r = kvm_x86_call(vcpu_pre_run)(vcpu);
11687+
r = kvm_x86_vcpu_pre_run(vcpu);
1167411688
if (r <= 0)
1167511689
goto out;
1167611690

0 commit comments

Comments
 (0)