18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ci/*
48c2ecf20Sopenharmony_ci * This file contains definitions from Hyper-V Hypervisor Top-Level Functional
58c2ecf20Sopenharmony_ci * Specification (TLFS):
68c2ecf20Sopenharmony_ci * https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/reference/tlfs
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef _ASM_X86_HYPERV_TLFS_H
108c2ecf20Sopenharmony_ci#define _ASM_X86_HYPERV_TLFS_H
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/types.h>
138c2ecf20Sopenharmony_ci#include <asm/page.h>
148c2ecf20Sopenharmony_ci/*
158c2ecf20Sopenharmony_ci * The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent
168c2ecf20Sopenharmony_ci * is set by CPUID(HvCpuIdFunctionVersionAndFeatures).
178c2ecf20Sopenharmony_ci */
188c2ecf20Sopenharmony_ci#define HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS	0x40000000
198c2ecf20Sopenharmony_ci#define HYPERV_CPUID_INTERFACE			0x40000001
208c2ecf20Sopenharmony_ci#define HYPERV_CPUID_VERSION			0x40000002
218c2ecf20Sopenharmony_ci#define HYPERV_CPUID_FEATURES			0x40000003
228c2ecf20Sopenharmony_ci#define HYPERV_CPUID_ENLIGHTMENT_INFO		0x40000004
238c2ecf20Sopenharmony_ci#define HYPERV_CPUID_IMPLEMENT_LIMITS		0x40000005
248c2ecf20Sopenharmony_ci#define HYPERV_CPUID_NESTED_FEATURES		0x4000000A
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#define HYPERV_HYPERVISOR_PRESENT_BIT		0x80000000
278c2ecf20Sopenharmony_ci#define HYPERV_CPUID_MIN			0x40000005
288c2ecf20Sopenharmony_ci#define HYPERV_CPUID_MAX			0x4000ffff
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci/*
318c2ecf20Sopenharmony_ci * Group D Features.  The bit assignments are custom to each architecture.
328c2ecf20Sopenharmony_ci * On x86/x64 these are HYPERV_CPUID_FEATURES.EDX bits.
338c2ecf20Sopenharmony_ci */
348c2ecf20Sopenharmony_ci/* The MWAIT instruction is available (per section MONITOR / MWAIT) */
358c2ecf20Sopenharmony_ci#define HV_X64_MWAIT_AVAILABLE				BIT(0)
368c2ecf20Sopenharmony_ci/* Guest debugging support is available */
378c2ecf20Sopenharmony_ci#define HV_X64_GUEST_DEBUGGING_AVAILABLE		BIT(1)
388c2ecf20Sopenharmony_ci/* Performance Monitor support is available*/
398c2ecf20Sopenharmony_ci#define HV_X64_PERF_MONITOR_AVAILABLE			BIT(2)
408c2ecf20Sopenharmony_ci/* Support for physical CPU dynamic partitioning events is available*/
418c2ecf20Sopenharmony_ci#define HV_X64_CPU_DYNAMIC_PARTITIONING_AVAILABLE	BIT(3)
428c2ecf20Sopenharmony_ci/*
438c2ecf20Sopenharmony_ci * Support for passing hypercall input parameter block via XMM
448c2ecf20Sopenharmony_ci * registers is available
458c2ecf20Sopenharmony_ci */
468c2ecf20Sopenharmony_ci#define HV_X64_HYPERCALL_PARAMS_XMM_AVAILABLE		BIT(4)
478c2ecf20Sopenharmony_ci/* Support for a virtual guest idle state is available */
488c2ecf20Sopenharmony_ci#define HV_X64_GUEST_IDLE_STATE_AVAILABLE		BIT(5)
498c2ecf20Sopenharmony_ci/* Frequency MSRs available */
508c2ecf20Sopenharmony_ci#define HV_FEATURE_FREQUENCY_MSRS_AVAILABLE		BIT(8)
518c2ecf20Sopenharmony_ci/* Crash MSR available */
528c2ecf20Sopenharmony_ci#define HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE		BIT(10)
538c2ecf20Sopenharmony_ci/* Support for debug MSRs available */
548c2ecf20Sopenharmony_ci#define HV_FEATURE_DEBUG_MSRS_AVAILABLE			BIT(11)
558c2ecf20Sopenharmony_ci/* stimer Direct Mode is available */
568c2ecf20Sopenharmony_ci#define HV_STIMER_DIRECT_MODE_AVAILABLE			BIT(19)
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci/*
598c2ecf20Sopenharmony_ci * Implementation recommendations. Indicates which behaviors the hypervisor
608c2ecf20Sopenharmony_ci * recommends the OS implement for optimal performance.
618c2ecf20Sopenharmony_ci * These are HYPERV_CPUID_ENLIGHTMENT_INFO.EAX bits.
628c2ecf20Sopenharmony_ci */
638c2ecf20Sopenharmony_ci/*
648c2ecf20Sopenharmony_ci * Recommend using hypercall for address space switches rather
658c2ecf20Sopenharmony_ci * than MOV to CR3 instruction
668c2ecf20Sopenharmony_ci */
678c2ecf20Sopenharmony_ci#define HV_X64_AS_SWITCH_RECOMMENDED			BIT(0)
688c2ecf20Sopenharmony_ci/* Recommend using hypercall for local TLB flushes rather
698c2ecf20Sopenharmony_ci * than INVLPG or MOV to CR3 instructions */
708c2ecf20Sopenharmony_ci#define HV_X64_LOCAL_TLB_FLUSH_RECOMMENDED		BIT(1)
718c2ecf20Sopenharmony_ci/*
728c2ecf20Sopenharmony_ci * Recommend using hypercall for remote TLB flushes rather
738c2ecf20Sopenharmony_ci * than inter-processor interrupts
748c2ecf20Sopenharmony_ci */
758c2ecf20Sopenharmony_ci#define HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED		BIT(2)
768c2ecf20Sopenharmony_ci/*
778c2ecf20Sopenharmony_ci * Recommend using MSRs for accessing APIC registers
788c2ecf20Sopenharmony_ci * EOI, ICR and TPR rather than their memory-mapped counterparts
798c2ecf20Sopenharmony_ci */
808c2ecf20Sopenharmony_ci#define HV_X64_APIC_ACCESS_RECOMMENDED			BIT(3)
818c2ecf20Sopenharmony_ci/* Recommend using the hypervisor-provided MSR to initiate a system RESET */
828c2ecf20Sopenharmony_ci#define HV_X64_SYSTEM_RESET_RECOMMENDED			BIT(4)
838c2ecf20Sopenharmony_ci/*
848c2ecf20Sopenharmony_ci * Recommend using relaxed timing for this partition. If used,
858c2ecf20Sopenharmony_ci * the VM should disable any watchdog timeouts that rely on the
868c2ecf20Sopenharmony_ci * timely delivery of external interrupts
878c2ecf20Sopenharmony_ci */
888c2ecf20Sopenharmony_ci#define HV_X64_RELAXED_TIMING_RECOMMENDED		BIT(5)
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci/*
918c2ecf20Sopenharmony_ci * Recommend not using Auto End-Of-Interrupt feature
928c2ecf20Sopenharmony_ci */
938c2ecf20Sopenharmony_ci#define HV_DEPRECATING_AEOI_RECOMMENDED			BIT(9)
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci/*
968c2ecf20Sopenharmony_ci * Recommend using cluster IPI hypercalls.
978c2ecf20Sopenharmony_ci */
988c2ecf20Sopenharmony_ci#define HV_X64_CLUSTER_IPI_RECOMMENDED			BIT(10)
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci/* Recommend using the newer ExProcessorMasks interface */
1018c2ecf20Sopenharmony_ci#define HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED		BIT(11)
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci/* Recommend using enlightened VMCS */
1048c2ecf20Sopenharmony_ci#define HV_X64_ENLIGHTENED_VMCS_RECOMMENDED		BIT(14)
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci/*
1078c2ecf20Sopenharmony_ci * Virtual processor will never share a physical core with another virtual
1088c2ecf20Sopenharmony_ci * processor, except for virtual processors that are reported as sibling SMT
1098c2ecf20Sopenharmony_ci * threads.
1108c2ecf20Sopenharmony_ci */
1118c2ecf20Sopenharmony_ci#define HV_X64_NO_NONARCH_CORESHARING			BIT(18)
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci/* Nested features. These are HYPERV_CPUID_NESTED_FEATURES.EAX bits. */
1148c2ecf20Sopenharmony_ci#define HV_X64_NESTED_DIRECT_FLUSH			BIT(17)
1158c2ecf20Sopenharmony_ci#define HV_X64_NESTED_GUEST_MAPPING_FLUSH		BIT(18)
1168c2ecf20Sopenharmony_ci#define HV_X64_NESTED_MSR_BITMAP			BIT(19)
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci/* Hyper-V specific model specific registers (MSRs) */
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci/* MSR used to identify the guest OS. */
1218c2ecf20Sopenharmony_ci#define HV_X64_MSR_GUEST_OS_ID			0x40000000
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci/* MSR used to setup pages used to communicate with the hypervisor. */
1248c2ecf20Sopenharmony_ci#define HV_X64_MSR_HYPERCALL			0x40000001
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci/* MSR used to provide vcpu index */
1278c2ecf20Sopenharmony_ci#define HV_X64_MSR_VP_INDEX			0x40000002
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci/* MSR used to reset the guest OS. */
1308c2ecf20Sopenharmony_ci#define HV_X64_MSR_RESET			0x40000003
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci/* MSR used to provide vcpu runtime in 100ns units */
1338c2ecf20Sopenharmony_ci#define HV_X64_MSR_VP_RUNTIME			0x40000010
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci/* MSR used to read the per-partition time reference counter */
1368c2ecf20Sopenharmony_ci#define HV_X64_MSR_TIME_REF_COUNT		0x40000020
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci/* A partition's reference time stamp counter (TSC) page */
1398c2ecf20Sopenharmony_ci#define HV_X64_MSR_REFERENCE_TSC		0x40000021
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci/* MSR used to retrieve the TSC frequency */
1428c2ecf20Sopenharmony_ci#define HV_X64_MSR_TSC_FREQUENCY		0x40000022
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci/* MSR used to retrieve the local APIC timer frequency */
1458c2ecf20Sopenharmony_ci#define HV_X64_MSR_APIC_FREQUENCY		0x40000023
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci/* Define the virtual APIC registers */
1488c2ecf20Sopenharmony_ci#define HV_X64_MSR_EOI				0x40000070
1498c2ecf20Sopenharmony_ci#define HV_X64_MSR_ICR				0x40000071
1508c2ecf20Sopenharmony_ci#define HV_X64_MSR_TPR				0x40000072
1518c2ecf20Sopenharmony_ci#define HV_X64_MSR_VP_ASSIST_PAGE		0x40000073
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci/* Define synthetic interrupt controller model specific registers. */
1548c2ecf20Sopenharmony_ci#define HV_X64_MSR_SCONTROL			0x40000080
1558c2ecf20Sopenharmony_ci#define HV_X64_MSR_SVERSION			0x40000081
1568c2ecf20Sopenharmony_ci#define HV_X64_MSR_SIEFP			0x40000082
1578c2ecf20Sopenharmony_ci#define HV_X64_MSR_SIMP				0x40000083
1588c2ecf20Sopenharmony_ci#define HV_X64_MSR_EOM				0x40000084
1598c2ecf20Sopenharmony_ci#define HV_X64_MSR_SINT0			0x40000090
1608c2ecf20Sopenharmony_ci#define HV_X64_MSR_SINT1			0x40000091
1618c2ecf20Sopenharmony_ci#define HV_X64_MSR_SINT2			0x40000092
1628c2ecf20Sopenharmony_ci#define HV_X64_MSR_SINT3			0x40000093
1638c2ecf20Sopenharmony_ci#define HV_X64_MSR_SINT4			0x40000094
1648c2ecf20Sopenharmony_ci#define HV_X64_MSR_SINT5			0x40000095
1658c2ecf20Sopenharmony_ci#define HV_X64_MSR_SINT6			0x40000096
1668c2ecf20Sopenharmony_ci#define HV_X64_MSR_SINT7			0x40000097
1678c2ecf20Sopenharmony_ci#define HV_X64_MSR_SINT8			0x40000098
1688c2ecf20Sopenharmony_ci#define HV_X64_MSR_SINT9			0x40000099
1698c2ecf20Sopenharmony_ci#define HV_X64_MSR_SINT10			0x4000009A
1708c2ecf20Sopenharmony_ci#define HV_X64_MSR_SINT11			0x4000009B
1718c2ecf20Sopenharmony_ci#define HV_X64_MSR_SINT12			0x4000009C
1728c2ecf20Sopenharmony_ci#define HV_X64_MSR_SINT13			0x4000009D
1738c2ecf20Sopenharmony_ci#define HV_X64_MSR_SINT14			0x4000009E
1748c2ecf20Sopenharmony_ci#define HV_X64_MSR_SINT15			0x4000009F
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci/*
1778c2ecf20Sopenharmony_ci * Synthetic Timer MSRs. Four timers per vcpu.
1788c2ecf20Sopenharmony_ci */
1798c2ecf20Sopenharmony_ci#define HV_X64_MSR_STIMER0_CONFIG		0x400000B0
1808c2ecf20Sopenharmony_ci#define HV_X64_MSR_STIMER0_COUNT		0x400000B1
1818c2ecf20Sopenharmony_ci#define HV_X64_MSR_STIMER1_CONFIG		0x400000B2
1828c2ecf20Sopenharmony_ci#define HV_X64_MSR_STIMER1_COUNT		0x400000B3
1838c2ecf20Sopenharmony_ci#define HV_X64_MSR_STIMER2_CONFIG		0x400000B4
1848c2ecf20Sopenharmony_ci#define HV_X64_MSR_STIMER2_COUNT		0x400000B5
1858c2ecf20Sopenharmony_ci#define HV_X64_MSR_STIMER3_CONFIG		0x400000B6
1868c2ecf20Sopenharmony_ci#define HV_X64_MSR_STIMER3_COUNT		0x400000B7
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ci/* Hyper-V guest idle MSR */
1898c2ecf20Sopenharmony_ci#define HV_X64_MSR_GUEST_IDLE			0x400000F0
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_ci/* Hyper-V guest crash notification MSR's */
1928c2ecf20Sopenharmony_ci#define HV_X64_MSR_CRASH_P0			0x40000100
1938c2ecf20Sopenharmony_ci#define HV_X64_MSR_CRASH_P1			0x40000101
1948c2ecf20Sopenharmony_ci#define HV_X64_MSR_CRASH_P2			0x40000102
1958c2ecf20Sopenharmony_ci#define HV_X64_MSR_CRASH_P3			0x40000103
1968c2ecf20Sopenharmony_ci#define HV_X64_MSR_CRASH_P4			0x40000104
1978c2ecf20Sopenharmony_ci#define HV_X64_MSR_CRASH_CTL			0x40000105
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci/* TSC emulation after migration */
2008c2ecf20Sopenharmony_ci#define HV_X64_MSR_REENLIGHTENMENT_CONTROL	0x40000106
2018c2ecf20Sopenharmony_ci#define HV_X64_MSR_TSC_EMULATION_CONTROL	0x40000107
2028c2ecf20Sopenharmony_ci#define HV_X64_MSR_TSC_EMULATION_STATUS		0x40000108
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci/* TSC invariant control */
2058c2ecf20Sopenharmony_ci#define HV_X64_MSR_TSC_INVARIANT_CONTROL	0x40000118
2068c2ecf20Sopenharmony_ci
2078c2ecf20Sopenharmony_ci/*
2088c2ecf20Sopenharmony_ci * Declare the MSR used to setup pages used to communicate with the hypervisor.
2098c2ecf20Sopenharmony_ci */
2108c2ecf20Sopenharmony_ciunion hv_x64_msr_hypercall_contents {
2118c2ecf20Sopenharmony_ci	u64 as_uint64;
2128c2ecf20Sopenharmony_ci	struct {
2138c2ecf20Sopenharmony_ci		u64 enable:1;
2148c2ecf20Sopenharmony_ci		u64 reserved:11;
2158c2ecf20Sopenharmony_ci		u64 guest_physical_address:52;
2168c2ecf20Sopenharmony_ci	} __packed;
2178c2ecf20Sopenharmony_ci};
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_cistruct hv_reenlightenment_control {
2208c2ecf20Sopenharmony_ci	__u64 vector:8;
2218c2ecf20Sopenharmony_ci	__u64 reserved1:8;
2228c2ecf20Sopenharmony_ci	__u64 enabled:1;
2238c2ecf20Sopenharmony_ci	__u64 reserved2:15;
2248c2ecf20Sopenharmony_ci	__u64 target_vp:32;
2258c2ecf20Sopenharmony_ci}  __packed;
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_cistruct hv_tsc_emulation_control {
2288c2ecf20Sopenharmony_ci	__u64 enabled:1;
2298c2ecf20Sopenharmony_ci	__u64 reserved:63;
2308c2ecf20Sopenharmony_ci} __packed;
2318c2ecf20Sopenharmony_ci
2328c2ecf20Sopenharmony_cistruct hv_tsc_emulation_status {
2338c2ecf20Sopenharmony_ci	__u64 inprogress:1;
2348c2ecf20Sopenharmony_ci	__u64 reserved:63;
2358c2ecf20Sopenharmony_ci} __packed;
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ci#define HV_X64_MSR_HYPERCALL_ENABLE		0x00000001
2388c2ecf20Sopenharmony_ci#define HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT	12
2398c2ecf20Sopenharmony_ci#define HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_MASK	\
2408c2ecf20Sopenharmony_ci		(~((1ull << HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT) - 1))
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_ci#define HV_X64_MSR_CRASH_PARAMS		\
2438c2ecf20Sopenharmony_ci		(1 + (HV_X64_MSR_CRASH_P4 - HV_X64_MSR_CRASH_P0))
2448c2ecf20Sopenharmony_ci
2458c2ecf20Sopenharmony_ci#define HV_IPI_LOW_VECTOR	0x10
2468c2ecf20Sopenharmony_ci#define HV_IPI_HIGH_VECTOR	0xff
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_ci#define HV_X64_MSR_VP_ASSIST_PAGE_ENABLE	0x00000001
2498c2ecf20Sopenharmony_ci#define HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_SHIFT	12
2508c2ecf20Sopenharmony_ci#define HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_MASK	\
2518c2ecf20Sopenharmony_ci		(~((1ull << HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_SHIFT) - 1))
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ci/* Hyper-V Enlightened VMCS version mask in nested features CPUID */
2548c2ecf20Sopenharmony_ci#define HV_X64_ENLIGHTENED_VMCS_VERSION		0xff
2558c2ecf20Sopenharmony_ci
2568c2ecf20Sopenharmony_ci#define HV_X64_MSR_TSC_REFERENCE_ENABLE		0x00000001
2578c2ecf20Sopenharmony_ci#define HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT	12
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_ci/* Define hypervisor message types. */
2618c2ecf20Sopenharmony_cienum hv_message_type {
2628c2ecf20Sopenharmony_ci	HVMSG_NONE			= 0x00000000,
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_ci	/* Memory access messages. */
2658c2ecf20Sopenharmony_ci	HVMSG_UNMAPPED_GPA		= 0x80000000,
2668c2ecf20Sopenharmony_ci	HVMSG_GPA_INTERCEPT		= 0x80000001,
2678c2ecf20Sopenharmony_ci
2688c2ecf20Sopenharmony_ci	/* Timer notification messages. */
2698c2ecf20Sopenharmony_ci	HVMSG_TIMER_EXPIRED		= 0x80000010,
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_ci	/* Error messages. */
2728c2ecf20Sopenharmony_ci	HVMSG_INVALID_VP_REGISTER_VALUE	= 0x80000020,
2738c2ecf20Sopenharmony_ci	HVMSG_UNRECOVERABLE_EXCEPTION	= 0x80000021,
2748c2ecf20Sopenharmony_ci	HVMSG_UNSUPPORTED_FEATURE	= 0x80000022,
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci	/* Trace buffer complete messages. */
2778c2ecf20Sopenharmony_ci	HVMSG_EVENTLOG_BUFFERCOMPLETE	= 0x80000040,
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_ci	/* Platform-specific processor intercept messages. */
2808c2ecf20Sopenharmony_ci	HVMSG_X64_IOPORT_INTERCEPT	= 0x80010000,
2818c2ecf20Sopenharmony_ci	HVMSG_X64_MSR_INTERCEPT		= 0x80010001,
2828c2ecf20Sopenharmony_ci	HVMSG_X64_CPUID_INTERCEPT	= 0x80010002,
2838c2ecf20Sopenharmony_ci	HVMSG_X64_EXCEPTION_INTERCEPT	= 0x80010003,
2848c2ecf20Sopenharmony_ci	HVMSG_X64_APIC_EOI		= 0x80010004,
2858c2ecf20Sopenharmony_ci	HVMSG_X64_LEGACY_FP_ERROR	= 0x80010005
2868c2ecf20Sopenharmony_ci};
2878c2ecf20Sopenharmony_ci
2888c2ecf20Sopenharmony_cistruct hv_nested_enlightenments_control {
2898c2ecf20Sopenharmony_ci	struct {
2908c2ecf20Sopenharmony_ci		__u32 directhypercall:1;
2918c2ecf20Sopenharmony_ci		__u32 reserved:31;
2928c2ecf20Sopenharmony_ci	} features;
2938c2ecf20Sopenharmony_ci	struct {
2948c2ecf20Sopenharmony_ci		__u32 reserved;
2958c2ecf20Sopenharmony_ci	} hypercallControls;
2968c2ecf20Sopenharmony_ci} __packed;
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_ci/* Define virtual processor assist page structure. */
2998c2ecf20Sopenharmony_cistruct hv_vp_assist_page {
3008c2ecf20Sopenharmony_ci	__u32 apic_assist;
3018c2ecf20Sopenharmony_ci	__u32 reserved1;
3028c2ecf20Sopenharmony_ci	__u64 vtl_control[3];
3038c2ecf20Sopenharmony_ci	struct hv_nested_enlightenments_control nested_control;
3048c2ecf20Sopenharmony_ci	__u8 enlighten_vmentry;
3058c2ecf20Sopenharmony_ci	__u8 reserved2[7];
3068c2ecf20Sopenharmony_ci	__u64 current_nested_vmcs;
3078c2ecf20Sopenharmony_ci} __packed;
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_cistruct hv_enlightened_vmcs {
3108c2ecf20Sopenharmony_ci	u32 revision_id;
3118c2ecf20Sopenharmony_ci	u32 abort;
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci	u16 host_es_selector;
3148c2ecf20Sopenharmony_ci	u16 host_cs_selector;
3158c2ecf20Sopenharmony_ci	u16 host_ss_selector;
3168c2ecf20Sopenharmony_ci	u16 host_ds_selector;
3178c2ecf20Sopenharmony_ci	u16 host_fs_selector;
3188c2ecf20Sopenharmony_ci	u16 host_gs_selector;
3198c2ecf20Sopenharmony_ci	u16 host_tr_selector;
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_ci	u16 padding16_1;
3228c2ecf20Sopenharmony_ci
3238c2ecf20Sopenharmony_ci	u64 host_ia32_pat;
3248c2ecf20Sopenharmony_ci	u64 host_ia32_efer;
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_ci	u64 host_cr0;
3278c2ecf20Sopenharmony_ci	u64 host_cr3;
3288c2ecf20Sopenharmony_ci	u64 host_cr4;
3298c2ecf20Sopenharmony_ci
3308c2ecf20Sopenharmony_ci	u64 host_ia32_sysenter_esp;
3318c2ecf20Sopenharmony_ci	u64 host_ia32_sysenter_eip;
3328c2ecf20Sopenharmony_ci	u64 host_rip;
3338c2ecf20Sopenharmony_ci	u32 host_ia32_sysenter_cs;
3348c2ecf20Sopenharmony_ci
3358c2ecf20Sopenharmony_ci	u32 pin_based_vm_exec_control;
3368c2ecf20Sopenharmony_ci	u32 vm_exit_controls;
3378c2ecf20Sopenharmony_ci	u32 secondary_vm_exec_control;
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ci	u64 io_bitmap_a;
3408c2ecf20Sopenharmony_ci	u64 io_bitmap_b;
3418c2ecf20Sopenharmony_ci	u64 msr_bitmap;
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_ci	u16 guest_es_selector;
3448c2ecf20Sopenharmony_ci	u16 guest_cs_selector;
3458c2ecf20Sopenharmony_ci	u16 guest_ss_selector;
3468c2ecf20Sopenharmony_ci	u16 guest_ds_selector;
3478c2ecf20Sopenharmony_ci	u16 guest_fs_selector;
3488c2ecf20Sopenharmony_ci	u16 guest_gs_selector;
3498c2ecf20Sopenharmony_ci	u16 guest_ldtr_selector;
3508c2ecf20Sopenharmony_ci	u16 guest_tr_selector;
3518c2ecf20Sopenharmony_ci
3528c2ecf20Sopenharmony_ci	u32 guest_es_limit;
3538c2ecf20Sopenharmony_ci	u32 guest_cs_limit;
3548c2ecf20Sopenharmony_ci	u32 guest_ss_limit;
3558c2ecf20Sopenharmony_ci	u32 guest_ds_limit;
3568c2ecf20Sopenharmony_ci	u32 guest_fs_limit;
3578c2ecf20Sopenharmony_ci	u32 guest_gs_limit;
3588c2ecf20Sopenharmony_ci	u32 guest_ldtr_limit;
3598c2ecf20Sopenharmony_ci	u32 guest_tr_limit;
3608c2ecf20Sopenharmony_ci	u32 guest_gdtr_limit;
3618c2ecf20Sopenharmony_ci	u32 guest_idtr_limit;
3628c2ecf20Sopenharmony_ci
3638c2ecf20Sopenharmony_ci	u32 guest_es_ar_bytes;
3648c2ecf20Sopenharmony_ci	u32 guest_cs_ar_bytes;
3658c2ecf20Sopenharmony_ci	u32 guest_ss_ar_bytes;
3668c2ecf20Sopenharmony_ci	u32 guest_ds_ar_bytes;
3678c2ecf20Sopenharmony_ci	u32 guest_fs_ar_bytes;
3688c2ecf20Sopenharmony_ci	u32 guest_gs_ar_bytes;
3698c2ecf20Sopenharmony_ci	u32 guest_ldtr_ar_bytes;
3708c2ecf20Sopenharmony_ci	u32 guest_tr_ar_bytes;
3718c2ecf20Sopenharmony_ci
3728c2ecf20Sopenharmony_ci	u64 guest_es_base;
3738c2ecf20Sopenharmony_ci	u64 guest_cs_base;
3748c2ecf20Sopenharmony_ci	u64 guest_ss_base;
3758c2ecf20Sopenharmony_ci	u64 guest_ds_base;
3768c2ecf20Sopenharmony_ci	u64 guest_fs_base;
3778c2ecf20Sopenharmony_ci	u64 guest_gs_base;
3788c2ecf20Sopenharmony_ci	u64 guest_ldtr_base;
3798c2ecf20Sopenharmony_ci	u64 guest_tr_base;
3808c2ecf20Sopenharmony_ci	u64 guest_gdtr_base;
3818c2ecf20Sopenharmony_ci	u64 guest_idtr_base;
3828c2ecf20Sopenharmony_ci
3838c2ecf20Sopenharmony_ci	u64 padding64_1[3];
3848c2ecf20Sopenharmony_ci
3858c2ecf20Sopenharmony_ci	u64 vm_exit_msr_store_addr;
3868c2ecf20Sopenharmony_ci	u64 vm_exit_msr_load_addr;
3878c2ecf20Sopenharmony_ci	u64 vm_entry_msr_load_addr;
3888c2ecf20Sopenharmony_ci
3898c2ecf20Sopenharmony_ci	u64 cr3_target_value0;
3908c2ecf20Sopenharmony_ci	u64 cr3_target_value1;
3918c2ecf20Sopenharmony_ci	u64 cr3_target_value2;
3928c2ecf20Sopenharmony_ci	u64 cr3_target_value3;
3938c2ecf20Sopenharmony_ci
3948c2ecf20Sopenharmony_ci	u32 page_fault_error_code_mask;
3958c2ecf20Sopenharmony_ci	u32 page_fault_error_code_match;
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_ci	u32 cr3_target_count;
3988c2ecf20Sopenharmony_ci	u32 vm_exit_msr_store_count;
3998c2ecf20Sopenharmony_ci	u32 vm_exit_msr_load_count;
4008c2ecf20Sopenharmony_ci	u32 vm_entry_msr_load_count;
4018c2ecf20Sopenharmony_ci
4028c2ecf20Sopenharmony_ci	u64 tsc_offset;
4038c2ecf20Sopenharmony_ci	u64 virtual_apic_page_addr;
4048c2ecf20Sopenharmony_ci	u64 vmcs_link_pointer;
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_ci	u64 guest_ia32_debugctl;
4078c2ecf20Sopenharmony_ci	u64 guest_ia32_pat;
4088c2ecf20Sopenharmony_ci	u64 guest_ia32_efer;
4098c2ecf20Sopenharmony_ci
4108c2ecf20Sopenharmony_ci	u64 guest_pdptr0;
4118c2ecf20Sopenharmony_ci	u64 guest_pdptr1;
4128c2ecf20Sopenharmony_ci	u64 guest_pdptr2;
4138c2ecf20Sopenharmony_ci	u64 guest_pdptr3;
4148c2ecf20Sopenharmony_ci
4158c2ecf20Sopenharmony_ci	u64 guest_pending_dbg_exceptions;
4168c2ecf20Sopenharmony_ci	u64 guest_sysenter_esp;
4178c2ecf20Sopenharmony_ci	u64 guest_sysenter_eip;
4188c2ecf20Sopenharmony_ci
4198c2ecf20Sopenharmony_ci	u32 guest_activity_state;
4208c2ecf20Sopenharmony_ci	u32 guest_sysenter_cs;
4218c2ecf20Sopenharmony_ci
4228c2ecf20Sopenharmony_ci	u64 cr0_guest_host_mask;
4238c2ecf20Sopenharmony_ci	u64 cr4_guest_host_mask;
4248c2ecf20Sopenharmony_ci	u64 cr0_read_shadow;
4258c2ecf20Sopenharmony_ci	u64 cr4_read_shadow;
4268c2ecf20Sopenharmony_ci	u64 guest_cr0;
4278c2ecf20Sopenharmony_ci	u64 guest_cr3;
4288c2ecf20Sopenharmony_ci	u64 guest_cr4;
4298c2ecf20Sopenharmony_ci	u64 guest_dr7;
4308c2ecf20Sopenharmony_ci
4318c2ecf20Sopenharmony_ci	u64 host_fs_base;
4328c2ecf20Sopenharmony_ci	u64 host_gs_base;
4338c2ecf20Sopenharmony_ci	u64 host_tr_base;
4348c2ecf20Sopenharmony_ci	u64 host_gdtr_base;
4358c2ecf20Sopenharmony_ci	u64 host_idtr_base;
4368c2ecf20Sopenharmony_ci	u64 host_rsp;
4378c2ecf20Sopenharmony_ci
4388c2ecf20Sopenharmony_ci	u64 ept_pointer;
4398c2ecf20Sopenharmony_ci
4408c2ecf20Sopenharmony_ci	u16 virtual_processor_id;
4418c2ecf20Sopenharmony_ci	u16 padding16_2[3];
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_ci	u64 padding64_2[5];
4448c2ecf20Sopenharmony_ci	u64 guest_physical_address;
4458c2ecf20Sopenharmony_ci
4468c2ecf20Sopenharmony_ci	u32 vm_instruction_error;
4478c2ecf20Sopenharmony_ci	u32 vm_exit_reason;
4488c2ecf20Sopenharmony_ci	u32 vm_exit_intr_info;
4498c2ecf20Sopenharmony_ci	u32 vm_exit_intr_error_code;
4508c2ecf20Sopenharmony_ci	u32 idt_vectoring_info_field;
4518c2ecf20Sopenharmony_ci	u32 idt_vectoring_error_code;
4528c2ecf20Sopenharmony_ci	u32 vm_exit_instruction_len;
4538c2ecf20Sopenharmony_ci	u32 vmx_instruction_info;
4548c2ecf20Sopenharmony_ci
4558c2ecf20Sopenharmony_ci	u64 exit_qualification;
4568c2ecf20Sopenharmony_ci	u64 exit_io_instruction_ecx;
4578c2ecf20Sopenharmony_ci	u64 exit_io_instruction_esi;
4588c2ecf20Sopenharmony_ci	u64 exit_io_instruction_edi;
4598c2ecf20Sopenharmony_ci	u64 exit_io_instruction_eip;
4608c2ecf20Sopenharmony_ci
4618c2ecf20Sopenharmony_ci	u64 guest_linear_address;
4628c2ecf20Sopenharmony_ci	u64 guest_rsp;
4638c2ecf20Sopenharmony_ci	u64 guest_rflags;
4648c2ecf20Sopenharmony_ci
4658c2ecf20Sopenharmony_ci	u32 guest_interruptibility_info;
4668c2ecf20Sopenharmony_ci	u32 cpu_based_vm_exec_control;
4678c2ecf20Sopenharmony_ci	u32 exception_bitmap;
4688c2ecf20Sopenharmony_ci	u32 vm_entry_controls;
4698c2ecf20Sopenharmony_ci	u32 vm_entry_intr_info_field;
4708c2ecf20Sopenharmony_ci	u32 vm_entry_exception_error_code;
4718c2ecf20Sopenharmony_ci	u32 vm_entry_instruction_len;
4728c2ecf20Sopenharmony_ci	u32 tpr_threshold;
4738c2ecf20Sopenharmony_ci
4748c2ecf20Sopenharmony_ci	u64 guest_rip;
4758c2ecf20Sopenharmony_ci
4768c2ecf20Sopenharmony_ci	u32 hv_clean_fields;
4778c2ecf20Sopenharmony_ci	u32 padding32_1;
4788c2ecf20Sopenharmony_ci	u32 hv_synthetic_controls;
4798c2ecf20Sopenharmony_ci	struct {
4808c2ecf20Sopenharmony_ci		u32 nested_flush_hypercall:1;
4818c2ecf20Sopenharmony_ci		u32 msr_bitmap:1;
4828c2ecf20Sopenharmony_ci		u32 reserved:30;
4838c2ecf20Sopenharmony_ci	}  __packed hv_enlightenments_control;
4848c2ecf20Sopenharmony_ci	u32 hv_vp_id;
4858c2ecf20Sopenharmony_ci	u32 padding32_2;
4868c2ecf20Sopenharmony_ci	u64 hv_vm_id;
4878c2ecf20Sopenharmony_ci	u64 partition_assist_page;
4888c2ecf20Sopenharmony_ci	u64 padding64_4[4];
4898c2ecf20Sopenharmony_ci	u64 guest_bndcfgs;
4908c2ecf20Sopenharmony_ci	u64 padding64_5[7];
4918c2ecf20Sopenharmony_ci	u64 xss_exit_bitmap;
4928c2ecf20Sopenharmony_ci	u64 padding64_6[7];
4938c2ecf20Sopenharmony_ci} __packed;
4948c2ecf20Sopenharmony_ci
4958c2ecf20Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_NONE			0
4968c2ecf20Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_IO_BITMAP		BIT(0)
4978c2ecf20Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_MSR_BITMAP		BIT(1)
4988c2ecf20Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP2		BIT(2)
4998c2ecf20Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP1		BIT(3)
5008c2ecf20Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_PROC		BIT(4)
5018c2ecf20Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_EVENT		BIT(5)
5028c2ecf20Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_ENTRY		BIT(6)
5038c2ecf20Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_EXCPN		BIT(7)
5048c2ecf20Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CRDR			BIT(8)
5058c2ecf20Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_XLAT		BIT(9)
5068c2ecf20Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_BASIC		BIT(10)
5078c2ecf20Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1		BIT(11)
5088c2ecf20Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2		BIT(12)
5098c2ecf20Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_POINTER		BIT(13)
5108c2ecf20Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1		BIT(14)
5118c2ecf20Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_ENLIGHTENMENTSCONTROL	BIT(15)
5128c2ecf20Sopenharmony_ci
5138c2ecf20Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL			0xFFFF
5148c2ecf20Sopenharmony_ci
5158c2ecf20Sopenharmony_cistruct hv_partition_assist_pg {
5168c2ecf20Sopenharmony_ci	u32 tlb_lock_count;
5178c2ecf20Sopenharmony_ci};
5188c2ecf20Sopenharmony_ci
5198c2ecf20Sopenharmony_ci
5208c2ecf20Sopenharmony_ci#include <asm-generic/hyperv-tlfs.h>
5218c2ecf20Sopenharmony_ci
5228c2ecf20Sopenharmony_ci#endif
523