KVM: nVMX: KVM_SET_NESTED_STATE - Tear down old EVMCS state before setting new state
authorAaron Lewis <aaronlewis@google.com>
Thu, 2 May 2019 18:31:33 +0000 (11:31 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 8 May 2019 12:12:08 +0000 (14:12 +0200)
Move call to nested_enable_evmcs until after free_nested() is complete.

Signed-off-by: Aaron Lewis <aaronlewis@google.com>
Reviewed-by: Marc Orr <marcorr@google.com>
Reviewed-by: Peter Shier <pshier@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/nested.c

index 04b40a98f60bdc2595102500aeec6095fb2ff587..cec77f30f61c4ad86779b1ce5f7749282a4d0b69 100644 (file)
@@ -5333,9 +5333,6 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,
        if (kvm_state->format != 0)
                return -EINVAL;
 
-       if (kvm_state->flags & KVM_STATE_NESTED_EVMCS)
-               nested_enable_evmcs(vcpu, NULL);
-
        if (!nested_vmx_allowed(vcpu))
                return kvm_state->vmx.vmxon_pa == -1ull ? 0 : -EINVAL;
 
@@ -5377,6 +5374,9 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,
        if (kvm_state->vmx.vmxon_pa == -1ull)
                return 0;
 
+       if (kvm_state->flags & KVM_STATE_NESTED_EVMCS)
+               nested_enable_evmcs(vcpu, NULL);
+
        vmx->nested.vmxon_ptr = kvm_state->vmx.vmxon_pa;
        ret = enter_vmx_operation(vcpu);
        if (ret)