KVM: x86: nSVM/nVMX: set nested_run_pending on VM entry which is a result of RSM
authorMaxim Levitsky <mlevitsk@redhat.com>
Mon, 7 Feb 2022 15:54:21 +0000 (17:54 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 8 Feb 2022 18:30:48 +0000 (13:30 -0500)
While RSM induced VM entries are not full VM entries,
they still need to be followed by actual VM entry to complete it,
unlike setting the nested state.

This patch fixes boot of hyperv and SMM enabled
windows VM running nested on KVM, which fail due
to this issue combined with lack of dirty bit setting.

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Cc: stable@vger.kernel.org
Message-Id: <20220207155447.840194-5-mlevitsk@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/svm/svm.c
arch/x86/kvm/vmx/vmx.c

index fabbc73c68e2534abc132f75bc1ad0243af5894b..2ea7985028fe5e0a55cf6c487757c6271b6555de 100644 (file)
@@ -4263,6 +4263,11 @@ static int svm_leave_smm(struct kvm_vcpu *vcpu, const char *smstate)
        nested_copy_vmcb_save_to_cache(svm, &vmcb12->save);
        ret = enter_svm_guest_mode(vcpu, vmcb12_gpa, vmcb12, false);
 
+       if (ret)
+               goto unmap_save;
+
+       svm->nested.nested_run_pending = 1;
+
 unmap_save:
        kvm_vcpu_unmap(vcpu, &map_save, true);
 unmap_map:
index 6c27bd0c89e1e613782c85637634e6215928ac24..efda5e4d624763879778344aca2b4cdcdebb3193 100644 (file)
@@ -7659,6 +7659,7 @@ static int vmx_leave_smm(struct kvm_vcpu *vcpu, const char *smstate)
                if (ret)
                        return ret;
 
+               vmx->nested.nested_run_pending = 1;
                vmx->nested.smm.guest_mode = false;
        }
        return 0;