162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci 362306a36Sopenharmony_ci/* 462306a36Sopenharmony_ci * This file contains definitions from Hyper-V Hypervisor Top-Level Functional 562306a36Sopenharmony_ci * Specification (TLFS): 662306a36Sopenharmony_ci * https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/reference/tlfs 762306a36Sopenharmony_ci */ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#ifndef _ASM_X86_HYPERV_TLFS_H 1062306a36Sopenharmony_ci#define _ASM_X86_HYPERV_TLFS_H 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#include <linux/types.h> 1362306a36Sopenharmony_ci#include <asm/page.h> 1462306a36Sopenharmony_ci/* 1562306a36Sopenharmony_ci * The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent 1662306a36Sopenharmony_ci * is set by CPUID(HvCpuIdFunctionVersionAndFeatures). 1762306a36Sopenharmony_ci */ 1862306a36Sopenharmony_ci#define HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS 0x40000000 1962306a36Sopenharmony_ci#define HYPERV_CPUID_INTERFACE 0x40000001 2062306a36Sopenharmony_ci#define HYPERV_CPUID_VERSION 0x40000002 2162306a36Sopenharmony_ci#define HYPERV_CPUID_FEATURES 0x40000003 2262306a36Sopenharmony_ci#define HYPERV_CPUID_ENLIGHTMENT_INFO 0x40000004 2362306a36Sopenharmony_ci#define HYPERV_CPUID_IMPLEMENT_LIMITS 0x40000005 2462306a36Sopenharmony_ci#define HYPERV_CPUID_CPU_MANAGEMENT_FEATURES 0x40000007 2562306a36Sopenharmony_ci#define HYPERV_CPUID_NESTED_FEATURES 0x4000000A 2662306a36Sopenharmony_ci#define HYPERV_CPUID_ISOLATION_CONFIG 0x4000000C 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci#define HYPERV_CPUID_VIRT_STACK_INTERFACE 0x40000081 2962306a36Sopenharmony_ci#define HYPERV_VS_INTERFACE_EAX_SIGNATURE 0x31235356 /* "VS#1" */ 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci#define HYPERV_CPUID_VIRT_STACK_PROPERTIES 0x40000082 3262306a36Sopenharmony_ci/* Support for the extended IOAPIC RTE format */ 3362306a36Sopenharmony_ci#define HYPERV_VS_PROPERTIES_EAX_EXTENDED_IOAPIC_RTE BIT(2) 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci#define HYPERV_HYPERVISOR_PRESENT_BIT 0x80000000 3662306a36Sopenharmony_ci#define HYPERV_CPUID_MIN 0x40000005 3762306a36Sopenharmony_ci#define HYPERV_CPUID_MAX 0x4000ffff 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci/* 4062306a36Sopenharmony_ci * Group D Features. The bit assignments are custom to each architecture. 4162306a36Sopenharmony_ci * On x86/x64 these are HYPERV_CPUID_FEATURES.EDX bits. 4262306a36Sopenharmony_ci */ 4362306a36Sopenharmony_ci/* The MWAIT instruction is available (per section MONITOR / MWAIT) */ 4462306a36Sopenharmony_ci#define HV_X64_MWAIT_AVAILABLE BIT(0) 4562306a36Sopenharmony_ci/* Guest debugging support is available */ 4662306a36Sopenharmony_ci#define HV_X64_GUEST_DEBUGGING_AVAILABLE BIT(1) 4762306a36Sopenharmony_ci/* Performance Monitor support is available*/ 4862306a36Sopenharmony_ci#define HV_X64_PERF_MONITOR_AVAILABLE BIT(2) 4962306a36Sopenharmony_ci/* Support for physical CPU dynamic partitioning events is available*/ 5062306a36Sopenharmony_ci#define HV_X64_CPU_DYNAMIC_PARTITIONING_AVAILABLE BIT(3) 5162306a36Sopenharmony_ci/* 5262306a36Sopenharmony_ci * Support for passing hypercall input parameter block via XMM 5362306a36Sopenharmony_ci * registers is available 5462306a36Sopenharmony_ci */ 5562306a36Sopenharmony_ci#define HV_X64_HYPERCALL_XMM_INPUT_AVAILABLE BIT(4) 5662306a36Sopenharmony_ci/* Support for a virtual guest idle state is available */ 5762306a36Sopenharmony_ci#define HV_X64_GUEST_IDLE_STATE_AVAILABLE BIT(5) 5862306a36Sopenharmony_ci/* Frequency MSRs available */ 5962306a36Sopenharmony_ci#define HV_FEATURE_FREQUENCY_MSRS_AVAILABLE BIT(8) 6062306a36Sopenharmony_ci/* Crash MSR available */ 6162306a36Sopenharmony_ci#define HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE BIT(10) 6262306a36Sopenharmony_ci/* Support for debug MSRs available */ 6362306a36Sopenharmony_ci#define HV_FEATURE_DEBUG_MSRS_AVAILABLE BIT(11) 6462306a36Sopenharmony_ci/* Support for extended gva ranges for flush hypercalls available */ 6562306a36Sopenharmony_ci#define HV_FEATURE_EXT_GVA_RANGES_FLUSH BIT(14) 6662306a36Sopenharmony_ci/* 6762306a36Sopenharmony_ci * Support for returning hypercall output block via XMM 6862306a36Sopenharmony_ci * registers is available 6962306a36Sopenharmony_ci */ 7062306a36Sopenharmony_ci#define HV_X64_HYPERCALL_XMM_OUTPUT_AVAILABLE BIT(15) 7162306a36Sopenharmony_ci/* stimer Direct Mode is available */ 7262306a36Sopenharmony_ci#define HV_STIMER_DIRECT_MODE_AVAILABLE BIT(19) 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci/* 7562306a36Sopenharmony_ci * Implementation recommendations. Indicates which behaviors the hypervisor 7662306a36Sopenharmony_ci * recommends the OS implement for optimal performance. 7762306a36Sopenharmony_ci * These are HYPERV_CPUID_ENLIGHTMENT_INFO.EAX bits. 7862306a36Sopenharmony_ci */ 7962306a36Sopenharmony_ci/* 8062306a36Sopenharmony_ci * Recommend using hypercall for address space switches rather 8162306a36Sopenharmony_ci * than MOV to CR3 instruction 8262306a36Sopenharmony_ci */ 8362306a36Sopenharmony_ci#define HV_X64_AS_SWITCH_RECOMMENDED BIT(0) 8462306a36Sopenharmony_ci/* Recommend using hypercall for local TLB flushes rather 8562306a36Sopenharmony_ci * than INVLPG or MOV to CR3 instructions */ 8662306a36Sopenharmony_ci#define HV_X64_LOCAL_TLB_FLUSH_RECOMMENDED BIT(1) 8762306a36Sopenharmony_ci/* 8862306a36Sopenharmony_ci * Recommend using hypercall for remote TLB flushes rather 8962306a36Sopenharmony_ci * than inter-processor interrupts 9062306a36Sopenharmony_ci */ 9162306a36Sopenharmony_ci#define HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED BIT(2) 9262306a36Sopenharmony_ci/* 9362306a36Sopenharmony_ci * Recommend using MSRs for accessing APIC registers 9462306a36Sopenharmony_ci * EOI, ICR and TPR rather than their memory-mapped counterparts 9562306a36Sopenharmony_ci */ 9662306a36Sopenharmony_ci#define HV_X64_APIC_ACCESS_RECOMMENDED BIT(3) 9762306a36Sopenharmony_ci/* Recommend using the hypervisor-provided MSR to initiate a system RESET */ 9862306a36Sopenharmony_ci#define HV_X64_SYSTEM_RESET_RECOMMENDED BIT(4) 9962306a36Sopenharmony_ci/* 10062306a36Sopenharmony_ci * Recommend using relaxed timing for this partition. If used, 10162306a36Sopenharmony_ci * the VM should disable any watchdog timeouts that rely on the 10262306a36Sopenharmony_ci * timely delivery of external interrupts 10362306a36Sopenharmony_ci */ 10462306a36Sopenharmony_ci#define HV_X64_RELAXED_TIMING_RECOMMENDED BIT(5) 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ci/* 10762306a36Sopenharmony_ci * Recommend not using Auto End-Of-Interrupt feature 10862306a36Sopenharmony_ci */ 10962306a36Sopenharmony_ci#define HV_DEPRECATING_AEOI_RECOMMENDED BIT(9) 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_ci/* 11262306a36Sopenharmony_ci * Recommend using cluster IPI hypercalls. 11362306a36Sopenharmony_ci */ 11462306a36Sopenharmony_ci#define HV_X64_CLUSTER_IPI_RECOMMENDED BIT(10) 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci/* Recommend using the newer ExProcessorMasks interface */ 11762306a36Sopenharmony_ci#define HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED BIT(11) 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ci/* Indicates that the hypervisor is nested within a Hyper-V partition. */ 12062306a36Sopenharmony_ci#define HV_X64_HYPERV_NESTED BIT(12) 12162306a36Sopenharmony_ci 12262306a36Sopenharmony_ci/* Recommend using enlightened VMCS */ 12362306a36Sopenharmony_ci#define HV_X64_ENLIGHTENED_VMCS_RECOMMENDED BIT(14) 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_ci/* Use hypercalls for MMIO config space access */ 12662306a36Sopenharmony_ci#define HV_X64_USE_MMIO_HYPERCALLS BIT(21) 12762306a36Sopenharmony_ci 12862306a36Sopenharmony_ci/* 12962306a36Sopenharmony_ci * CPU management features identification. 13062306a36Sopenharmony_ci * These are HYPERV_CPUID_CPU_MANAGEMENT_FEATURES.EAX bits. 13162306a36Sopenharmony_ci */ 13262306a36Sopenharmony_ci#define HV_X64_START_LOGICAL_PROCESSOR BIT(0) 13362306a36Sopenharmony_ci#define HV_X64_CREATE_ROOT_VIRTUAL_PROCESSOR BIT(1) 13462306a36Sopenharmony_ci#define HV_X64_PERFORMANCE_COUNTER_SYNC BIT(2) 13562306a36Sopenharmony_ci#define HV_X64_RESERVED_IDENTITY_BIT BIT(31) 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ci/* 13862306a36Sopenharmony_ci * Virtual processor will never share a physical core with another virtual 13962306a36Sopenharmony_ci * processor, except for virtual processors that are reported as sibling SMT 14062306a36Sopenharmony_ci * threads. 14162306a36Sopenharmony_ci */ 14262306a36Sopenharmony_ci#define HV_X64_NO_NONARCH_CORESHARING BIT(18) 14362306a36Sopenharmony_ci 14462306a36Sopenharmony_ci/* Nested features. These are HYPERV_CPUID_NESTED_FEATURES.EAX bits. */ 14562306a36Sopenharmony_ci#define HV_X64_NESTED_DIRECT_FLUSH BIT(17) 14662306a36Sopenharmony_ci#define HV_X64_NESTED_GUEST_MAPPING_FLUSH BIT(18) 14762306a36Sopenharmony_ci#define HV_X64_NESTED_MSR_BITMAP BIT(19) 14862306a36Sopenharmony_ci 14962306a36Sopenharmony_ci/* Nested features #2. These are HYPERV_CPUID_NESTED_FEATURES.EBX bits. */ 15062306a36Sopenharmony_ci#define HV_X64_NESTED_EVMCS1_PERF_GLOBAL_CTRL BIT(0) 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_ci/* 15362306a36Sopenharmony_ci * This is specific to AMD and specifies that enlightened TLB flush is 15462306a36Sopenharmony_ci * supported. If guest opts in to this feature, ASID invalidations only 15562306a36Sopenharmony_ci * flushes gva -> hpa mapping entries. To flush the TLB entries derived 15662306a36Sopenharmony_ci * from NPT, hypercalls should be used (HvFlushGuestPhysicalAddressSpace 15762306a36Sopenharmony_ci * or HvFlushGuestPhysicalAddressList). 15862306a36Sopenharmony_ci */ 15962306a36Sopenharmony_ci#define HV_X64_NESTED_ENLIGHTENED_TLB BIT(22) 16062306a36Sopenharmony_ci 16162306a36Sopenharmony_ci/* HYPERV_CPUID_ISOLATION_CONFIG.EAX bits. */ 16262306a36Sopenharmony_ci#define HV_PARAVISOR_PRESENT BIT(0) 16362306a36Sopenharmony_ci 16462306a36Sopenharmony_ci/* HYPERV_CPUID_ISOLATION_CONFIG.EBX bits. */ 16562306a36Sopenharmony_ci#define HV_ISOLATION_TYPE GENMASK(3, 0) 16662306a36Sopenharmony_ci#define HV_SHARED_GPA_BOUNDARY_ACTIVE BIT(5) 16762306a36Sopenharmony_ci#define HV_SHARED_GPA_BOUNDARY_BITS GENMASK(11, 6) 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_cienum hv_isolation_type { 17062306a36Sopenharmony_ci HV_ISOLATION_TYPE_NONE = 0, 17162306a36Sopenharmony_ci HV_ISOLATION_TYPE_VBS = 1, 17262306a36Sopenharmony_ci HV_ISOLATION_TYPE_SNP = 2, 17362306a36Sopenharmony_ci HV_ISOLATION_TYPE_TDX = 3 17462306a36Sopenharmony_ci}; 17562306a36Sopenharmony_ci 17662306a36Sopenharmony_ci/* Hyper-V specific model specific registers (MSRs) */ 17762306a36Sopenharmony_ci 17862306a36Sopenharmony_ci/* MSR used to identify the guest OS. */ 17962306a36Sopenharmony_ci#define HV_X64_MSR_GUEST_OS_ID 0x40000000 18062306a36Sopenharmony_ci 18162306a36Sopenharmony_ci/* MSR used to setup pages used to communicate with the hypervisor. */ 18262306a36Sopenharmony_ci#define HV_X64_MSR_HYPERCALL 0x40000001 18362306a36Sopenharmony_ci 18462306a36Sopenharmony_ci/* MSR used to provide vcpu index */ 18562306a36Sopenharmony_ci#define HV_REGISTER_VP_INDEX 0x40000002 18662306a36Sopenharmony_ci 18762306a36Sopenharmony_ci/* MSR used to reset the guest OS. */ 18862306a36Sopenharmony_ci#define HV_X64_MSR_RESET 0x40000003 18962306a36Sopenharmony_ci 19062306a36Sopenharmony_ci/* MSR used to provide vcpu runtime in 100ns units */ 19162306a36Sopenharmony_ci#define HV_X64_MSR_VP_RUNTIME 0x40000010 19262306a36Sopenharmony_ci 19362306a36Sopenharmony_ci/* MSR used to read the per-partition time reference counter */ 19462306a36Sopenharmony_ci#define HV_REGISTER_TIME_REF_COUNT 0x40000020 19562306a36Sopenharmony_ci 19662306a36Sopenharmony_ci/* A partition's reference time stamp counter (TSC) page */ 19762306a36Sopenharmony_ci#define HV_REGISTER_REFERENCE_TSC 0x40000021 19862306a36Sopenharmony_ci 19962306a36Sopenharmony_ci/* MSR used to retrieve the TSC frequency */ 20062306a36Sopenharmony_ci#define HV_X64_MSR_TSC_FREQUENCY 0x40000022 20162306a36Sopenharmony_ci 20262306a36Sopenharmony_ci/* MSR used to retrieve the local APIC timer frequency */ 20362306a36Sopenharmony_ci#define HV_X64_MSR_APIC_FREQUENCY 0x40000023 20462306a36Sopenharmony_ci 20562306a36Sopenharmony_ci/* Define the virtual APIC registers */ 20662306a36Sopenharmony_ci#define HV_X64_MSR_EOI 0x40000070 20762306a36Sopenharmony_ci#define HV_X64_MSR_ICR 0x40000071 20862306a36Sopenharmony_ci#define HV_X64_MSR_TPR 0x40000072 20962306a36Sopenharmony_ci#define HV_X64_MSR_VP_ASSIST_PAGE 0x40000073 21062306a36Sopenharmony_ci 21162306a36Sopenharmony_ci/* Define synthetic interrupt controller model specific registers. */ 21262306a36Sopenharmony_ci#define HV_REGISTER_SCONTROL 0x40000080 21362306a36Sopenharmony_ci#define HV_REGISTER_SVERSION 0x40000081 21462306a36Sopenharmony_ci#define HV_REGISTER_SIEFP 0x40000082 21562306a36Sopenharmony_ci#define HV_REGISTER_SIMP 0x40000083 21662306a36Sopenharmony_ci#define HV_REGISTER_EOM 0x40000084 21762306a36Sopenharmony_ci#define HV_REGISTER_SINT0 0x40000090 21862306a36Sopenharmony_ci#define HV_REGISTER_SINT1 0x40000091 21962306a36Sopenharmony_ci#define HV_REGISTER_SINT2 0x40000092 22062306a36Sopenharmony_ci#define HV_REGISTER_SINT3 0x40000093 22162306a36Sopenharmony_ci#define HV_REGISTER_SINT4 0x40000094 22262306a36Sopenharmony_ci#define HV_REGISTER_SINT5 0x40000095 22362306a36Sopenharmony_ci#define HV_REGISTER_SINT6 0x40000096 22462306a36Sopenharmony_ci#define HV_REGISTER_SINT7 0x40000097 22562306a36Sopenharmony_ci#define HV_REGISTER_SINT8 0x40000098 22662306a36Sopenharmony_ci#define HV_REGISTER_SINT9 0x40000099 22762306a36Sopenharmony_ci#define HV_REGISTER_SINT10 0x4000009A 22862306a36Sopenharmony_ci#define HV_REGISTER_SINT11 0x4000009B 22962306a36Sopenharmony_ci#define HV_REGISTER_SINT12 0x4000009C 23062306a36Sopenharmony_ci#define HV_REGISTER_SINT13 0x4000009D 23162306a36Sopenharmony_ci#define HV_REGISTER_SINT14 0x4000009E 23262306a36Sopenharmony_ci#define HV_REGISTER_SINT15 0x4000009F 23362306a36Sopenharmony_ci 23462306a36Sopenharmony_ci/* 23562306a36Sopenharmony_ci * Define synthetic interrupt controller model specific registers for 23662306a36Sopenharmony_ci * nested hypervisor. 23762306a36Sopenharmony_ci */ 23862306a36Sopenharmony_ci#define HV_REGISTER_NESTED_SCONTROL 0x40001080 23962306a36Sopenharmony_ci#define HV_REGISTER_NESTED_SVERSION 0x40001081 24062306a36Sopenharmony_ci#define HV_REGISTER_NESTED_SIEFP 0x40001082 24162306a36Sopenharmony_ci#define HV_REGISTER_NESTED_SIMP 0x40001083 24262306a36Sopenharmony_ci#define HV_REGISTER_NESTED_EOM 0x40001084 24362306a36Sopenharmony_ci#define HV_REGISTER_NESTED_SINT0 0x40001090 24462306a36Sopenharmony_ci 24562306a36Sopenharmony_ci/* 24662306a36Sopenharmony_ci * Synthetic Timer MSRs. Four timers per vcpu. 24762306a36Sopenharmony_ci */ 24862306a36Sopenharmony_ci#define HV_REGISTER_STIMER0_CONFIG 0x400000B0 24962306a36Sopenharmony_ci#define HV_REGISTER_STIMER0_COUNT 0x400000B1 25062306a36Sopenharmony_ci#define HV_REGISTER_STIMER1_CONFIG 0x400000B2 25162306a36Sopenharmony_ci#define HV_REGISTER_STIMER1_COUNT 0x400000B3 25262306a36Sopenharmony_ci#define HV_REGISTER_STIMER2_CONFIG 0x400000B4 25362306a36Sopenharmony_ci#define HV_REGISTER_STIMER2_COUNT 0x400000B5 25462306a36Sopenharmony_ci#define HV_REGISTER_STIMER3_CONFIG 0x400000B6 25562306a36Sopenharmony_ci#define HV_REGISTER_STIMER3_COUNT 0x400000B7 25662306a36Sopenharmony_ci 25762306a36Sopenharmony_ci/* Hyper-V guest idle MSR */ 25862306a36Sopenharmony_ci#define HV_X64_MSR_GUEST_IDLE 0x400000F0 25962306a36Sopenharmony_ci 26062306a36Sopenharmony_ci/* Hyper-V guest crash notification MSR's */ 26162306a36Sopenharmony_ci#define HV_REGISTER_CRASH_P0 0x40000100 26262306a36Sopenharmony_ci#define HV_REGISTER_CRASH_P1 0x40000101 26362306a36Sopenharmony_ci#define HV_REGISTER_CRASH_P2 0x40000102 26462306a36Sopenharmony_ci#define HV_REGISTER_CRASH_P3 0x40000103 26562306a36Sopenharmony_ci#define HV_REGISTER_CRASH_P4 0x40000104 26662306a36Sopenharmony_ci#define HV_REGISTER_CRASH_CTL 0x40000105 26762306a36Sopenharmony_ci 26862306a36Sopenharmony_ci/* TSC emulation after migration */ 26962306a36Sopenharmony_ci#define HV_X64_MSR_REENLIGHTENMENT_CONTROL 0x40000106 27062306a36Sopenharmony_ci#define HV_X64_MSR_TSC_EMULATION_CONTROL 0x40000107 27162306a36Sopenharmony_ci#define HV_X64_MSR_TSC_EMULATION_STATUS 0x40000108 27262306a36Sopenharmony_ci 27362306a36Sopenharmony_ci/* TSC invariant control */ 27462306a36Sopenharmony_ci#define HV_X64_MSR_TSC_INVARIANT_CONTROL 0x40000118 27562306a36Sopenharmony_ci 27662306a36Sopenharmony_ci/* HV_X64_MSR_TSC_INVARIANT_CONTROL bits */ 27762306a36Sopenharmony_ci#define HV_EXPOSE_INVARIANT_TSC BIT_ULL(0) 27862306a36Sopenharmony_ci 27962306a36Sopenharmony_ci/* Register name aliases for temporary compatibility */ 28062306a36Sopenharmony_ci#define HV_X64_MSR_STIMER0_COUNT HV_REGISTER_STIMER0_COUNT 28162306a36Sopenharmony_ci#define HV_X64_MSR_STIMER0_CONFIG HV_REGISTER_STIMER0_CONFIG 28262306a36Sopenharmony_ci#define HV_X64_MSR_STIMER1_COUNT HV_REGISTER_STIMER1_COUNT 28362306a36Sopenharmony_ci#define HV_X64_MSR_STIMER1_CONFIG HV_REGISTER_STIMER1_CONFIG 28462306a36Sopenharmony_ci#define HV_X64_MSR_STIMER2_COUNT HV_REGISTER_STIMER2_COUNT 28562306a36Sopenharmony_ci#define HV_X64_MSR_STIMER2_CONFIG HV_REGISTER_STIMER2_CONFIG 28662306a36Sopenharmony_ci#define HV_X64_MSR_STIMER3_COUNT HV_REGISTER_STIMER3_COUNT 28762306a36Sopenharmony_ci#define HV_X64_MSR_STIMER3_CONFIG HV_REGISTER_STIMER3_CONFIG 28862306a36Sopenharmony_ci#define HV_X64_MSR_SCONTROL HV_REGISTER_SCONTROL 28962306a36Sopenharmony_ci#define HV_X64_MSR_SVERSION HV_REGISTER_SVERSION 29062306a36Sopenharmony_ci#define HV_X64_MSR_SIMP HV_REGISTER_SIMP 29162306a36Sopenharmony_ci#define HV_X64_MSR_SIEFP HV_REGISTER_SIEFP 29262306a36Sopenharmony_ci#define HV_X64_MSR_VP_INDEX HV_REGISTER_VP_INDEX 29362306a36Sopenharmony_ci#define HV_X64_MSR_EOM HV_REGISTER_EOM 29462306a36Sopenharmony_ci#define HV_X64_MSR_SINT0 HV_REGISTER_SINT0 29562306a36Sopenharmony_ci#define HV_X64_MSR_SINT15 HV_REGISTER_SINT15 29662306a36Sopenharmony_ci#define HV_X64_MSR_CRASH_P0 HV_REGISTER_CRASH_P0 29762306a36Sopenharmony_ci#define HV_X64_MSR_CRASH_P1 HV_REGISTER_CRASH_P1 29862306a36Sopenharmony_ci#define HV_X64_MSR_CRASH_P2 HV_REGISTER_CRASH_P2 29962306a36Sopenharmony_ci#define HV_X64_MSR_CRASH_P3 HV_REGISTER_CRASH_P3 30062306a36Sopenharmony_ci#define HV_X64_MSR_CRASH_P4 HV_REGISTER_CRASH_P4 30162306a36Sopenharmony_ci#define HV_X64_MSR_CRASH_CTL HV_REGISTER_CRASH_CTL 30262306a36Sopenharmony_ci#define HV_X64_MSR_TIME_REF_COUNT HV_REGISTER_TIME_REF_COUNT 30362306a36Sopenharmony_ci#define HV_X64_MSR_REFERENCE_TSC HV_REGISTER_REFERENCE_TSC 30462306a36Sopenharmony_ci 30562306a36Sopenharmony_ci/* 30662306a36Sopenharmony_ci * Registers are only accessible via HVCALL_GET_VP_REGISTERS hvcall and 30762306a36Sopenharmony_ci * there is not associated MSR address. 30862306a36Sopenharmony_ci */ 30962306a36Sopenharmony_ci#define HV_X64_REGISTER_VSM_VP_STATUS 0x000D0003 31062306a36Sopenharmony_ci#define HV_X64_VTL_MASK GENMASK(3, 0) 31162306a36Sopenharmony_ci 31262306a36Sopenharmony_ci/* Hyper-V memory host visibility */ 31362306a36Sopenharmony_cienum hv_mem_host_visibility { 31462306a36Sopenharmony_ci VMBUS_PAGE_NOT_VISIBLE = 0, 31562306a36Sopenharmony_ci VMBUS_PAGE_VISIBLE_READ_ONLY = 1, 31662306a36Sopenharmony_ci VMBUS_PAGE_VISIBLE_READ_WRITE = 3 31762306a36Sopenharmony_ci}; 31862306a36Sopenharmony_ci 31962306a36Sopenharmony_ci/* HvCallModifySparseGpaPageHostVisibility hypercall */ 32062306a36Sopenharmony_ci#define HV_MAX_MODIFY_GPA_REP_COUNT ((PAGE_SIZE / sizeof(u64)) - 2) 32162306a36Sopenharmony_cistruct hv_gpa_range_for_visibility { 32262306a36Sopenharmony_ci u64 partition_id; 32362306a36Sopenharmony_ci u32 host_visibility:2; 32462306a36Sopenharmony_ci u32 reserved0:30; 32562306a36Sopenharmony_ci u32 reserved1; 32662306a36Sopenharmony_ci u64 gpa_page_list[HV_MAX_MODIFY_GPA_REP_COUNT]; 32762306a36Sopenharmony_ci} __packed; 32862306a36Sopenharmony_ci 32962306a36Sopenharmony_ci/* 33062306a36Sopenharmony_ci * Declare the MSR used to setup pages used to communicate with the hypervisor. 33162306a36Sopenharmony_ci */ 33262306a36Sopenharmony_ciunion hv_x64_msr_hypercall_contents { 33362306a36Sopenharmony_ci u64 as_uint64; 33462306a36Sopenharmony_ci struct { 33562306a36Sopenharmony_ci u64 enable:1; 33662306a36Sopenharmony_ci u64 reserved:11; 33762306a36Sopenharmony_ci u64 guest_physical_address:52; 33862306a36Sopenharmony_ci } __packed; 33962306a36Sopenharmony_ci}; 34062306a36Sopenharmony_ci 34162306a36Sopenharmony_ciunion hv_vp_assist_msr_contents { 34262306a36Sopenharmony_ci u64 as_uint64; 34362306a36Sopenharmony_ci struct { 34462306a36Sopenharmony_ci u64 enable:1; 34562306a36Sopenharmony_ci u64 reserved:11; 34662306a36Sopenharmony_ci u64 pfn:52; 34762306a36Sopenharmony_ci } __packed; 34862306a36Sopenharmony_ci}; 34962306a36Sopenharmony_ci 35062306a36Sopenharmony_cistruct hv_reenlightenment_control { 35162306a36Sopenharmony_ci __u64 vector:8; 35262306a36Sopenharmony_ci __u64 reserved1:8; 35362306a36Sopenharmony_ci __u64 enabled:1; 35462306a36Sopenharmony_ci __u64 reserved2:15; 35562306a36Sopenharmony_ci __u64 target_vp:32; 35662306a36Sopenharmony_ci} __packed; 35762306a36Sopenharmony_ci 35862306a36Sopenharmony_cistruct hv_tsc_emulation_control { 35962306a36Sopenharmony_ci __u64 enabled:1; 36062306a36Sopenharmony_ci __u64 reserved:63; 36162306a36Sopenharmony_ci} __packed; 36262306a36Sopenharmony_ci 36362306a36Sopenharmony_cistruct hv_tsc_emulation_status { 36462306a36Sopenharmony_ci __u64 inprogress:1; 36562306a36Sopenharmony_ci __u64 reserved:63; 36662306a36Sopenharmony_ci} __packed; 36762306a36Sopenharmony_ci 36862306a36Sopenharmony_ci#define HV_X64_MSR_HYPERCALL_ENABLE 0x00000001 36962306a36Sopenharmony_ci#define HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT 12 37062306a36Sopenharmony_ci#define HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_MASK \ 37162306a36Sopenharmony_ci (~((1ull << HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT) - 1)) 37262306a36Sopenharmony_ci 37362306a36Sopenharmony_ci#define HV_X64_MSR_CRASH_PARAMS \ 37462306a36Sopenharmony_ci (1 + (HV_X64_MSR_CRASH_P4 - HV_X64_MSR_CRASH_P0)) 37562306a36Sopenharmony_ci 37662306a36Sopenharmony_ci#define HV_IPI_LOW_VECTOR 0x10 37762306a36Sopenharmony_ci#define HV_IPI_HIGH_VECTOR 0xff 37862306a36Sopenharmony_ci 37962306a36Sopenharmony_ci#define HV_X64_MSR_VP_ASSIST_PAGE_ENABLE 0x00000001 38062306a36Sopenharmony_ci#define HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_SHIFT 12 38162306a36Sopenharmony_ci#define HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_MASK \ 38262306a36Sopenharmony_ci (~((1ull << HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_SHIFT) - 1)) 38362306a36Sopenharmony_ci 38462306a36Sopenharmony_ci/* Hyper-V Enlightened VMCS version mask in nested features CPUID */ 38562306a36Sopenharmony_ci#define HV_X64_ENLIGHTENED_VMCS_VERSION 0xff 38662306a36Sopenharmony_ci 38762306a36Sopenharmony_ci#define HV_X64_MSR_TSC_REFERENCE_ENABLE 0x00000001 38862306a36Sopenharmony_ci#define HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT 12 38962306a36Sopenharmony_ci 39062306a36Sopenharmony_ci/* Number of XMM registers used in hypercall input/output */ 39162306a36Sopenharmony_ci#define HV_HYPERCALL_MAX_XMM_REGISTERS 6 39262306a36Sopenharmony_ci 39362306a36Sopenharmony_cistruct hv_nested_enlightenments_control { 39462306a36Sopenharmony_ci struct { 39562306a36Sopenharmony_ci __u32 directhypercall:1; 39662306a36Sopenharmony_ci __u32 reserved:31; 39762306a36Sopenharmony_ci } features; 39862306a36Sopenharmony_ci struct { 39962306a36Sopenharmony_ci __u32 inter_partition_comm:1; 40062306a36Sopenharmony_ci __u32 reserved:31; 40162306a36Sopenharmony_ci } hypercallControls; 40262306a36Sopenharmony_ci} __packed; 40362306a36Sopenharmony_ci 40462306a36Sopenharmony_ci/* Define virtual processor assist page structure. */ 40562306a36Sopenharmony_cistruct hv_vp_assist_page { 40662306a36Sopenharmony_ci __u32 apic_assist; 40762306a36Sopenharmony_ci __u32 reserved1; 40862306a36Sopenharmony_ci __u32 vtl_entry_reason; 40962306a36Sopenharmony_ci __u32 vtl_reserved; 41062306a36Sopenharmony_ci __u64 vtl_ret_x64rax; 41162306a36Sopenharmony_ci __u64 vtl_ret_x64rcx; 41262306a36Sopenharmony_ci struct hv_nested_enlightenments_control nested_control; 41362306a36Sopenharmony_ci __u8 enlighten_vmentry; 41462306a36Sopenharmony_ci __u8 reserved2[7]; 41562306a36Sopenharmony_ci __u64 current_nested_vmcs; 41662306a36Sopenharmony_ci __u8 synthetic_time_unhalted_timer_expired; 41762306a36Sopenharmony_ci __u8 reserved3[7]; 41862306a36Sopenharmony_ci __u8 virtualization_fault_information[40]; 41962306a36Sopenharmony_ci __u8 reserved4[8]; 42062306a36Sopenharmony_ci __u8 intercept_message[256]; 42162306a36Sopenharmony_ci __u8 vtl_ret_actions[256]; 42262306a36Sopenharmony_ci} __packed; 42362306a36Sopenharmony_ci 42462306a36Sopenharmony_cistruct hv_enlightened_vmcs { 42562306a36Sopenharmony_ci u32 revision_id; 42662306a36Sopenharmony_ci u32 abort; 42762306a36Sopenharmony_ci 42862306a36Sopenharmony_ci u16 host_es_selector; 42962306a36Sopenharmony_ci u16 host_cs_selector; 43062306a36Sopenharmony_ci u16 host_ss_selector; 43162306a36Sopenharmony_ci u16 host_ds_selector; 43262306a36Sopenharmony_ci u16 host_fs_selector; 43362306a36Sopenharmony_ci u16 host_gs_selector; 43462306a36Sopenharmony_ci u16 host_tr_selector; 43562306a36Sopenharmony_ci 43662306a36Sopenharmony_ci u16 padding16_1; 43762306a36Sopenharmony_ci 43862306a36Sopenharmony_ci u64 host_ia32_pat; 43962306a36Sopenharmony_ci u64 host_ia32_efer; 44062306a36Sopenharmony_ci 44162306a36Sopenharmony_ci u64 host_cr0; 44262306a36Sopenharmony_ci u64 host_cr3; 44362306a36Sopenharmony_ci u64 host_cr4; 44462306a36Sopenharmony_ci 44562306a36Sopenharmony_ci u64 host_ia32_sysenter_esp; 44662306a36Sopenharmony_ci u64 host_ia32_sysenter_eip; 44762306a36Sopenharmony_ci u64 host_rip; 44862306a36Sopenharmony_ci u32 host_ia32_sysenter_cs; 44962306a36Sopenharmony_ci 45062306a36Sopenharmony_ci u32 pin_based_vm_exec_control; 45162306a36Sopenharmony_ci u32 vm_exit_controls; 45262306a36Sopenharmony_ci u32 secondary_vm_exec_control; 45362306a36Sopenharmony_ci 45462306a36Sopenharmony_ci u64 io_bitmap_a; 45562306a36Sopenharmony_ci u64 io_bitmap_b; 45662306a36Sopenharmony_ci u64 msr_bitmap; 45762306a36Sopenharmony_ci 45862306a36Sopenharmony_ci u16 guest_es_selector; 45962306a36Sopenharmony_ci u16 guest_cs_selector; 46062306a36Sopenharmony_ci u16 guest_ss_selector; 46162306a36Sopenharmony_ci u16 guest_ds_selector; 46262306a36Sopenharmony_ci u16 guest_fs_selector; 46362306a36Sopenharmony_ci u16 guest_gs_selector; 46462306a36Sopenharmony_ci u16 guest_ldtr_selector; 46562306a36Sopenharmony_ci u16 guest_tr_selector; 46662306a36Sopenharmony_ci 46762306a36Sopenharmony_ci u32 guest_es_limit; 46862306a36Sopenharmony_ci u32 guest_cs_limit; 46962306a36Sopenharmony_ci u32 guest_ss_limit; 47062306a36Sopenharmony_ci u32 guest_ds_limit; 47162306a36Sopenharmony_ci u32 guest_fs_limit; 47262306a36Sopenharmony_ci u32 guest_gs_limit; 47362306a36Sopenharmony_ci u32 guest_ldtr_limit; 47462306a36Sopenharmony_ci u32 guest_tr_limit; 47562306a36Sopenharmony_ci u32 guest_gdtr_limit; 47662306a36Sopenharmony_ci u32 guest_idtr_limit; 47762306a36Sopenharmony_ci 47862306a36Sopenharmony_ci u32 guest_es_ar_bytes; 47962306a36Sopenharmony_ci u32 guest_cs_ar_bytes; 48062306a36Sopenharmony_ci u32 guest_ss_ar_bytes; 48162306a36Sopenharmony_ci u32 guest_ds_ar_bytes; 48262306a36Sopenharmony_ci u32 guest_fs_ar_bytes; 48362306a36Sopenharmony_ci u32 guest_gs_ar_bytes; 48462306a36Sopenharmony_ci u32 guest_ldtr_ar_bytes; 48562306a36Sopenharmony_ci u32 guest_tr_ar_bytes; 48662306a36Sopenharmony_ci 48762306a36Sopenharmony_ci u64 guest_es_base; 48862306a36Sopenharmony_ci u64 guest_cs_base; 48962306a36Sopenharmony_ci u64 guest_ss_base; 49062306a36Sopenharmony_ci u64 guest_ds_base; 49162306a36Sopenharmony_ci u64 guest_fs_base; 49262306a36Sopenharmony_ci u64 guest_gs_base; 49362306a36Sopenharmony_ci u64 guest_ldtr_base; 49462306a36Sopenharmony_ci u64 guest_tr_base; 49562306a36Sopenharmony_ci u64 guest_gdtr_base; 49662306a36Sopenharmony_ci u64 guest_idtr_base; 49762306a36Sopenharmony_ci 49862306a36Sopenharmony_ci u64 padding64_1[3]; 49962306a36Sopenharmony_ci 50062306a36Sopenharmony_ci u64 vm_exit_msr_store_addr; 50162306a36Sopenharmony_ci u64 vm_exit_msr_load_addr; 50262306a36Sopenharmony_ci u64 vm_entry_msr_load_addr; 50362306a36Sopenharmony_ci 50462306a36Sopenharmony_ci u64 cr3_target_value0; 50562306a36Sopenharmony_ci u64 cr3_target_value1; 50662306a36Sopenharmony_ci u64 cr3_target_value2; 50762306a36Sopenharmony_ci u64 cr3_target_value3; 50862306a36Sopenharmony_ci 50962306a36Sopenharmony_ci u32 page_fault_error_code_mask; 51062306a36Sopenharmony_ci u32 page_fault_error_code_match; 51162306a36Sopenharmony_ci 51262306a36Sopenharmony_ci u32 cr3_target_count; 51362306a36Sopenharmony_ci u32 vm_exit_msr_store_count; 51462306a36Sopenharmony_ci u32 vm_exit_msr_load_count; 51562306a36Sopenharmony_ci u32 vm_entry_msr_load_count; 51662306a36Sopenharmony_ci 51762306a36Sopenharmony_ci u64 tsc_offset; 51862306a36Sopenharmony_ci u64 virtual_apic_page_addr; 51962306a36Sopenharmony_ci u64 vmcs_link_pointer; 52062306a36Sopenharmony_ci 52162306a36Sopenharmony_ci u64 guest_ia32_debugctl; 52262306a36Sopenharmony_ci u64 guest_ia32_pat; 52362306a36Sopenharmony_ci u64 guest_ia32_efer; 52462306a36Sopenharmony_ci 52562306a36Sopenharmony_ci u64 guest_pdptr0; 52662306a36Sopenharmony_ci u64 guest_pdptr1; 52762306a36Sopenharmony_ci u64 guest_pdptr2; 52862306a36Sopenharmony_ci u64 guest_pdptr3; 52962306a36Sopenharmony_ci 53062306a36Sopenharmony_ci u64 guest_pending_dbg_exceptions; 53162306a36Sopenharmony_ci u64 guest_sysenter_esp; 53262306a36Sopenharmony_ci u64 guest_sysenter_eip; 53362306a36Sopenharmony_ci 53462306a36Sopenharmony_ci u32 guest_activity_state; 53562306a36Sopenharmony_ci u32 guest_sysenter_cs; 53662306a36Sopenharmony_ci 53762306a36Sopenharmony_ci u64 cr0_guest_host_mask; 53862306a36Sopenharmony_ci u64 cr4_guest_host_mask; 53962306a36Sopenharmony_ci u64 cr0_read_shadow; 54062306a36Sopenharmony_ci u64 cr4_read_shadow; 54162306a36Sopenharmony_ci u64 guest_cr0; 54262306a36Sopenharmony_ci u64 guest_cr3; 54362306a36Sopenharmony_ci u64 guest_cr4; 54462306a36Sopenharmony_ci u64 guest_dr7; 54562306a36Sopenharmony_ci 54662306a36Sopenharmony_ci u64 host_fs_base; 54762306a36Sopenharmony_ci u64 host_gs_base; 54862306a36Sopenharmony_ci u64 host_tr_base; 54962306a36Sopenharmony_ci u64 host_gdtr_base; 55062306a36Sopenharmony_ci u64 host_idtr_base; 55162306a36Sopenharmony_ci u64 host_rsp; 55262306a36Sopenharmony_ci 55362306a36Sopenharmony_ci u64 ept_pointer; 55462306a36Sopenharmony_ci 55562306a36Sopenharmony_ci u16 virtual_processor_id; 55662306a36Sopenharmony_ci u16 padding16_2[3]; 55762306a36Sopenharmony_ci 55862306a36Sopenharmony_ci u64 padding64_2[5]; 55962306a36Sopenharmony_ci u64 guest_physical_address; 56062306a36Sopenharmony_ci 56162306a36Sopenharmony_ci u32 vm_instruction_error; 56262306a36Sopenharmony_ci u32 vm_exit_reason; 56362306a36Sopenharmony_ci u32 vm_exit_intr_info; 56462306a36Sopenharmony_ci u32 vm_exit_intr_error_code; 56562306a36Sopenharmony_ci u32 idt_vectoring_info_field; 56662306a36Sopenharmony_ci u32 idt_vectoring_error_code; 56762306a36Sopenharmony_ci u32 vm_exit_instruction_len; 56862306a36Sopenharmony_ci u32 vmx_instruction_info; 56962306a36Sopenharmony_ci 57062306a36Sopenharmony_ci u64 exit_qualification; 57162306a36Sopenharmony_ci u64 exit_io_instruction_ecx; 57262306a36Sopenharmony_ci u64 exit_io_instruction_esi; 57362306a36Sopenharmony_ci u64 exit_io_instruction_edi; 57462306a36Sopenharmony_ci u64 exit_io_instruction_eip; 57562306a36Sopenharmony_ci 57662306a36Sopenharmony_ci u64 guest_linear_address; 57762306a36Sopenharmony_ci u64 guest_rsp; 57862306a36Sopenharmony_ci u64 guest_rflags; 57962306a36Sopenharmony_ci 58062306a36Sopenharmony_ci u32 guest_interruptibility_info; 58162306a36Sopenharmony_ci u32 cpu_based_vm_exec_control; 58262306a36Sopenharmony_ci u32 exception_bitmap; 58362306a36Sopenharmony_ci u32 vm_entry_controls; 58462306a36Sopenharmony_ci u32 vm_entry_intr_info_field; 58562306a36Sopenharmony_ci u32 vm_entry_exception_error_code; 58662306a36Sopenharmony_ci u32 vm_entry_instruction_len; 58762306a36Sopenharmony_ci u32 tpr_threshold; 58862306a36Sopenharmony_ci 58962306a36Sopenharmony_ci u64 guest_rip; 59062306a36Sopenharmony_ci 59162306a36Sopenharmony_ci u32 hv_clean_fields; 59262306a36Sopenharmony_ci u32 padding32_1; 59362306a36Sopenharmony_ci u32 hv_synthetic_controls; 59462306a36Sopenharmony_ci struct { 59562306a36Sopenharmony_ci u32 nested_flush_hypercall:1; 59662306a36Sopenharmony_ci u32 msr_bitmap:1; 59762306a36Sopenharmony_ci u32 reserved:30; 59862306a36Sopenharmony_ci } __packed hv_enlightenments_control; 59962306a36Sopenharmony_ci u32 hv_vp_id; 60062306a36Sopenharmony_ci u32 padding32_2; 60162306a36Sopenharmony_ci u64 hv_vm_id; 60262306a36Sopenharmony_ci u64 partition_assist_page; 60362306a36Sopenharmony_ci u64 padding64_4[4]; 60462306a36Sopenharmony_ci u64 guest_bndcfgs; 60562306a36Sopenharmony_ci u64 guest_ia32_perf_global_ctrl; 60662306a36Sopenharmony_ci u64 guest_ia32_s_cet; 60762306a36Sopenharmony_ci u64 guest_ssp; 60862306a36Sopenharmony_ci u64 guest_ia32_int_ssp_table_addr; 60962306a36Sopenharmony_ci u64 guest_ia32_lbr_ctl; 61062306a36Sopenharmony_ci u64 padding64_5[2]; 61162306a36Sopenharmony_ci u64 xss_exit_bitmap; 61262306a36Sopenharmony_ci u64 encls_exiting_bitmap; 61362306a36Sopenharmony_ci u64 host_ia32_perf_global_ctrl; 61462306a36Sopenharmony_ci u64 tsc_multiplier; 61562306a36Sopenharmony_ci u64 host_ia32_s_cet; 61662306a36Sopenharmony_ci u64 host_ssp; 61762306a36Sopenharmony_ci u64 host_ia32_int_ssp_table_addr; 61862306a36Sopenharmony_ci u64 padding64_6; 61962306a36Sopenharmony_ci} __packed; 62062306a36Sopenharmony_ci 62162306a36Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_NONE 0 62262306a36Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_IO_BITMAP BIT(0) 62362306a36Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_MSR_BITMAP BIT(1) 62462306a36Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP2 BIT(2) 62562306a36Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP1 BIT(3) 62662306a36Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_PROC BIT(4) 62762306a36Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_EVENT BIT(5) 62862306a36Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_ENTRY BIT(6) 62962306a36Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_EXCPN BIT(7) 63062306a36Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CRDR BIT(8) 63162306a36Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_XLAT BIT(9) 63262306a36Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_BASIC BIT(10) 63362306a36Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1 BIT(11) 63462306a36Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 BIT(12) 63562306a36Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_POINTER BIT(13) 63662306a36Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1 BIT(14) 63762306a36Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_ENLIGHTENMENTSCONTROL BIT(15) 63862306a36Sopenharmony_ci 63962306a36Sopenharmony_ci#define HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL 0xFFFF 64062306a36Sopenharmony_ci 64162306a36Sopenharmony_ci/* 64262306a36Sopenharmony_ci * Note, Hyper-V isn't actually stealing bit 28 from Intel, just abusing it by 64362306a36Sopenharmony_ci * pairing it with architecturally impossible exit reasons. Bit 28 is set only 64462306a36Sopenharmony_ci * on SMI exits to a SMI transfer monitor (STM) and if and only if a MTF VM-Exit 64562306a36Sopenharmony_ci * is pending. I.e. it will never be set by hardware for non-SMI exits (there 64662306a36Sopenharmony_ci * are only three), nor will it ever be set unless the VMM is an STM. 64762306a36Sopenharmony_ci */ 64862306a36Sopenharmony_ci#define HV_VMX_SYNTHETIC_EXIT_REASON_TRAP_AFTER_FLUSH 0x10000031 64962306a36Sopenharmony_ci 65062306a36Sopenharmony_ci/* 65162306a36Sopenharmony_ci * Hyper-V uses the software reserved 32 bytes in VMCB control area to expose 65262306a36Sopenharmony_ci * SVM enlightenments to guests. 65362306a36Sopenharmony_ci */ 65462306a36Sopenharmony_cistruct hv_vmcb_enlightenments { 65562306a36Sopenharmony_ci struct __packed hv_enlightenments_control { 65662306a36Sopenharmony_ci u32 nested_flush_hypercall:1; 65762306a36Sopenharmony_ci u32 msr_bitmap:1; 65862306a36Sopenharmony_ci u32 enlightened_npt_tlb: 1; 65962306a36Sopenharmony_ci u32 reserved:29; 66062306a36Sopenharmony_ci } __packed hv_enlightenments_control; 66162306a36Sopenharmony_ci u32 hv_vp_id; 66262306a36Sopenharmony_ci u64 hv_vm_id; 66362306a36Sopenharmony_ci u64 partition_assist_page; 66462306a36Sopenharmony_ci u64 reserved; 66562306a36Sopenharmony_ci} __packed; 66662306a36Sopenharmony_ci 66762306a36Sopenharmony_ci/* 66862306a36Sopenharmony_ci * Hyper-V uses the software reserved clean bit in VMCB. 66962306a36Sopenharmony_ci */ 67062306a36Sopenharmony_ci#define HV_VMCB_NESTED_ENLIGHTENMENTS 31 67162306a36Sopenharmony_ci 67262306a36Sopenharmony_ci/* Synthetic VM-Exit */ 67362306a36Sopenharmony_ci#define HV_SVM_EXITCODE_ENL 0xf0000000 67462306a36Sopenharmony_ci#define HV_SVM_ENL_EXITCODE_TRAP_AFTER_FLUSH (1) 67562306a36Sopenharmony_ci 67662306a36Sopenharmony_cistruct hv_partition_assist_pg { 67762306a36Sopenharmony_ci u32 tlb_lock_count; 67862306a36Sopenharmony_ci}; 67962306a36Sopenharmony_ci 68062306a36Sopenharmony_cienum hv_interrupt_type { 68162306a36Sopenharmony_ci HV_X64_INTERRUPT_TYPE_FIXED = 0x0000, 68262306a36Sopenharmony_ci HV_X64_INTERRUPT_TYPE_LOWESTPRIORITY = 0x0001, 68362306a36Sopenharmony_ci HV_X64_INTERRUPT_TYPE_SMI = 0x0002, 68462306a36Sopenharmony_ci HV_X64_INTERRUPT_TYPE_REMOTEREAD = 0x0003, 68562306a36Sopenharmony_ci HV_X64_INTERRUPT_TYPE_NMI = 0x0004, 68662306a36Sopenharmony_ci HV_X64_INTERRUPT_TYPE_INIT = 0x0005, 68762306a36Sopenharmony_ci HV_X64_INTERRUPT_TYPE_SIPI = 0x0006, 68862306a36Sopenharmony_ci HV_X64_INTERRUPT_TYPE_EXTINT = 0x0007, 68962306a36Sopenharmony_ci HV_X64_INTERRUPT_TYPE_LOCALINT0 = 0x0008, 69062306a36Sopenharmony_ci HV_X64_INTERRUPT_TYPE_LOCALINT1 = 0x0009, 69162306a36Sopenharmony_ci HV_X64_INTERRUPT_TYPE_MAXIMUM = 0x000A, 69262306a36Sopenharmony_ci}; 69362306a36Sopenharmony_ci 69462306a36Sopenharmony_ciunion hv_msi_address_register { 69562306a36Sopenharmony_ci u32 as_uint32; 69662306a36Sopenharmony_ci struct { 69762306a36Sopenharmony_ci u32 reserved1:2; 69862306a36Sopenharmony_ci u32 destination_mode:1; 69962306a36Sopenharmony_ci u32 redirection_hint:1; 70062306a36Sopenharmony_ci u32 reserved2:8; 70162306a36Sopenharmony_ci u32 destination_id:8; 70262306a36Sopenharmony_ci u32 msi_base:12; 70362306a36Sopenharmony_ci }; 70462306a36Sopenharmony_ci} __packed; 70562306a36Sopenharmony_ci 70662306a36Sopenharmony_ciunion hv_msi_data_register { 70762306a36Sopenharmony_ci u32 as_uint32; 70862306a36Sopenharmony_ci struct { 70962306a36Sopenharmony_ci u32 vector:8; 71062306a36Sopenharmony_ci u32 delivery_mode:3; 71162306a36Sopenharmony_ci u32 reserved1:3; 71262306a36Sopenharmony_ci u32 level_assert:1; 71362306a36Sopenharmony_ci u32 trigger_mode:1; 71462306a36Sopenharmony_ci u32 reserved2:16; 71562306a36Sopenharmony_ci }; 71662306a36Sopenharmony_ci} __packed; 71762306a36Sopenharmony_ci 71862306a36Sopenharmony_ci/* HvRetargetDeviceInterrupt hypercall */ 71962306a36Sopenharmony_ciunion hv_msi_entry { 72062306a36Sopenharmony_ci u64 as_uint64; 72162306a36Sopenharmony_ci struct { 72262306a36Sopenharmony_ci union hv_msi_address_register address; 72362306a36Sopenharmony_ci union hv_msi_data_register data; 72462306a36Sopenharmony_ci } __packed; 72562306a36Sopenharmony_ci}; 72662306a36Sopenharmony_ci 72762306a36Sopenharmony_cistruct hv_x64_segment_register { 72862306a36Sopenharmony_ci u64 base; 72962306a36Sopenharmony_ci u32 limit; 73062306a36Sopenharmony_ci u16 selector; 73162306a36Sopenharmony_ci union { 73262306a36Sopenharmony_ci struct { 73362306a36Sopenharmony_ci u16 segment_type : 4; 73462306a36Sopenharmony_ci u16 non_system_segment : 1; 73562306a36Sopenharmony_ci u16 descriptor_privilege_level : 2; 73662306a36Sopenharmony_ci u16 present : 1; 73762306a36Sopenharmony_ci u16 reserved : 4; 73862306a36Sopenharmony_ci u16 available : 1; 73962306a36Sopenharmony_ci u16 _long : 1; 74062306a36Sopenharmony_ci u16 _default : 1; 74162306a36Sopenharmony_ci u16 granularity : 1; 74262306a36Sopenharmony_ci } __packed; 74362306a36Sopenharmony_ci u16 attributes; 74462306a36Sopenharmony_ci }; 74562306a36Sopenharmony_ci} __packed; 74662306a36Sopenharmony_ci 74762306a36Sopenharmony_cistruct hv_x64_table_register { 74862306a36Sopenharmony_ci u16 pad[3]; 74962306a36Sopenharmony_ci u16 limit; 75062306a36Sopenharmony_ci u64 base; 75162306a36Sopenharmony_ci} __packed; 75262306a36Sopenharmony_ci 75362306a36Sopenharmony_cistruct hv_init_vp_context { 75462306a36Sopenharmony_ci u64 rip; 75562306a36Sopenharmony_ci u64 rsp; 75662306a36Sopenharmony_ci u64 rflags; 75762306a36Sopenharmony_ci 75862306a36Sopenharmony_ci struct hv_x64_segment_register cs; 75962306a36Sopenharmony_ci struct hv_x64_segment_register ds; 76062306a36Sopenharmony_ci struct hv_x64_segment_register es; 76162306a36Sopenharmony_ci struct hv_x64_segment_register fs; 76262306a36Sopenharmony_ci struct hv_x64_segment_register gs; 76362306a36Sopenharmony_ci struct hv_x64_segment_register ss; 76462306a36Sopenharmony_ci struct hv_x64_segment_register tr; 76562306a36Sopenharmony_ci struct hv_x64_segment_register ldtr; 76662306a36Sopenharmony_ci 76762306a36Sopenharmony_ci struct hv_x64_table_register idtr; 76862306a36Sopenharmony_ci struct hv_x64_table_register gdtr; 76962306a36Sopenharmony_ci 77062306a36Sopenharmony_ci u64 efer; 77162306a36Sopenharmony_ci u64 cr0; 77262306a36Sopenharmony_ci u64 cr3; 77362306a36Sopenharmony_ci u64 cr4; 77462306a36Sopenharmony_ci u64 msr_cr_pat; 77562306a36Sopenharmony_ci} __packed; 77662306a36Sopenharmony_ci 77762306a36Sopenharmony_ciunion hv_input_vtl { 77862306a36Sopenharmony_ci u8 as_uint8; 77962306a36Sopenharmony_ci struct { 78062306a36Sopenharmony_ci u8 target_vtl: 4; 78162306a36Sopenharmony_ci u8 use_target_vtl: 1; 78262306a36Sopenharmony_ci u8 reserved_z: 3; 78362306a36Sopenharmony_ci }; 78462306a36Sopenharmony_ci} __packed; 78562306a36Sopenharmony_ci 78662306a36Sopenharmony_cistruct hv_enable_vp_vtl { 78762306a36Sopenharmony_ci u64 partition_id; 78862306a36Sopenharmony_ci u32 vp_index; 78962306a36Sopenharmony_ci union hv_input_vtl target_vtl; 79062306a36Sopenharmony_ci u8 mbz0; 79162306a36Sopenharmony_ci u16 mbz1; 79262306a36Sopenharmony_ci struct hv_init_vp_context vp_context; 79362306a36Sopenharmony_ci} __packed; 79462306a36Sopenharmony_ci 79562306a36Sopenharmony_cistruct hv_get_vp_from_apic_id_in { 79662306a36Sopenharmony_ci u64 partition_id; 79762306a36Sopenharmony_ci union hv_input_vtl target_vtl; 79862306a36Sopenharmony_ci u8 res[7]; 79962306a36Sopenharmony_ci u32 apic_ids[]; 80062306a36Sopenharmony_ci} __packed; 80162306a36Sopenharmony_ci 80262306a36Sopenharmony_ci#include <asm-generic/hyperv-tlfs.h> 80362306a36Sopenharmony_ci 80462306a36Sopenharmony_ci#endif 805