The VMCS launch state is not set to "launched" unless the VMLAUNCH actually succeeds. VMLAUNCH failure includes VM-entry failure during or after loading guest state (i.e. VM-exits with bit 31 set in the exit reason). Note that this change does not address the related problem that a failure to launch/resume vmcs02 (i.e. vmx->fail) is not handled correctly. Fixes: cd232ad02f002 ("KVM: nVMX: Implement VMLAUNCH and VMRESUME") Signed-off-by: Jim Mattson <jmattson@xxxxxxxxxx> --- arch/x86/kvm/vmx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 4cddd6fab1c5..1d308c5b89fd 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -10396,8 +10396,6 @@ static int enter_vmx_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry) return 1; } - vmcs12->launch_state = 1; - /* * Note no nested_vmx_succeed or nested_vmx_fail here. At this point * we are no longer running L1, and VMLAUNCH/VMRESUME has not yet @@ -10800,6 +10798,7 @@ static void prepare_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12, vmcs12->exit_qualification = exit_qualification; if (!(vmcs12->vm_exit_reason & VMX_EXIT_REASONS_FAILED_VMENTRY)) { + vmcs12->launch_state = 1; update_vmcs12_vm_entry_controls(vcpu, vmcs12); save_vmcs12_guest_state(vcpu, vmcs12); record_extra_vmcs12_exit_information(vcpu, vmcs12, -- 2.13.0.219.gdb65acc882-goog