From nobody Thu Apr 2 23:02:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86425C54EE9 for ; Tue, 20 Sep 2022 03:04:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229673AbiITDEE (ORCPT ); Mon, 19 Sep 2022 23:04:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229801AbiITDDn (ORCPT ); Mon, 19 Sep 2022 23:03:43 -0400 Received: from mail.nfschina.com (mail.nfschina.com [124.16.136.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 607CA5852C; Mon, 19 Sep 2022 20:03:42 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id 24BBC1E80D1C; Tue, 20 Sep 2022 11:00:35 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FpVUwppaUQEi; Tue, 20 Sep 2022 11:00:32 +0800 (CST) Received: from localhost.localdomain (unknown [219.141.250.2]) (Authenticated sender: kunyu@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 233AA1E80D17; Tue, 20 Sep 2022 11:00:32 +0800 (CST) From: Li kunyu To: 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 Cc: linux-hyperv@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Li kunyu Subject: [PATCH] asm-generic: Remove the parameters of the generate_guest_id function and modify the return type and modify the function name Date: Tue, 20 Sep 2022 11:03:35 +0800 Message-Id: <20220920030335.69132-1-kunyu@nfschina.com> X-Mailer: git-send-email 2.18.2 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Li kunyu --- 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; =20 /* Setup the guest ID */ - guest_id =3D generate_guest_id(0, LINUX_VERSION_CODE, 0); + guest_id =3D hv_generate_guest_id(); hv_set_vpreg(HV_REGISTER_GUEST_OSID, guest_id); =20 /* 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 =3D generate_guest_id(0, LINUX_VERSION_CODE, 0); + guest_id =3D hv_generate_guest_id(); wrmsrl(HV_X64_MSR_GUEST_OS_ID, guest_id); =20 /* 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..78e7dc9e9587 100644 --- a/include/asm-generic/mshyperv.h +++ b/include/asm-generic/mshyperv.h @@ -25,6 +25,7 @@ #include #include #include +#include =20 struct ms_hyperv_info { u32 features; @@ -105,15 +106,12 @@ static inline u64 hv_do_rep_hypercall(u16 code, u16 r= ep_count, u16 varhead_size, } =20 /* 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 generate_guest_id(void) { - __u64 guest_id =3D 0; + u64 guest_id; =20 - guest_id =3D (((__u64)HV_LINUX_VENDOR_ID) << 48); - guest_id |=3D (d_info1 << 48); - guest_id |=3D (kernel_version << 16); - guest_id |=3D d_info2; + guest_id =3D (((u64)HV_LINUX_VENDOR_ID) << 48); + guest_id |=3D (((u64)LINUX_VERSION_CODE) << 16); =20 return guest_id; } --=20 2.18.2