VM-Exit handler for different exit reasons.
23{
28
29
30
31
32 VCpu = &
g_GuestState[KeGetCurrentProcessorNumberEx(NULL)];
33
34
35
36
37 VCpu->
Regs = GuestRegs;
38
39
40
41
43
44
45
46
48 ExitReason &= 0xffff;
49
50
51
52
53
55 {
57 }
58
59
60
61
63
64
65
66
68
69
70
71
72 __vmx_vmread(VMCS_GUEST_RSP, &VCpu->
Regs->
rsp);
73
74
75
76
78
79
80
81
82
83
84
85 switch (ExitReason)
86 {
87 case VMX_EXIT_REASON_TRIPLE_FAULT:
88 {
90
91 break;
92 }
93
94
95
96
97
98
99
100 case VMX_EXIT_REASON_EXECUTE_VMCLEAR:
101 case VMX_EXIT_REASON_EXECUTE_VMPTRLD:
102 case VMX_EXIT_REASON_EXECUTE_VMPTRST:
103 case VMX_EXIT_REASON_EXECUTE_VMREAD:
104 case VMX_EXIT_REASON_EXECUTE_VMRESUME:
105 case VMX_EXIT_REASON_EXECUTE_VMWRITE:
106 case VMX_EXIT_REASON_EXECUTE_VMXOFF:
107 case VMX_EXIT_REASON_EXECUTE_VMXON:
108 case VMX_EXIT_REASON_EXECUTE_VMLAUNCH:
109 {
110
111
112
113
114
115
116
117
118
119
121
122 break;
123 }
124 case VMX_EXIT_REASON_EXECUTE_INVEPT:
125 case VMX_EXIT_REASON_EXECUTE_INVVPID:
126 case VMX_EXIT_REASON_EXECUTE_GETSEC:
127 case VMX_EXIT_REASON_EXECUTE_INVD:
128 {
129
130
131
133
134 break;
135 }
136 case VMX_EXIT_REASON_MOV_CR:
137 {
138
139
140
142
143 break;
144 }
145 case VMX_EXIT_REASON_EXECUTE_RDMSR:
146 {
147
148
149
151
152 break;
153 }
154 case VMX_EXIT_REASON_EXECUTE_WRMSR:
155 {
156
157
158
160
161 break;
162 }
163 case VMX_EXIT_REASON_EXECUTE_CPUID:
164 {
165
166
167
169
170 break;
171 }
172
173 case VMX_EXIT_REASON_EXECUTE_IO_INSTRUCTION:
174 {
175
176
177
179
180 break;
181 }
182 case VMX_EXIT_REASON_EPT_VIOLATION:
183 {
185 {
186 LogError(
"Err, there were errors in handling EPT violation");
187 }
188
189 break;
190 }
191 case VMX_EXIT_REASON_EPT_MISCONFIGURATION:
192 {
194
195 break;
196 }
197 case VMX_EXIT_REASON_EXECUTE_VMCALL:
198 {
199
200
201
203
204 break;
205 }
206 case VMX_EXIT_REASON_EXCEPTION_OR_NMI:
207 {
208
209
210
212
213 break;
214 }
215 case VMX_EXIT_REASON_EXTERNAL_INTERRUPT:
216 {
217
218
219
221
222 break;
223 }
224 case VMX_EXIT_REASON_INTERRUPT_WINDOW:
225 {
226
227
228
229
231
232 break;
233 }
234 case VMX_EXIT_REASON_NMI_WINDOW:
235 {
236
237
238
240
241 break;
242 }
243 case VMX_EXIT_REASON_MONITOR_TRAP_FLAG:
244 {
245
246
247
249
250 break;
251 }
252 case VMX_EXIT_REASON_EXECUTE_HLT:
253 {
254
255
256
257
258
259
260
261 break;
262 }
263 case VMX_EXIT_REASON_EXECUTE_RDTSC:
264 case VMX_EXIT_REASON_EXECUTE_RDTSCP:
265
266 {
267
268
269
270
271
272 if (ShouldEmulateRdtscp)
273 {
275 }
276
277 break;
278 }
279 case VMX_EXIT_REASON_EXECUTE_RDPMC:
280 {
281
282
283
285
286 break;
287 }
288 case VMX_EXIT_REASON_MOV_DR:
289 {
290
291
292
294
295 break;
296 }
297 case VMX_EXIT_REASON_EXECUTE_XSETBV:
298 {
299
300
301
303
304 break;
305 }
306 case VMX_EXIT_REASON_VMX_PREEMPTION_TIMER_EXPIRED:
307 {
308
309
310
312
313 break;
314 }
315 case VMX_EXIT_REASON_PAGE_MODIFICATION_LOG_FULL:
316 {
317
318
319
321
322 break;
323 }
324 default:
325 {
326 LogError(
"Err, unknown vmexit, reason : 0x%llx", ExitReason);
327
328 break;
329 }
330 }
331
332
333
334
335
337 {
339 }
340
341
342
343
345 {
347 }
348
349
350
351
353 {
354 if (ExitReason != VMX_EXIT_REASON_EXECUTE_RDTSC && ExitReason != VMX_EXIT_REASON_EXECUTE_RDTSCP && ExitReason != VMX_EXIT_REASON_EXECUTE_CPUID)
355 {
356
357
358
359
361 }
362 }
363
364
365
366
368
369
370
371
372 return Result;
373}
UCHAR BOOLEAN
Definition BasicTypes.h:39
#define TRUE
Definition BasicTypes.h:55
#define FALSE
Definition BasicTypes.h:54
unsigned int UINT32
Definition BasicTypes.h:48
VOID VmxHandleTripleFaults(VIRTUAL_MACHINE_STATE *VCpu)
Handling triple fault VM-exits.
Definition CrossVmexits.c:50
VOID VmxHandleVmxPreemptionTimerVmexit(VIRTUAL_MACHINE_STATE *VCpu)
Handling VMX Preemption Timer vm-exits.
Definition CrossVmexits.c:33
VOID VmxHandleXsetbv(VIRTUAL_MACHINE_STATE *VCpu)
Handling XSETBV Instruction vm-exits.
Definition CrossVmexits.c:21
VOID DirtyLoggingHandleVmexits(VIRTUAL_MACHINE_STATE *VCpu)
Handling vm-exits of PML.
Definition DirtyLogging.c:300
VOID DispatchEventException(VIRTUAL_MACHINE_STATE *VCpu)
Handling debugger functions related to EXCEPTION events.
Definition Dispatch.c:755
VOID DispatchEventRdpmc(VIRTUAL_MACHINE_STATE *VCpu)
Handling debugger functions related to RDPMC events.
Definition Dispatch.c:589
VOID DispatchEventRdmsr(VIRTUAL_MACHINE_STATE *VCpu)
Handling debugger functions related to RDMSR events.
Definition Dispatch.c:499
VOID DispatchEventCpuid(VIRTUAL_MACHINE_STATE *VCpu)
Handling debugger functions related to CPUID events.
Definition Dispatch.c:113
VOID DispatchEventTsc(VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN IsRdtscp)
Handling debugger functions related to RDTSC/RDTSCP events.
Definition Dispatch.c:194
VOID DispatchEventIO(VIRTUAL_MACHINE_STATE *VCpu)
Handling debugger functions related to IO events.
Definition Dispatch.c:425
VOID DispatchEventMov2DebugRegs(VIRTUAL_MACHINE_STATE *VCpu)
Handling debugger functions related to MOV 2 DR events.
Definition Dispatch.c:634
VOID DispatchEventVmcall(VIRTUAL_MACHINE_STATE *VCpu)
Handling debugger functions related to VMCALL events.
Definition Dispatch.c:248
VOID DispatchEventMovToFromControlRegisters(VIRTUAL_MACHINE_STATE *VCpu)
Handling debugger functions related to mov to/from CR events.
Definition Dispatch.c:691
VOID DispatchEventWrmsr(VIRTUAL_MACHINE_STATE *VCpu)
Handling debugger functions related to WRMSR events.
Definition Dispatch.c:544
VOID DispatchEventExternalInterrupts(VIRTUAL_MACHINE_STATE *VCpu)
Handling debugger functions related to external-interrupt events.
Definition Dispatch.c:850
BOOLEAN EptHandleEptViolation(VIRTUAL_MACHINE_STATE *VCpu)
Handle VM exits for EPT violations.
Definition Ept.c:1002
VOID EptHandleMisconfiguration(VOID)
Handle vm-exits for EPT Misconfiguration.
Definition Ept.c:1046
VOID EventInjectUndefinedOpcode(VIRTUAL_MACHINE_STATE *VCpu)
Inject #UD to the guest (Invalid Opcode - Undefined Opcode)
Definition Events.c:79
VIRTUAL_MACHINE_STATE * g_GuestState
Save the state and variables related to virtualization on each to logical core.
Definition GlobalVariables.h:38
BOOLEAN g_TransparentMode
Shows whether the debugger transparent mode is enabled (true) or not (false)
Definition GlobalVariables.h:75
VOID HvResumeToNextInstruction()
Add the current instruction length to guest rip to resume to next instruction.
Definition Hv.c:302
#define LogError(format,...)
Log in the case of error.
Definition HyperDbgHyperLogIntrinsics.h:113
VOID IdtEmulationHandleInterruptWindowExiting(_Inout_ VIRTUAL_MACHINE_STATE *VCpu)
Handle interrupt-window exitings.
Definition IdtEmulation.c:565
VOID IdtEmulationHandleNmiWindowExiting(_Inout_ VIRTUAL_MACHINE_STATE *VCpu)
Handle NMI-window exitings.
Definition IdtEmulation.c:508
VOID MtfHandleVmexit(VIRTUAL_MACHINE_STATE *VCpu)
Handle Monitor Trap Flag vm-exits.
Definition Mtf.c:21
BOOLEAN TransparentModeStart(VIRTUAL_MACHINE_STATE *VCpu, UINT32 ExitReason)
VM-Exit handler for different exit reasons.
Definition Transparency.c:493
UCHAR VmxVmread32P(size_t Field, UINT32 *FieldValue)
VMX VMREAD instruction (32-bit)
Definition Vmx.c:86
NULL()
Definition test-case-generator.py:530
The status of each core after and before VMX.
Definition State.h:290
UINT32 ExitQualification
Definition State.h:308
BOOLEAN IncrementRip
Definition State.h:292
GUEST_REGS * Regs
Definition State.h:305
VMX_VMXOFF_STATE VmxoffState
Definition State.h:328
BOOLEAN IsOnVmxRootMode
Definition State.h:291
VM_EXIT_TRANSPARENCY TransparencyState
Definition State.h:330
UINT64 LastVmexitRip
Definition State.h:309
UINT64 PreviousTimeStampCounter
Definition State.h:138
BOOLEAN IsVmxoffExecuted
Definition State.h:152
UINT64 rsp
Definition BasicTypes.h:79