@@ -10985,7 +10985,13 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch)
if (ret)
return ret;
- if (vmcs12->guest_activity_state == GUEST_ACTIVITY_HLT)
+ /*
+ * If we're entering a halted L2 vcpu and the L2 vcpu won't be woken
+ * by event injection or VID, halt vcpu for optimization.
+ */
+ if ((vmcs12->guest_activity_state == GUEST_ACTIVITY_HLT) &&
+ !(vmcs12->vm_entry_intr_info_field & VECTORING_INFO_VALID_MASK) &&
+ !(nested_cpu_has_vid(vmcs12) && (vmcs12->guest_intr_status & 0xff)))
return kvm_vcpu_halt(vcpu);
vmx->nested.nested_run_pending = 1;