From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Saurabh Sengar <ssengar@linux.microsoft.com>
Cc: ssengar@microsoft.com, kys@microsoft.com, haiyangz@microsoft.com,
wei.liu@kernel.org, decui@microsoft.com, tglx@linutronix.de,
mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
x86@kernel.org, hpa@zytor.com, linux-hyperv@vger.kernel.org,
linux-kernel@vger.kernel.org, mikelley@microsoft.com
Subject: Re: [PATCH] x86/hyperv: Restrict get_vtl to only VTL platforms
Date: Thu, 14 Sep 2023 16:49:08 +0200 [thread overview]
Message-ID: <874jjwq07v.fsf@redhat.com> (raw)
In-Reply-To: <1694604531-17128-1-git-send-email-ssengar@linux.microsoft.com>
Saurabh Sengar <ssengar@linux.microsoft.com> writes:
> For non VTL platforms vtl is always 0, and there is no need of
> get_vtl function. For VTL platforms get_vtl should always succeed
> and should return the correct VTL.
>
> Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com>
> ---
> arch/x86/hyperv/hv_init.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
> index 783ed339f341..e589c240565a 100644
> --- a/arch/x86/hyperv/hv_init.c
> +++ b/arch/x86/hyperv/hv_init.c
> @@ -416,8 +416,8 @@ static u8 __init get_vtl(void)
> if (hv_result_success(ret)) {
> ret = output->as64.low & HV_X64_VTL_MASK;
> } else {
> - pr_err("Failed to get VTL(%lld) and set VTL to zero by default.\n", ret);
> - ret = 0;
> + pr_err("Failed to get VTL(error: %lld) exiting...\n", ret);
Nitpick: arch/x86/hyperv/hv_init.c lacks pr_fmt so the message won't get
prefixed with "Hyper-V". I'm not sure 'VTL' abbreviation has the only,
Hyper-V specific meaning. I'd suggest we add
#define pr_fmt(fmt) "Hyper-V: " fmt
to the beginning of the file.
> + BUG();
> }
>
> local_irq_restore(flags);
> @@ -604,8 +604,10 @@ void __init hyperv_init(void)
> hv_query_ext_cap(0);
>
> /* Find the VTL */
> - if (!ms_hyperv.paravisor_present && hv_isolation_type_snp())
> + if (IS_ENABLED(CONFIG_HYPERV_VTL_MODE))
> ms_hyperv.vtl = get_vtl();
> + else
> + ms_hyperv.vtl = 0;
Is 'else' branch really needed? 'ms_hyperv' seems to be a statically
allocated global. But instead of doing this, what about putting the
whole get_vtl() funtion under '#if (IS_ENABLED(CONFIG_HYPERV_VTL_MODE))', i.e.:
#if IS_ENABLED(CONFIG_HYPERV_VTL_MODE)
static u8 __init get_vtl(void)
{
u64 control = HV_HYPERCALL_REP_COMP_1 | HVCALL_GET_VP_REGISTERS;
...
}
#else
static inline get_vtl(void) { return 0; }
#endif
and then we can always do
ms_hyperv.vtl = get_vtl();
unconditionally?
>
> return;
--
Vitaly
next prev parent reply other threads:[~2023-09-14 14:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-13 11:28 [PATCH] x86/hyperv: Restrict get_vtl to only VTL platforms Saurabh Sengar
2023-09-14 14:49 ` Vitaly Kuznetsov [this message]
2023-09-15 6:57 ` Saurabh Singh Sengar
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=874jjwq07v.fsf@redhat.com \
--to=vkuznets@redhat.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=hpa@zytor.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mikelley@microsoft.com \
--cc=mingo@redhat.com \
--cc=ssengar@linux.microsoft.com \
--cc=ssengar@microsoft.com \
--cc=tglx@linutronix.de \
--cc=wei.liu@kernel.org \
--cc=x86@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.