hyperv: simplify and rename generate_guest_id
Subsystems (5)
PATCH v6 1/1 hyperv: simplify and rename generate_guest_id
The generate_guest_id function is more suitable for use after the following modifications.
1. The return value of the function is modified to u64.
2. Remove the d_info1 and d_info2 parameters from the function, keep the u64 type kernel_version parameter.
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.
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
v6: Modify the patch description information to the changed information a
fter discussion
--- 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(-)
arch/arm64/hyperv/mshyperv.c +1 -1
@@ -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 */
arch/x86/hyperv/hv_init.c +1 -1
@@ -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. */
include/asm-generic/mshyperv.h +3 -6
@@ -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; }
Signature · 1 line
2.18.2
From: Li kunyu <[email protected]> Sent: Tuesday, September 27, 2022 11:41 PM
Quoted 77 lines
The
generate_guest_idfunction is more suitable for use after the following modifications.
1. The return value of the function is modified to u64.
2. Remove thed_info1andd_info2parameters from the function, keep the u64 typekernel_versionparameter.
3. Rename the function to make it clearly a Hyper-V related function, and modify it tohv_generate_guest_id.Signed-off-by Li kunyu <[email protected]>--------
v2: Fixgenerate_guest_idtohv_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 theLINUX_VERSION_CODEmacro is passed in the function call
v6: Modify the patch description information to the changed information a
fter discussion--- 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(-)arch/arm64/hyperv/mshyperv.c +1
-1@@ -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 */ arch/x86/hyperv/hv_init.c +1
-1@@ -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. */ include/asm-generic/mshyperv.h +3
-7@@ -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; } --
Quoted 1 line
2.18.2
Wei Liu
maintainerQuoted 10 lines · Li kunyu
The
generate_guest_idfunction is more suitable for use after the following modifications.
1. The return value of the function is modified to u64.
2. Remove thed_info1andd_info2parameters from the function, keep the u64 typekernel_versionparameter.
3. Rename the function to make it clearly a Hyper-V related function, and modify it tohv_generate_guest_id.Signed-off-by Li kunyu <[email protected]>
Quoted 10 lines
--------
v2: Fixgenerate_guest_idtohv_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 theLINUX_VERSION_CODEmacro is passed in the function call
v6: Modify the patch description information to the changed information a
fter discussion
This part -- normally the change history should be stripped when the patch is committed with git-am(1).
The usual way of doing it is to place them (and any other text that is not intended to be committed) after three dashes. No fewer, no more, only three dashes.
Why three dashes? Git-am(1) has the following:
The patch is expected to be inline, directly following the message. Any line that is of the form:
• three-dashes and end-of-line, or
• a line that begins with "diff -", or
• a line that begins with "Index: "
is taken as the beginning of a patch, and the commit log message is terminated before the first occurrence of such a line.
Notice the last sentence. You used eight dashes. Git-am(1) does not consider that pattern terminates the commit log message.
There is no need for you to do anything. I've cleaned up the commit message and applied it to hyperv-next. I thought the above tidbit can help you (or anyone else who doesn't know about this and happens to read this lengthy email) in your future patch submission though. :-)
Thanks,
Wei.
Thank you very much for your help, and thank the members of the mailing list (in the sending list). With your help, I learned more standard patch writing method and patch modification ideas.
thanks,
kunyu.