diff options
author | Lai Jiangshan <laijs@cn.fujitsu.com> | 2010-04-17 16:41:47 +0800 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-05-17 12:19:10 +0300 |
commit | cdbecfc398a904ce9f5c126638b09a2429fb86ed (patch) | |
tree | eb28bdd09dab5809af17a7e49e3a720fcff95ce2 /arch | |
parent | b83d4a9cfc81503a082331cc5d1e480d99f3a531 (diff) | |
download | linux-3.10-cdbecfc398a904ce9f5c126638b09a2429fb86ed.tar.gz linux-3.10-cdbecfc398a904ce9f5c126638b09a2429fb86ed.tar.bz2 linux-3.10-cdbecfc398a904ce9f5c126638b09a2429fb86ed.zip |
KVM: VMX: free vpid when fail to create vcpu
Fix bug of the exception path, free allocated vpid when fail
to create vcpu.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kvm/vmx.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index d0a10b5612e..54c0035a63f 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -2333,6 +2333,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); @@ -3916,10 +3926,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); @@ -3981,6 +3988,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); } |