forked from Minki/linux
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 <kunyu@nfschina.com> Reviewed-by: Michael Kelley <mikelley@microsoft.com> Link: https://lore.kernel.org/r/20220928064046.3545-1-kunyu@nfschina.com Signed-off-by: Wei Liu <wei.liu@kernel.org>
This commit is contained in:
parent
fb2d14add4
commit
d5ebde1e2b
@ -38,7 +38,7 @@ static int __init hyperv_init(void)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Setup the guest ID */
|
/* 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);
|
hv_set_vpreg(HV_REGISTER_GUEST_OSID, guest_id);
|
||||||
|
|
||||||
/* Get the features and hints from Hyper-V */
|
/* Get the features and hints from Hyper-V */
|
||||||
|
@ -426,7 +426,7 @@ void __init hyperv_init(void)
|
|||||||
* 1. Register the guest ID
|
* 1. Register the guest ID
|
||||||
* 2. Enable the hypercall and register the hypercall page
|
* 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);
|
wrmsrl(HV_X64_MSR_GUEST_OS_ID, guest_id);
|
||||||
|
|
||||||
/* Hyper-V requires to write guest os id via ghcb in SNP IVM. */
|
/* Hyper-V requires to write guest os id via ghcb in SNP IVM. */
|
||||||
|
@ -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 */
|
/* Generate the guest OS identifier as described in the Hyper-V TLFS */
|
||||||
static inline __u64 generate_guest_id(__u64 d_info1, __u64 kernel_version,
|
static inline u64 hv_generate_guest_id(u64 kernel_version)
|
||||||
__u64 d_info2)
|
|
||||||
{
|
{
|
||||||
__u64 guest_id = 0;
|
u64 guest_id;
|
||||||
|
|
||||||
guest_id = (((__u64)HV_LINUX_VENDOR_ID) << 48);
|
guest_id = (((u64)HV_LINUX_VENDOR_ID) << 48);
|
||||||
guest_id |= (d_info1 << 48);
|
|
||||||
guest_id |= (kernel_version << 16);
|
guest_id |= (kernel_version << 16);
|
||||||
guest_id |= d_info2;
|
|
||||||
|
|
||||||
return guest_id;
|
return guest_id;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user