Commit 1f755a82 authored by Paolo Bonzini's avatar Paolo Bonzini

kvm: Make init_rmode_tss() return 0 on success.

In init_rmode_tss(), 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_set_tss_addr(), and ret is redundant.

This patch removes the redundant variable, by making init_rmode_tss()
return 0 on success, -errno on failure.
Reviewed-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent dd598091
...@@ -3930,7 +3930,7 @@ static int init_rmode_tss(struct kvm *kvm) ...@@ -3930,7 +3930,7 @@ static int init_rmode_tss(struct kvm *kvm)
{ {
gfn_t fn; gfn_t fn;
u16 data = 0; u16 data = 0;
int r, idx, ret = 0; int idx, r;
idx = srcu_read_lock(&kvm->srcu); idx = srcu_read_lock(&kvm->srcu);
fn = kvm->arch.tss_addr >> PAGE_SHIFT; fn = kvm->arch.tss_addr >> PAGE_SHIFT;
...@@ -3952,13 +3952,9 @@ static int init_rmode_tss(struct kvm *kvm) ...@@ -3952,13 +3952,9 @@ static int init_rmode_tss(struct kvm *kvm)
r = kvm_write_guest_page(kvm, fn, &data, r = kvm_write_guest_page(kvm, fn, &data,
RMODE_TSS_SIZE - 2 * PAGE_SIZE - 1, RMODE_TSS_SIZE - 2 * PAGE_SIZE - 1,
sizeof(u8)); sizeof(u8));
if (r < 0)
goto out;
ret = 1;
out: out:
srcu_read_unlock(&kvm->srcu, idx); srcu_read_unlock(&kvm->srcu, idx);
return ret; return r;
} }
static int init_rmode_identity_map(struct kvm *kvm) static int init_rmode_identity_map(struct kvm *kvm)
...@@ -4751,10 +4747,7 @@ static int vmx_set_tss_addr(struct kvm *kvm, unsigned int addr) ...@@ -4751,10 +4747,7 @@ static int vmx_set_tss_addr(struct kvm *kvm, unsigned int addr)
if (ret) if (ret)
return ret; return ret;
kvm->arch.tss_addr = addr; kvm->arch.tss_addr = addr;
if (!init_rmode_tss(kvm)) return init_rmode_tss(kvm);
return -ENOMEM;
return 0;
} }
static bool rmode_exception(struct kvm_vcpu *vcpu, int vec) static bool rmode_exception(struct kvm_vcpu *vcpu, int vec)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment