From: Wei Liu <wei.liu@kernel.org>
To: Li kunyu <kunyu@nfschina.com>
Cc: kys@microsoft.com, haiyangz@microsoft.com,
sthemmin@microsoft.com, wei.liu@kernel.org, decui@microsoft.com,
catalin.marinas@arm.com, will@kernel.org, tglx@linutronix.de,
mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
x86@kernel.org, hpa@zytor.com, arnd@arndb.de,
linux-hyperv@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org
Subject: Re: [PATCH v2] asm-generic: Remove the parameters of the generate_guest_id function and modify the return type and modify the function name
Date: Fri, 23 Sep 2022 10:28:36 +0000 [thread overview]
Message-ID: <Yy2KVM08HMiv46d6@liuwe-devbox-debian-v2> (raw)
In-Reply-To: <20220920032837.69469-1-kunyu@nfschina.com>
Hi Kunyu
The subject line is far too long.
Please change it to
hyperv: simplify and rename generate_guest_id
On Tue, Sep 20, 2022 at 11:28:37AM +0800, Li kunyu wrote:
> The generate_guest_id function is more suitable for use after the
> following modifications.
> 1. Modify the type of the guest_id variable to u64, which is compatible
> with the caller.
> 2. Remove all parameters from the function, and write the parameter
> (LINUX_VERSION_CODE) passed in by the actual call into the function
> implementation.
> 3. Rename the function to make it clearly a Hyper-V related function,
> and modify it to hv_generate_guest_id.
>
> v2:
> Fix generate_guest_id to hv_generate_guest_id.
The patch version information shouldn't be part of the commit message.
You can use scissors to separate them
---8<---
v2: ...
When the patch gets applied, text after the scissors will be stripped
automatically.
>
> Signed-off-by: Li kunyu <kunyu@nfschina.com>
BTW, the previous patch was submitted by Li Zeming. Did you two agree on
who to take this forward?
> ---
> arch/arm64/hyperv/mshyperv.c | 2 +-
> arch/x86/hyperv/hv_init.c | 2 +-
> include/asm-generic/mshyperv.h | 12 +++++-------
> 3 files changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/arch/arm64/hyperv/mshyperv.c b/arch/arm64/hyperv/mshyperv.c
> index bbbe351e9045..3863fd226e0e 100644
> --- a/arch/arm64/hyperv/mshyperv.c
> +++ b/arch/arm64/hyperv/mshyperv.c
> @@ -38,7 +38,7 @@ static int __init hyperv_init(void)
> return 0;
>
> /* Setup the guest ID */
> - guest_id = generate_guest_id(0, LINUX_VERSION_CODE, 0);
> + guest_id = hv_generate_guest_id();
> hv_set_vpreg(HV_REGISTER_GUEST_OSID, guest_id);
>
> /* Get the features and hints from Hyper-V */
> diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
> index 3de6d8b53367..93770791b858 100644
> --- a/arch/x86/hyperv/hv_init.c
> +++ b/arch/x86/hyperv/hv_init.c
> @@ -426,7 +426,7 @@ void __init hyperv_init(void)
> * 1. Register the guest ID
> * 2. Enable the hypercall and register the hypercall page
> */
> - guest_id = generate_guest_id(0, LINUX_VERSION_CODE, 0);
> + guest_id = hv_generate_guest_id();
> wrmsrl(HV_X64_MSR_GUEST_OS_ID, guest_id);
>
> /* Hyper-V requires to write guest os id via ghcb in SNP IVM. */
> diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h
> index c05d2ce9b6cd..7f4a23cee56f 100644
> --- a/include/asm-generic/mshyperv.h
> +++ b/include/asm-generic/mshyperv.h
> @@ -25,6 +25,7 @@
> #include <linux/nmi.h>
> #include <asm/ptrace.h>
> #include <asm/hyperv-tlfs.h>
> +#include <linux/version.h>
>
> struct ms_hyperv_info {
> u32 features;
> @@ -105,15 +106,12 @@ static inline u64 hv_do_rep_hypercall(u16 code, u16 rep_count, u16 varhead_size,
> }
>
> /* Generate the guest OS identifier as described in the Hyper-V TLFS */
> -static inline __u64 generate_guest_id(__u64 d_info1, __u64 kernel_version,
> - __u64 d_info2)
> +static inline u64 hv_generate_guest_id(void)
^^
There are two spaces. We only need one.
I know it is not introduced by you, but since you're modifying the code
anyway, you may as well drop the extraneous space.
> {
> - __u64 guest_id = 0;
> + u64 guest_id;
>
> - guest_id = (((__u64)HV_LINUX_VENDOR_ID) << 48);
> - guest_id |= (d_info1 << 48);
> - guest_id |= (kernel_version << 16);
> - guest_id |= d_info2;
> + guest_id = (((u64)HV_LINUX_VENDOR_ID) << 48);
> + guest_id |= (((u64)LINUX_VERSION_CODE) << 16);
>
> return guest_id;
> }
> --
> 2.18.2
>
next prev parent reply other threads:[~2022-09-23 10:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-20 3:28 [PATCH v2] asm-generic: Remove the parameters of the generate_guest_id function and modify the return type and modify the function name Li kunyu
2022-09-23 10:28 ` Wei Liu [this message]
2022-09-23 11:19 ` Li kunyu
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=Yy2KVM08HMiv46d6@liuwe-devbox-debian-v2 \
--to=wei.liu@kernel.org \
--cc=arnd@arndb.de \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=dave.hansen@linux.intel.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=hpa@zytor.com \
--cc=kunyu@nfschina.com \
--cc=kys@microsoft.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=sthemmin@microsoft.com \
--cc=tglx@linutronix.de \
--cc=will@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 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).