From: Jim Mattson Subject: [PATCH 4/4] KVM: nVMX: Don't set vmcs12 to "launched" when VMLAUNCH fails Date: Thu, 1 Jun 2017 15:13:06 -0700 Message-ID: <20170601221306.86372-5-jmattson@google.com> References: <20170601221306.86372-1-jmattson@google.com> Cc: Jim Mattson To: kvm@vger.kernel.org, nyh@il.ibm.com Return-path: Received: from mail-pf0-f174.google.com ([209.85.192.174]:36272 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751141AbdFAWN5 (ORCPT ); Thu, 1 Jun 2017 18:13:57 -0400 Received: by mail-pf0-f174.google.com with SMTP id m17so38781848pfg.3 for ; Thu, 01 Jun 2017 15:13:57 -0700 (PDT) In-Reply-To: <20170601221306.86372-1-jmattson@google.com> Sender: kvm-owner@vger.kernel.org List-ID: 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 --- 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