]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
kvm: nVMX: Set nested_run_pending in vmx_set_nested_state after checks complete
authorAaron Lewis <aaronlewis@google.com>
Thu, 2 May 2019 18:31:25 +0000 (11:31 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 8 May 2019 12:14:08 +0000 (14:14 +0200)
nested_run_pending=1 implies we have successfully entered guest mode.
Move setting from external state in vmx_set_nested_state() until after
all other checks are complete.

Based on a patch by Aaron Lewis.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/nested.c

index cec77f30f61c4ad86779b1ce5f7749282a4d0b69..e58caff92694ec22b7d9852a5f3c81ed85721146 100644 (file)
@@ -5420,9 +5420,6 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,
        if (!(kvm_state->flags & KVM_STATE_NESTED_GUEST_MODE))
                return 0;
 
-       vmx->nested.nested_run_pending =
-               !!(kvm_state->flags & KVM_STATE_NESTED_RUN_PENDING);
-
        if (nested_cpu_has_shadow_vmcs(vmcs12) &&
            vmcs12->vmcs_link_pointer != -1ull) {
                struct vmcs12 *shadow_vmcs12 = get_shadow_vmcs12(vcpu);
@@ -5446,9 +5443,14 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,
                return -EINVAL;
 
        vmx->nested.dirty_vmcs12 = true;
+       vmx->nested.nested_run_pending =
+               !!(kvm_state->flags & KVM_STATE_NESTED_RUN_PENDING);
+
        ret = nested_vmx_enter_non_root_mode(vcpu, false);
-       if (ret)
+       if (ret) {
+               vmx->nested.nested_run_pending = 0;
                return -EINVAL;
+       }
 
        return 0;
 }