28#define VMXON_SIZE 4096
34#define PIN_BASED_VM_EXECUTION_CONTROLS_EXTERNAL_INTERRUPT 0x00000001
35#define PIN_BASED_VM_EXECUTION_CONTROLS_NMI_EXITING 0x00000008
36#define PIN_BASED_VM_EXECUTION_CONTROLS_VIRTUAL_NMI 0x00000020
37#define PIN_BASED_VM_EXECUTION_CONTROLS_ACTIVE_VMX_TIMER 0x00000040
38#define PIN_BASED_VM_EXECUTION_CONTROLS_PROCESS_POSTED_INTERRUPTS 0x00000080
44#define CPU_BASED_VIRTUAL_INTR_PENDING 0x00000004
45#define CPU_BASED_USE_TSC_OFFSETTING 0x00000008
46#define CPU_BASED_HLT_EXITING 0x00000080
47#define CPU_BASED_INVLPG_EXITING 0x00000200
48#define CPU_BASED_MWAIT_EXITING 0x00000400
49#define CPU_BASED_RDPMC_EXITING 0x00000800
50#define CPU_BASED_RDTSC_EXITING 0x00001000
51#define CPU_BASED_CR3_LOAD_EXITING 0x00008000
52#define CPU_BASED_CR3_STORE_EXITING 0x00010000
53#define CPU_BASED_CR8_LOAD_EXITING 0x00080000
54#define CPU_BASED_CR8_STORE_EXITING 0x00100000
55#define CPU_BASED_TPR_SHADOW 0x00200000
56#define CPU_BASED_VIRTUAL_NMI_PENDING 0x00400000
57#define CPU_BASED_MOV_DR_EXITING 0x00800000
58#define CPU_BASED_UNCOND_IO_EXITING 0x01000000
59#define CPU_BASED_ACTIVATE_IO_BITMAP 0x02000000
60#define CPU_BASED_MONITOR_TRAP_FLAG 0x08000000
61#define CPU_BASED_ACTIVATE_MSR_BITMAP 0x10000000
62#define CPU_BASED_MONITOR_EXITING 0x20000000
63#define CPU_BASED_PAUSE_EXITING 0x40000000
64#define CPU_BASED_ACTIVATE_SECONDARY_CONTROLS 0x80000000
70#define CPU_BASED_CTL2_ENABLE_EPT 0x2
71#define CPU_BASED_CTL2_RDTSCP 0x8
72#define CPU_BASED_CTL2_ENABLE_VPID 0x20
73#define CPU_BASED_CTL2_UNRESTRICTED_GUEST 0x80
74#define CPU_BASED_CTL2_VIRTUAL_INTERRUPT_DELIVERY 0x200
75#define CPU_BASED_CTL2_ENABLE_INVPCID 0x1000
76#define CPU_BASED_CTL2_ENABLE_VMFUNC 0x2000
77#define CPU_BASED_CTL2_ENABLE_XSAVE_XRSTORS 0x100000
83#define VM_EXIT_SAVE_DEBUG_CONTROLS 0x00000004
84#define VM_EXIT_HOST_ADDR_SPACE_SIZE 0x00000200
85#define VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL 0x00001000
86#define VM_EXIT_ACK_INTR_ON_EXIT 0x00008000
87#define VM_EXIT_SAVE_IA32_PAT 0x00040000
88#define VM_EXIT_LOAD_IA32_PAT 0x00080000
89#define VM_EXIT_SAVE_IA32_EFER 0x00100000
90#define VM_EXIT_LOAD_IA32_EFER 0x00200000
91#define VM_EXIT_SAVE_VMX_PREEMPTION_TIMER 0x00400000
97#define VM_ENTRY_LOAD_DEBUG_CONTROLS 0x00000004
98#define VM_ENTRY_IA32E_MODE 0x00000200
99#define VM_ENTRY_SMM 0x00000400
100#define VM_ENTRY_DEACT_DUAL_MONITOR 0x00000800
101#define VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL 0x00002000
102#define VM_ENTRY_LOAD_IA32_PAT 0x00004000
103#define VM_ENTRY_LOAD_IA32_EFER 0x00008000
109#define HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS 0x40000000
110#define HYPERV_CPUID_INTERFACE 0x40000001
111#define HYPERV_CPUID_VERSION 0x40000002
112#define HYPERV_CPUID_FEATURES 0x40000003
113#define HYPERV_CPUID_ENLIGHTMENT_INFO 0x40000004
114#define HYPERV_CPUID_IMPLEMENT_LIMITS 0x40000005
115#define HYPERV_HYPERVISOR_PRESENT_BIT 0x80000000
116#define HYPERV_CPUID_MIN 0x40000005
117#define HYPERV_CPUID_MAX 0x4000ffff
123#define GUEST_INTR_STATE_STI 0x00000001
124#define GUEST_INTR_STATE_MOV_SS 0x00000002
125#define GUEST_INTR_STATE_SMI 0x00000004
126#define GUEST_INTR_STATE_NMI 0x00000008
127#define GUEST_INTR_STATE_ENCLAVE_INTR 0x00000010
133#define SHADOW_INT_MOV_SS 0x01
134#define SHADOW_INT_STI 0x02
140#define VMM_STACK_SIZE 0x8000
142#define IS_VALID_DEBUG_REGISTER(DebugRegister) \
143 (((DebugRegister <= VMX_EXIT_QUALIFICATION_REGISTER_DR0) && (DebugRegister <= VMX_EXIT_QUALIFICATION_REGISTER_DR7)) && (DebugRegister != 0x00000004 && DebugRegister != 0x00000005))
290#define VMCS_GUEST_DEBUGCTL_HIGH 0x00002803
291#define VIRTUAL_PROCESSOR_ID 0x00000000
412 const CHAR * Address2,
418 const wchar_t * Address2,
424 const CHAR * Address2,
unsigned short UINT16
Definition BasicTypes.h:47
signed int INT32
Definition BasicTypes.h:44
UCHAR BOOLEAN
Definition BasicTypes.h:39
unsigned char UCHAR
Definition BasicTypes.h:35
#define VOID
Definition BasicTypes.h:33
unsigned __int64 UINT64
Definition BasicTypes.h:21
unsigned int UINT32
Definition BasicTypes.h:48
char CHAR
Definition BasicTypes.h:31
ThreeOpFunc1 interlocked_compare_exchange ThreeOpFunc2 event_inject_error_code memcpy TwoOpFunc1 ed eb eq interlocked_exchange interlocked_exchange_add TwoOpFunc2 spinlock_lock_custom_wait event_inject OneOpFunc1 poi db dd dw dq neg hi low not check_address disassemble_len disassemble_len32 disassemble_len64 interlocked_increment interlocked_decrement reference physical_to_virtual virtual_to_physical OneOpFunc2 print formats event_enable event_disable event_clear test_statement spinlock_lock spinlock_unlock event_sc OneOpFunc3 strlen TwoOpFunc3 strcmp ThreeOpFunc3 memcmp strncmp ThreeOpFunc4 wcsncmp OneOpFunc4 wcslen TwoOpFunc4 wcscmp ZeroOpFunc1 pause flush event_trace_step event_trace_step_in event_trace_step_out event_trace_instrumentation_step event_trace_instrumentation_step_in VarArgFunc1 printf OperatorsTwoOperand or xor and asr asl add sub mul div mod gt lt egt elt equal neq OperatorsOneOperand inc dec reference dereference SemantiRules start_of_if jmp jz jnz jmp_to_end_and_jzcompleted end_of_if start_of_while end_of_while vargstart mov start_of_do_while start_of_do_while_commands end_of_do_while start_of_for for_inc_dec start_of_for_ommands end_of_if ignore_lvalue push pop call ret Registers rax eax ax ah al rcx ecx cx ch cl rdx edx dx dh dl rbx ebx bx bh bl rsp esp sp spl rbp ebp bp bpl rsi esi si sil rdi edi di dil r8 r8d r8w r8h r8l r9 r9d r9w r9h r9l r10 r10d r10w r10h r10l r11 r11d r11w r11h r11l r12 r12d r12w r12h r12l r13 r13d r13w r13h r13l r14 r14d r14w r14h r14l r15 r15d r15w r15h r15l ds es fs gs cs ss rflags eflags flags cf pf af zf sf tf if df of iopl nt rf vm ac vif vip id rip eip ip idtr ldtr gdtr tr cr0 cr2 cr3 cr4 cr8 dr0 dr1 dr2 dr3 dr6 dr7 PseudoRegisters pid tid pname core proc thread peb teb ip buffer context event_tag event_id event_stage date time S STATEMENT S S
Definition Grammar.txt:51
UCHAR VmxVmread64P(size_t Field, UINT64 *FieldValue)
VMX VMREAD instruction (64-bit)
Definition Vmx.c:72
union _HYPERCALL_INPUT_VALUE * PHYPERCALL_INPUT_VALUE
VOID VmxVmptrst()
Implementation of VMPTRST instruction.
Definition Vmx.c:748
UCHAR VmxVmread16P(size_t Field, UINT16 *FieldValue)
VMX VMREAD instruction (16-bit)
Definition Vmx.c:104
UINT64 VmxReturnInstructionPointerForVmxoff()
Get the RIP of guest (VMCS_GUEST_RIP) in the case of return from VMXOFF.
Definition Vmx.c:1189
UINT64 VmxReturnStackPointerForVmxoff()
Get the RIP of guest (VMCS_GUEST_RIP) in the case of return from VMXOFF.
Definition Vmx.c:1178
UCHAR VmxVmwrite64(size_t Field, UINT64 FieldValue)
VMX VMWRITE instruction (64-bit)
Definition Vmx.c:122
BOOLEAN VmxGetCurrentExecutionMode()
Check current execution mode (vmx-root and non-root)
Definition Vmx.c:222
VOID VmxHandleTripleFaults(VIRTUAL_MACHINE_STATE *VCpu)
Handling triple fault VM-exits.
Definition CrossVmexits.c:50
UINT32 VmxCompatibleWcslen(const wchar_t *S)
implementation of vmx-root mode compatible wcslen
Definition Vmx.c:1379
BOOLEAN VmxSetupVmcs(_In_ VIRTUAL_MACHINE_STATE *VCpu, _In_ PVOID GuestStack)
VOID VmxPerformTermination()
Terminate Vmx on all logical cores.
Definition Vmx.c:1200
BOOLEAN VmxPerformVirtualizationOnAllCores()
Initialize essential VMX Operation tasks.
Definition Vmx.c:413
UCHAR VmxVmread64(size_t Field, UINT64 FieldValue)
VMX VMREAD instruction (64-bit)
Definition Vmx.c:22
BOOLEAN VmxGetCurrentLaunchState()
Check if the VMX is launched or not.
Definition Vmx.c:246
VOID VmxFixCr4AndCr0Bits()
Fix values for cr0 and cr4 bits.
Definition Vmx.c:541
INT32 VmxCompatibleWcscmp(const wchar_t *Address1, const wchar_t *Address2, SIZE_T Num, BOOLEAN IsWcsncmp)
implementation of vmx-root mode compatible wcscmp and wcsncmp
Definition Vmx.c:1610
UCHAR VmxVmwrite16(size_t Field, UINT16 FieldValue)
VMX VMWRITE instruction (16-bit)
Definition Vmx.c:152
enum _MOV_TO_DEBUG_REG MOV_TO_DEBUG_REG
MOV to debug registers states.
_MOV_TO_DEBUG_REG
MOV to debug registers states.
Definition Vmx.h:298
@ AccessFromDebugRegister
Definition Vmx.h:300
@ AccessToDebugRegister
Definition Vmx.h:299
VOID VmxVmresume()
Resume VM using VMRESUME instruction.
Definition Vmx.c:1020
UCHAR VmxVmread32(size_t Field, UINT32 FieldValue)
VMX VMREAD instruction (32-bit)
Definition Vmx.c:36
VOID VmxHandleVmxPreemptionTimerVmexit(VIRTUAL_MACHINE_STATE *VCpu)
Handling VMX Preemption Timer vm-exits.
Definition CrossVmexits.c:33
UINT32 VmxCompatibleStrlen(const CHAR *S)
implementation of vmx-root mode compatible strlen
Definition Vmx.c:1290
HYPERCALL_CODE
Hyper-V Hypercalls.
Definition Vmx.h:172
@ HvUnmapStatsPage
Definition Vmx.h:237
@ HvClearVirtualInterrupt
Definition Vmx.h:214
@ HvGetPartitionId
Definition Vmx.h:198
@ HvCallParkedVirtualProcessors
Definition Vmx.h:179
@ HvCallConnectPort
Definition Vmx.h:273
@ HvCallEnableVpVtl
Definition Vmx.h:184
@ HvInstallIntercept
Definition Vmx.h:205
@ HvMapGpaPages
Definition Vmx.h:203
@ HvSwitchVirtualAddressSpace
Definition Vmx.h:173
@ HvCallMapSparseGpaPages
Definition Vmx.h:238
@ HvCallSendSyntheticClusterIpiEx
Definition Vmx.h:190
@ HvInitializePartition
Definition Vmx.h:193
@ HvCallPrepareForHibernate
Definition Vmx.h:258
@ HvCallQueryNumaDistance
Definition Vmx.h:244
@ HvCallVtlReturn
Definition Vmx.h:187
@ HvFinalizeEventLogBufferGroup
Definition Vmx.h:225
@ HvCallEnablePartitionVtl
Definition Vmx.h:182
@ HvCallAddLogicalProcessor
Definition Vmx.h:242
@ HvCallMapDevicePages
Definition Vmx.h:252
@ HvCallCreatePort
Definition Vmx.h:272
@ HvDepositMemory
Definition Vmx.h:200
@ HvCallGetLogicalProcessorRegisters
Definition Vmx.h:260
@ HvCallSetSystemProperty
Definition Vmx.h:239
@ HvCallFlushVirtualAddressListEx
Definition Vmx.h:189
@ HvCallRegisterInterceptResult
Definition Vmx.h:269
@ HvDeleteVp
Definition Vmx.h:207
@ HvSavePartitionState
Definition Vmx.h:222
@ HvReadGpa
Definition Vmx.h:211
@ HvCallModifyVtlProtectionMask
Definition Vmx.h:181
@ HvCallNotifyStandbyTransition
Definition Vmx.h:256
@ HvCallGetSpaPageList
Definition Vmx.h:274
@ HvGetLogicalProcessorRunTime
Definition Vmx.h:176
@ HvFlushEventLogBuffer
Definition Vmx.h:232
@ HvCallModifySparseGpaPages
Definition Vmx.h:268
@ HvDeletePort
Definition Vmx.h:216
@ HvCallDisablePartitionVtl
Definition Vmx.h:183
@ HvCallUnmapDevicePages
Definition Vmx.h:253
@ HvCallRemoveLogicalProcessor
Definition Vmx.h:243
@ HvCallRetargetDeviceInterrupt
Definition Vmx.h:250
@ HvCallSetPortProperty
Definition Vmx.h:240
@ HvSetEventLogGroupSources
Definition Vmx.h:230
@ HvCreatePartition
Definition Vmx.h:192
@ HvDeleteEventLogBuffer
Definition Vmx.h:227
@ HvGetPartitionProperty
Definition Vmx.h:196
@ HvCallVtlCall
Definition Vmx.h:186
@ HvCallPrepareForSleep
Definition Vmx.h:257
@ HvWithdrawMemory
Definition Vmx.h:201
@ HvFinalizePartition
Definition Vmx.h:194
@ HvCallNotifyPartitionEvent
Definition Vmx.h:259
@ HvSetVpRegisters
Definition Vmx.h:209
@ HvMapStatsPage
Definition Vmx.h:236
@ HvSetPartitionProperty
Definition Vmx.h:197
@ HvCallCollectLivedump
Definition Vmx.h:266
@ HvCallGetLogicalProcessorProperty
Definition Vmx.h:246
@ HvPostMessage
Definition Vmx.h:220
@ HvFlushVirtualAddressList
Definition Vmx.h:175
@ HvCallGetVpIndexFromApicId
Definition Vmx.h:277
@ HvCallSyntheticClusterIpi
Definition Vmx.h:180
@ HvCallScrubPartition
Definition Vmx.h:265
@ HvCallSetLogicalProcessorProperty
Definition Vmx.h:245
@ HvSignalEvent
Definition Vmx.h:221
@ HvUnmapEventLogBuffer
Definition Vmx.h:229
@ HvCallDisableVpVtl
Definition Vmx.h:185
@ HvInitializeEventLogBufferGroup
Definition Vmx.h:224
@ HvCreateVp
Definition Vmx.h:206
@ HvCallUnmapDeviceInterrupt
Definition Vmx.h:249
@ HvCallStartVirtualProcessor
Definition Vmx.h:276
@ HvGetNextChildPartition
Definition Vmx.h:199
@ HvCallMapDeviceInterrupt
Definition Vmx.h:248
@ HvResetDebugSession
Definition Vmx.h:235
@ HvCallDetachDevice
Definition Vmx.h:255
@ HvRetrieveDebugData
Definition Vmx.h:234
@ HvDeletePartition
Definition Vmx.h:195
@ HvCallUnregisterInterceptResult
Definition Vmx.h:270
@ HvCallNotifyRingEmpty
Definition Vmx.h:263
@ HvGetVpRegisters
Definition Vmx.h:208
@ HvFlushVirtualAddressSpace
Definition Vmx.h:174
@ HvDisconnectPort
Definition Vmx.h:219
@ HvCallAttachDevice
Definition Vmx.h:254
@ HvCallDisableHypervisor
Definition Vmx.h:267
@ HvPostDebugData
Definition Vmx.h:233
@ HvCallQueryAssotiatedLpsforMca
Definition Vmx.h:262
@ HvGetMemoryBalance
Definition Vmx.h:202
@ HvTranslateVirtualAddress
Definition Vmx.h:210
@ HvCallGetSystemProperty
Definition Vmx.h:247
@ HvUnmapGpaPages
Definition Vmx.h:204
@ HvCreateEventLogBuffer
Definition Vmx.h:226
@ HvConnectPort
Definition Vmx.h:217
@ HvCallAssertVirtualInterrupt
Definition Vmx.h:271
@ HvCallFlushVirtualAddressSpaceEx
Definition Vmx.h:188
@ HvCallSetLogicalProcessorRegisters
Definition Vmx.h:261
@ HvGetPortProperty
Definition Vmx.h:218
@ HvWriteGpa
Definition Vmx.h:212
@ HvCallNotifyLongSpinWait
Definition Vmx.h:178
@ HvReleaseEventLogBuffer
Definition Vmx.h:231
@ HvCallFlushGuestPhysicalAddressList
Definition Vmx.h:280
@ HvCallFlushGuestPhysicalAddressSpace
Definition Vmx.h:279
@ HvRestorePartitionState
Definition Vmx.h:223
@ HvCallInjectSyntheticMachineCheck
Definition Vmx.h:264
@ HvMapEventLogBuffer
Definition Vmx.h:228
BOOLEAN VmxLoadVmcs(_In_ VIRTUAL_MACHINE_STATE *VCpu)
BOOLEAN VmxClearVmcsState(_In_ VIRTUAL_MACHINE_STATE *VCpu)
INT32 VmxCompatibleStrcmp(const CHAR *Address1, const CHAR *Address2, SIZE_T Num, BOOLEAN IsStrncmp)
implementation of vmx-root mode compatible strcmp and strncmp
Definition Vmx.c:1472
INT32 VmxCompatibleMemcmp(const CHAR *Address1, const CHAR *Address2, size_t Count)
implementation of vmx-root mode compatible memcmp
Definition Vmx.c:1748
BOOLEAN VmxCheckVmxSupport()
Check whether VMX Feature is supported or not.
Definition Vmx.c:166
VOID VmxHandleXsetbv(VIRTUAL_MACHINE_STATE *VCpu)
Handling XSETBV Instruction vm-exits.
Definition CrossVmexits.c:21
BOOLEAN VmxPerformVirtualizationOnSpecificCore()
Allocates Vmx regions for all logical cores (Vmxon region and Vmcs region)
Definition Vmx.c:500
VOID VmxVmxoff(VIRTUAL_MACHINE_STATE *VCpu)
Prepare and execute Vmxoff instruction.
Definition Vmx.c:1101
BOOLEAN VmxCheckIsOnVmxRoot()
It can deterministically check whether the caller is on vmx-root mode or not.
Definition Vmx.c:576
BOOLEAN VmxTerminate()
Broadcast to terminate VMX on all logical cores.
Definition Vmx.c:699
UCHAR VmxVmread16(size_t Field, UINT16 FieldValue)
VMX VMREAD instruction (16-bit)
Definition Vmx.c:54
BOOLEAN VmxInitialize()
Initialize the VMX operation.
Definition Vmx.c:260
union _HYPERCALL_INPUT_VALUE HYPERCALL_INPUT_VALUE
Hypercalls for Hyper-V.
UCHAR VmxVmwrite32(size_t Field, UINT32 FieldValue)
VMX VMWRITE instruction (32-bit)
Definition Vmx.c:136
UCHAR VmxVmread32P(size_t Field, UINT32 *FieldValue)
VMX VMREAD instruction (32-bit)
Definition Vmx.c:86
BOOLEAN VmxVirtualizeCurrentSystem(PVOID GuestStack)
Initialize VMX Operation.
Definition Vmx.c:605
The status of each core after and before VMX.
Definition State.h:290
Hypercalls for Hyper-V.
Definition Vmx.h:150
UINT64 RepStartIndex
Definition Vmx.h:161
UINT64 CallCode
Definition Vmx.h:154
UINT64 RepCount
Definition Vmx.h:159
UINT64 Fast
Definition Vmx.h:155
UINT64 VariableHeaderSize
Definition Vmx.h:156
struct _HYPERCALL_INPUT_VALUE::@48 Fields
UINT64 IsNested
Definition Vmx.h:157
UINT64 Flags
Definition Vmx.h:151
UINT64 Reserved0
Definition Vmx.h:158
UINT64 Reserved2
Definition Vmx.h:162
UINT64 Reserved1
Definition Vmx.h:160