* [PATCH] KVM: arm64: eliminate unnecessary var err and jump label in set_core_reg()
@ 2019-11-28 3:09 linmiaohe
2019-11-28 8:56 ` Auger Eric
0 siblings, 1 reply; 2+ messages in thread
From: linmiaohe @ 2019-11-28 3:09 UTC (permalink / raw)
To: maz, pbonzini, rkrcmar, james.morse, julien.thierry.kdev,
suzuki.poulose, christoffer.dall, catalin.marinas, eric.auger,
gregkh, will, andre.przywara, tglx
Cc: linmiaohe, linux-arm-kernel, kvmarm, linux-kernel, kvm
From: Miaohe Lin <linmiaohe@huawei.com>
The var err and jump label out isn't really needed in
set_core_reg(). Clean them up.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
arch/arm64/kvm/guest.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c
index 3b836c91609e..88eb6e5399ed 100644
--- a/arch/arm64/kvm/guest.c
+++ b/arch/arm64/kvm/guest.c
@@ -159,7 +159,6 @@ static int set_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
__uint128_t tmp;
void *valp = &tmp;
u64 off;
- int err = 0;
/* Our ID is an index into the kvm_regs struct. */
off = core_reg_offset_from_id(reg->id);
@@ -173,10 +172,8 @@ static int set_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
if (KVM_REG_SIZE(reg->id) > sizeof(tmp))
return -EINVAL;
- if (copy_from_user(valp, uaddr, KVM_REG_SIZE(reg->id))) {
- err = -EFAULT;
- goto out;
- }
+ if (copy_from_user(valp, uaddr, KVM_REG_SIZE(reg->id)))
+ return -EFAULT;
if (off == KVM_REG_ARM_CORE_REG(regs.pstate)) {
u64 mode = (*(u64 *)valp) & PSR_AA32_MODE_MASK;
@@ -200,14 +197,12 @@ static int set_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
return -EINVAL;
break;
default:
- err = -EINVAL;
- goto out;
+ return -EINVAL;
}
}
memcpy((u32 *)regs + off, valp, KVM_REG_SIZE(reg->id));
-out:
- return err;
+ return 0;
}
#define vq_word(vq) (((vq) - SVE_VQ_MIN) / 64)
--
2.19.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: arm64: eliminate unnecessary var err and jump label in set_core_reg()
2019-11-28 3:09 [PATCH] KVM: arm64: eliminate unnecessary var err and jump label in set_core_reg() linmiaohe
@ 2019-11-28 8:56 ` Auger Eric
0 siblings, 0 replies; 2+ messages in thread
From: Auger Eric @ 2019-11-28 8:56 UTC (permalink / raw)
To: linmiaohe, maz, pbonzini, rkrcmar, james.morse,
julien.thierry.kdev, suzuki.poulose, christoffer.dall,
catalin.marinas, gregkh, will, andre.przywara, tglx
Cc: linux-arm-kernel, kvmarm, linux-kernel, kvm
Hi,
On 11/28/19 4:09 AM, linmiaohe wrote:
> From: Miaohe Lin <linmiaohe@huawei.com>
>
> The var err and jump label out isn't really needed in
> set_core_reg(). Clean them up.
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Thanks
Eric
> ---
> arch/arm64/kvm/guest.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c
> index 3b836c91609e..88eb6e5399ed 100644
> --- a/arch/arm64/kvm/guest.c
> +++ b/arch/arm64/kvm/guest.c
> @@ -159,7 +159,6 @@ static int set_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
> __uint128_t tmp;
> void *valp = &tmp;
> u64 off;
> - int err = 0;
>
> /* Our ID is an index into the kvm_regs struct. */
> off = core_reg_offset_from_id(reg->id);
> @@ -173,10 +172,8 @@ static int set_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
> if (KVM_REG_SIZE(reg->id) > sizeof(tmp))
> return -EINVAL;
>
> - if (copy_from_user(valp, uaddr, KVM_REG_SIZE(reg->id))) {
> - err = -EFAULT;
> - goto out;
> - }
> + if (copy_from_user(valp, uaddr, KVM_REG_SIZE(reg->id)))
> + return -EFAULT;
>
> if (off == KVM_REG_ARM_CORE_REG(regs.pstate)) {
> u64 mode = (*(u64 *)valp) & PSR_AA32_MODE_MASK;
> @@ -200,14 +197,12 @@ static int set_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
> return -EINVAL;
> break;
> default:
> - err = -EINVAL;
> - goto out;
> + return -EINVAL;
> }
> }
>
> memcpy((u32 *)regs + off, valp, KVM_REG_SIZE(reg->id));
> -out:
> - return err;
> + return 0;
> }
>
> #define vq_word(vq) (((vq) - SVE_VQ_MIN) / 64)
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-11-28 8:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-28 3:09 [PATCH] KVM: arm64: eliminate unnecessary var err and jump label in set_core_reg() linmiaohe
2019-11-28 8:56 ` Auger Eric
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).