Skip to content

Commit

Permalink
KVM: x86: nSVM: restore the L1 host state prior to resuming nested gu…
Browse files Browse the repository at this point in the history
…est 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]>
  • Loading branch information
Maxim Levitsky authored and bonzini committed Sep 22, 2021
1 parent 8d68bad commit e2e6e44
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions arch/x86/kvm/svm/svm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/*
Expand All @@ -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);
}
}
Expand Down

0 comments on commit e2e6e44

Please sign in to comment.