Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp230968rwb; Sun, 25 Sep 2022 19:26:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM79UJNq/7Tgu/jwyDfCsMwi74jlqgsnDXLMhCp4zfMcGaRcP22MkwDzNdqq3XcqyYlVnDPd X-Received: by 2002:aa7:cd92:0:b0:456:cbb5:2027 with SMTP id x18-20020aa7cd92000000b00456cbb52027mr14088990edv.384.1664159183888; Sun, 25 Sep 2022 19:26:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664159183; cv=none; d=google.com; s=arc-20160816; b=KskPbuI2GTwnIaPEprCUP7VYU3oGhKxVaROk7WFCJMprXEvTnfT6HV3AuYfH1izIaq oUAMh83bzKJRLAmZFqvY3At9jurza++ATNUQdwR3MniqelBviLO8T1zs+kqOeFgCqdmo HyfRJ9+pDyKDfce3Zph1dGjoewNFNchMPFdgVh0jv4kiEwxQYUzj/WuDzIvwDqGgCTZv tWZnfc9RU7+JsNBX8io3KCdSNoiCX3uxo7AQmX/HTY3DXSK2e9QVPXYmJDmdakFjOxmm 9j+MM8wYVxljZpkh9AibgW3h5z5AQPezCZLQ76s2cjUzM3AiBMJdc+gHGmIgwz/p1Q1v bDOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=OeyD9KwpON7XeIluvkKL+Ejvou640In3JrXYEQk3SLg=; b=GLIzBE6VARWkyB71VYChu3xabPQLgsCBw3Ikge5R66iEGNIMYxM1ED6+vWedTuQWFo ybTqncfXMzLtvFaUA1Avq2tuwKRCU68QzssbBtRhvUYWoAW4EcYuwFf9A/0zi5imxCmM yuCjV1gpjgWwSyuMADkpulzVOXlH4oGeodneNgf+3ajh+vIAur30xjM1S6cryJLXJX+7 IYZmKvzKAZHQRaMdiTHjsD06qAyMx7n7NwkmaI5bzotrLIZObs8P3BbnxcYsdgXxCu6r s4kQd7gKvAVXyrrxcM7/dOND7eHa2cPlrUvmOvg55o80ugZdmIA5/pQF/e5RBUKa4yRg p+GA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y6-20020a056402440600b00453d55cb36csi17777004eda.365.2022.09.25.19.25.59; Sun, 25 Sep 2022 19:26:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233278AbiIZBtY (ORCPT + 99 others); Sun, 25 Sep 2022 21:49:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231521AbiIZBtW (ORCPT ); Sun, 25 Sep 2022 21:49:22 -0400 Received: from mail.nfschina.com (unknown [124.16.136.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8B4472AE02; Sun, 25 Sep 2022 18:49:20 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id B9B7D1E80D3D; Mon, 26 Sep 2022 09:45:14 +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 vbs55Yj4xvMW; Mon, 26 Sep 2022 09:45:11 +0800 (CST) Received: from localhost.localdomain (unknown [219.141.250.2]) (Authenticated sender: kunyu@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 6268F1E80D10; Mon, 26 Sep 2022 09:45:11 +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, hpa@zytor.com, arnd@arndb.de Cc: x86@kernel.org, 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 v4] hyperv: simplify and rename generate_guest_id Date: Mon, 26 Sep 2022 09:48:50 +0800 Message-Id: <20220926014850.3202-1-kunyu@nfschina.com> X-Mailer: git-send-email 2.18.2 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,MAY_BE_FORGED, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -------- 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 in the calling file, and add #inclu de in the function implementation file --- arch/arm64/hyperv/mshyperv.c | 3 +-- arch/x86/hyperv/hv_init.c | 3 +-- include/asm-generic/mshyperv.h | 12 +++++------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/arch/arm64/hyperv/mshyperv.c b/arch/arm64/hyperv/mshyperv.c index bbbe351e9045..637186f4df1f 100644 --- a/arch/arm64/hyperv/mshyperv.c +++ b/arch/arm64/hyperv/mshyperv.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include @@ -38,7 +37,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..04d32cd3e838 100644 --- a/arch/x86/hyperv/hv_init.c +++ b/arch/x86/hyperv/hv_init.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -426,7 +425,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..9155575b7e34 100644 --- a/include/asm-generic/mshyperv.h +++ b/include/asm-generic/mshyperv.h @@ -25,6 +25,7 @@ #include #include #include +#include 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) { - __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