Skip to content

Commit f51770e

Browse files
tang-chenbonzini
authored andcommitted
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>
1 parent a255d47 commit f51770e

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

‎arch/x86/kvm/vmx.c‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3963,25 +3963,23 @@ static int init_rmode_tss(struct kvm *kvm)
39633963

39643964
static int init_rmode_identity_map(struct kvm *kvm)
39653965
{
3966-
int i, idx, r, ret = 0;
3966+
int i, idx, r = 0;
39673967
pfn_t identity_map_pfn;
39683968
u32 tmp;
39693969

39703970
if (!enable_ept)
3971-
return 1;
3971+
return 0;
39723972

39733973
/* Protect kvm->arch.ept_identity_pagetable_done. */
39743974
mutex_lock(&kvm->slots_lock);
39753975

3976-
if (likely(kvm->arch.ept_identity_pagetable_done)) {
3977-
ret = 1;
3976+
if (likely(kvm->arch.ept_identity_pagetable_done))
39783977
goto out2;
3979-
}
39803978

39813979
identity_map_pfn = kvm->arch.ept_identity_map_addr >> PAGE_SHIFT;
39823980

39833981
r = alloc_identity_pagetable(kvm);
3984-
if (r)
3982+
if (r < 0)
39853983
goto out2;
39863984

39873985
idx = srcu_read_lock(&kvm->srcu);
@@ -3998,13 +3996,13 @@ static int init_rmode_identity_map(struct kvm *kvm)
39983996
goto out;
39993997
}
40003998
kvm->arch.ept_identity_pagetable_done = true;
4001-
ret = 1;
3999+
40024000
out:
40034001
srcu_read_unlock(&kvm->srcu, idx);
40044002

40054003
out2:
40064004
mutex_unlock(&kvm->slots_lock);
4007-
return ret;
4005+
return r;
40084006
}
40094007

40104008
static void seg_setup(int seg)
@@ -7756,8 +7754,8 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
77567754
if (!kvm->arch.ept_identity_map_addr)
77577755
kvm->arch.ept_identity_map_addr =
77587756
VMX_EPT_IDENTITY_PAGETABLE_ADDR;
7759-
err = -ENOMEM;
7760-
if (!init_rmode_identity_map(kvm))
7757+
err = init_rmode_identity_map(kvm);
7758+
if (err)
77617759
goto free_vmcs;
77627760
}
77637761

0 commit comments

Comments
 (0)