Skip to contentSkip to conversation

kvm vmx: free vpid when fail to create vcpu

PATCH Applied Lai Jiangshan 2 participants 2 messages Apr 17, 2010 – Apr 22, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kvm vmx: free vpid when fail to create vcpu

Fix bug of the exception path, free allocated vpid when fail to create vcpu.

---

arch/x86/kvm/vmx.c +12 -4
index 686492e..077cac5 100644
@@ -2290,6 +2290,16 @@ static void allocate_vpid(struct vcpu_vmx *vmx)
 	spin_unlock(&vmx_vpid_lock);
 }
 
+static void free_vpid(struct vcpu_vmx *vmx)
+{
+	if (!enable_vpid)
+		return;
+	spin_lock(&vmx_vpid_lock);
+	if (vmx->vpid != 0)
+		__clear_bit(vmx->vpid, vmx_vpid_bitmap);
+	spin_unlock(&vmx_vpid_lock);
+}
+
 static void __vmx_disable_intercept_for_msr(unsigned long *msr_bitmap, u32 msr)
 {
 	int f = sizeof(unsigned long);
@@ -3915,10 +3925,7 @@ static void vmx_free_vcpu(struct kvm_vcpu *vcpu)
 {
 	struct vcpu_vmx *vmx = to_vmx(vcpu);
 
-	spin_lock(&vmx_vpid_lock);
-	if (vmx->vpid != 0)
-		__clear_bit(vmx->vpid, vmx_vpid_bitmap);
-	spin_unlock(&vmx_vpid_lock);
+	free_vpid(vmx);
 	vmx_free_vmcs(vcpu);
 	kfree(vmx->guest_msrs);
 	kvm_vcpu_uninit(vcpu);
@@ -3980,6 +3987,7 @@ free_msrs:
 uninit_vcpu:
 	kvm_vcpu_uninit(&vmx->vcpu);
 free_vcpu:
+	free_vpid(vmx);
 	kmem_cache_free(kvm_vcpu_cache, vmx);
 	return ERR_PTR(err);
 }
Applied
#1 lore raw
Quoted 3 lines · Lai Jiangshan

Fix bug of the exception path, free allocated vpid when fail to create vcpu.

Applied, thanks.

Signature · 1 line
error compiling committee.c: too many arguments to function