From: Maxim Levitsky <mlevitsk@redhat.com>
To: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/4] KVM: x86: Drop unnecessary goto+label in kvm_arch_init()
Date: Mon, 18 Jul 2022 13:03:41 +0300 [thread overview]
Message-ID: <2c8fd8e1179fc63084ec451496df5b68caae2756.camel@redhat.com> (raw)
In-Reply-To: <20220715230016.3762909-3-seanjc@google.com>
On Fri, 2022-07-15 at 23:00 +0000, Sean Christopherson wrote:
> Return directly if kvm_arch_init() detects an error before doing any real
> work, jumping through a label obfuscates what's happening and carries the
> unnecessary risk of leaving 'r' uninitialized.
>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
> arch/x86/kvm/x86.c | 24 ++++++++----------------
> 1 file changed, 8 insertions(+), 16 deletions(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 12199c40f2bc..41aa3137665c 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -9146,21 +9146,18 @@ int kvm_arch_init(void *opaque)
>
> if (kvm_x86_ops.hardware_enable) {
> pr_err("kvm: already loaded vendor module '%s'\n", kvm_x86_ops.name);
> - r = -EEXIST;
> - goto out;
> + return -EEXIST;
> }
>
> if (!ops->cpu_has_kvm_support()) {
> pr_err_ratelimited("kvm: no hardware support for '%s'\n",
> ops->runtime_ops->name);
> - r = -EOPNOTSUPP;
> - goto out;
> + return -EOPNOTSUPP;
> }
> if (ops->disabled_by_bios()) {
> pr_err_ratelimited("kvm: support for '%s' disabled by bios\n",
> ops->runtime_ops->name);
> - r = -EOPNOTSUPP;
> - goto out;
> + return -EOPNOTSUPP;
> }
>
> /*
> @@ -9170,14 +9167,12 @@ int kvm_arch_init(void *opaque)
> */
> if (!boot_cpu_has(X86_FEATURE_FPU) || !boot_cpu_has(X86_FEATURE_FXSR)) {
> printk(KERN_ERR "kvm: inadequate fpu\n");
> - r = -EOPNOTSUPP;
> - goto out;
> + return -EOPNOTSUPP;
> }
>
> if (IS_ENABLED(CONFIG_PREEMPT_RT) && !boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) {
> pr_err("RT requires X86_FEATURE_CONSTANT_TSC\n");
> - r = -EOPNOTSUPP;
> - goto out;
> + return -EOPNOTSUPP;
> }
>
> /*
> @@ -9190,21 +9185,19 @@ int kvm_arch_init(void *opaque)
> if (rdmsrl_safe(MSR_IA32_CR_PAT, &host_pat) ||
> (host_pat & GENMASK(2, 0)) != 6) {
> pr_err("kvm: host PAT[0] is not WB\n");
> - r = -EIO;
> - goto out;
> + return -EIO;
> }
>
> - r = -ENOMEM;
> -
> x86_emulator_cache = kvm_alloc_emulator_cache();
> if (!x86_emulator_cache) {
> pr_err("kvm: failed to allocate cache for x86 emulator\n");
> - goto out;
> + return -ENOMEM;
> }
>
> user_return_msrs = alloc_percpu(struct kvm_user_return_msrs);
> if (!user_return_msrs) {
> printk(KERN_ERR "kvm: failed to allocate percpu kvm_user_return_msrs\n");
> + r = -ENOMEM;
> goto out_free_x86_emulator_cache;
> }
> kvm_nr_uret_msrs = 0;
> @@ -9235,7 +9228,6 @@ int kvm_arch_init(void *opaque)
> free_percpu(user_return_msrs);
> out_free_x86_emulator_cache:
> kmem_cache_destroy(x86_emulator_cache);
> -out:
> return r;
> }
>
I honestly don't see much value in this change, but I don't mind it either.
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Best regards,
Maxim Levitsky
next prev parent reply other threads:[~2022-07-18 10:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-15 23:00 [PATCH 0/4] KVM: x86/mmu: Memtype related cleanups Sean Christopherson
2022-07-15 23:00 ` [PATCH 1/4] KVM: x86: Reject loading KVM if host.PAT[0] != WB Sean Christopherson
2022-07-15 23:06 ` Jim Mattson
2022-07-15 23:18 ` Sean Christopherson
2022-07-18 9:42 ` Maxim Levitsky
2022-07-15 23:00 ` [PATCH 2/4] KVM: x86: Drop unnecessary goto+label in kvm_arch_init() Sean Christopherson
2022-07-18 10:03 ` Maxim Levitsky [this message]
2022-07-18 15:10 ` Sean Christopherson
2022-07-15 23:00 ` [PATCH 3/4] KVM: x86/mmu: Add shadow mask for effective host MTRR memtype Sean Christopherson
2022-07-18 12:08 ` Maxim Levitsky
2022-07-18 16:07 ` Sean Christopherson
2022-07-15 23:00 ` [PATCH 4/4] KVM: x86/mmu: Restrict mapping level based on guest MTRR iff they're used Sean Christopherson
2022-07-18 12:08 ` Maxim Levitsky
2022-07-19 17:59 ` [PATCH 0/4] KVM: x86/mmu: Memtype related cleanups Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2c8fd8e1179fc63084ec451496df5b68caae2756.camel@redhat.com \
--to=mlevitsk@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome