Greg Kroah-Hartman | 6f52b16 | 2017-11-01 15:08:43 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ |
Vitaly Kuznetsov | 5a48580 | 2018-03-20 15:02:05 +0100 | [diff] [blame] | 2 | |
| 3 | /* |
| 4 | * This file contains definitions from Hyper-V Hypervisor Top-Level Functional |
| 5 | * Specification (TLFS): |
| 6 | * https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/reference/tlfs |
| 7 | */ |
| 8 | |
| 9 | #ifndef _ASM_X86_HYPERV_TLFS_H |
| 10 | #define _ASM_X86_HYPERV_TLFS_H |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 11 | |
| 12 | #include <linux/types.h> |
| 13 | |
| 14 | /* |
| 15 | * The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent |
| 16 | * is set by CPUID(HvCpuIdFunctionVersionAndFeatures). |
| 17 | */ |
| 18 | #define HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS 0x40000000 |
| 19 | #define HYPERV_CPUID_INTERFACE 0x40000001 |
| 20 | #define HYPERV_CPUID_VERSION 0x40000002 |
| 21 | #define HYPERV_CPUID_FEATURES 0x40000003 |
| 22 | #define HYPERV_CPUID_ENLIGHTMENT_INFO 0x40000004 |
| 23 | #define HYPERV_CPUID_IMPLEMENT_LIMITS 0x40000005 |
Vitaly Kuznetsov | 5431390b | 2018-03-20 15:02:10 +0100 | [diff] [blame] | 24 | #define HYPERV_CPUID_NESTED_FEATURES 0x4000000A |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 25 | |
Ky Srinivasan | a2a47c6 | 2010-05-06 12:08:41 -0700 | [diff] [blame] | 26 | #define HYPERV_HYPERVISOR_PRESENT_BIT 0x80000000 |
| 27 | #define HYPERV_CPUID_MIN 0x40000005 |
H. Peter Anvin | e08cae4 | 2010-05-07 16:57:28 -0700 | [diff] [blame] | 28 | #define HYPERV_CPUID_MAX 0x4000ffff |
Ky Srinivasan | a2a47c6 | 2010-05-06 12:08:41 -0700 | [diff] [blame] | 29 | |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 30 | /* |
| 31 | * Feature identification. EAX indicates which features are available |
| 32 | * to the partition based upon the current partition privileges. |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 33 | * These are HYPERV_CPUID_FEATURES.EAX bits. |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 34 | */ |
| 35 | |
| 36 | /* VP Runtime (HV_X64_MSR_VP_RUNTIME) available */ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 37 | #define HV_X64_MSR_VP_RUNTIME_AVAILABLE BIT(0) |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 38 | /* Partition Reference Counter (HV_X64_MSR_TIME_REF_COUNT) available*/ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 39 | #define HV_MSR_TIME_REF_COUNT_AVAILABLE BIT(1) |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 40 | /* |
| 41 | * Basic SynIC MSRs (HV_X64_MSR_SCONTROL through HV_X64_MSR_EOM |
| 42 | * and HV_X64_MSR_SINT0 through HV_X64_MSR_SINT15) available |
| 43 | */ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 44 | #define HV_X64_MSR_SYNIC_AVAILABLE BIT(2) |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 45 | /* |
| 46 | * Synthetic Timer MSRs (HV_X64_MSR_STIMER0_CONFIG through |
| 47 | * HV_X64_MSR_STIMER3_COUNT) available |
| 48 | */ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 49 | #define HV_MSR_SYNTIMER_AVAILABLE BIT(3) |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 50 | /* |
| 51 | * APIC access MSRs (HV_X64_MSR_EOI, HV_X64_MSR_ICR and HV_X64_MSR_TPR) |
| 52 | * are available |
| 53 | */ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 54 | #define HV_X64_MSR_APIC_ACCESS_AVAILABLE BIT(4) |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 55 | /* Hypercall MSRs (HV_X64_MSR_GUEST_OS_ID and HV_X64_MSR_HYPERCALL) available*/ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 56 | #define HV_X64_MSR_HYPERCALL_AVAILABLE BIT(5) |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 57 | /* Access virtual processor index MSR (HV_X64_MSR_VP_INDEX) available*/ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 58 | #define HV_X64_MSR_VP_INDEX_AVAILABLE BIT(6) |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 59 | /* Virtual system reset MSR (HV_X64_MSR_RESET) is available*/ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 60 | #define HV_X64_MSR_RESET_AVAILABLE BIT(7) |
| 61 | /* |
| 62 | * Access statistics pages MSRs (HV_X64_MSR_STATS_PARTITION_RETAIL_PAGE, |
| 63 | * HV_X64_MSR_STATS_PARTITION_INTERNAL_PAGE, HV_X64_MSR_STATS_VP_RETAIL_PAGE, |
| 64 | * HV_X64_MSR_STATS_VP_INTERNAL_PAGE) available |
| 65 | */ |
| 66 | #define HV_X64_MSR_STAT_PAGES_AVAILABLE BIT(8) |
| 67 | /* Partition reference TSC MSR is available */ |
| 68 | #define HV_MSR_REFERENCE_TSC_AVAILABLE BIT(9) |
| 69 | /* Partition Guest IDLE MSR is available */ |
| 70 | #define HV_X64_MSR_GUEST_IDLE_AVAILABLE BIT(10) |
| 71 | /* |
| 72 | * There is a single feature flag that signifies if the partition has access |
| 73 | * to MSRs with local APIC and TSC frequencies. |
| 74 | */ |
| 75 | #define HV_X64_ACCESS_FREQUENCY_MSRS BIT(11) |
| 76 | /* AccessReenlightenmentControls privilege */ |
| 77 | #define HV_X64_ACCESS_REENLIGHTENMENT BIT(13) |
Michael Kelley | 248e742 | 2018-03-04 22:17:18 -0700 | [diff] [blame] | 78 | |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 79 | /* |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 80 | * Feature identification: indicates which flags were specified at partition |
| 81 | * creation. The format is the same as the partition creation flag structure |
| 82 | * defined in section Partition Creation Flags. |
| 83 | * These are HYPERV_CPUID_FEATURES.EBX bits. |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 84 | */ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 85 | #define HV_X64_CREATE_PARTITIONS BIT(0) |
| 86 | #define HV_X64_ACCESS_PARTITION_ID BIT(1) |
| 87 | #define HV_X64_ACCESS_MEMORY_POOL BIT(2) |
| 88 | #define HV_X64_ADJUST_MESSAGE_BUFFERS BIT(3) |
| 89 | #define HV_X64_POST_MESSAGES BIT(4) |
| 90 | #define HV_X64_SIGNAL_EVENTS BIT(5) |
| 91 | #define HV_X64_CREATE_PORT BIT(6) |
| 92 | #define HV_X64_CONNECT_PORT BIT(7) |
| 93 | #define HV_X64_ACCESS_STATS BIT(8) |
| 94 | #define HV_X64_DEBUGGING BIT(11) |
| 95 | #define HV_X64_CPU_POWER_MANAGEMENT BIT(12) |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 96 | |
| 97 | /* |
| 98 | * Feature identification. EDX indicates which miscellaneous features |
| 99 | * are available to the partition. |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 100 | * These are HYPERV_CPUID_FEATURES.EDX bits. |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 101 | */ |
| 102 | /* The MWAIT instruction is available (per section MONITOR / MWAIT) */ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 103 | #define HV_X64_MWAIT_AVAILABLE BIT(0) |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 104 | /* Guest debugging support is available */ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 105 | #define HV_X64_GUEST_DEBUGGING_AVAILABLE BIT(1) |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 106 | /* Performance Monitor support is available*/ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 107 | #define HV_X64_PERF_MONITOR_AVAILABLE BIT(2) |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 108 | /* Support for physical CPU dynamic partitioning events is available*/ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 109 | #define HV_X64_CPU_DYNAMIC_PARTITIONING_AVAILABLE BIT(3) |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 110 | /* |
| 111 | * Support for passing hypercall input parameter block via XMM |
| 112 | * registers is available |
| 113 | */ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 114 | #define HV_X64_HYPERCALL_PARAMS_XMM_AVAILABLE BIT(4) |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 115 | /* Support for a virtual guest idle state is available */ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 116 | #define HV_X64_GUEST_IDLE_STATE_AVAILABLE BIT(5) |
| 117 | /* Frequency MSRs available */ |
| 118 | #define HV_FEATURE_FREQUENCY_MSRS_AVAILABLE BIT(8) |
| 119 | /* Crash MSR available */ |
| 120 | #define HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE BIT(10) |
| 121 | /* stimer Direct Mode is available */ |
| 122 | #define HV_STIMER_DIRECT_MODE_AVAILABLE BIT(19) |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 123 | |
| 124 | /* |
| 125 | * Implementation recommendations. Indicates which behaviors the hypervisor |
| 126 | * recommends the OS implement for optimal performance. |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 127 | * These are HYPERV_CPUID_ENLIGHTMENT_INFO.EAX bits. |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 128 | */ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 129 | /* |
| 130 | * Recommend using hypercall for address space switches rather |
| 131 | * than MOV to CR3 instruction |
| 132 | */ |
| 133 | #define HV_X64_AS_SWITCH_RECOMMENDED BIT(0) |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 134 | /* Recommend using hypercall for local TLB flushes rather |
| 135 | * than INVLPG or MOV to CR3 instructions */ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 136 | #define HV_X64_LOCAL_TLB_FLUSH_RECOMMENDED BIT(1) |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 137 | /* |
| 138 | * Recommend using hypercall for remote TLB flushes rather |
| 139 | * than inter-processor interrupts |
| 140 | */ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 141 | #define HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED BIT(2) |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 142 | /* |
| 143 | * Recommend using MSRs for accessing APIC registers |
| 144 | * EOI, ICR and TPR rather than their memory-mapped counterparts |
| 145 | */ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 146 | #define HV_X64_APIC_ACCESS_RECOMMENDED BIT(3) |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 147 | /* Recommend using the hypervisor-provided MSR to initiate a system RESET */ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 148 | #define HV_X64_SYSTEM_RESET_RECOMMENDED BIT(4) |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 149 | /* |
| 150 | * Recommend using relaxed timing for this partition. If used, |
| 151 | * the VM should disable any watchdog timeouts that rely on the |
| 152 | * timely delivery of external interrupts |
| 153 | */ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 154 | #define HV_X64_RELAXED_TIMING_RECOMMENDED BIT(5) |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 155 | |
K. Y. Srinivasan | d058fa7 | 2017-01-19 11:51:48 -0700 | [diff] [blame] | 156 | /* |
Michael Kelley | 7dc9b6b | 2018-06-05 13:37:54 -0700 | [diff] [blame] | 157 | * Recommend not using Auto End-Of-Interrupt feature |
K. Y. Srinivasan | 6c248aa | 2017-03-14 18:01:39 -0700 | [diff] [blame] | 158 | */ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 159 | #define HV_DEPRECATING_AEOI_RECOMMENDED BIT(9) |
K. Y. Srinivasan | 6c248aa | 2017-03-14 18:01:39 -0700 | [diff] [blame] | 160 | |
K. Y. Srinivasan | 68bb7bf | 2018-05-16 14:53:31 -0700 | [diff] [blame] | 161 | /* |
| 162 | * Recommend using cluster IPI hypercalls. |
| 163 | */ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 164 | #define HV_X64_CLUSTER_IPI_RECOMMENDED BIT(10) |
K. Y. Srinivasan | 68bb7bf | 2018-05-16 14:53:31 -0700 | [diff] [blame] | 165 | |
Vitaly Kuznetsov | 628f54c | 2017-08-02 18:09:20 +0200 | [diff] [blame] | 166 | /* Recommend using the newer ExProcessorMasks interface */ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 167 | #define HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED BIT(11) |
Vitaly Kuznetsov | 628f54c | 2017-08-02 18:09:20 +0200 | [diff] [blame] | 168 | |
Vitaly Kuznetsov | a46d15c | 2018-03-20 15:02:08 +0100 | [diff] [blame] | 169 | /* Recommend using enlightened VMCS */ |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 170 | #define HV_X64_ENLIGHTENED_VMCS_RECOMMENDED BIT(14) |
Vitaly Kuznetsov | a46d15c | 2018-03-20 15:02:08 +0100 | [diff] [blame] | 171 | |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 172 | /* Nested features. These are HYPERV_CPUID_NESTED_FEATURES.EAX bits. */ |
| 173 | #define HV_X64_NESTED_GUEST_MAPPING_FLUSH BIT(18) |
| 174 | #define HV_X64_NESTED_MSR_BITMAP BIT(19) |
| 175 | |
| 176 | /* Hyper-V specific model specific registers (MSRs) */ |
K. Y. Srinivasan | d058fa7 | 2017-01-19 11:51:48 -0700 | [diff] [blame] | 177 | |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 178 | /* MSR used to identify the guest OS. */ |
| 179 | #define HV_X64_MSR_GUEST_OS_ID 0x40000000 |
| 180 | |
| 181 | /* MSR used to setup pages used to communicate with the hypervisor. */ |
| 182 | #define HV_X64_MSR_HYPERCALL 0x40000001 |
| 183 | |
| 184 | /* MSR used to provide vcpu index */ |
| 185 | #define HV_X64_MSR_VP_INDEX 0x40000002 |
| 186 | |
Andrey Smetanin | e516ceb | 2015-09-16 12:29:48 +0300 | [diff] [blame] | 187 | /* MSR used to reset the guest OS. */ |
| 188 | #define HV_X64_MSR_RESET 0x40000003 |
| 189 | |
Andrey Smetanin | 9eec50b | 2015-09-16 12:29:50 +0300 | [diff] [blame] | 190 | /* MSR used to provide vcpu runtime in 100ns units */ |
| 191 | #define HV_X64_MSR_VP_RUNTIME 0x40000010 |
| 192 | |
Ky Srinivasan | a2a47c6 | 2010-05-06 12:08:41 -0700 | [diff] [blame] | 193 | /* MSR used to read the per-partition time reference counter */ |
| 194 | #define HV_X64_MSR_TIME_REF_COUNT 0x40000020 |
| 195 | |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 196 | /* A partition's reference time stamp counter (TSC) page */ |
| 197 | #define HV_X64_MSR_REFERENCE_TSC 0x40000021 |
| 198 | |
K. Y. Srinivasan | 9e7827b | 2013-09-30 17:28:52 +0200 | [diff] [blame] | 199 | /* MSR used to retrieve the TSC frequency */ |
| 200 | #define HV_X64_MSR_TSC_FREQUENCY 0x40000022 |
| 201 | |
| 202 | /* MSR used to retrieve the local APIC timer frequency */ |
| 203 | #define HV_X64_MSR_APIC_FREQUENCY 0x40000023 |
| 204 | |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 205 | /* Define the virtual APIC registers */ |
| 206 | #define HV_X64_MSR_EOI 0x40000070 |
| 207 | #define HV_X64_MSR_ICR 0x40000071 |
| 208 | #define HV_X64_MSR_TPR 0x40000072 |
Ladi Prosek | d4abc57 | 2018-03-20 15:02:07 +0100 | [diff] [blame] | 209 | #define HV_X64_MSR_VP_ASSIST_PAGE 0x40000073 |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 210 | |
| 211 | /* Define synthetic interrupt controller model specific registers. */ |
| 212 | #define HV_X64_MSR_SCONTROL 0x40000080 |
| 213 | #define HV_X64_MSR_SVERSION 0x40000081 |
| 214 | #define HV_X64_MSR_SIEFP 0x40000082 |
| 215 | #define HV_X64_MSR_SIMP 0x40000083 |
| 216 | #define HV_X64_MSR_EOM 0x40000084 |
| 217 | #define HV_X64_MSR_SINT0 0x40000090 |
| 218 | #define HV_X64_MSR_SINT1 0x40000091 |
| 219 | #define HV_X64_MSR_SINT2 0x40000092 |
| 220 | #define HV_X64_MSR_SINT3 0x40000093 |
| 221 | #define HV_X64_MSR_SINT4 0x40000094 |
| 222 | #define HV_X64_MSR_SINT5 0x40000095 |
| 223 | #define HV_X64_MSR_SINT6 0x40000096 |
| 224 | #define HV_X64_MSR_SINT7 0x40000097 |
| 225 | #define HV_X64_MSR_SINT8 0x40000098 |
| 226 | #define HV_X64_MSR_SINT9 0x40000099 |
| 227 | #define HV_X64_MSR_SINT10 0x4000009A |
| 228 | #define HV_X64_MSR_SINT11 0x4000009B |
| 229 | #define HV_X64_MSR_SINT12 0x4000009C |
| 230 | #define HV_X64_MSR_SINT13 0x4000009D |
| 231 | #define HV_X64_MSR_SINT14 0x4000009E |
| 232 | #define HV_X64_MSR_SINT15 0x4000009F |
| 233 | |
K. Y. Srinivasan | 4061ed9 | 2015-01-09 23:54:32 -0800 | [diff] [blame] | 234 | /* |
| 235 | * Synthetic Timer MSRs. Four timers per vcpu. |
| 236 | */ |
| 237 | #define HV_X64_MSR_STIMER0_CONFIG 0x400000B0 |
| 238 | #define HV_X64_MSR_STIMER0_COUNT 0x400000B1 |
| 239 | #define HV_X64_MSR_STIMER1_CONFIG 0x400000B2 |
| 240 | #define HV_X64_MSR_STIMER1_COUNT 0x400000B3 |
| 241 | #define HV_X64_MSR_STIMER2_CONFIG 0x400000B4 |
| 242 | #define HV_X64_MSR_STIMER2_COUNT 0x400000B5 |
| 243 | #define HV_X64_MSR_STIMER3_CONFIG 0x400000B6 |
| 244 | #define HV_X64_MSR_STIMER3_COUNT 0x400000B7 |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 245 | |
Yi Sun | f726c46 | 2018-09-27 14:01:43 +0800 | [diff] [blame] | 246 | /* Hyper-V guest idle MSR */ |
| 247 | #define HV_X64_MSR_GUEST_IDLE 0x400000F0 |
| 248 | |
Andrey Smetanin | a88464a | 2015-07-02 19:07:46 +0300 | [diff] [blame] | 249 | /* Hyper-V guest crash notification MSR's */ |
| 250 | #define HV_X64_MSR_CRASH_P0 0x40000100 |
| 251 | #define HV_X64_MSR_CRASH_P1 0x40000101 |
| 252 | #define HV_X64_MSR_CRASH_P2 0x40000102 |
| 253 | #define HV_X64_MSR_CRASH_P3 0x40000103 |
| 254 | #define HV_X64_MSR_CRASH_P4 0x40000104 |
| 255 | #define HV_X64_MSR_CRASH_CTL 0x40000105 |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 256 | |
| 257 | /* TSC emulation after migration */ |
| 258 | #define HV_X64_MSR_REENLIGHTENMENT_CONTROL 0x40000106 |
| 259 | #define HV_X64_MSR_TSC_EMULATION_CONTROL 0x40000107 |
| 260 | #define HV_X64_MSR_TSC_EMULATION_STATUS 0x40000108 |
Andrey Smetanin | a88464a | 2015-07-02 19:07:46 +0300 | [diff] [blame] | 261 | |
Vitaly Kuznetsov | 415bd1c | 2018-03-20 15:02:06 +0100 | [diff] [blame] | 262 | /* |
| 263 | * Declare the MSR used to setup pages used to communicate with the hypervisor. |
| 264 | */ |
| 265 | union hv_x64_msr_hypercall_contents { |
| 266 | u64 as_uint64; |
| 267 | struct { |
| 268 | u64 enable:1; |
| 269 | u64 reserved:11; |
| 270 | u64 guest_physical_address:52; |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 271 | } __packed; |
Vitaly Kuznetsov | 415bd1c | 2018-03-20 15:02:06 +0100 | [diff] [blame] | 272 | }; |
| 273 | |
| 274 | /* |
| 275 | * TSC page layout. |
| 276 | */ |
| 277 | struct ms_hyperv_tsc_page { |
| 278 | volatile u32 tsc_sequence; |
| 279 | u32 reserved1; |
| 280 | volatile u64 tsc_scale; |
| 281 | volatile s64 tsc_offset; |
| 282 | u64 reserved2[509]; |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 283 | } __packed; |
Vitaly Kuznetsov | 415bd1c | 2018-03-20 15:02:06 +0100 | [diff] [blame] | 284 | |
| 285 | /* |
| 286 | * The guest OS needs to register the guest ID with the hypervisor. |
| 287 | * The guest ID is a 64 bit entity and the structure of this ID is |
| 288 | * specified in the Hyper-V specification: |
| 289 | * |
| 290 | * msdn.microsoft.com/en-us/library/windows/hardware/ff542653%28v=vs.85%29.aspx |
| 291 | * |
| 292 | * While the current guideline does not specify how Linux guest ID(s) |
| 293 | * need to be generated, our plan is to publish the guidelines for |
| 294 | * Linux and other guest operating systems that currently are hosted |
| 295 | * on Hyper-V. The implementation here conforms to this yet |
| 296 | * unpublished guidelines. |
| 297 | * |
| 298 | * |
| 299 | * Bit(s) |
| 300 | * 63 - Indicates if the OS is Open Source or not; 1 is Open Source |
| 301 | * 62:56 - Os Type; Linux is 0x100 |
| 302 | * 55:48 - Distro specific identification |
| 303 | * 47:16 - Linux kernel version number |
| 304 | * 15:0 - Distro specific identification |
| 305 | * |
| 306 | * |
| 307 | */ |
| 308 | |
| 309 | #define HV_LINUX_VENDOR_ID 0x8100 |
| 310 | |
Vitaly Kuznetsov | 9328626 | 2018-01-24 14:23:33 +0100 | [diff] [blame] | 311 | struct hv_reenlightenment_control { |
KarimAllah Ahmed | 8942664 | 2018-02-20 08:39:51 +0100 | [diff] [blame] | 312 | __u64 vector:8; |
| 313 | __u64 reserved1:8; |
| 314 | __u64 enabled:1; |
| 315 | __u64 reserved2:15; |
| 316 | __u64 target_vp:32; |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 317 | } __packed; |
Vitaly Kuznetsov | 9328626 | 2018-01-24 14:23:33 +0100 | [diff] [blame] | 318 | |
Vitaly Kuznetsov | 9328626 | 2018-01-24 14:23:33 +0100 | [diff] [blame] | 319 | struct hv_tsc_emulation_control { |
KarimAllah Ahmed | 8942664 | 2018-02-20 08:39:51 +0100 | [diff] [blame] | 320 | __u64 enabled:1; |
| 321 | __u64 reserved:63; |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 322 | } __packed; |
Vitaly Kuznetsov | 9328626 | 2018-01-24 14:23:33 +0100 | [diff] [blame] | 323 | |
| 324 | struct hv_tsc_emulation_status { |
KarimAllah Ahmed | 8942664 | 2018-02-20 08:39:51 +0100 | [diff] [blame] | 325 | __u64 inprogress:1; |
| 326 | __u64 reserved:63; |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 327 | } __packed; |
Vitaly Kuznetsov | 9328626 | 2018-01-24 14:23:33 +0100 | [diff] [blame] | 328 | |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 329 | #define HV_X64_MSR_HYPERCALL_ENABLE 0x00000001 |
| 330 | #define HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT 12 |
| 331 | #define HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_MASK \ |
| 332 | (~((1ull << HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT) - 1)) |
| 333 | |
Vitaly Kuznetsov | a4987de | 2018-12-10 18:21:53 +0100 | [diff] [blame] | 334 | /* |
| 335 | * Crash notification (HV_X64_MSR_CRASH_CTL) flags. |
| 336 | */ |
| 337 | #define HV_CRASH_CTL_CRASH_NOTIFY_MSG BIT_ULL(62) |
| 338 | #define HV_CRASH_CTL_CRASH_NOTIFY BIT_ULL(63) |
| 339 | #define HV_X64_MSR_CRASH_PARAMS \ |
| 340 | (1 + (HV_X64_MSR_CRASH_P4 - HV_X64_MSR_CRASH_P0)) |
| 341 | |
K. Y. Srinivasan | 68bb7bf | 2018-05-16 14:53:31 -0700 | [diff] [blame] | 342 | #define HV_IPI_LOW_VECTOR 0x10 |
| 343 | #define HV_IPI_HIGH_VECTOR 0xff |
| 344 | |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 345 | /* Declare the various hypercall operations. */ |
Vitaly Kuznetsov | 2ffd9e3 | 2017-08-02 18:09:19 +0200 | [diff] [blame] | 346 | #define HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE 0x0002 |
| 347 | #define HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST 0x0003 |
Andrey Smetanin | 8ed6d76 | 2016-02-11 16:44:57 +0300 | [diff] [blame] | 348 | #define HVCALL_NOTIFY_LONG_SPIN_WAIT 0x0008 |
K. Y. Srinivasan | 68bb7bf | 2018-05-16 14:53:31 -0700 | [diff] [blame] | 349 | #define HVCALL_SEND_IPI 0x000b |
Vitaly Kuznetsov | 628f54c | 2017-08-02 18:09:20 +0200 | [diff] [blame] | 350 | #define HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX 0x0013 |
| 351 | #define HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST_EX 0x0014 |
K. Y. Srinivasan | 366f03b | 2018-05-16 14:53:32 -0700 | [diff] [blame] | 352 | #define HVCALL_SEND_IPI_EX 0x0015 |
Andrey Smetanin | 18f0986 | 2016-02-11 16:44:58 +0300 | [diff] [blame] | 353 | #define HVCALL_POST_MESSAGE 0x005c |
| 354 | #define HVCALL_SIGNAL_EVENT 0x005d |
Tianyu Lan | eb914cf | 2018-07-19 08:40:06 +0000 | [diff] [blame] | 355 | #define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE 0x00af |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 356 | |
Ladi Prosek | d4abc57 | 2018-03-20 15:02:07 +0100 | [diff] [blame] | 357 | #define HV_X64_MSR_VP_ASSIST_PAGE_ENABLE 0x00000001 |
| 358 | #define HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_SHIFT 12 |
| 359 | #define HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_MASK \ |
| 360 | (~((1ull << HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_SHIFT) - 1)) |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 361 | |
Vitaly Kuznetsov | 5431390b | 2018-03-20 15:02:10 +0100 | [diff] [blame] | 362 | /* Hyper-V Enlightened VMCS version mask in nested features CPUID */ |
| 363 | #define HV_X64_ENLIGHTENED_VMCS_VERSION 0xff |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 364 | |
Vadim Rozenfeld | e984097 | 2014-01-16 20:18:37 +1100 | [diff] [blame] | 365 | #define HV_X64_MSR_TSC_REFERENCE_ENABLE 0x00000001 |
| 366 | #define HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT 12 |
| 367 | |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 368 | #define HV_PROCESSOR_POWER_STATE_C0 0 |
| 369 | #define HV_PROCESSOR_POWER_STATE_C1 1 |
| 370 | #define HV_PROCESSOR_POWER_STATE_C2 2 |
| 371 | #define HV_PROCESSOR_POWER_STATE_C3 3 |
| 372 | |
Vitaly Kuznetsov | 2ffd9e3 | 2017-08-02 18:09:19 +0200 | [diff] [blame] | 373 | #define HV_FLUSH_ALL_PROCESSORS BIT(0) |
| 374 | #define HV_FLUSH_ALL_VIRTUAL_ADDRESS_SPACES BIT(1) |
| 375 | #define HV_FLUSH_NON_GLOBAL_MAPPINGS_ONLY BIT(2) |
| 376 | #define HV_FLUSH_USE_EXTENDED_RANGE_FORMAT BIT(3) |
| 377 | |
Vitaly Kuznetsov | 628f54c | 2017-08-02 18:09:20 +0200 | [diff] [blame] | 378 | enum HV_GENERIC_SET_FORMAT { |
K. Y. Srinivasan | 366f03b | 2018-05-16 14:53:32 -0700 | [diff] [blame] | 379 | HV_GENERIC_SET_SPARSE_4K, |
Vitaly Kuznetsov | 628f54c | 2017-08-02 18:09:20 +0200 | [diff] [blame] | 380 | HV_GENERIC_SET_ALL, |
| 381 | }; |
| 382 | |
Vitaly Kuznetsov | 415bd1c | 2018-03-20 15:02:06 +0100 | [diff] [blame] | 383 | #define HV_HYPERCALL_RESULT_MASK GENMASK_ULL(15, 0) |
| 384 | #define HV_HYPERCALL_FAST_BIT BIT(16) |
| 385 | #define HV_HYPERCALL_VARHEAD_OFFSET 17 |
| 386 | #define HV_HYPERCALL_REP_COMP_OFFSET 32 |
| 387 | #define HV_HYPERCALL_REP_COMP_MASK GENMASK_ULL(43, 32) |
| 388 | #define HV_HYPERCALL_REP_START_OFFSET 48 |
| 389 | #define HV_HYPERCALL_REP_START_MASK GENMASK_ULL(59, 48) |
| 390 | |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 391 | /* hypercall status code */ |
| 392 | #define HV_STATUS_SUCCESS 0 |
| 393 | #define HV_STATUS_INVALID_HYPERCALL_CODE 2 |
| 394 | #define HV_STATUS_INVALID_HYPERCALL_INPUT 3 |
| 395 | #define HV_STATUS_INVALID_ALIGNMENT 4 |
Roman Kagan | faeb783 | 2018-02-01 16:48:32 +0300 | [diff] [blame] | 396 | #define HV_STATUS_INVALID_PARAMETER 5 |
Dexuan Cui | 89f9f67 | 2015-02-27 11:25:59 -0800 | [diff] [blame] | 397 | #define HV_STATUS_INSUFFICIENT_MEMORY 11 |
Roman Kagan | faeb783 | 2018-02-01 16:48:32 +0300 | [diff] [blame] | 398 | #define HV_STATUS_INVALID_PORT_ID 17 |
Dexuan Cui | 89f9f67 | 2015-02-27 11:25:59 -0800 | [diff] [blame] | 399 | #define HV_STATUS_INVALID_CONNECTION_ID 18 |
K. Y. Srinivasan | 5289d3d | 2011-08-25 09:49:01 -0700 | [diff] [blame] | 400 | #define HV_STATUS_INSUFFICIENT_BUFFERS 19 |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 401 | |
Vadim Rozenfeld | e984097 | 2014-01-16 20:18:37 +1100 | [diff] [blame] | 402 | typedef struct _HV_REFERENCE_TSC_PAGE { |
| 403 | __u32 tsc_sequence; |
| 404 | __u32 res1; |
| 405 | __u64 tsc_scale; |
| 406 | __s64 tsc_offset; |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 407 | } __packed HV_REFERENCE_TSC_PAGE, *PHV_REFERENCE_TSC_PAGE; |
Vadim Rozenfeld | e984097 | 2014-01-16 20:18:37 +1100 | [diff] [blame] | 408 | |
Andrey Smetanin | c75efa9 | 2015-10-16 10:07:50 +0300 | [diff] [blame] | 409 | /* Define the number of synthetic interrupt sources. */ |
| 410 | #define HV_SYNIC_SINT_COUNT (16) |
| 411 | /* Define the expected SynIC version. */ |
| 412 | #define HV_SYNIC_VERSION_1 (0x1) |
Vitaly Kuznetsov | 98f65ad | 2018-03-01 15:15:13 +0100 | [diff] [blame] | 413 | /* Valid SynIC vectors are 16-255. */ |
| 414 | #define HV_SYNIC_FIRST_VALID_VECTOR (16) |
Andrey Smetanin | c75efa9 | 2015-10-16 10:07:50 +0300 | [diff] [blame] | 415 | |
| 416 | #define HV_SYNIC_CONTROL_ENABLE (1ULL << 0) |
| 417 | #define HV_SYNIC_SIMP_ENABLE (1ULL << 0) |
| 418 | #define HV_SYNIC_SIEFP_ENABLE (1ULL << 0) |
| 419 | #define HV_SYNIC_SINT_MASKED (1ULL << 16) |
| 420 | #define HV_SYNIC_SINT_AUTO_EOI (1ULL << 17) |
| 421 | #define HV_SYNIC_SINT_VECTOR_MASK (0xFF) |
| 422 | |
Andrey Smetanin | 4f39bcf | 2015-11-30 19:22:14 +0300 | [diff] [blame] | 423 | #define HV_SYNIC_STIMER_COUNT (4) |
| 424 | |
Andrey Smetanin | 5b423ef | 2015-11-30 19:22:15 +0300 | [diff] [blame] | 425 | /* Define synthetic interrupt controller message constants. */ |
| 426 | #define HV_MESSAGE_SIZE (256) |
| 427 | #define HV_MESSAGE_PAYLOAD_BYTE_COUNT (240) |
| 428 | #define HV_MESSAGE_PAYLOAD_QWORD_COUNT (30) |
| 429 | |
| 430 | /* Define hypervisor message types. */ |
| 431 | enum hv_message_type { |
| 432 | HVMSG_NONE = 0x00000000, |
| 433 | |
| 434 | /* Memory access messages. */ |
| 435 | HVMSG_UNMAPPED_GPA = 0x80000000, |
| 436 | HVMSG_GPA_INTERCEPT = 0x80000001, |
| 437 | |
| 438 | /* Timer notification messages. */ |
| 439 | HVMSG_TIMER_EXPIRED = 0x80000010, |
| 440 | |
| 441 | /* Error messages. */ |
| 442 | HVMSG_INVALID_VP_REGISTER_VALUE = 0x80000020, |
| 443 | HVMSG_UNRECOVERABLE_EXCEPTION = 0x80000021, |
| 444 | HVMSG_UNSUPPORTED_FEATURE = 0x80000022, |
| 445 | |
| 446 | /* Trace buffer complete messages. */ |
| 447 | HVMSG_EVENTLOG_BUFFERCOMPLETE = 0x80000040, |
| 448 | |
| 449 | /* Platform-specific processor intercept messages. */ |
| 450 | HVMSG_X64_IOPORT_INTERCEPT = 0x80010000, |
| 451 | HVMSG_X64_MSR_INTERCEPT = 0x80010001, |
| 452 | HVMSG_X64_CPUID_INTERCEPT = 0x80010002, |
| 453 | HVMSG_X64_EXCEPTION_INTERCEPT = 0x80010003, |
| 454 | HVMSG_X64_APIC_EOI = 0x80010004, |
| 455 | HVMSG_X64_LEGACY_FP_ERROR = 0x80010005 |
| 456 | }; |
| 457 | |
| 458 | /* Define synthetic interrupt controller message flags. */ |
| 459 | union hv_message_flags { |
| 460 | __u8 asu8; |
| 461 | struct { |
| 462 | __u8 msg_pending:1; |
| 463 | __u8 reserved:7; |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 464 | } __packed; |
Andrey Smetanin | 5b423ef | 2015-11-30 19:22:15 +0300 | [diff] [blame] | 465 | }; |
| 466 | |
| 467 | /* Define port identifier type. */ |
| 468 | union hv_port_id { |
| 469 | __u32 asu32; |
| 470 | struct { |
| 471 | __u32 id:24; |
| 472 | __u32 reserved:8; |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 473 | } __packed u; |
Andrey Smetanin | 5b423ef | 2015-11-30 19:22:15 +0300 | [diff] [blame] | 474 | }; |
| 475 | |
| 476 | /* Define synthetic interrupt controller message header. */ |
| 477 | struct hv_message_header { |
| 478 | __u32 message_type; |
| 479 | __u8 payload_size; |
| 480 | union hv_message_flags message_flags; |
| 481 | __u8 reserved[2]; |
| 482 | union { |
| 483 | __u64 sender; |
| 484 | union hv_port_id port; |
| 485 | }; |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 486 | } __packed; |
Andrey Smetanin | 5b423ef | 2015-11-30 19:22:15 +0300 | [diff] [blame] | 487 | |
| 488 | /* Define synthetic interrupt controller message format. */ |
| 489 | struct hv_message { |
| 490 | struct hv_message_header header; |
| 491 | union { |
| 492 | __u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT]; |
| 493 | } u; |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 494 | } __packed; |
Andrey Smetanin | 5b423ef | 2015-11-30 19:22:15 +0300 | [diff] [blame] | 495 | |
| 496 | /* Define the synthetic interrupt message page layout. */ |
| 497 | struct hv_message_page { |
| 498 | struct hv_message sint_message[HV_SYNIC_SINT_COUNT]; |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 499 | } __packed; |
Andrey Smetanin | 5b423ef | 2015-11-30 19:22:15 +0300 | [diff] [blame] | 500 | |
Andrey Smetanin | c71acc4 | 2015-11-30 19:22:16 +0300 | [diff] [blame] | 501 | /* Define timer message payload structure. */ |
| 502 | struct hv_timer_message_payload { |
| 503 | __u32 timer_index; |
| 504 | __u32 reserved; |
| 505 | __u64 expiration_time; /* When the timer expired */ |
| 506 | __u64 delivery_time; /* When the message was delivered */ |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 507 | } __packed; |
Andrey Smetanin | c71acc4 | 2015-11-30 19:22:16 +0300 | [diff] [blame] | 508 | |
Vitaly Kuznetsov | a46d15c | 2018-03-20 15:02:08 +0100 | [diff] [blame] | 509 | /* Define virtual processor assist page structure. */ |
| 510 | struct hv_vp_assist_page { |
| 511 | __u32 apic_assist; |
| 512 | __u32 reserved; |
| 513 | __u64 vtl_control[2]; |
| 514 | __u64 nested_enlightenments_control[2]; |
| 515 | __u32 enlighten_vmentry; |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 516 | __u32 padding; |
Vitaly Kuznetsov | a46d15c | 2018-03-20 15:02:08 +0100 | [diff] [blame] | 517 | __u64 current_nested_vmcs; |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 518 | } __packed; |
Vitaly Kuznetsov | a46d15c | 2018-03-20 15:02:08 +0100 | [diff] [blame] | 519 | |
Vitaly Kuznetsov | 68d1eb7 | 2018-03-20 15:02:09 +0100 | [diff] [blame] | 520 | struct hv_enlightened_vmcs { |
| 521 | u32 revision_id; |
| 522 | u32 abort; |
| 523 | |
| 524 | u16 host_es_selector; |
| 525 | u16 host_cs_selector; |
| 526 | u16 host_ss_selector; |
| 527 | u16 host_ds_selector; |
| 528 | u16 host_fs_selector; |
| 529 | u16 host_gs_selector; |
| 530 | u16 host_tr_selector; |
| 531 | |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 532 | u16 padding16_1; |
| 533 | |
Vitaly Kuznetsov | 68d1eb7 | 2018-03-20 15:02:09 +0100 | [diff] [blame] | 534 | u64 host_ia32_pat; |
| 535 | u64 host_ia32_efer; |
| 536 | |
| 537 | u64 host_cr0; |
| 538 | u64 host_cr3; |
| 539 | u64 host_cr4; |
| 540 | |
| 541 | u64 host_ia32_sysenter_esp; |
| 542 | u64 host_ia32_sysenter_eip; |
| 543 | u64 host_rip; |
| 544 | u32 host_ia32_sysenter_cs; |
| 545 | |
| 546 | u32 pin_based_vm_exec_control; |
| 547 | u32 vm_exit_controls; |
| 548 | u32 secondary_vm_exec_control; |
| 549 | |
| 550 | u64 io_bitmap_a; |
| 551 | u64 io_bitmap_b; |
| 552 | u64 msr_bitmap; |
| 553 | |
| 554 | u16 guest_es_selector; |
| 555 | u16 guest_cs_selector; |
| 556 | u16 guest_ss_selector; |
| 557 | u16 guest_ds_selector; |
| 558 | u16 guest_fs_selector; |
| 559 | u16 guest_gs_selector; |
| 560 | u16 guest_ldtr_selector; |
| 561 | u16 guest_tr_selector; |
| 562 | |
| 563 | u32 guest_es_limit; |
| 564 | u32 guest_cs_limit; |
| 565 | u32 guest_ss_limit; |
| 566 | u32 guest_ds_limit; |
| 567 | u32 guest_fs_limit; |
| 568 | u32 guest_gs_limit; |
| 569 | u32 guest_ldtr_limit; |
| 570 | u32 guest_tr_limit; |
| 571 | u32 guest_gdtr_limit; |
| 572 | u32 guest_idtr_limit; |
| 573 | |
| 574 | u32 guest_es_ar_bytes; |
| 575 | u32 guest_cs_ar_bytes; |
| 576 | u32 guest_ss_ar_bytes; |
| 577 | u32 guest_ds_ar_bytes; |
| 578 | u32 guest_fs_ar_bytes; |
| 579 | u32 guest_gs_ar_bytes; |
| 580 | u32 guest_ldtr_ar_bytes; |
| 581 | u32 guest_tr_ar_bytes; |
| 582 | |
| 583 | u64 guest_es_base; |
| 584 | u64 guest_cs_base; |
| 585 | u64 guest_ss_base; |
| 586 | u64 guest_ds_base; |
| 587 | u64 guest_fs_base; |
| 588 | u64 guest_gs_base; |
| 589 | u64 guest_ldtr_base; |
| 590 | u64 guest_tr_base; |
| 591 | u64 guest_gdtr_base; |
| 592 | u64 guest_idtr_base; |
| 593 | |
| 594 | u64 padding64_1[3]; |
| 595 | |
| 596 | u64 vm_exit_msr_store_addr; |
| 597 | u64 vm_exit_msr_load_addr; |
| 598 | u64 vm_entry_msr_load_addr; |
| 599 | |
| 600 | u64 cr3_target_value0; |
| 601 | u64 cr3_target_value1; |
| 602 | u64 cr3_target_value2; |
| 603 | u64 cr3_target_value3; |
| 604 | |
| 605 | u32 page_fault_error_code_mask; |
| 606 | u32 page_fault_error_code_match; |
| 607 | |
| 608 | u32 cr3_target_count; |
| 609 | u32 vm_exit_msr_store_count; |
| 610 | u32 vm_exit_msr_load_count; |
| 611 | u32 vm_entry_msr_load_count; |
| 612 | |
| 613 | u64 tsc_offset; |
| 614 | u64 virtual_apic_page_addr; |
| 615 | u64 vmcs_link_pointer; |
| 616 | |
| 617 | u64 guest_ia32_debugctl; |
| 618 | u64 guest_ia32_pat; |
| 619 | u64 guest_ia32_efer; |
| 620 | |
| 621 | u64 guest_pdptr0; |
| 622 | u64 guest_pdptr1; |
| 623 | u64 guest_pdptr2; |
| 624 | u64 guest_pdptr3; |
| 625 | |
| 626 | u64 guest_pending_dbg_exceptions; |
| 627 | u64 guest_sysenter_esp; |
| 628 | u64 guest_sysenter_eip; |
| 629 | |
| 630 | u32 guest_activity_state; |
| 631 | u32 guest_sysenter_cs; |
| 632 | |
| 633 | u64 cr0_guest_host_mask; |
| 634 | u64 cr4_guest_host_mask; |
| 635 | u64 cr0_read_shadow; |
| 636 | u64 cr4_read_shadow; |
| 637 | u64 guest_cr0; |
| 638 | u64 guest_cr3; |
| 639 | u64 guest_cr4; |
| 640 | u64 guest_dr7; |
| 641 | |
| 642 | u64 host_fs_base; |
| 643 | u64 host_gs_base; |
| 644 | u64 host_tr_base; |
| 645 | u64 host_gdtr_base; |
| 646 | u64 host_idtr_base; |
| 647 | u64 host_rsp; |
| 648 | |
| 649 | u64 ept_pointer; |
| 650 | |
| 651 | u16 virtual_processor_id; |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 652 | u16 padding16_2[3]; |
Vitaly Kuznetsov | 68d1eb7 | 2018-03-20 15:02:09 +0100 | [diff] [blame] | 653 | |
| 654 | u64 padding64_2[5]; |
| 655 | u64 guest_physical_address; |
| 656 | |
| 657 | u32 vm_instruction_error; |
| 658 | u32 vm_exit_reason; |
| 659 | u32 vm_exit_intr_info; |
| 660 | u32 vm_exit_intr_error_code; |
| 661 | u32 idt_vectoring_info_field; |
| 662 | u32 idt_vectoring_error_code; |
| 663 | u32 vm_exit_instruction_len; |
| 664 | u32 vmx_instruction_info; |
| 665 | |
| 666 | u64 exit_qualification; |
| 667 | u64 exit_io_instruction_ecx; |
| 668 | u64 exit_io_instruction_esi; |
| 669 | u64 exit_io_instruction_edi; |
| 670 | u64 exit_io_instruction_eip; |
| 671 | |
| 672 | u64 guest_linear_address; |
| 673 | u64 guest_rsp; |
| 674 | u64 guest_rflags; |
| 675 | |
| 676 | u32 guest_interruptibility_info; |
| 677 | u32 cpu_based_vm_exec_control; |
| 678 | u32 exception_bitmap; |
| 679 | u32 vm_entry_controls; |
| 680 | u32 vm_entry_intr_info_field; |
| 681 | u32 vm_entry_exception_error_code; |
| 682 | u32 vm_entry_instruction_len; |
| 683 | u32 tpr_threshold; |
| 684 | |
| 685 | u64 guest_rip; |
| 686 | |
| 687 | u32 hv_clean_fields; |
| 688 | u32 hv_padding_32; |
| 689 | u32 hv_synthetic_controls; |
Vitaly Kuznetsov | ceef7d1 | 2018-04-16 12:50:33 +0200 | [diff] [blame] | 690 | struct { |
| 691 | u32 nested_flush_hypercall:1; |
| 692 | u32 msr_bitmap:1; |
| 693 | u32 reserved:30; |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 694 | } __packed hv_enlightenments_control; |
Vitaly Kuznetsov | 68d1eb7 | 2018-03-20 15:02:09 +0100 | [diff] [blame] | 695 | u32 hv_vp_id; |
| 696 | |
| 697 | u64 hv_vm_id; |
| 698 | u64 partition_assist_page; |
| 699 | u64 padding64_4[4]; |
| 700 | u64 guest_bndcfgs; |
| 701 | u64 padding64_5[7]; |
| 702 | u64 xss_exit_bitmap; |
| 703 | u64 padding64_6[7]; |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 704 | } __packed; |
Vitaly Kuznetsov | 68d1eb7 | 2018-03-20 15:02:09 +0100 | [diff] [blame] | 705 | |
| 706 | #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_NONE 0 |
| 707 | #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_IO_BITMAP BIT(0) |
| 708 | #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_MSR_BITMAP BIT(1) |
| 709 | #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP2 BIT(2) |
| 710 | #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP1 BIT(3) |
| 711 | #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_PROC BIT(4) |
| 712 | #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_EVENT BIT(5) |
| 713 | #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_ENTRY BIT(6) |
| 714 | #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_EXCPN BIT(7) |
| 715 | #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CRDR BIT(8) |
| 716 | #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_XLAT BIT(9) |
| 717 | #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_BASIC BIT(10) |
| 718 | #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1 BIT(11) |
| 719 | #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 BIT(12) |
| 720 | #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_POINTER BIT(13) |
| 721 | #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1 BIT(14) |
| 722 | #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_ENLIGHTENMENTSCONTROL BIT(15) |
| 723 | |
| 724 | #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL 0xFFFF |
| 725 | |
Andrey Smetanin | 1f4b34f | 2015-11-30 19:22:21 +0300 | [diff] [blame] | 726 | #define HV_STIMER_ENABLE (1ULL << 0) |
| 727 | #define HV_STIMER_PERIODIC (1ULL << 1) |
| 728 | #define HV_STIMER_LAZY (1ULL << 2) |
| 729 | #define HV_STIMER_AUTOENABLE (1ULL << 3) |
| 730 | #define HV_STIMER_SINT(config) (__u8)(((config) >> 16) & 0x0F) |
| 731 | |
Vitaly Kuznetsov | 0aa6725 | 2018-11-26 16:47:29 +0100 | [diff] [blame^] | 732 | /* Define synthetic interrupt controller flag constants. */ |
| 733 | #define HV_EVENT_FLAGS_COUNT (256 * 8) |
| 734 | #define HV_EVENT_FLAGS_LONG_COUNT (256 / sizeof(unsigned long)) |
| 735 | |
| 736 | /* |
| 737 | * Synthetic timer configuration. |
| 738 | */ |
| 739 | union hv_stimer_config { |
| 740 | u64 as_uint64; |
| 741 | struct { |
| 742 | u64 enable:1; |
| 743 | u64 periodic:1; |
| 744 | u64 lazy:1; |
| 745 | u64 auto_enable:1; |
| 746 | u64 apic_vector:8; |
| 747 | u64 direct_mode:1; |
| 748 | u64 reserved_z0:3; |
| 749 | u64 sintx:4; |
| 750 | u64 reserved_z1:44; |
| 751 | } __packed; |
| 752 | }; |
| 753 | |
| 754 | |
| 755 | /* Define the synthetic interrupt controller event flags format. */ |
| 756 | union hv_synic_event_flags { |
| 757 | unsigned long flags[HV_EVENT_FLAGS_LONG_COUNT]; |
| 758 | }; |
| 759 | |
| 760 | /* Define SynIC control register. */ |
| 761 | union hv_synic_scontrol { |
| 762 | u64 as_uint64; |
| 763 | struct { |
| 764 | u64 enable:1; |
| 765 | u64 reserved:63; |
| 766 | } __packed; |
| 767 | }; |
| 768 | |
| 769 | /* Define synthetic interrupt source. */ |
| 770 | union hv_synic_sint { |
| 771 | u64 as_uint64; |
| 772 | struct { |
| 773 | u64 vector:8; |
| 774 | u64 reserved1:8; |
| 775 | u64 masked:1; |
| 776 | u64 auto_eoi:1; |
| 777 | u64 reserved2:46; |
| 778 | } __packed; |
| 779 | }; |
| 780 | |
| 781 | /* Define the format of the SIMP register */ |
| 782 | union hv_synic_simp { |
| 783 | u64 as_uint64; |
| 784 | struct { |
| 785 | u64 simp_enabled:1; |
| 786 | u64 preserved:11; |
| 787 | u64 base_simp_gpa:52; |
| 788 | } __packed; |
| 789 | }; |
| 790 | |
| 791 | /* Define the format of the SIEFP register */ |
| 792 | union hv_synic_siefp { |
| 793 | u64 as_uint64; |
| 794 | struct { |
| 795 | u64 siefp_enabled:1; |
| 796 | u64 preserved:11; |
| 797 | u64 base_siefp_gpa:52; |
| 798 | } __packed; |
| 799 | }; |
| 800 | |
K. Y. Srinivasan | 366f03b | 2018-05-16 14:53:32 -0700 | [diff] [blame] | 801 | struct hv_vpset { |
| 802 | u64 format; |
| 803 | u64 valid_bank_mask; |
| 804 | u64 bank_contents[]; |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 805 | } __packed; |
K. Y. Srinivasan | 366f03b | 2018-05-16 14:53:32 -0700 | [diff] [blame] | 806 | |
Vitaly Kuznetsov | a1efa9b | 2018-08-27 18:48:57 +0200 | [diff] [blame] | 807 | /* HvCallSendSyntheticClusterIpi hypercall */ |
| 808 | struct hv_send_ipi { |
| 809 | u32 vector; |
| 810 | u32 reserved; |
| 811 | u64 cpu_mask; |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 812 | } __packed; |
Vitaly Kuznetsov | a1efa9b | 2018-08-27 18:48:57 +0200 | [diff] [blame] | 813 | |
| 814 | /* HvCallSendSyntheticClusterIpiEx hypercall */ |
| 815 | struct hv_send_ipi_ex { |
K. Y. Srinivasan | 366f03b | 2018-05-16 14:53:32 -0700 | [diff] [blame] | 816 | u32 vector; |
| 817 | u32 reserved; |
| 818 | struct hv_vpset vp_set; |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 819 | } __packed; |
K. Y. Srinivasan | 366f03b | 2018-05-16 14:53:32 -0700 | [diff] [blame] | 820 | |
Tianyu Lan | eb914cf | 2018-07-19 08:40:06 +0000 | [diff] [blame] | 821 | /* HvFlushGuestPhysicalAddressSpace hypercalls */ |
| 822 | struct hv_guest_mapping_flush { |
| 823 | u64 address_space; |
| 824 | u64 flags; |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 825 | } __packed; |
Tianyu Lan | eb914cf | 2018-07-19 08:40:06 +0000 | [diff] [blame] | 826 | |
Vitaly Kuznetsov | c9c92be | 2018-05-16 17:21:24 +0200 | [diff] [blame] | 827 | /* HvFlushVirtualAddressSpace, HvFlushVirtualAddressList hypercalls */ |
| 828 | struct hv_tlb_flush { |
| 829 | u64 address_space; |
| 830 | u64 flags; |
| 831 | u64 processor_mask; |
| 832 | u64 gva_list[]; |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 833 | } __packed; |
Vitaly Kuznetsov | c9c92be | 2018-05-16 17:21:24 +0200 | [diff] [blame] | 834 | |
| 835 | /* HvFlushVirtualAddressSpaceEx, HvFlushVirtualAddressListEx hypercalls */ |
| 836 | struct hv_tlb_flush_ex { |
| 837 | u64 address_space; |
| 838 | u64 flags; |
| 839 | struct hv_vpset hv_vp_set; |
| 840 | u64 gva_list[]; |
Vitaly Kuznetsov | ec08449 | 2018-12-12 18:57:01 +0100 | [diff] [blame] | 841 | } __packed; |
Vitaly Kuznetsov | c9c92be | 2018-05-16 17:21:24 +0200 | [diff] [blame] | 842 | |
Gleb Natapov | 1d5103c | 2010-01-17 15:51:21 +0200 | [diff] [blame] | 843 | #endif |