Skip to content

Commit d5ebde1

Browse files
likunyurliuw
authored andcommitted
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. Signed-off-by: Li kunyu <[email protected]> Reviewed-by: Michael Kelley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Wei Liu <[email protected]>
1 parent fb2d14a commit d5ebde1

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

arch/arm64/hyperv/mshyperv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static int __init hyperv_init(void)
3838
return 0;
3939

4040
/* Setup the guest ID */
41-
guest_id = generate_guest_id(0, LINUX_VERSION_CODE, 0);
41+
guest_id = hv_generate_guest_id(LINUX_VERSION_CODE);
4242
hv_set_vpreg(HV_REGISTER_GUEST_OSID, guest_id);
4343

4444
/* Get the features and hints from Hyper-V */

arch/x86/hyperv/hv_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ void __init hyperv_init(void)
426426
* 1. Register the guest ID
427427
* 2. Enable the hypercall and register the hypercall page
428428
*/
429-
guest_id = generate_guest_id(0, LINUX_VERSION_CODE, 0);
429+
guest_id = hv_generate_guest_id(LINUX_VERSION_CODE);
430430
wrmsrl(HV_X64_MSR_GUEST_OS_ID, guest_id);
431431

432432
/* Hyper-V requires to write guest os id via ghcb in SNP IVM. */

include/asm-generic/mshyperv.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,12 @@ static inline u64 hv_do_rep_hypercall(u16 code, u16 rep_count, u16 varhead_size,
105105
}
106106

107107
/* Generate the guest OS identifier as described in the Hyper-V TLFS */
108-
static inline __u64 generate_guest_id(__u64 d_info1, __u64 kernel_version,
109-
__u64 d_info2)
108+
static inline u64 hv_generate_guest_id(u64 kernel_version)
110109
{
111-
__u64 guest_id = 0;
110+
u64 guest_id;
112111

113-
guest_id = (((__u64)HV_LINUX_VENDOR_ID) << 48);
114-
guest_id |= (d_info1 << 48);
112+
guest_id = (((u64)HV_LINUX_VENDOR_ID) << 48);
115113
guest_id |= (kernel_version << 16);
116-
guest_id |= d_info2;
117114

118115
return guest_id;
119116
}

0 commit comments

Comments
 (0)