Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hyperv: Switch from hyperv-tlfs.h to hyperv/hvhdk.h

Switch to using hvhdk.h everywhere in the kernel. This header
includes all the new Hyper-V headers in include/hyperv, which form a
superset of the definitions found in hyperv-tlfs.h.

This makes it easier to add new Hyper-V interfaces without being
restricted to those in the TLFS doc (reflected in hyperv-tlfs.h).

To be more consistent with the original Hyper-V code, the names of
some definitions are changed slightly. Update those where needed.

Update comments in mshyperv.h files to point to include/hyperv for
adding new definitions.

Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Reviewed-by: Easwar Hariharan <eahariha@linux.microsoft.com>
Signed-off-by: Roman Kisel <romank@linux.microsoft.com>
Reviewed-by: Easwar Hariharan <eahariha@linux.microsoft.com>
Link: https://lore.kernel.org/r/1732577084-2122-5-git-send-email-nunodasneves@linux.microsoft.com
Link: https://lore.kernel.org/r/20250108222138.1623703-3-romank@linux.microsoft.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>

authored by

Nuno Das Neves and committed by
Wei Liu
ef5a3c92 e68bda71

+39 -41
+1 -1
arch/arm64/hyperv/hv_core.c
··· 14 14 #include <linux/arm-smccc.h> 15 15 #include <linux/module.h> 16 16 #include <asm-generic/bug.h> 17 - #include <asm/hyperv-tlfs.h> 17 + #include <hyperv/hvhdk.h> 18 18 #include <asm/mshyperv.h> 19 19 20 20 /*
+2 -2
arch/arm64/hyperv/mshyperv.c
··· 49 49 hv_set_vpreg(HV_REGISTER_GUEST_OS_ID, guest_id); 50 50 51 51 /* Get the features and hints from Hyper-V */ 52 - hv_get_vpreg_128(HV_REGISTER_FEATURES, &result); 52 + hv_get_vpreg_128(HV_REGISTER_PRIVILEGES_AND_FEATURES_INFO, &result); 53 53 ms_hyperv.features = result.as32.a; 54 54 ms_hyperv.priv_high = result.as32.b; 55 55 ms_hyperv.misc_features = result.as32.c; 56 56 57 - hv_get_vpreg_128(HV_REGISTER_ENLIGHTENMENTS, &result); 57 + hv_get_vpreg_128(HV_REGISTER_FEATURES_INFO, &result); 58 58 ms_hyperv.hints = result.as32.a; 59 59 60 60 pr_info("Hyper-V: privilege flags low 0x%x, high 0x%x, hints 0x%x, misc 0x%x\n",
+3 -4
arch/arm64/include/asm/mshyperv.h
··· 6 6 * the ARM64 architecture. See include/asm-generic/mshyperv.h for 7 7 * definitions are that architecture independent. 8 8 * 9 - * Definitions that are specified in the Hyper-V Top Level Functional 10 - * Spec (TLFS) should not go in this file, but should instead go in 11 - * hyperv-tlfs.h. 9 + * Definitions that are derived from Hyper-V code or headers should not go in 10 + * this file, but should instead go in the relevant files in include/hyperv. 12 11 * 13 12 * Copyright (C) 2021, Microsoft, Inc. 14 13 * ··· 19 20 20 21 #include <linux/types.h> 21 22 #include <linux/arm-smccc.h> 22 - #include <asm/hyperv-tlfs.h> 23 + #include <hyperv/hvhdk.h> 23 24 24 25 /* 25 26 * Declare calls to get and set Hyper-V VP register values on ARM64, which
+10 -10
arch/x86/hyperv/hv_init.c
··· 19 19 #include <asm/sev.h> 20 20 #include <asm/ibt.h> 21 21 #include <asm/hypervisor.h> 22 - #include <asm/hyperv-tlfs.h> 22 + #include <hyperv/hvhdk.h> 23 23 #include <asm/mshyperv.h> 24 24 #include <asm/idtentry.h> 25 25 #include <asm/set_memory.h> ··· 415 415 static u8 __init get_vtl(void) 416 416 { 417 417 u64 control = HV_HYPERCALL_REP_COMP_1 | HVCALL_GET_VP_REGISTERS; 418 - struct hv_get_vp_registers_input *input; 419 - struct hv_get_vp_registers_output *output; 418 + struct hv_input_get_vp_registers *input; 419 + struct hv_output_get_vp_registers *output; 420 420 unsigned long flags; 421 421 u64 ret; 422 422 423 423 local_irq_save(flags); 424 424 input = *this_cpu_ptr(hyperv_pcpu_input_arg); 425 - output = (struct hv_get_vp_registers_output *)input; 425 + output = (struct hv_output_get_vp_registers *)input; 426 426 427 - memset(input, 0, struct_size(input, element, 1)); 428 - input->header.partitionid = HV_PARTITION_ID_SELF; 429 - input->header.vpindex = HV_VP_INDEX_SELF; 430 - input->header.inputvtl = 0; 431 - input->element[0].name0 = HV_X64_REGISTER_VSM_VP_STATUS; 427 + memset(input, 0, struct_size(input, names, 1)); 428 + input->partition_id = HV_PARTITION_ID_SELF; 429 + input->vp_index = HV_VP_INDEX_SELF; 430 + input->input_vtl.as_uint8 = 0; 431 + input->names[0] = HV_REGISTER_VSM_VP_STATUS; 432 432 433 433 ret = hv_do_hypercall(control, input, output); 434 434 if (hv_result_success(ret)) { 435 - ret = output->as64.low & HV_X64_VTL_MASK; 435 + ret = output->values[0].reg8 & HV_X64_VTL_MASK; 436 436 } else { 437 437 pr_err("Failed to get VTL(error: %lld) exiting...\n", ret); 438 438 BUG();
+1 -1
arch/x86/hyperv/hv_proc.c
··· 176 176 input->partition_id = partition_id; 177 177 input->vp_index = vp_index; 178 178 input->flags = flags; 179 - input->subnode_type = HvSubnodeAny; 179 + input->subnode_type = HV_SUBNODE_ANY; 180 180 input->proximity_domain_info = hv_numa_node_to_pxm_info(node); 181 181 status = hv_do_hypercall(HVCALL_CREATE_VP, input, NULL); 182 182 local_irq_restore(irq_flags);
+1 -1
arch/x86/hyperv/nested.c
··· 11 11 12 12 13 13 #include <linux/types.h> 14 - #include <asm/hyperv-tlfs.h> 14 + #include <hyperv/hvhdk.h> 15 15 #include <asm/mshyperv.h> 16 16 #include <asm/tlbflush.h> 17 17
+1 -1
arch/x86/include/asm/kvm_host.h
··· 35 35 #include <asm/asm.h> 36 36 #include <asm/kvm_page_track.h> 37 37 #include <asm/kvm_vcpu_regs.h> 38 - #include <asm/hyperv-tlfs.h> 39 38 #include <asm/reboot.h> 39 + #include <hyperv/hvhdk.h> 40 40 41 41 #define __KVM_HAVE_ARCH_VCPU_DEBUGFS 42 42
+1 -1
arch/x86/include/asm/mshyperv.h
··· 6 6 #include <linux/nmi.h> 7 7 #include <linux/msi.h> 8 8 #include <linux/io.h> 9 - #include <asm/hyperv-tlfs.h> 10 9 #include <asm/nospec-branch.h> 11 10 #include <asm/paravirt.h> 11 + #include <hyperv/hvhdk.h> 12 12 13 13 /* 14 14 * Hyper-V always provides a single IO-APIC at this MMIO address.
+1 -1
arch/x86/include/asm/svm.h
··· 5 5 #include <uapi/asm/svm.h> 6 6 #include <uapi/asm/kvm.h> 7 7 8 - #include <asm/hyperv-tlfs.h> 8 + #include <hyperv/hvhdk.h> 9 9 10 10 /* 11 11 * 32-bit intercept words in the VMCB Control Area, starting
+1 -1
arch/x86/kernel/cpu/mshyperv.c
··· 19 19 #include <linux/random.h> 20 20 #include <asm/processor.h> 21 21 #include <asm/hypervisor.h> 22 - #include <asm/hyperv-tlfs.h> 22 + #include <hyperv/hvhdk.h> 23 23 #include <asm/mshyperv.h> 24 24 #include <asm/desc.h> 25 25 #include <asm/idtentry.h>
+1 -1
arch/x86/kvm/vmx/hyperv_evmcs.h
··· 6 6 #ifndef __KVM_X86_VMX_HYPERV_EVMCS_H 7 7 #define __KVM_X86_VMX_HYPERV_EVMCS_H 8 8 9 - #include <asm/hyperv-tlfs.h> 9 + #include <hyperv/hvhdk.h> 10 10 11 11 #include "capabilities.h" 12 12 #include "vmcs12.h"
+1 -1
arch/x86/kvm/vmx/vmx_onhyperv.h
··· 3 3 #ifndef __ARCH_X86_KVM_VMX_ONHYPERV_H__ 4 4 #define __ARCH_X86_KVM_VMX_ONHYPERV_H__ 5 5 6 - #include <asm/hyperv-tlfs.h> 6 + #include <hyperv/hvhdk.h> 7 7 #include <asm/mshyperv.h> 8 8 9 9 #include <linux/jump_label.h>
+1 -1
drivers/clocksource/hyperv_timer.c
··· 23 23 #include <linux/acpi.h> 24 24 #include <linux/hyperv.h> 25 25 #include <clocksource/hyperv_timer.h> 26 - #include <asm/hyperv-tlfs.h> 26 + #include <hyperv/hvhdk.h> 27 27 #include <asm/mshyperv.h> 28 28 29 29 static struct clock_event_device __percpu *hv_clock_event;
+2 -2
drivers/hv/hv_balloon.c
··· 28 28 #include <linux/sizes.h> 29 29 30 30 #include <linux/hyperv.h> 31 - #include <asm/hyperv-tlfs.h> 31 + #include <hyperv/hvhdk.h> 32 32 33 33 #include <asm/mshyperv.h> 34 34 ··· 1586 1586 return -ENOSPC; 1587 1587 } 1588 1588 1589 - hint->type = HV_EXT_MEMORY_HEAT_HINT_TYPE_COLD_DISCARD; 1589 + hint->heat_type = HV_EXTMEM_HEAT_HINT_COLD_DISCARD; 1590 1590 hint->reserved = 0; 1591 1591 for_each_sg(sgl, sg, nents, i) { 1592 1592 union hv_gpa_page_range *range;
+1 -1
drivers/hv/hv_common.c
··· 28 28 #include <linux/slab.h> 29 29 #include <linux/dma-map-ops.h> 30 30 #include <linux/set_memory.h> 31 - #include <asm/hyperv-tlfs.h> 31 + #include <hyperv/hvhdk.h> 32 32 #include <asm/mshyperv.h> 33 33 34 34 /*
+1 -1
drivers/hv/hv_kvp.c
··· 27 27 #include <linux/connector.h> 28 28 #include <linux/workqueue.h> 29 29 #include <linux/hyperv.h> 30 - #include <asm/hyperv-tlfs.h> 30 + #include <hyperv/hvhdk.h> 31 31 32 32 #include "hyperv_vmbus.h" 33 33 #include "hv_utils_transport.h"
+1 -1
drivers/hv/hv_snapshot.c
··· 12 12 #include <linux/connector.h> 13 13 #include <linux/workqueue.h> 14 14 #include <linux/hyperv.h> 15 - #include <asm/hyperv-tlfs.h> 15 + #include <hyperv/hvhdk.h> 16 16 17 17 #include "hyperv_vmbus.h" 18 18 #include "hv_utils_transport.h"
+1 -1
drivers/hv/hyperv_vmbus.h
··· 15 15 #include <linux/list.h> 16 16 #include <linux/bitops.h> 17 17 #include <asm/sync_bitops.h> 18 - #include <asm/hyperv-tlfs.h> 19 18 #include <linux/atomic.h> 20 19 #include <linux/hyperv.h> 21 20 #include <linux/interrupt.h> 21 + #include <hyperv/hvhdk.h> 22 22 23 23 #include "hv_trace.h" 24 24
+3 -4
include/asm-generic/mshyperv.h
··· 6 6 * independent. See arch/<arch>/include/asm/mshyperv.h for definitions 7 7 * that are specific to architecture <arch>. 8 8 * 9 - * Definitions that are specified in the Hyper-V Top Level Functional 10 - * Spec (TLFS) should not go in this file, but should instead go in 11 - * hyperv-tlfs.h. 9 + * Definitions that are derived from Hyper-V code or headers should not go in 10 + * this file, but should instead go in the relevant files in include/hyperv. 12 11 * 13 12 * Copyright (C) 2019, Microsoft, Inc. 14 13 * ··· 24 25 #include <linux/cpumask.h> 25 26 #include <linux/nmi.h> 26 27 #include <asm/ptrace.h> 27 - #include <asm/hyperv-tlfs.h> 28 + #include <hyperv/hvhdk.h> 28 29 29 30 #define VTPM_BASE_ADDRESS 0xfed40000 30 31
+1 -1
include/clocksource/hyperv_timer.h
··· 15 15 16 16 #include <linux/clocksource.h> 17 17 #include <linux/math64.h> 18 - #include <asm/hyperv-tlfs.h> 18 + #include <hyperv/hvhdk.h> 19 19 20 20 #define HV_MAX_MAX_DELTA_TICKS 0xffffffff 21 21 #define HV_MIN_DELTA_TICKS 1
+1 -1
include/linux/hyperv.h
··· 24 24 #include <linux/mod_devicetable.h> 25 25 #include <linux/interrupt.h> 26 26 #include <linux/reciprocal_div.h> 27 - #include <asm/hyperv-tlfs.h> 27 + #include <hyperv/hvhdk.h> 28 28 29 29 #define MAX_PAGE_BUFFER_COUNT 32 30 30 #define MAX_MULTIPAGE_BUFFER_COUNT 32 /* 128K */
+3 -3
net/vmw_vsock/hyperv_transport.c
··· 13 13 #include <linux/hyperv.h> 14 14 #include <net/sock.h> 15 15 #include <net/af_vsock.h> 16 - #include <asm/hyperv-tlfs.h> 16 + #include <hyperv/hvhdk.h> 17 17 18 18 /* Older (VMBUS version 'VERSION_WIN10' or before) Windows hosts have some 19 19 * stricter requirements on the hv_sock ring buffer size of six 4K pages. 20 - * hyperv-tlfs defines HV_HYP_PAGE_SIZE as 4K. Newer hosts don't have this 21 - * limitation; but, keep the defaults the same for compat. 20 + * HV_HYP_PAGE_SIZE is defined as 4K. Newer hosts don't have this limitation; 21 + * but, keep the defaults the same for compat. 22 22 */ 23 23 #define RINGBUFFER_HVS_RCV_SIZE (HV_HYP_PAGE_SIZE * 6) 24 24 #define RINGBUFFER_HVS_SND_SIZE (HV_HYP_PAGE_SIZE * 6)