]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
KVM: x86: Refactor handling of SIPI_RECEIVED when setting MP_STATE
authorSean Christopherson <seanjc@google.com>
Thu, 5 Jun 2025 19:50:18 +0000 (12:50 -0700)
committerSean Christopherson <seanjc@google.com>
Fri, 20 Jun 2025 20:08:00 +0000 (13:08 -0700)
Convert the incoming mp_state to INIT_RECIEVED instead of manually calling
kvm_set_mp_state() to make it more obvious that the SIPI_RECEIVED logic is
translating the incoming state to KVM's internal tracking, as opposed to
being some entirely unique flow.

Opportunistically add a comment to explain what the code is doing.

No functional change intended.

Link: https://lore.kernel.org/r/20250605195018.539901-5-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/x86.c

index f7eaff64ed0195d22f9857bfd7d69a760c52e79a..ceea434d297ea8477cf71870c6c6c213458ce3f5 100644 (file)
@@ -11929,11 +11929,17 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
                goto out;
        }
 
+       /*
+        * SIPI_RECEIVED is obsolete and no longer used internally; KVM instead
+        * leaves the vCPU in INIT_RECIEVED (Wait-For-SIPI) and pends the SIPI.
+        * Translate SIPI_RECEIVED as appropriate for backwards compatibility.
+        */
        if (mp_state->mp_state == KVM_MP_STATE_SIPI_RECEIVED) {
-               kvm_set_mp_state(vcpu, KVM_MP_STATE_INIT_RECEIVED);
+               mp_state->mp_state = KVM_MP_STATE_INIT_RECEIVED;
                set_bit(KVM_APIC_SIPI, &vcpu->arch.apic->pending_events);
-       } else
-               kvm_set_mp_state(vcpu, mp_state->mp_state);
+       }
+
+       kvm_set_mp_state(vcpu, mp_state->mp_state);
        kvm_make_request(KVM_REQ_EVENT, vcpu);
 
        ret = 0;