mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Michael Kelley (LINUX)" <mikelley@microsoft.com>
To: Li kunyu <kunyu@nfschina.com>, KY Srinivasan <kys@microsoft.com>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	Stephen Hemminger <sthemmin@microsoft.com>,
	"wei.liu@kernel.org" <wei.liu@kernel.org>,
	Dexuan Cui <decui@microsoft.com>,
	"catalin.marinas@arm.com" <catalin.marinas@arm.com>,
	"will@kernel.org" <will@kernel.org>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"bp@alien8.de" <bp@alien8.de>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"hpa@zytor.com" <hpa@zytor.com>, "arnd@arndb.de" <arnd@arndb.de>
Cc: "x86@kernel.org" <x86@kernel.org>,
	"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>
Subject: RE: [PATCH v5] hyperv: simplify and rename generate_guest_id
Date: Tue, 27 Sep 2022 21:08:48 +0000	[thread overview]
Message-ID: <BYAPR21MB1688ABC8562E0AC0830237C9D7559@BYAPR21MB1688.namprd21.prod.outlook.com> (raw)
In-Reply-To: <20220927074550.3347-1-kunyu@nfschina.com>

From: Li kunyu <kunyu@nfschina.com> Sent: Tuesday, September 27, 2022 12:46 AM
> 
> 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.

The above statement is no longer true.

> 3. Rename the function to make it clearly a Hyper-V related function,
> and modify it to hv_generate_guest_id.
> 
> Signed-off-by: Li kunyu <kunyu@nfschina.com>
> 
> --------
>  v2: Fix generate_guest_id to hv_generate_guest_id.
>  v3: Fix [PATCH v2] asm-generic: Remove the ... to [PATCH v3] hyperv: simp
>      lify ... and remove extra spaces
>  v4: Remove #include <linux/version.h> in the calling file, and add #inclu
>      de <linux/version.h> in the function implementation file
>  v5: <linux/version.h> is changed to the definition position before v4, an
>      d the LINUX_VERSION_CODE macro is passed in the function call
> ---
>  arch/arm64/hyperv/mshyperv.c   | 2 +-
>  arch/x86/hyperv/hv_init.c      | 2 +-
>  include/asm-generic/mshyperv.h | 9 +++------
>  3 files changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/arm64/hyperv/mshyperv.c b/arch/arm64/hyperv/mshyperv.c
> index bbbe351e9045..a406454578f0 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(LINUX_VERSION_CODE);
>  	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..032d85ac33fa 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(LINUX_VERSION_CODE);
>  	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..bfb9eb9d7215 100644
> --- a/include/asm-generic/mshyperv.h
> +++ b/include/asm-generic/mshyperv.h
> @@ -105,15 +105,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(u64 kernel_version)
>  {
> -	__u64 guest_id = 0;
> +	u64 guest_id;
> 
> -	guest_id = (((__u64)HV_LINUX_VENDOR_ID) << 48);
> -	guest_id |= (d_info1 << 48);
> +	guest_id = (((u64)HV_LINUX_VENDOR_ID) << 48);
>  	guest_id |= (kernel_version << 16);
> -	guest_id |= d_info2;
> 
>  	return guest_id;
>  }
> --
> 2.18.2

I'm good with the code.  Thanks for taking into the account the input
from Olaf Hering.  But per my comment above, the commit message
needs to be updated to reflect this last change.

Michael


      reply	other threads:[~2022-09-27 21:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-27  7:45 Li kunyu
2022-09-27 21:08 ` Michael Kelley (LINUX) [this message]

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=BYAPR21MB1688ABC8562E0AC0830237C9D7559@BYAPR21MB1688.namprd21.prod.outlook.com \
    --to=mikelley@microsoft.com \
    --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=wei.liu@kernel.org \
    --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

all inboxes | Powered by JetHome®