aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTang Chen <tangchen@cn.fujitsu.com>2014-09-16 06:41:59 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2014-09-17 07:10:12 -0400
commitf51770ed465e6eb41da7fa16fd92eb67069600cf (patch)
treebe1cceaafe499026b0c93d2617f9af64f2ed41f1
parenta255d4795f83cf3e6a1c7d5ab998392d9413298c (diff)
kvm: Make init_rmode_identity_map() return 0 on success.
In init_rmode_identity_map(), there two variables indicating the return value, r and ret, and it return 0 on error, 1 on success. The function is only called by vmx_create_vcpu(), and ret is redundant. This patch removes the redundant variable, and makes init_rmode_identity_map() return 0 on success, -errno on failure. Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--arch/x86/kvm/vmx.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 5de0d7b1d8a9..6ffd643d1a64 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3963,25 +3963,23 @@ out:
3963 3963
3964static int init_rmode_identity_map(struct kvm *kvm) 3964static int init_rmode_identity_map(struct kvm *kvm)
3965{ 3965{
3966 int i, idx, r, ret = 0; 3966 int i, idx, r = 0;
3967 pfn_t identity_map_pfn; 3967 pfn_t identity_map_pfn;
3968 u32 tmp; 3968 u32 tmp;
3969 3969
3970 if (!enable_ept) 3970 if (!enable_ept)
3971 return 1; 3971 return 0;
3972 3972
3973 /* Protect kvm->arch.ept_identity_pagetable_done. */ 3973 /* Protect kvm->arch.ept_identity_pagetable_done. */
3974 mutex_lock(&kvm->slots_lock); 3974 mutex_lock(&kvm->slots_lock);
3975 3975
3976 if (likely(kvm->arch.ept_identity_pagetable_done)) { 3976 if (likely(kvm->arch.ept_identity_pagetable_done))
3977 ret = 1;
3978 goto out2; 3977 goto out2;
3979 }
3980 3978
3981 identity_map_pfn = kvm->arch.ept_identity_map_addr >> PAGE_SHIFT; 3979 identity_map_pfn = kvm->arch.ept_identity_map_addr >> PAGE_SHIFT;
3982 3980
3983 r = alloc_identity_pagetable(kvm); 3981 r = alloc_identity_pagetable(kvm);
3984 if (r) 3982 if (r < 0)
3985 goto out2; 3983 goto out2;
3986 3984
3987 idx = srcu_read_lock(&kvm->srcu); 3985 idx = srcu_read_lock(&kvm->srcu);
@@ -3998,13 +3996,13 @@ static int init_rmode_identity_map(struct kvm *kvm)
3998 goto out; 3996 goto out;
3999 } 3997 }
4000 kvm->arch.ept_identity_pagetable_done = true; 3998 kvm->arch.ept_identity_pagetable_done = true;
4001 ret = 1; 3999
4002out: 4000out:
4003 srcu_read_unlock(&kvm->srcu, idx); 4001 srcu_read_unlock(&kvm->srcu, idx);
4004 4002
4005out2: 4003out2:
4006 mutex_unlock(&kvm->slots_lock); 4004 mutex_unlock(&kvm->slots_lock);
4007 return ret; 4005 return r;
4008} 4006}
4009 4007
4010static void seg_setup(int seg) 4008static void seg_setup(int seg)
@@ -7756,8 +7754,8 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
7756 if (!kvm->arch.ept_identity_map_addr) 7754 if (!kvm->arch.ept_identity_map_addr)
7757 kvm->arch.ept_identity_map_addr = 7755 kvm->arch.ept_identity_map_addr =
7758 VMX_EPT_IDENTITY_PAGETABLE_ADDR; 7756 VMX_EPT_IDENTITY_PAGETABLE_ADDR;
7759 err = -ENOMEM; 7757 err = init_rmode_identity_map(kvm);
7760 if (!init_rmode_identity_map(kvm)) 7758 if (err)
7761 goto free_vmcs; 7759 goto free_vmcs;
7762 } 7760 }
7763 7761