summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorMaxim Levitsky <mlevitsk@redhat.com>2021-09-13 17:09:49 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2021-09-22 17:33:16 +0300
commite2e6e449d68ddf4ccb0bf72cc50fbc6c69fe7f63 (patch)
tree18f7e811da3f5415d37e57b122397aa29bf06998 /arch
parent8d68bad6d869fae8f4d50ab6423538dec7da72d1 (diff)
downloadlinux-e2e6e449d68ddf4ccb0bf72cc50fbc6c69fe7f63.tar.xz
KVM: x86: nSVM: restore the L1 host state prior to resuming nested guest on SMM exit
Otherwise guest entry code might see incorrect L1 state (e.g paging state). Fixes: 37be407b2ce8 ("KVM: nSVM: Fix L1 state corruption upon return from SMM") Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> Message-Id: <20210913140954.165665-3-mlevitsk@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kvm/svm/svm.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 05e8d4d27969..35cac2046f69 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -4351,11 +4351,6 @@ static int svm_leave_smm(struct kvm_vcpu *vcpu, const char *smstate)
if (svm_allocate_nested(svm))
return 1;
- vmcb12 = map.hva;
-
- nested_load_control_from_vmcb12(svm, &vmcb12->control);
-
- ret = enter_svm_guest_mode(vcpu, vmcb12_gpa, vmcb12);
kvm_vcpu_unmap(vcpu, &map, true);
/*
@@ -4369,6 +4364,13 @@ static int svm_leave_smm(struct kvm_vcpu *vcpu, const char *smstate)
svm_copy_vmrun_state(&svm->vmcb01.ptr->save,
map_save.hva + 0x400);
+ /*
+ * Enter the nested guest now
+ */
+ vmcb12 = map.hva;
+ nested_load_control_from_vmcb12(svm, &vmcb12->control);
+ ret = enter_svm_guest_mode(vcpu, vmcb12_gpa, vmcb12);
+
kvm_vcpu_unmap(vcpu, &map_save, true);
}
}