|
@@ -8844,6 +8844,22 @@ static void vmx_load_vmcs01(struct kvm_vcpu *vcpu)
|
|
|
put_cpu();
|
|
put_cpu();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/*
|
|
|
|
|
+ * Ensure that the current vmcs of the logical processor is the
|
|
|
|
|
+ * vmcs01 of the vcpu before calling free_nested().
|
|
|
|
|
+ */
|
|
|
|
|
+static void vmx_free_vcpu_nested(struct kvm_vcpu *vcpu)
|
|
|
|
|
+{
|
|
|
|
|
+ struct vcpu_vmx *vmx = to_vmx(vcpu);
|
|
|
|
|
+ int r;
|
|
|
|
|
+
|
|
|
|
|
+ r = vcpu_load(vcpu);
|
|
|
|
|
+ BUG_ON(r);
|
|
|
|
|
+ vmx_load_vmcs01(vcpu);
|
|
|
|
|
+ free_nested(vmx);
|
|
|
|
|
+ vcpu_put(vcpu);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static void vmx_free_vcpu(struct kvm_vcpu *vcpu)
|
|
static void vmx_free_vcpu(struct kvm_vcpu *vcpu)
|
|
|
{
|
|
{
|
|
|
struct vcpu_vmx *vmx = to_vmx(vcpu);
|
|
struct vcpu_vmx *vmx = to_vmx(vcpu);
|
|
@@ -8852,8 +8868,7 @@ static void vmx_free_vcpu(struct kvm_vcpu *vcpu)
|
|
|
vmx_destroy_pml_buffer(vmx);
|
|
vmx_destroy_pml_buffer(vmx);
|
|
|
free_vpid(vmx->vpid);
|
|
free_vpid(vmx->vpid);
|
|
|
leave_guest_mode(vcpu);
|
|
leave_guest_mode(vcpu);
|
|
|
- vmx_load_vmcs01(vcpu);
|
|
|
|
|
- free_nested(vmx);
|
|
|
|
|
|
|
+ vmx_free_vcpu_nested(vcpu);
|
|
|
free_loaded_vmcs(vmx->loaded_vmcs);
|
|
free_loaded_vmcs(vmx->loaded_vmcs);
|
|
|
kfree(vmx->guest_msrs);
|
|
kfree(vmx->guest_msrs);
|
|
|
kvm_vcpu_uninit(vcpu);
|
|
kvm_vcpu_uninit(vcpu);
|