diff options
author | Tang Chen <tangchen@cn.fujitsu.com> | 2014-09-16 18:41:59 +0800 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2014-09-17 13:10:12 +0200 |
commit | f51770ed465e6eb41da7fa16fd92eb67069600cf (patch) | |
tree | be1cceaafe499026b0c93d2617f9af64f2ed41f1 | |
parent | a255d4795f83cf3e6a1c7d5ab998392d9413298c (diff) | |
download | linux-f51770ed465e6eb41da7fa16fd92eb67069600cf.tar.gz linux-f51770ed465e6eb41da7fa16fd92eb67069600cf.tar.bz2 linux-f51770ed465e6eb41da7fa16fd92eb67069600cf.zip |
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.c | 18 |
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: static int init_rmode_identity_map(struct kvm *kvm) { - int i, idx, r, ret = 0; + int i, idx, r = 0; pfn_t identity_map_pfn; u32 tmp; if (!enable_ept) - return 1; + return 0; /* Protect kvm->arch.ept_identity_pagetable_done. */ mutex_lock(&kvm->slots_lock); - if (likely(kvm->arch.ept_identity_pagetable_done)) { - ret = 1; + if (likely(kvm->arch.ept_identity_pagetable_done)) goto out2; - } identity_map_pfn = kvm->arch.ept_identity_map_addr >> PAGE_SHIFT; r = alloc_identity_pagetable(kvm); - if (r) + if (r < 0) goto out2; idx = srcu_read_lock(&kvm->srcu); @@ -3998,13 +3996,13 @@ static int init_rmode_identity_map(struct kvm *kvm) goto out; } kvm->arch.ept_identity_pagetable_done = true; - ret = 1; + out: srcu_read_unlock(&kvm->srcu, idx); out2: mutex_unlock(&kvm->slots_lock); - return ret; + return r; } static void seg_setup(int seg) @@ -7756,8 +7754,8 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id) if (!kvm->arch.ept_identity_map_addr) kvm->arch.ept_identity_map_addr = VMX_EPT_IDENTITY_PAGETABLE_ADDR; - err = -ENOMEM; - if (!init_rmode_identity_map(kvm)) + err = init_rmode_identity_map(kvm); + if (err) goto free_vmcs; } |