1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/include/hyperv/hvgdk_ext.h
Nuno Das Neves e68bda71a2 hyperv: Add new Hyper-V headers in include/hyperv
These headers contain definitions for regular Hyper-V guests (as in
hyperv-tlfs.h), as well as interfaces for more privileged guests like
the root partition (aka Dom0).

These files are derived from headers exported from Hyper-V, rather than
being derived from the TLFS document. (Although, to preserve
compatibility with existing Linux code, some definitions are copied
directly from hyperv-tlfs.h too).

The new files follow a naming convention according to their original
use:
- hdk "host development kit"
- gdk "guest development kit"
With postfix "_mini" implying userspace-only headers, and "_ext" for
extended hypercalls.

The use of multiple files and their original names is primarily to
keep the provenance of exactly where they came from in Hyper-V
code, which is helpful for manual maintenance and extension
of these definitions. Microsoft maintainers importing new definitions
should take care to put them in the right file. However, Linux kernel
code that uses any of the definitions need not be aware of the multiple
files or assign any meaning to the new names. Linux kernel code should
always just include hvhdk.h

Note the new headers contain both arm64 and x86_64 definitions. Some are
guarded by #ifdefs, and some are instead prefixed with the architecture,
e.g. hv_x64_*. These conventions are kept from Hyper-V code as another
tactic to simplify the process of importing and maintaining the
definitions, rather than splitting them up into their own files in
arch/x86/ and arch/arm64/.

These headers are a step toward importing headers directly from Hyper-V
in the future, similar to Xen public files in include/xen/interface/.

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

46 lines
1.2 KiB
C

/* SPDX-License-Identifier: GPL-2.0 */
/*
* Type definitions for the Microsoft Hypervisor.
*/
#ifndef _HV_HVGDK_EXT_H
#define _HV_HVGDK_EXT_H
#include "hvgdk_mini.h"
/* Extended hypercalls */
#define HV_EXT_CALL_QUERY_CAPABILITIES 0x8001
#define HV_EXT_CALL_MEMORY_HEAT_HINT 0x8003
/* Extended hypercalls */
enum { /* HV_EXT_CALL */
HV_EXTCALL_QUERY_CAPABILITIES = 0x8001,
HV_EXTCALL_MEMORY_HEAT_HINT = 0x8003,
};
/* HV_EXT_OUTPUT_QUERY_CAPABILITIES */
#define HV_EXT_CAPABILITY_MEMORY_COLD_DISCARD_HINT BIT(8)
enum { /* HV_EXT_MEMORY_HEAT_HINT_TYPE */
HV_EXTMEM_HEAT_HINT_COLD = 0,
HV_EXTMEM_HEAT_HINT_HOT = 1,
HV_EXTMEM_HEAT_HINT_COLD_DISCARD = 2,
HV_EXTMEM_HEAT_HINT_MAX
};
/*
* The whole argument should fit in a page to be able to pass to the hypervisor
* in one hypercall.
*/
#define HV_MEMORY_HINT_MAX_GPA_PAGE_RANGES \
((HV_HYP_PAGE_SIZE - sizeof(struct hv_memory_hint)) / \
sizeof(union hv_gpa_page_range))
/* HvExtCallMemoryHeatHint hypercall */
#define HV_EXT_MEMORY_HEAT_HINT_TYPE_COLD_DISCARD 2
struct hv_memory_hint { /* HV_EXT_INPUT_MEMORY_HEAT_HINT */
u64 heat_type : 2; /* HV_EXTMEM_HEAT_HINT_* */
u64 reserved : 62;
union hv_gpa_page_range ranges[];
} __packed;
#endif /* _HV_HVGDK_EXT_H */