diff options
author | Lai Jiangshan <laijs@cn.fujitsu.com> | 2010-04-17 04:41:47 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-05-17 05:19:10 -0400 |
commit | cdbecfc398a904ce9f5c126638b09a2429fb86ed (patch) | |
tree | eb28bdd09dab5809af17a7e49e3a720fcff95ce2 /arch/x86/kvm | |
parent | b83d4a9cfc81503a082331cc5d1e480d99f3a531 (diff) |
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/x86/kvm')
-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 d0a10b5612e9..54c0035a63f0 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) | |||
2333 | spin_unlock(&vmx_vpid_lock); | 2333 | spin_unlock(&vmx_vpid_lock); |
2334 | } | 2334 | } |
2335 | 2335 | ||
2336 | static void free_vpid(struct vcpu_vmx *vmx) | ||
2337 | { | ||
2338 | if (!enable_vpid) | ||
2339 | return; | ||
2340 | spin_lock(&vmx_vpid_lock); | ||
2341 | if (vmx->vpid != 0) | ||
2342 | __clear_bit(vmx->vpid, vmx_vpid_bitmap); | ||
2343 | spin_unlock(&vmx_vpid_lock); | ||
2344 | } | ||
2345 | |||
2336 | static void __vmx_disable_intercept_for_msr(unsigned long *msr_bitmap, u32 msr) | 2346 | static void __vmx_disable_intercept_for_msr(unsigned long *msr_bitmap, u32 msr) |
2337 | { | 2347 | { |
2338 | int f = sizeof(unsigned long); | 2348 | int f = sizeof(unsigned long); |
@@ -3916,10 +3926,7 @@ static void vmx_free_vcpu(struct kvm_vcpu *vcpu) | |||
3916 | { | 3926 | { |
3917 | struct vcpu_vmx *vmx = to_vmx(vcpu); | 3927 | struct vcpu_vmx *vmx = to_vmx(vcpu); |
3918 | 3928 | ||
3919 | spin_lock(&vmx_vpid_lock); | 3929 | free_vpid(vmx); |
3920 | if (vmx->vpid != 0) | ||
3921 | __clear_bit(vmx->vpid, vmx_vpid_bitmap); | ||
3922 | spin_unlock(&vmx_vpid_lock); | ||
3923 | vmx_free_vmcs(vcpu); | 3930 | vmx_free_vmcs(vcpu); |
3924 | kfree(vmx->guest_msrs); | 3931 | kfree(vmx->guest_msrs); |
3925 | kvm_vcpu_uninit(vcpu); | 3932 | kvm_vcpu_uninit(vcpu); |
@@ -3981,6 +3988,7 @@ free_msrs: | |||
3981 | uninit_vcpu: | 3988 | uninit_vcpu: |
3982 | kvm_vcpu_uninit(&vmx->vcpu); | 3989 | kvm_vcpu_uninit(&vmx->vcpu); |
3983 | free_vcpu: | 3990 | free_vcpu: |
3991 | free_vpid(vmx); | ||
3984 | kmem_cache_free(kvm_vcpu_cache, vmx); | 3992 | kmem_cache_free(kvm_vcpu_cache, vmx); |
3985 | return ERR_PTR(err); | 3993 | return ERR_PTR(err); |
3986 | } | 3994 | } |