hyperv-tlfs.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * This file contains definitions from Hyper-V Hypervisor Top-Level Functional
  4. * Specification (TLFS):
  5. * https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/reference/tlfs
  6. */
  7. #ifndef _ASM_X86_HYPERV_TLFS_H
  8. #define _ASM_X86_HYPERV_TLFS_H
  9. #include <linux/types.h>
  10. #include <asm/page.h>
  11. /*
  12. * The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent
  13. * is set by CPUID(HvCpuIdFunctionVersionAndFeatures).
  14. */
  15. #define HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS 0x40000000
  16. #define HYPERV_CPUID_INTERFACE 0x40000001
  17. #define HYPERV_CPUID_VERSION 0x40000002
  18. #define HYPERV_CPUID_FEATURES 0x40000003
  19. #define HYPERV_CPUID_ENLIGHTMENT_INFO 0x40000004
  20. #define HYPERV_CPUID_IMPLEMENT_LIMITS 0x40000005
  21. #define HYPERV_CPUID_CPU_MANAGEMENT_FEATURES 0x40000007
  22. #define HYPERV_CPUID_NESTED_FEATURES 0x4000000A
  23. #define HYPERV_CPUID_ISOLATION_CONFIG 0x4000000C
  24. #define HYPERV_CPUID_VIRT_STACK_INTERFACE 0x40000081
  25. #define HYPERV_VS_INTERFACE_EAX_SIGNATURE 0x31235356 /* "VS#1" */
  26. #define HYPERV_CPUID_VIRT_STACK_PROPERTIES 0x40000082
  27. /* Support for the extended IOAPIC RTE format */
  28. #define HYPERV_VS_PROPERTIES_EAX_EXTENDED_IOAPIC_RTE BIT(2)
  29. #define HYPERV_HYPERVISOR_PRESENT_BIT 0x80000000
  30. #define HYPERV_CPUID_MIN 0x40000005
  31. #define HYPERV_CPUID_MAX 0x4000ffff
  32. /*
  33. * Group D Features. The bit assignments are custom to each architecture.
  34. * On x86/x64 these are HYPERV_CPUID_FEATURES.EDX bits.
  35. */
  36. /* The MWAIT instruction is available (per section MONITOR / MWAIT) */
  37. #define HV_X64_MWAIT_AVAILABLE BIT(0)
  38. /* Guest debugging support is available */
  39. #define HV_X64_GUEST_DEBUGGING_AVAILABLE BIT(1)
  40. /* Performance Monitor support is available*/
  41. #define HV_X64_PERF_MONITOR_AVAILABLE BIT(2)
  42. /* Support for physical CPU dynamic partitioning events is available*/
  43. #define HV_X64_CPU_DYNAMIC_PARTITIONING_AVAILABLE BIT(3)
  44. /*
  45. * Support for passing hypercall input parameter block via XMM
  46. * registers is available
  47. */
  48. #define HV_X64_HYPERCALL_XMM_INPUT_AVAILABLE BIT(4)
  49. /* Support for a virtual guest idle state is available */
  50. #define HV_X64_GUEST_IDLE_STATE_AVAILABLE BIT(5)
  51. /* Frequency MSRs available */
  52. #define HV_FEATURE_FREQUENCY_MSRS_AVAILABLE BIT(8)
  53. /* Crash MSR available */
  54. #define HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE BIT(10)
  55. /* Support for debug MSRs available */
  56. #define HV_FEATURE_DEBUG_MSRS_AVAILABLE BIT(11)
  57. /*
  58. * Support for returning hypercall output block via XMM
  59. * registers is available
  60. */
  61. #define HV_X64_HYPERCALL_XMM_OUTPUT_AVAILABLE BIT(15)
  62. /* stimer Direct Mode is available */
  63. #define HV_STIMER_DIRECT_MODE_AVAILABLE BIT(19)
  64. /*
  65. * Implementation recommendations. Indicates which behaviors the hypervisor
  66. * recommends the OS implement for optimal performance.
  67. * These are HYPERV_CPUID_ENLIGHTMENT_INFO.EAX bits.
  68. */
  69. /*
  70. * Recommend using hypercall for address space switches rather
  71. * than MOV to CR3 instruction
  72. */
  73. #define HV_X64_AS_SWITCH_RECOMMENDED BIT(0)
  74. /* Recommend using hypercall for local TLB flushes rather
  75. * than INVLPG or MOV to CR3 instructions */
  76. #define HV_X64_LOCAL_TLB_FLUSH_RECOMMENDED BIT(1)
  77. /*
  78. * Recommend using hypercall for remote TLB flushes rather
  79. * than inter-processor interrupts
  80. */
  81. #define HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED BIT(2)
  82. /*
  83. * Recommend using MSRs for accessing APIC registers
  84. * EOI, ICR and TPR rather than their memory-mapped counterparts
  85. */
  86. #define HV_X64_APIC_ACCESS_RECOMMENDED BIT(3)
  87. /* Recommend using the hypervisor-provided MSR to initiate a system RESET */
  88. #define HV_X64_SYSTEM_RESET_RECOMMENDED BIT(4)
  89. /*
  90. * Recommend using relaxed timing for this partition. If used,
  91. * the VM should disable any watchdog timeouts that rely on the
  92. * timely delivery of external interrupts
  93. */
  94. #define HV_X64_RELAXED_TIMING_RECOMMENDED BIT(5)
  95. /*
  96. * Recommend not using Auto End-Of-Interrupt feature
  97. */
  98. #define HV_DEPRECATING_AEOI_RECOMMENDED BIT(9)
  99. /*
  100. * Recommend using cluster IPI hypercalls.
  101. */
  102. #define HV_X64_CLUSTER_IPI_RECOMMENDED BIT(10)
  103. /* Recommend using the newer ExProcessorMasks interface */
  104. #define HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED BIT(11)
  105. /* Recommend using enlightened VMCS */
  106. #define HV_X64_ENLIGHTENED_VMCS_RECOMMENDED BIT(14)
  107. /*
  108. * CPU management features identification.
  109. * These are HYPERV_CPUID_CPU_MANAGEMENT_FEATURES.EAX bits.
  110. */
  111. #define HV_X64_START_LOGICAL_PROCESSOR BIT(0)
  112. #define HV_X64_CREATE_ROOT_VIRTUAL_PROCESSOR BIT(1)
  113. #define HV_X64_PERFORMANCE_COUNTER_SYNC BIT(2)
  114. #define HV_X64_RESERVED_IDENTITY_BIT BIT(31)
  115. /*
  116. * Virtual processor will never share a physical core with another virtual
  117. * processor, except for virtual processors that are reported as sibling SMT
  118. * threads.
  119. */
  120. #define HV_X64_NO_NONARCH_CORESHARING BIT(18)
  121. /* Nested features. These are HYPERV_CPUID_NESTED_FEATURES.EAX bits. */
  122. #define HV_X64_NESTED_DIRECT_FLUSH BIT(17)
  123. #define HV_X64_NESTED_GUEST_MAPPING_FLUSH BIT(18)
  124. #define HV_X64_NESTED_MSR_BITMAP BIT(19)
  125. /* Nested features #2. These are HYPERV_CPUID_NESTED_FEATURES.EBX bits. */
  126. #define HV_X64_NESTED_EVMCS1_PERF_GLOBAL_CTRL BIT(0)
  127. /*
  128. * This is specific to AMD and specifies that enlightened TLB flush is
  129. * supported. If guest opts in to this feature, ASID invalidations only
  130. * flushes gva -> hpa mapping entries. To flush the TLB entries derived
  131. * from NPT, hypercalls should be used (HvFlushGuestPhysicalAddressSpace
  132. * or HvFlushGuestPhysicalAddressList).
  133. */
  134. #define HV_X64_NESTED_ENLIGHTENED_TLB BIT(22)
  135. /* HYPERV_CPUID_ISOLATION_CONFIG.EAX bits. */
  136. #define HV_PARAVISOR_PRESENT BIT(0)
  137. /* HYPERV_CPUID_ISOLATION_CONFIG.EBX bits. */
  138. #define HV_ISOLATION_TYPE GENMASK(3, 0)
  139. #define HV_SHARED_GPA_BOUNDARY_ACTIVE BIT(5)
  140. #define HV_SHARED_GPA_BOUNDARY_BITS GENMASK(11, 6)
  141. enum hv_isolation_type {
  142. HV_ISOLATION_TYPE_NONE = 0,
  143. HV_ISOLATION_TYPE_VBS = 1,
  144. HV_ISOLATION_TYPE_SNP = 2
  145. };
  146. /* Hyper-V specific model specific registers (MSRs) */
  147. /* MSR used to identify the guest OS. */
  148. #define HV_X64_MSR_GUEST_OS_ID 0x40000000
  149. /* MSR used to setup pages used to communicate with the hypervisor. */
  150. #define HV_X64_MSR_HYPERCALL 0x40000001
  151. /* MSR used to provide vcpu index */
  152. #define HV_REGISTER_VP_INDEX 0x40000002
  153. /* MSR used to reset the guest OS. */
  154. #define HV_X64_MSR_RESET 0x40000003
  155. /* MSR used to provide vcpu runtime in 100ns units */
  156. #define HV_X64_MSR_VP_RUNTIME 0x40000010
  157. /* MSR used to read the per-partition time reference counter */
  158. #define HV_REGISTER_TIME_REF_COUNT 0x40000020
  159. /* A partition's reference time stamp counter (TSC) page */
  160. #define HV_REGISTER_REFERENCE_TSC 0x40000021
  161. /* MSR used to retrieve the TSC frequency */
  162. #define HV_X64_MSR_TSC_FREQUENCY 0x40000022
  163. /* MSR used to retrieve the local APIC timer frequency */
  164. #define HV_X64_MSR_APIC_FREQUENCY 0x40000023
  165. /* Define the virtual APIC registers */
  166. #define HV_X64_MSR_EOI 0x40000070
  167. #define HV_X64_MSR_ICR 0x40000071
  168. #define HV_X64_MSR_TPR 0x40000072
  169. #define HV_X64_MSR_VP_ASSIST_PAGE 0x40000073
  170. /* Define synthetic interrupt controller model specific registers. */
  171. #define HV_REGISTER_SCONTROL 0x40000080
  172. #define HV_REGISTER_SVERSION 0x40000081
  173. #define HV_REGISTER_SIEFP 0x40000082
  174. #define HV_REGISTER_SIMP 0x40000083
  175. #define HV_REGISTER_EOM 0x40000084
  176. #define HV_REGISTER_SINT0 0x40000090
  177. #define HV_REGISTER_SINT1 0x40000091
  178. #define HV_REGISTER_SINT2 0x40000092
  179. #define HV_REGISTER_SINT3 0x40000093
  180. #define HV_REGISTER_SINT4 0x40000094
  181. #define HV_REGISTER_SINT5 0x40000095
  182. #define HV_REGISTER_SINT6 0x40000096
  183. #define HV_REGISTER_SINT7 0x40000097
  184. #define HV_REGISTER_SINT8 0x40000098
  185. #define HV_REGISTER_SINT9 0x40000099
  186. #define HV_REGISTER_SINT10 0x4000009A
  187. #define HV_REGISTER_SINT11 0x4000009B
  188. #define HV_REGISTER_SINT12 0x4000009C
  189. #define HV_REGISTER_SINT13 0x4000009D
  190. #define HV_REGISTER_SINT14 0x4000009E
  191. #define HV_REGISTER_SINT15 0x4000009F
  192. /*
  193. * Synthetic Timer MSRs. Four timers per vcpu.
  194. */
  195. #define HV_REGISTER_STIMER0_CONFIG 0x400000B0
  196. #define HV_REGISTER_STIMER0_COUNT 0x400000B1
  197. #define HV_REGISTER_STIMER1_CONFIG 0x400000B2
  198. #define HV_REGISTER_STIMER1_COUNT 0x400000B3
  199. #define HV_REGISTER_STIMER2_CONFIG 0x400000B4
  200. #define HV_REGISTER_STIMER2_COUNT 0x400000B5
  201. #define HV_REGISTER_STIMER3_CONFIG 0x400000B6
  202. #define HV_REGISTER_STIMER3_COUNT 0x400000B7
  203. /* Hyper-V guest idle MSR */
  204. #define HV_X64_MSR_GUEST_IDLE 0x400000F0
  205. /* Hyper-V guest crash notification MSR's */
  206. #define HV_REGISTER_CRASH_P0 0x40000100
  207. #define HV_REGISTER_CRASH_P1 0x40000101
  208. #define HV_REGISTER_CRASH_P2 0x40000102
  209. #define HV_REGISTER_CRASH_P3 0x40000103
  210. #define HV_REGISTER_CRASH_P4 0x40000104
  211. #define HV_REGISTER_CRASH_CTL 0x40000105
  212. /* TSC emulation after migration */
  213. #define HV_X64_MSR_REENLIGHTENMENT_CONTROL 0x40000106
  214. #define HV_X64_MSR_TSC_EMULATION_CONTROL 0x40000107
  215. #define HV_X64_MSR_TSC_EMULATION_STATUS 0x40000108
  216. /* TSC invariant control */
  217. #define HV_X64_MSR_TSC_INVARIANT_CONTROL 0x40000118
  218. /* Register name aliases for temporary compatibility */
  219. #define HV_X64_MSR_STIMER0_COUNT HV_REGISTER_STIMER0_COUNT
  220. #define HV_X64_MSR_STIMER0_CONFIG HV_REGISTER_STIMER0_CONFIG
  221. #define HV_X64_MSR_STIMER1_COUNT HV_REGISTER_STIMER1_COUNT
  222. #define HV_X64_MSR_STIMER1_CONFIG HV_REGISTER_STIMER1_CONFIG
  223. #define HV_X64_MSR_STIMER2_COUNT HV_REGISTER_STIMER2_COUNT
  224. #define HV_X64_MSR_STIMER2_CONFIG HV_REGISTER_STIMER2_CONFIG
  225. #define HV_X64_MSR_STIMER3_COUNT HV_REGISTER_STIMER3_COUNT
  226. #define HV_X64_MSR_STIMER3_CONFIG HV_REGISTER_STIMER3_CONFIG
  227. #define HV_X64_MSR_SCONTROL HV_REGISTER_SCONTROL
  228. #define HV_X64_MSR_SVERSION HV_REGISTER_SVERSION
  229. #define HV_X64_MSR_SIMP HV_REGISTER_SIMP
  230. #define HV_X64_MSR_SIEFP HV_REGISTER_SIEFP
  231. #define HV_X64_MSR_VP_INDEX HV_REGISTER_VP_INDEX
  232. #define HV_X64_MSR_EOM HV_REGISTER_EOM
  233. #define HV_X64_MSR_SINT0 HV_REGISTER_SINT0
  234. #define HV_X64_MSR_SINT15 HV_REGISTER_SINT15
  235. #define HV_X64_MSR_CRASH_P0 HV_REGISTER_CRASH_P0
  236. #define HV_X64_MSR_CRASH_P1 HV_REGISTER_CRASH_P1
  237. #define HV_X64_MSR_CRASH_P2 HV_REGISTER_CRASH_P2
  238. #define HV_X64_MSR_CRASH_P3 HV_REGISTER_CRASH_P3
  239. #define HV_X64_MSR_CRASH_P4 HV_REGISTER_CRASH_P4
  240. #define HV_X64_MSR_CRASH_CTL HV_REGISTER_CRASH_CTL
  241. #define HV_X64_MSR_TIME_REF_COUNT HV_REGISTER_TIME_REF_COUNT
  242. #define HV_X64_MSR_REFERENCE_TSC HV_REGISTER_REFERENCE_TSC
  243. /* Hyper-V memory host visibility */
  244. enum hv_mem_host_visibility {
  245. VMBUS_PAGE_NOT_VISIBLE = 0,
  246. VMBUS_PAGE_VISIBLE_READ_ONLY = 1,
  247. VMBUS_PAGE_VISIBLE_READ_WRITE = 3
  248. };
  249. /* HvCallModifySparseGpaPageHostVisibility hypercall */
  250. #define HV_MAX_MODIFY_GPA_REP_COUNT ((PAGE_SIZE / sizeof(u64)) - 2)
  251. struct hv_gpa_range_for_visibility {
  252. u64 partition_id;
  253. u32 host_visibility:2;
  254. u32 reserved0:30;
  255. u32 reserved1;
  256. u64 gpa_page_list[HV_MAX_MODIFY_GPA_REP_COUNT];
  257. } __packed;
  258. /*
  259. * Declare the MSR used to setup pages used to communicate with the hypervisor.
  260. */
  261. union hv_x64_msr_hypercall_contents {
  262. u64 as_uint64;
  263. struct {
  264. u64 enable:1;
  265. u64 reserved:11;
  266. u64 guest_physical_address:52;
  267. } __packed;
  268. };
  269. union hv_vp_assist_msr_contents {
  270. u64 as_uint64;
  271. struct {
  272. u64 enable:1;
  273. u64 reserved:11;
  274. u64 pfn:52;
  275. } __packed;
  276. };
  277. struct hv_reenlightenment_control {
  278. __u64 vector:8;
  279. __u64 reserved1:8;
  280. __u64 enabled:1;
  281. __u64 reserved2:15;
  282. __u64 target_vp:32;
  283. } __packed;
  284. struct hv_tsc_emulation_control {
  285. __u64 enabled:1;
  286. __u64 reserved:63;
  287. } __packed;
  288. struct hv_tsc_emulation_status {
  289. __u64 inprogress:1;
  290. __u64 reserved:63;
  291. } __packed;
  292. #define HV_X64_MSR_HYPERCALL_ENABLE 0x00000001
  293. #define HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT 12
  294. #define HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_MASK \
  295. (~((1ull << HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT) - 1))
  296. #define HV_X64_MSR_CRASH_PARAMS \
  297. (1 + (HV_X64_MSR_CRASH_P4 - HV_X64_MSR_CRASH_P0))
  298. #define HV_IPI_LOW_VECTOR 0x10
  299. #define HV_IPI_HIGH_VECTOR 0xff
  300. #define HV_X64_MSR_VP_ASSIST_PAGE_ENABLE 0x00000001
  301. #define HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_SHIFT 12
  302. #define HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_MASK \
  303. (~((1ull << HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_SHIFT) - 1))
  304. /* Hyper-V Enlightened VMCS version mask in nested features CPUID */
  305. #define HV_X64_ENLIGHTENED_VMCS_VERSION 0xff
  306. #define HV_X64_MSR_TSC_REFERENCE_ENABLE 0x00000001
  307. #define HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT 12
  308. /* Number of XMM registers used in hypercall input/output */
  309. #define HV_HYPERCALL_MAX_XMM_REGISTERS 6
  310. struct hv_nested_enlightenments_control {
  311. struct {
  312. __u32 directhypercall:1;
  313. __u32 reserved:31;
  314. } features;
  315. struct {
  316. __u32 reserved;
  317. } hypercallControls;
  318. } __packed;
  319. /* Define virtual processor assist page structure. */
  320. struct hv_vp_assist_page {
  321. __u32 apic_assist;
  322. __u32 reserved1;
  323. __u64 vtl_control[3];
  324. struct hv_nested_enlightenments_control nested_control;
  325. __u8 enlighten_vmentry;
  326. __u8 reserved2[7];
  327. __u64 current_nested_vmcs;
  328. } __packed;
  329. struct hv_enlightened_vmcs {
  330. u32 revision_id;
  331. u32 abort;
  332. u16 host_es_selector;
  333. u16 host_cs_selector;
  334. u16 host_ss_selector;
  335. u16 host_ds_selector;
  336. u16 host_fs_selector;
  337. u16 host_gs_selector;
  338. u16 host_tr_selector;
  339. u16 padding16_1;
  340. u64 host_ia32_pat;
  341. u64 host_ia32_efer;
  342. u64 host_cr0;
  343. u64 host_cr3;
  344. u64 host_cr4;
  345. u64 host_ia32_sysenter_esp;
  346. u64 host_ia32_sysenter_eip;
  347. u64 host_rip;
  348. u32 host_ia32_sysenter_cs;
  349. u32 pin_based_vm_exec_control;
  350. u32 vm_exit_controls;
  351. u32 secondary_vm_exec_control;
  352. u64 io_bitmap_a;
  353. u64 io_bitmap_b;
  354. u64 msr_bitmap;
  355. u16 guest_es_selector;
  356. u16 guest_cs_selector;
  357. u16 guest_ss_selector;
  358. u16 guest_ds_selector;
  359. u16 guest_fs_selector;
  360. u16 guest_gs_selector;
  361. u16 guest_ldtr_selector;
  362. u16 guest_tr_selector;
  363. u32 guest_es_limit;
  364. u32 guest_cs_limit;
  365. u32 guest_ss_limit;
  366. u32 guest_ds_limit;
  367. u32 guest_fs_limit;
  368. u32 guest_gs_limit;
  369. u32 guest_ldtr_limit;
  370. u32 guest_tr_limit;
  371. u32 guest_gdtr_limit;
  372. u32 guest_idtr_limit;
  373. u32 guest_es_ar_bytes;
  374. u32 guest_cs_ar_bytes;
  375. u32 guest_ss_ar_bytes;
  376. u32 guest_ds_ar_bytes;
  377. u32 guest_fs_ar_bytes;
  378. u32 guest_gs_ar_bytes;
  379. u32 guest_ldtr_ar_bytes;
  380. u32 guest_tr_ar_bytes;
  381. u64 guest_es_base;
  382. u64 guest_cs_base;
  383. u64 guest_ss_base;
  384. u64 guest_ds_base;
  385. u64 guest_fs_base;
  386. u64 guest_gs_base;
  387. u64 guest_ldtr_base;
  388. u64 guest_tr_base;
  389. u64 guest_gdtr_base;
  390. u64 guest_idtr_base;
  391. u64 padding64_1[3];
  392. u64 vm_exit_msr_store_addr;
  393. u64 vm_exit_msr_load_addr;
  394. u64 vm_entry_msr_load_addr;
  395. u64 cr3_target_value0;
  396. u64 cr3_target_value1;
  397. u64 cr3_target_value2;
  398. u64 cr3_target_value3;
  399. u32 page_fault_error_code_mask;
  400. u32 page_fault_error_code_match;
  401. u32 cr3_target_count;
  402. u32 vm_exit_msr_store_count;
  403. u32 vm_exit_msr_load_count;
  404. u32 vm_entry_msr_load_count;
  405. u64 tsc_offset;
  406. u64 virtual_apic_page_addr;
  407. u64 vmcs_link_pointer;
  408. u64 guest_ia32_debugctl;
  409. u64 guest_ia32_pat;
  410. u64 guest_ia32_efer;
  411. u64 guest_pdptr0;
  412. u64 guest_pdptr1;
  413. u64 guest_pdptr2;
  414. u64 guest_pdptr3;
  415. u64 guest_pending_dbg_exceptions;
  416. u64 guest_sysenter_esp;
  417. u64 guest_sysenter_eip;
  418. u32 guest_activity_state;
  419. u32 guest_sysenter_cs;
  420. u64 cr0_guest_host_mask;
  421. u64 cr4_guest_host_mask;
  422. u64 cr0_read_shadow;
  423. u64 cr4_read_shadow;
  424. u64 guest_cr0;
  425. u64 guest_cr3;
  426. u64 guest_cr4;
  427. u64 guest_dr7;
  428. u64 host_fs_base;
  429. u64 host_gs_base;
  430. u64 host_tr_base;
  431. u64 host_gdtr_base;
  432. u64 host_idtr_base;
  433. u64 host_rsp;
  434. u64 ept_pointer;
  435. u16 virtual_processor_id;
  436. u16 padding16_2[3];
  437. u64 padding64_2[5];
  438. u64 guest_physical_address;
  439. u32 vm_instruction_error;
  440. u32 vm_exit_reason;
  441. u32 vm_exit_intr_info;
  442. u32 vm_exit_intr_error_code;
  443. u32 idt_vectoring_info_field;
  444. u32 idt_vectoring_error_code;
  445. u32 vm_exit_instruction_len;
  446. u32 vmx_instruction_info;
  447. u64 exit_qualification;
  448. u64 exit_io_instruction_ecx;
  449. u64 exit_io_instruction_esi;
  450. u64 exit_io_instruction_edi;
  451. u64 exit_io_instruction_eip;
  452. u64 guest_linear_address;
  453. u64 guest_rsp;
  454. u64 guest_rflags;
  455. u32 guest_interruptibility_info;
  456. u32 cpu_based_vm_exec_control;
  457. u32 exception_bitmap;
  458. u32 vm_entry_controls;
  459. u32 vm_entry_intr_info_field;
  460. u32 vm_entry_exception_error_code;
  461. u32 vm_entry_instruction_len;
  462. u32 tpr_threshold;
  463. u64 guest_rip;
  464. u32 hv_clean_fields;
  465. u32 padding32_1;
  466. u32 hv_synthetic_controls;
  467. struct {
  468. u32 nested_flush_hypercall:1;
  469. u32 msr_bitmap:1;
  470. u32 reserved:30;
  471. } __packed hv_enlightenments_control;
  472. u32 hv_vp_id;
  473. u32 padding32_2;
  474. u64 hv_vm_id;
  475. u64 partition_assist_page;
  476. u64 padding64_4[4];
  477. u64 guest_bndcfgs;
  478. u64 guest_ia32_perf_global_ctrl;
  479. u64 guest_ia32_s_cet;
  480. u64 guest_ssp;
  481. u64 guest_ia32_int_ssp_table_addr;
  482. u64 guest_ia32_lbr_ctl;
  483. u64 padding64_5[2];
  484. u64 xss_exit_bitmap;
  485. u64 encls_exiting_bitmap;
  486. u64 host_ia32_perf_global_ctrl;
  487. u64 tsc_multiplier;
  488. u64 host_ia32_s_cet;
  489. u64 host_ssp;
  490. u64 host_ia32_int_ssp_table_addr;
  491. u64 padding64_6;
  492. } __packed;
  493. #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_NONE 0
  494. #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_IO_BITMAP BIT(0)
  495. #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_MSR_BITMAP BIT(1)
  496. #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP2 BIT(2)
  497. #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP1 BIT(3)
  498. #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_PROC BIT(4)
  499. #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_EVENT BIT(5)
  500. #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_ENTRY BIT(6)
  501. #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_EXCPN BIT(7)
  502. #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CRDR BIT(8)
  503. #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_XLAT BIT(9)
  504. #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_BASIC BIT(10)
  505. #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1 BIT(11)
  506. #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2 BIT(12)
  507. #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_POINTER BIT(13)
  508. #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1 BIT(14)
  509. #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_ENLIGHTENMENTSCONTROL BIT(15)
  510. #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL 0xFFFF
  511. /*
  512. * Hyper-V uses the software reserved 32 bytes in VMCB control area to expose
  513. * SVM enlightenments to guests.
  514. */
  515. struct hv_vmcb_enlightenments {
  516. struct __packed hv_enlightenments_control {
  517. u32 nested_flush_hypercall:1;
  518. u32 msr_bitmap:1;
  519. u32 enlightened_npt_tlb: 1;
  520. u32 reserved:29;
  521. } __packed hv_enlightenments_control;
  522. u32 hv_vp_id;
  523. u64 hv_vm_id;
  524. u64 partition_assist_page;
  525. u64 reserved;
  526. } __packed;
  527. /*
  528. * Hyper-V uses the software reserved clean bit in VMCB.
  529. */
  530. #define HV_VMCB_NESTED_ENLIGHTENMENTS 31
  531. struct hv_partition_assist_pg {
  532. u32 tlb_lock_count;
  533. };
  534. enum hv_interrupt_type {
  535. HV_X64_INTERRUPT_TYPE_FIXED = 0x0000,
  536. HV_X64_INTERRUPT_TYPE_LOWESTPRIORITY = 0x0001,
  537. HV_X64_INTERRUPT_TYPE_SMI = 0x0002,
  538. HV_X64_INTERRUPT_TYPE_REMOTEREAD = 0x0003,
  539. HV_X64_INTERRUPT_TYPE_NMI = 0x0004,
  540. HV_X64_INTERRUPT_TYPE_INIT = 0x0005,
  541. HV_X64_INTERRUPT_TYPE_SIPI = 0x0006,
  542. HV_X64_INTERRUPT_TYPE_EXTINT = 0x0007,
  543. HV_X64_INTERRUPT_TYPE_LOCALINT0 = 0x0008,
  544. HV_X64_INTERRUPT_TYPE_LOCALINT1 = 0x0009,
  545. HV_X64_INTERRUPT_TYPE_MAXIMUM = 0x000A,
  546. };
  547. union hv_msi_address_register {
  548. u32 as_uint32;
  549. struct {
  550. u32 reserved1:2;
  551. u32 destination_mode:1;
  552. u32 redirection_hint:1;
  553. u32 reserved2:8;
  554. u32 destination_id:8;
  555. u32 msi_base:12;
  556. };
  557. } __packed;
  558. union hv_msi_data_register {
  559. u32 as_uint32;
  560. struct {
  561. u32 vector:8;
  562. u32 delivery_mode:3;
  563. u32 reserved1:3;
  564. u32 level_assert:1;
  565. u32 trigger_mode:1;
  566. u32 reserved2:16;
  567. };
  568. } __packed;
  569. /* HvRetargetDeviceInterrupt hypercall */
  570. union hv_msi_entry {
  571. u64 as_uint64;
  572. struct {
  573. union hv_msi_address_register address;
  574. union hv_msi_data_register data;
  575. } __packed;
  576. };
  577. #include <asm-generic/hyperv-tlfs.h>
  578. #endif