Skip to content

Commit e2e6e44

Browse files
Maxim Levitskybonzini
authored andcommitted
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: 37be407 ("KVM: nSVM: Fix L1 state corruption upon return from SMM") Signed-off-by: Maxim Levitsky <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 8d68bad commit e2e6e44

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

arch/x86/kvm/svm/svm.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4351,11 +4351,6 @@ static int svm_leave_smm(struct kvm_vcpu *vcpu, const char *smstate)
43514351
if (svm_allocate_nested(svm))
43524352
return 1;
43534353

4354-
vmcb12 = map.hva;
4355-
4356-
nested_load_control_from_vmcb12(svm, &vmcb12->control);
4357-
4358-
ret = enter_svm_guest_mode(vcpu, vmcb12_gpa, vmcb12);
43594354
kvm_vcpu_unmap(vcpu, &map, true);
43604355

43614356
/*
@@ -4369,6 +4364,13 @@ static int svm_leave_smm(struct kvm_vcpu *vcpu, const char *smstate)
43694364
svm_copy_vmrun_state(&svm->vmcb01.ptr->save,
43704365
map_save.hva + 0x400);
43714366

4367+
/*
4368+
* Enter the nested guest now
4369+
*/
4370+
vmcb12 = map.hva;
4371+
nested_load_control_from_vmcb12(svm, &vmcb12->control);
4372+
ret = enter_svm_guest_mode(vcpu, vmcb12_gpa, vmcb12);
4373+
43724374
kvm_vcpu_unmap(vcpu, &map_save, true);
43734375
}
43744376
}

0 commit comments

Comments
 (0)