linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kvm vmx: free vpid when fail to create vcpu
@ 2010-04-17  8:41 Lai Jiangshan
  2010-04-22 11:10 ` Avi Kivity
  0 siblings, 1 reply; 2+ messages in thread
From: Lai Jiangshan @ 2010-04-17  8:41 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti, LKML, kvm-owner


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

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 686492e..077cac5 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -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);
 }


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] kvm vmx: free vpid when fail to create vcpu
  2010-04-17  8:41 [PATCH] kvm vmx: free vpid when fail to create vcpu Lai Jiangshan
@ 2010-04-22 11:10 ` Avi Kivity
  0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2010-04-22 11:10 UTC (permalink / raw)
  To: Lai Jiangshan; +Cc: Marcelo Tosatti, LKML, KVM list

On 04/17/2010 11:41 AM, Lai Jiangshan wrote:
> Fix bug of the exception path, free allocated vpid when fail
> to create vcpu.
>    

Applied, thanks.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-04-22 11:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-17  8:41 [PATCH] kvm vmx: free vpid when fail to create vcpu Lai Jiangshan
2010-04-22 11:10 ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).