Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 
0003 /*
0004  * This file contains definitions from Hyper-V Hypervisor Top-Level Functional
0005  * Specification (TLFS):
0006  * https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/reference/tlfs
0007  */
0008 
0009 #ifndef _ASM_X86_HYPERV_TLFS_H
0010 #define _ASM_X86_HYPERV_TLFS_H
0011 
0012 #include <linux/types.h>
0013 #include <asm/page.h>
0014 /*
0015  * The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent
0016  * is set by CPUID(HvCpuIdFunctionVersionAndFeatures).
0017  */
0018 #define HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS   0x40000000
0019 #define HYPERV_CPUID_INTERFACE          0x40000001
0020 #define HYPERV_CPUID_VERSION            0x40000002
0021 #define HYPERV_CPUID_FEATURES           0x40000003
0022 #define HYPERV_CPUID_ENLIGHTMENT_INFO       0x40000004
0023 #define HYPERV_CPUID_IMPLEMENT_LIMITS       0x40000005
0024 #define HYPERV_CPUID_CPU_MANAGEMENT_FEATURES    0x40000007
0025 #define HYPERV_CPUID_NESTED_FEATURES        0x4000000A
0026 #define HYPERV_CPUID_ISOLATION_CONFIG       0x4000000C
0027 
0028 #define HYPERV_CPUID_VIRT_STACK_INTERFACE   0x40000081
0029 #define HYPERV_VS_INTERFACE_EAX_SIGNATURE   0x31235356  /* "VS#1" */
0030 
0031 #define HYPERV_CPUID_VIRT_STACK_PROPERTIES  0x40000082
0032 /* Support for the extended IOAPIC RTE format */
0033 #define HYPERV_VS_PROPERTIES_EAX_EXTENDED_IOAPIC_RTE    BIT(2)
0034 
0035 #define HYPERV_HYPERVISOR_PRESENT_BIT       0x80000000
0036 #define HYPERV_CPUID_MIN            0x40000005
0037 #define HYPERV_CPUID_MAX            0x4000ffff
0038 
0039 /*
0040  * Group D Features.  The bit assignments are custom to each architecture.
0041  * On x86/x64 these are HYPERV_CPUID_FEATURES.EDX bits.
0042  */
0043 /* The MWAIT instruction is available (per section MONITOR / MWAIT) */
0044 #define HV_X64_MWAIT_AVAILABLE              BIT(0)
0045 /* Guest debugging support is available */
0046 #define HV_X64_GUEST_DEBUGGING_AVAILABLE        BIT(1)
0047 /* Performance Monitor support is available*/
0048 #define HV_X64_PERF_MONITOR_AVAILABLE           BIT(2)
0049 /* Support for physical CPU dynamic partitioning events is available*/
0050 #define HV_X64_CPU_DYNAMIC_PARTITIONING_AVAILABLE   BIT(3)
0051 /*
0052  * Support for passing hypercall input parameter block via XMM
0053  * registers is available
0054  */
0055 #define HV_X64_HYPERCALL_XMM_INPUT_AVAILABLE        BIT(4)
0056 /* Support for a virtual guest idle state is available */
0057 #define HV_X64_GUEST_IDLE_STATE_AVAILABLE       BIT(5)
0058 /* Frequency MSRs available */
0059 #define HV_FEATURE_FREQUENCY_MSRS_AVAILABLE     BIT(8)
0060 /* Crash MSR available */
0061 #define HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE        BIT(10)
0062 /* Support for debug MSRs available */
0063 #define HV_FEATURE_DEBUG_MSRS_AVAILABLE         BIT(11)
0064 /*
0065  * Support for returning hypercall output block via XMM
0066  * registers is available
0067  */
0068 #define HV_X64_HYPERCALL_XMM_OUTPUT_AVAILABLE       BIT(15)
0069 /* stimer Direct Mode is available */
0070 #define HV_STIMER_DIRECT_MODE_AVAILABLE         BIT(19)
0071 
0072 /*
0073  * Implementation recommendations. Indicates which behaviors the hypervisor
0074  * recommends the OS implement for optimal performance.
0075  * These are HYPERV_CPUID_ENLIGHTMENT_INFO.EAX bits.
0076  */
0077 /*
0078  * Recommend using hypercall for address space switches rather
0079  * than MOV to CR3 instruction
0080  */
0081 #define HV_X64_AS_SWITCH_RECOMMENDED            BIT(0)
0082 /* Recommend using hypercall for local TLB flushes rather
0083  * than INVLPG or MOV to CR3 instructions */
0084 #define HV_X64_LOCAL_TLB_FLUSH_RECOMMENDED      BIT(1)
0085 /*
0086  * Recommend using hypercall for remote TLB flushes rather
0087  * than inter-processor interrupts
0088  */
0089 #define HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED     BIT(2)
0090 /*
0091  * Recommend using MSRs for accessing APIC registers
0092  * EOI, ICR and TPR rather than their memory-mapped counterparts
0093  */
0094 #define HV_X64_APIC_ACCESS_RECOMMENDED          BIT(3)
0095 /* Recommend using the hypervisor-provided MSR to initiate a system RESET */
0096 #define HV_X64_SYSTEM_RESET_RECOMMENDED         BIT(4)
0097 /*
0098  * Recommend using relaxed timing for this partition. If used,
0099  * the VM should disable any watchdog timeouts that rely on the
0100  * timely delivery of external interrupts
0101  */
0102 #define HV_X64_RELAXED_TIMING_RECOMMENDED       BIT(5)
0103 
0104 /*
0105  * Recommend not using Auto End-Of-Interrupt feature
0106  */
0107 #define HV_DEPRECATING_AEOI_RECOMMENDED         BIT(9)
0108 
0109 /*
0110  * Recommend using cluster IPI hypercalls.
0111  */
0112 #define HV_X64_CLUSTER_IPI_RECOMMENDED          BIT(10)
0113 
0114 /* Recommend using the newer ExProcessorMasks interface */
0115 #define HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED       BIT(11)
0116 
0117 /* Recommend using enlightened VMCS */
0118 #define HV_X64_ENLIGHTENED_VMCS_RECOMMENDED     BIT(14)
0119 
0120 /*
0121  * CPU management features identification.
0122  * These are HYPERV_CPUID_CPU_MANAGEMENT_FEATURES.EAX bits.
0123  */
0124 #define HV_X64_START_LOGICAL_PROCESSOR          BIT(0)
0125 #define HV_X64_CREATE_ROOT_VIRTUAL_PROCESSOR        BIT(1)
0126 #define HV_X64_PERFORMANCE_COUNTER_SYNC         BIT(2)
0127 #define HV_X64_RESERVED_IDENTITY_BIT            BIT(31)
0128 
0129 /*
0130  * Virtual processor will never share a physical core with another virtual
0131  * processor, except for virtual processors that are reported as sibling SMT
0132  * threads.
0133  */
0134 #define HV_X64_NO_NONARCH_CORESHARING           BIT(18)
0135 
0136 /* Nested features. These are HYPERV_CPUID_NESTED_FEATURES.EAX bits. */
0137 #define HV_X64_NESTED_DIRECT_FLUSH          BIT(17)
0138 #define HV_X64_NESTED_GUEST_MAPPING_FLUSH       BIT(18)
0139 #define HV_X64_NESTED_MSR_BITMAP            BIT(19)
0140 
0141 /*
0142  * This is specific to AMD and specifies that enlightened TLB flush is
0143  * supported. If guest opts in to this feature, ASID invalidations only
0144  * flushes gva -> hpa mapping entries. To flush the TLB entries derived
0145  * from NPT, hypercalls should be used (HvFlushGuestPhysicalAddressSpace
0146  * or HvFlushGuestPhysicalAddressList).
0147  */
0148 #define HV_X64_NESTED_ENLIGHTENED_TLB           BIT(22)
0149 
0150 /* HYPERV_CPUID_ISOLATION_CONFIG.EAX bits. */
0151 #define HV_PARAVISOR_PRESENT                BIT(0)
0152 
0153 /* HYPERV_CPUID_ISOLATION_CONFIG.EBX bits. */
0154 #define HV_ISOLATION_TYPE               GENMASK(3, 0)
0155 #define HV_SHARED_GPA_BOUNDARY_ACTIVE           BIT(5)
0156 #define HV_SHARED_GPA_BOUNDARY_BITS         GENMASK(11, 6)
0157 
0158 enum hv_isolation_type {
0159     HV_ISOLATION_TYPE_NONE  = 0,
0160     HV_ISOLATION_TYPE_VBS   = 1,
0161     HV_ISOLATION_TYPE_SNP   = 2
0162 };
0163 
0164 /* Hyper-V specific model specific registers (MSRs) */
0165 
0166 /* MSR used to identify the guest OS. */
0167 #define HV_X64_MSR_GUEST_OS_ID          0x40000000
0168 
0169 /* MSR used to setup pages used to communicate with the hypervisor. */
0170 #define HV_X64_MSR_HYPERCALL            0x40000001
0171 
0172 /* MSR used to provide vcpu index */
0173 #define HV_REGISTER_VP_INDEX            0x40000002
0174 
0175 /* MSR used to reset the guest OS. */
0176 #define HV_X64_MSR_RESET            0x40000003
0177 
0178 /* MSR used to provide vcpu runtime in 100ns units */
0179 #define HV_X64_MSR_VP_RUNTIME           0x40000010
0180 
0181 /* MSR used to read the per-partition time reference counter */
0182 #define HV_REGISTER_TIME_REF_COUNT      0x40000020
0183 
0184 /* A partition's reference time stamp counter (TSC) page */
0185 #define HV_REGISTER_REFERENCE_TSC       0x40000021
0186 
0187 /* MSR used to retrieve the TSC frequency */
0188 #define HV_X64_MSR_TSC_FREQUENCY        0x40000022
0189 
0190 /* MSR used to retrieve the local APIC timer frequency */
0191 #define HV_X64_MSR_APIC_FREQUENCY       0x40000023
0192 
0193 /* Define the virtual APIC registers */
0194 #define HV_X64_MSR_EOI              0x40000070
0195 #define HV_X64_MSR_ICR              0x40000071
0196 #define HV_X64_MSR_TPR              0x40000072
0197 #define HV_X64_MSR_VP_ASSIST_PAGE       0x40000073
0198 
0199 /* Define synthetic interrupt controller model specific registers. */
0200 #define HV_REGISTER_SCONTROL            0x40000080
0201 #define HV_REGISTER_SVERSION            0x40000081
0202 #define HV_REGISTER_SIEFP           0x40000082
0203 #define HV_REGISTER_SIMP            0x40000083
0204 #define HV_REGISTER_EOM             0x40000084
0205 #define HV_REGISTER_SINT0           0x40000090
0206 #define HV_REGISTER_SINT1           0x40000091
0207 #define HV_REGISTER_SINT2           0x40000092
0208 #define HV_REGISTER_SINT3           0x40000093
0209 #define HV_REGISTER_SINT4           0x40000094
0210 #define HV_REGISTER_SINT5           0x40000095
0211 #define HV_REGISTER_SINT6           0x40000096
0212 #define HV_REGISTER_SINT7           0x40000097
0213 #define HV_REGISTER_SINT8           0x40000098
0214 #define HV_REGISTER_SINT9           0x40000099
0215 #define HV_REGISTER_SINT10          0x4000009A
0216 #define HV_REGISTER_SINT11          0x4000009B
0217 #define HV_REGISTER_SINT12          0x4000009C
0218 #define HV_REGISTER_SINT13          0x4000009D
0219 #define HV_REGISTER_SINT14          0x4000009E
0220 #define HV_REGISTER_SINT15          0x4000009F
0221 
0222 /*
0223  * Synthetic Timer MSRs. Four timers per vcpu.
0224  */
0225 #define HV_REGISTER_STIMER0_CONFIG      0x400000B0
0226 #define HV_REGISTER_STIMER0_COUNT       0x400000B1
0227 #define HV_REGISTER_STIMER1_CONFIG      0x400000B2
0228 #define HV_REGISTER_STIMER1_COUNT       0x400000B3
0229 #define HV_REGISTER_STIMER2_CONFIG      0x400000B4
0230 #define HV_REGISTER_STIMER2_COUNT       0x400000B5
0231 #define HV_REGISTER_STIMER3_CONFIG      0x400000B6
0232 #define HV_REGISTER_STIMER3_COUNT       0x400000B7
0233 
0234 /* Hyper-V guest idle MSR */
0235 #define HV_X64_MSR_GUEST_IDLE           0x400000F0
0236 
0237 /* Hyper-V guest crash notification MSR's */
0238 #define HV_REGISTER_CRASH_P0            0x40000100
0239 #define HV_REGISTER_CRASH_P1            0x40000101
0240 #define HV_REGISTER_CRASH_P2            0x40000102
0241 #define HV_REGISTER_CRASH_P3            0x40000103
0242 #define HV_REGISTER_CRASH_P4            0x40000104
0243 #define HV_REGISTER_CRASH_CTL           0x40000105
0244 
0245 /* TSC emulation after migration */
0246 #define HV_X64_MSR_REENLIGHTENMENT_CONTROL  0x40000106
0247 #define HV_X64_MSR_TSC_EMULATION_CONTROL    0x40000107
0248 #define HV_X64_MSR_TSC_EMULATION_STATUS     0x40000108
0249 
0250 /* TSC invariant control */
0251 #define HV_X64_MSR_TSC_INVARIANT_CONTROL    0x40000118
0252 
0253 /* Register name aliases for temporary compatibility */
0254 #define HV_X64_MSR_STIMER0_COUNT    HV_REGISTER_STIMER0_COUNT
0255 #define HV_X64_MSR_STIMER0_CONFIG   HV_REGISTER_STIMER0_CONFIG
0256 #define HV_X64_MSR_STIMER1_COUNT    HV_REGISTER_STIMER1_COUNT
0257 #define HV_X64_MSR_STIMER1_CONFIG   HV_REGISTER_STIMER1_CONFIG
0258 #define HV_X64_MSR_STIMER2_COUNT    HV_REGISTER_STIMER2_COUNT
0259 #define HV_X64_MSR_STIMER2_CONFIG   HV_REGISTER_STIMER2_CONFIG
0260 #define HV_X64_MSR_STIMER3_COUNT    HV_REGISTER_STIMER3_COUNT
0261 #define HV_X64_MSR_STIMER3_CONFIG   HV_REGISTER_STIMER3_CONFIG
0262 #define HV_X64_MSR_SCONTROL     HV_REGISTER_SCONTROL
0263 #define HV_X64_MSR_SVERSION     HV_REGISTER_SVERSION
0264 #define HV_X64_MSR_SIMP         HV_REGISTER_SIMP
0265 #define HV_X64_MSR_SIEFP        HV_REGISTER_SIEFP
0266 #define HV_X64_MSR_VP_INDEX     HV_REGISTER_VP_INDEX
0267 #define HV_X64_MSR_EOM          HV_REGISTER_EOM
0268 #define HV_X64_MSR_SINT0        HV_REGISTER_SINT0
0269 #define HV_X64_MSR_SINT15       HV_REGISTER_SINT15
0270 #define HV_X64_MSR_CRASH_P0     HV_REGISTER_CRASH_P0
0271 #define HV_X64_MSR_CRASH_P1     HV_REGISTER_CRASH_P1
0272 #define HV_X64_MSR_CRASH_P2     HV_REGISTER_CRASH_P2
0273 #define HV_X64_MSR_CRASH_P3     HV_REGISTER_CRASH_P3
0274 #define HV_X64_MSR_CRASH_P4     HV_REGISTER_CRASH_P4
0275 #define HV_X64_MSR_CRASH_CTL        HV_REGISTER_CRASH_CTL
0276 #define HV_X64_MSR_TIME_REF_COUNT   HV_REGISTER_TIME_REF_COUNT
0277 #define HV_X64_MSR_REFERENCE_TSC    HV_REGISTER_REFERENCE_TSC
0278 
0279 /* Hyper-V memory host visibility */
0280 enum hv_mem_host_visibility {
0281     VMBUS_PAGE_NOT_VISIBLE      = 0,
0282     VMBUS_PAGE_VISIBLE_READ_ONLY    = 1,
0283     VMBUS_PAGE_VISIBLE_READ_WRITE   = 3
0284 };
0285 
0286 /* HvCallModifySparseGpaPageHostVisibility hypercall */
0287 #define HV_MAX_MODIFY_GPA_REP_COUNT ((PAGE_SIZE / sizeof(u64)) - 2)
0288 struct hv_gpa_range_for_visibility {
0289     u64 partition_id;
0290     u32 host_visibility:2;
0291     u32 reserved0:30;
0292     u32 reserved1;
0293     u64 gpa_page_list[HV_MAX_MODIFY_GPA_REP_COUNT];
0294 } __packed;
0295 
0296 /*
0297  * Declare the MSR used to setup pages used to communicate with the hypervisor.
0298  */
0299 union hv_x64_msr_hypercall_contents {
0300     u64 as_uint64;
0301     struct {
0302         u64 enable:1;
0303         u64 reserved:11;
0304         u64 guest_physical_address:52;
0305     } __packed;
0306 };
0307 
0308 union hv_vp_assist_msr_contents {
0309     u64 as_uint64;
0310     struct {
0311         u64 enable:1;
0312         u64 reserved:11;
0313         u64 pfn:52;
0314     } __packed;
0315 };
0316 
0317 struct hv_reenlightenment_control {
0318     __u64 vector:8;
0319     __u64 reserved1:8;
0320     __u64 enabled:1;
0321     __u64 reserved2:15;
0322     __u64 target_vp:32;
0323 }  __packed;
0324 
0325 struct hv_tsc_emulation_control {
0326     __u64 enabled:1;
0327     __u64 reserved:63;
0328 } __packed;
0329 
0330 struct hv_tsc_emulation_status {
0331     __u64 inprogress:1;
0332     __u64 reserved:63;
0333 } __packed;
0334 
0335 #define HV_X64_MSR_HYPERCALL_ENABLE     0x00000001
0336 #define HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT 12
0337 #define HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_MASK  \
0338         (~((1ull << HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT) - 1))
0339 
0340 #define HV_X64_MSR_CRASH_PARAMS     \
0341         (1 + (HV_X64_MSR_CRASH_P4 - HV_X64_MSR_CRASH_P0))
0342 
0343 #define HV_IPI_LOW_VECTOR   0x10
0344 #define HV_IPI_HIGH_VECTOR  0xff
0345 
0346 #define HV_X64_MSR_VP_ASSIST_PAGE_ENABLE    0x00000001
0347 #define HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_SHIFT 12
0348 #define HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_MASK  \
0349         (~((1ull << HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_SHIFT) - 1))
0350 
0351 /* Hyper-V Enlightened VMCS version mask in nested features CPUID */
0352 #define HV_X64_ENLIGHTENED_VMCS_VERSION     0xff
0353 
0354 #define HV_X64_MSR_TSC_REFERENCE_ENABLE     0x00000001
0355 #define HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT  12
0356 
0357 /* Number of XMM registers used in hypercall input/output */
0358 #define HV_HYPERCALL_MAX_XMM_REGISTERS      6
0359 
0360 struct hv_nested_enlightenments_control {
0361     struct {
0362         __u32 directhypercall:1;
0363         __u32 reserved:31;
0364     } features;
0365     struct {
0366         __u32 reserved;
0367     } hypercallControls;
0368 } __packed;
0369 
0370 /* Define virtual processor assist page structure. */
0371 struct hv_vp_assist_page {
0372     __u32 apic_assist;
0373     __u32 reserved1;
0374     __u64 vtl_control[3];
0375     struct hv_nested_enlightenments_control nested_control;
0376     __u8 enlighten_vmentry;
0377     __u8 reserved2[7];
0378     __u64 current_nested_vmcs;
0379 } __packed;
0380 
0381 struct hv_enlightened_vmcs {
0382     u32 revision_id;
0383     u32 abort;
0384 
0385     u16 host_es_selector;
0386     u16 host_cs_selector;
0387     u16 host_ss_selector;
0388     u16 host_ds_selector;
0389     u16 host_fs_selector;
0390     u16 host_gs_selector;
0391     u16 host_tr_selector;
0392 
0393     u16 padding16_1;
0394 
0395     u64 host_ia32_pat;
0396     u64 host_ia32_efer;
0397 
0398     u64 host_cr0;
0399     u64 host_cr3;
0400     u64 host_cr4;
0401 
0402     u64 host_ia32_sysenter_esp;
0403     u64 host_ia32_sysenter_eip;
0404     u64 host_rip;
0405     u32 host_ia32_sysenter_cs;
0406 
0407     u32 pin_based_vm_exec_control;
0408     u32 vm_exit_controls;
0409     u32 secondary_vm_exec_control;
0410 
0411     u64 io_bitmap_a;
0412     u64 io_bitmap_b;
0413     u64 msr_bitmap;
0414 
0415     u16 guest_es_selector;
0416     u16 guest_cs_selector;
0417     u16 guest_ss_selector;
0418     u16 guest_ds_selector;
0419     u16 guest_fs_selector;
0420     u16 guest_gs_selector;
0421     u16 guest_ldtr_selector;
0422     u16 guest_tr_selector;
0423 
0424     u32 guest_es_limit;
0425     u32 guest_cs_limit;
0426     u32 guest_ss_limit;
0427     u32 guest_ds_limit;
0428     u32 guest_fs_limit;
0429     u32 guest_gs_limit;
0430     u32 guest_ldtr_limit;
0431     u32 guest_tr_limit;
0432     u32 guest_gdtr_limit;
0433     u32 guest_idtr_limit;
0434 
0435     u32 guest_es_ar_bytes;
0436     u32 guest_cs_ar_bytes;
0437     u32 guest_ss_ar_bytes;
0438     u32 guest_ds_ar_bytes;
0439     u32 guest_fs_ar_bytes;
0440     u32 guest_gs_ar_bytes;
0441     u32 guest_ldtr_ar_bytes;
0442     u32 guest_tr_ar_bytes;
0443 
0444     u64 guest_es_base;
0445     u64 guest_cs_base;
0446     u64 guest_ss_base;
0447     u64 guest_ds_base;
0448     u64 guest_fs_base;
0449     u64 guest_gs_base;
0450     u64 guest_ldtr_base;
0451     u64 guest_tr_base;
0452     u64 guest_gdtr_base;
0453     u64 guest_idtr_base;
0454 
0455     u64 padding64_1[3];
0456 
0457     u64 vm_exit_msr_store_addr;
0458     u64 vm_exit_msr_load_addr;
0459     u64 vm_entry_msr_load_addr;
0460 
0461     u64 cr3_target_value0;
0462     u64 cr3_target_value1;
0463     u64 cr3_target_value2;
0464     u64 cr3_target_value3;
0465 
0466     u32 page_fault_error_code_mask;
0467     u32 page_fault_error_code_match;
0468 
0469     u32 cr3_target_count;
0470     u32 vm_exit_msr_store_count;
0471     u32 vm_exit_msr_load_count;
0472     u32 vm_entry_msr_load_count;
0473 
0474     u64 tsc_offset;
0475     u64 virtual_apic_page_addr;
0476     u64 vmcs_link_pointer;
0477 
0478     u64 guest_ia32_debugctl;
0479     u64 guest_ia32_pat;
0480     u64 guest_ia32_efer;
0481 
0482     u64 guest_pdptr0;
0483     u64 guest_pdptr1;
0484     u64 guest_pdptr2;
0485     u64 guest_pdptr3;
0486 
0487     u64 guest_pending_dbg_exceptions;
0488     u64 guest_sysenter_esp;
0489     u64 guest_sysenter_eip;
0490 
0491     u32 guest_activity_state;
0492     u32 guest_sysenter_cs;
0493 
0494     u64 cr0_guest_host_mask;
0495     u64 cr4_guest_host_mask;
0496     u64 cr0_read_shadow;
0497     u64 cr4_read_shadow;
0498     u64 guest_cr0;
0499     u64 guest_cr3;
0500     u64 guest_cr4;
0501     u64 guest_dr7;
0502 
0503     u64 host_fs_base;
0504     u64 host_gs_base;
0505     u64 host_tr_base;
0506     u64 host_gdtr_base;
0507     u64 host_idtr_base;
0508     u64 host_rsp;
0509 
0510     u64 ept_pointer;
0511 
0512     u16 virtual_processor_id;
0513     u16 padding16_2[3];
0514 
0515     u64 padding64_2[5];
0516     u64 guest_physical_address;
0517 
0518     u32 vm_instruction_error;
0519     u32 vm_exit_reason;
0520     u32 vm_exit_intr_info;
0521     u32 vm_exit_intr_error_code;
0522     u32 idt_vectoring_info_field;
0523     u32 idt_vectoring_error_code;
0524     u32 vm_exit_instruction_len;
0525     u32 vmx_instruction_info;
0526 
0527     u64 exit_qualification;
0528     u64 exit_io_instruction_ecx;
0529     u64 exit_io_instruction_esi;
0530     u64 exit_io_instruction_edi;
0531     u64 exit_io_instruction_eip;
0532 
0533     u64 guest_linear_address;
0534     u64 guest_rsp;
0535     u64 guest_rflags;
0536 
0537     u32 guest_interruptibility_info;
0538     u32 cpu_based_vm_exec_control;
0539     u32 exception_bitmap;
0540     u32 vm_entry_controls;
0541     u32 vm_entry_intr_info_field;
0542     u32 vm_entry_exception_error_code;
0543     u32 vm_entry_instruction_len;
0544     u32 tpr_threshold;
0545 
0546     u64 guest_rip;
0547 
0548     u32 hv_clean_fields;
0549     u32 hv_padding_32;
0550     u32 hv_synthetic_controls;
0551     struct {
0552         u32 nested_flush_hypercall:1;
0553         u32 msr_bitmap:1;
0554         u32 reserved:30;
0555     }  __packed hv_enlightenments_control;
0556     u32 hv_vp_id;
0557 
0558     u64 hv_vm_id;
0559     u64 partition_assist_page;
0560     u64 padding64_4[4];
0561     u64 guest_bndcfgs;
0562     u64 padding64_5[7];
0563     u64 xss_exit_bitmap;
0564     u64 padding64_6[7];
0565 } __packed;
0566 
0567 #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_NONE         0
0568 #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_IO_BITMAP        BIT(0)
0569 #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_MSR_BITMAP       BIT(1)
0570 #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP2     BIT(2)
0571 #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP1     BIT(3)
0572 #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_PROC     BIT(4)
0573 #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_EVENT        BIT(5)
0574 #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_ENTRY        BIT(6)
0575 #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_EXCPN        BIT(7)
0576 #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CRDR         BIT(8)
0577 #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_XLAT     BIT(9)
0578 #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_BASIC      BIT(10)
0579 #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1       BIT(11)
0580 #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2       BIT(12)
0581 #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_POINTER     BIT(13)
0582 #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1        BIT(14)
0583 #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_ENLIGHTENMENTSCONTROL    BIT(15)
0584 
0585 #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL          0xFFFF
0586 
0587 struct hv_partition_assist_pg {
0588     u32 tlb_lock_count;
0589 };
0590 
0591 enum hv_interrupt_type {
0592     HV_X64_INTERRUPT_TYPE_FIXED             = 0x0000,
0593     HV_X64_INTERRUPT_TYPE_LOWESTPRIORITY    = 0x0001,
0594     HV_X64_INTERRUPT_TYPE_SMI               = 0x0002,
0595     HV_X64_INTERRUPT_TYPE_REMOTEREAD        = 0x0003,
0596     HV_X64_INTERRUPT_TYPE_NMI               = 0x0004,
0597     HV_X64_INTERRUPT_TYPE_INIT              = 0x0005,
0598     HV_X64_INTERRUPT_TYPE_SIPI              = 0x0006,
0599     HV_X64_INTERRUPT_TYPE_EXTINT            = 0x0007,
0600     HV_X64_INTERRUPT_TYPE_LOCALINT0         = 0x0008,
0601     HV_X64_INTERRUPT_TYPE_LOCALINT1         = 0x0009,
0602     HV_X64_INTERRUPT_TYPE_MAXIMUM           = 0x000A,
0603 };
0604 
0605 union hv_msi_address_register {
0606     u32 as_uint32;
0607     struct {
0608         u32 reserved1:2;
0609         u32 destination_mode:1;
0610         u32 redirection_hint:1;
0611         u32 reserved2:8;
0612         u32 destination_id:8;
0613         u32 msi_base:12;
0614     };
0615 } __packed;
0616 
0617 union hv_msi_data_register {
0618     u32 as_uint32;
0619     struct {
0620         u32 vector:8;
0621         u32 delivery_mode:3;
0622         u32 reserved1:3;
0623         u32 level_assert:1;
0624         u32 trigger_mode:1;
0625         u32 reserved2:16;
0626     };
0627 } __packed;
0628 
0629 /* HvRetargetDeviceInterrupt hypercall */
0630 union hv_msi_entry {
0631     u64 as_uint64;
0632     struct {
0633         union hv_msi_address_register address;
0634         union hv_msi_data_register data;
0635     } __packed;
0636 };
0637 
0638 #include <asm-generic/hyperv-tlfs.h>
0639 
0640 #endif