Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp762105rwb; Fri, 23 Sep 2022 03:57:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM65FnOWx+8bP8zlRKC6pQmDhpqIDS4epxM2sQ6TVECDpaNfvL1RHCYQPbuX/HeY1TKBR6rc X-Received: by 2002:a17:903:1c4:b0:176:e348:c386 with SMTP id e4-20020a17090301c400b00176e348c386mr7717034plh.3.1663930663158; Fri, 23 Sep 2022 03:57:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663930663; cv=none; d=google.com; s=arc-20160816; b=BnP6mfyk1yCzPnype9WB9jYNDXIOk79+OAr6cz9vVspY3DXudomVwOkL3gEcBsuv1w kqGKbLm0KkfPn8Y7pWY7HG7zkXGXhHCHdEKEiOgfWtOf5ptD//Uqf7mBGSSve6CLCrNj ZeSNMAZrpZ2LF7/egpi2m4WMQwoAEN66YJZ1sIOfanT74jkmmIA4Kun4DgJT2jwmcz92 xb+Z88awSArSEBwjnWemlsicN7ImtABHb1KDjrD31CfYtL8i7H2GzRSKBBwAMVcDmFfw dG6DsBcjVmDZp/9vd2fX0S2tCgkV2pE0JAB8PXxbWq4zCHcVWC3k9fxVWNSY3B28gBx6 LG0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=OCZ/F0HrnTTtm97NDW9M9Tgyn70w4D8p3nQznpQwDv8=; b=UIZ8I3wPDOXue7z9pukD9jBNFw3Mms+ZDzXfny5dJzWF3lQbkcck8U5c8oQBy1sruS LeKH5596fVti+mHx9vQUfA75XUI5Q2Ts+mdjId8fMVJ/ogjfZhSQ5Nk/TSi4IxoGlkMl 0wi3PD/iD3hF61W2RRcpbpXAaGpLDjxnYR64BuxvOpjYYmoUfqJvsFbOgtQ6MRPS6Uei WziHY+SFoWY5jAcJ3huLDFtLQElY42Dj9tNvhdr2uHsyw1ywhqRjOv2ViBgGgpBo8MQ8 mKTkV54+GB9E1KV8qCQ76itzLIUbMoKxYfnZezM9gkWXnjNo6u/qEjFvarzVcZ4jXhZJ roEw== 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n19-20020a634d53000000b00438766f903asi8911511pgl.490.2022.09.23.03.57.31; Fri, 23 Sep 2022 03:57:43 -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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231160AbiIWK3U (ORCPT + 99 others); Fri, 23 Sep 2022 06:29:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231879AbiIWK2l (ORCPT ); Fri, 23 Sep 2022 06:28:41 -0400 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2317F12ED86; Fri, 23 Sep 2022 03:28:40 -0700 (PDT) Received: by mail-wr1-f53.google.com with SMTP id t7so19672815wrm.10; Fri, 23 Sep 2022 03:28:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=OCZ/F0HrnTTtm97NDW9M9Tgyn70w4D8p3nQznpQwDv8=; b=mDRFLfmWFzqbUrpb3WKlPhSxhZ1xOsM2YL/VPBETqEJX9MTOhZlcMpQLZkxOvDC5ZI EEYjEhvhYSZQ9ihjkgQS1sgEXqntDiQiNv0kDdZOW/DoWg/pd/uj1cGvBqvbQ8E4C+tS SG4QXpAflEei7eCl1FdUnWOBkjIc4GvpGRlD8k1X1PwARNCfm5k8VUHmJGhwPjQt0FY5 i7Z0ayY+fRgxXyB7cHJpKEKLzspw52SHnpHOhlBAqmWgGoEpwbcU+qEE12zLoNp4bkvi 4Vn6kwJSpRq6BLo2wfmY0qgfYSKLLD/bzGmQSItEEVodLegM8udaPhkC7+GUzCkf0n3G /b9w== X-Gm-Message-State: ACrzQf2e/Bd9ST+1lA/dD0rmBYSlh+DzY81YKU2HHDHtLd+SvDoYIk1U fOXWY1x8WeagY8IV6AwHHjg= X-Received: by 2002:a5d:64e5:0:b0:22a:3cae:93bf with SMTP id g5-20020a5d64e5000000b0022a3cae93bfmr4833236wri.323.1663928918727; Fri, 23 Sep 2022 03:28:38 -0700 (PDT) Received: from liuwe-devbox-debian-v2 ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id x12-20020adfffcc000000b0022ac672654dsm6976948wrs.58.2022.09.23.03.28.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Sep 2022 03:28:38 -0700 (PDT) Date: Fri, 23 Sep 2022 10:28:36 +0000 From: Wei Liu To: Li kunyu 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 Message-ID: References: <20220920032837.69469-1-kunyu@nfschina.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220920032837.69469-1-kunyu@nfschina.com> X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS 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 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 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 > #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) ^^ 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 >