vcpu_load(vcpu);
  
 -      if (!lapic_in_kernel(vcpu) &&
 -          mp_state->mp_state != KVM_MP_STATE_RUNNABLE)
 +      switch (mp_state->mp_state) {
 +      case KVM_MP_STATE_UNINITIALIZED:
 +      case KVM_MP_STATE_HALTED:
 +      case KVM_MP_STATE_AP_RESET_HOLD:
 +      case KVM_MP_STATE_INIT_RECEIVED:
 +      case KVM_MP_STATE_SIPI_RECEIVED:
 +              if (!lapic_in_kernel(vcpu))
 +                      goto out;
 +              break;
 +
 +      case KVM_MP_STATE_RUNNABLE:
 +              break;
 +
 +      default:
                goto out;
 +      }
  
        /*
-        * KVM_MP_STATE_INIT_RECEIVED means the processor is in
-        * INIT state; latched init should be reported using
-        * KVM_SET_VCPU_EVENTS, so reject it here.
+        * Pending INITs are reported using KVM_SET_VCPU_EVENTS, disallow
+        * forcing the guest into INIT/SIPI if those events are supposed to be
+        * blocked.  KVM prioritizes SMI over INIT, so reject INIT/SIPI state
+        * if an SMI is pending as well.
         */
-       if ((kvm_vcpu_latch_init(vcpu) || vcpu->arch.smi_pending) &&
+       if ((!kvm_apic_init_sipi_allowed(vcpu) || vcpu->arch.smi_pending) &&
            (mp_state->mp_state == KVM_MP_STATE_SIPI_RECEIVED ||
             mp_state->mp_state == KVM_MP_STATE_INIT_RECEIVED))
                goto out;