提交 42124925 编写于 作者: J Jan Kiszka 提交者: Paolo Bonzini

KVM: nVMX: Leave VMX mode on clearing of feature control MSR

When userspace sets MSR_IA32_FEATURE_CONTROL to 0, make sure we leave
root and non-root mode, fully disabling VMX. The register state of the
VCPU is undefined after this step, so userspace has to set it to a
proper state afterward.

This enables to reboot a VM while it is running some hypervisor code.
Signed-off-by: NJan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 8246bf52
...@@ -2455,6 +2455,8 @@ static int vmx_get_vmx_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata) ...@@ -2455,6 +2455,8 @@ static int vmx_get_vmx_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata)
return 1; return 1;
} }
static void vmx_leave_nested(struct kvm_vcpu *vcpu);
static int vmx_set_vmx_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) static int vmx_set_vmx_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
{ {
u32 msr_index = msr_info->index; u32 msr_index = msr_info->index;
...@@ -2470,6 +2472,8 @@ static int vmx_set_vmx_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) ...@@ -2470,6 +2472,8 @@ static int vmx_set_vmx_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
& FEATURE_CONTROL_LOCKED) & FEATURE_CONTROL_LOCKED)
return 0; return 0;
to_vmx(vcpu)->nested.msr_ia32_feature_control = data; to_vmx(vcpu)->nested.msr_ia32_feature_control = data;
if (host_initialized && data == 0)
vmx_leave_nested(vcpu);
return 1; return 1;
} }
...@@ -8503,6 +8507,16 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu) ...@@ -8503,6 +8507,16 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu)
vmx->nested.sync_shadow_vmcs = true; vmx->nested.sync_shadow_vmcs = true;
} }
/*
* Forcibly leave nested mode in order to be able to reset the VCPU later on.
*/
static void vmx_leave_nested(struct kvm_vcpu *vcpu)
{
if (is_guest_mode(vcpu))
nested_vmx_vmexit(vcpu);
free_nested(to_vmx(vcpu));
}
/* /*
* L1's failure to enter L2 is a subset of a normal exit, as explained in * L1's failure to enter L2 is a subset of a normal exit, as explained in
* 23.7 "VM-entry failures during or after loading guest state" (this also * 23.7 "VM-entry failures during or after loading guest state" (this also
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册