KVM: nSVM: leave guest mode when clearing EFER.SVME
According to the AMD manual, the effect of turning off EFER.SVME while a guest is running is undefined. We make it leave guest mode immediately, similar to the effect of clearing the VMX bit in MSR_IA32_FEAT_CTL. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
ca46d739e3
commit
c513f484c5
|
@ -618,6 +618,22 @@ int nested_svm_vmexit(struct vcpu_svm *svm)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Forcibly leave nested mode in order to be able to reset the VCPU later on.
|
||||||
|
*/
|
||||||
|
void svm_leave_nested(struct vcpu_svm *svm)
|
||||||
|
{
|
||||||
|
if (is_guest_mode(&svm->vcpu)) {
|
||||||
|
struct vmcb *hsave = svm->nested.hsave;
|
||||||
|
struct vmcb *vmcb = svm->vmcb;
|
||||||
|
|
||||||
|
svm->nested.nested_run_pending = 0;
|
||||||
|
leave_guest_mode(&svm->vcpu);
|
||||||
|
copy_vmcb_control_area(&vmcb->control, &hsave->control);
|
||||||
|
nested_svm_uninit_mmu_context(&svm->vcpu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int nested_svm_exit_handled_msr(struct vcpu_svm *svm)
|
static int nested_svm_exit_handled_msr(struct vcpu_svm *svm)
|
||||||
{
|
{
|
||||||
u32 offset, msr, value;
|
u32 offset, msr, value;
|
||||||
|
|
|
@ -265,6 +265,7 @@ static int get_npt_level(struct kvm_vcpu *vcpu)
|
||||||
|
|
||||||
void svm_set_efer(struct kvm_vcpu *vcpu, u64 efer)
|
void svm_set_efer(struct kvm_vcpu *vcpu, u64 efer)
|
||||||
{
|
{
|
||||||
|
struct vcpu_svm *svm = to_svm(vcpu);
|
||||||
vcpu->arch.efer = efer;
|
vcpu->arch.efer = efer;
|
||||||
|
|
||||||
if (!npt_enabled) {
|
if (!npt_enabled) {
|
||||||
|
@ -275,8 +276,13 @@ void svm_set_efer(struct kvm_vcpu *vcpu, u64 efer)
|
||||||
efer &= ~EFER_LME;
|
efer &= ~EFER_LME;
|
||||||
}
|
}
|
||||||
|
|
||||||
to_svm(vcpu)->vmcb->save.efer = efer | EFER_SVME;
|
if (!(efer & EFER_SVME)) {
|
||||||
mark_dirty(to_svm(vcpu)->vmcb, VMCB_CR);
|
svm_leave_nested(svm);
|
||||||
|
svm_set_gif(svm, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
svm->vmcb->save.efer = efer | EFER_SVME;
|
||||||
|
mark_dirty(svm->vmcb, VMCB_CR);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int is_external_interrupt(u32 info)
|
static int is_external_interrupt(u32 info)
|
||||||
|
|
|
@ -389,6 +389,7 @@ static inline bool nested_exit_on_nmi(struct vcpu_svm *svm)
|
||||||
|
|
||||||
void enter_svm_guest_mode(struct vcpu_svm *svm, u64 vmcb_gpa,
|
void enter_svm_guest_mode(struct vcpu_svm *svm, u64 vmcb_gpa,
|
||||||
struct vmcb *nested_vmcb);
|
struct vmcb *nested_vmcb);
|
||||||
|
void svm_leave_nested(struct vcpu_svm *svm);
|
||||||
int nested_svm_vmrun(struct vcpu_svm *svm);
|
int nested_svm_vmrun(struct vcpu_svm *svm);
|
||||||
void nested_svm_vmloadsave(struct vmcb *from_vmcb, struct vmcb *to_vmcb);
|
void nested_svm_vmloadsave(struct vmcb *from_vmcb, struct vmcb *to_vmcb);
|
||||||
int nested_svm_vmexit(struct vcpu_svm *svm);
|
int nested_svm_vmexit(struct vcpu_svm *svm);
|
||||||
|
|
Loading…
Reference in New Issue