1 | /* $Id: HMInternal.h 77716 2019-03-15 08:29:06Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * HM - Internal header file.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2019 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef VMM_INCLUDED_SRC_include_HMInternal_h
|
---|
19 | #define VMM_INCLUDED_SRC_include_HMInternal_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include <VBox/cdefs.h>
|
---|
25 | #include <VBox/types.h>
|
---|
26 | #include <VBox/vmm/stam.h>
|
---|
27 | #include <VBox/dis.h>
|
---|
28 | #include <VBox/vmm/hm.h>
|
---|
29 | #include <VBox/vmm/hm_vmx.h>
|
---|
30 | #include <VBox/vmm/hm_svm.h>
|
---|
31 | #include <VBox/vmm/pgm.h>
|
---|
32 | #include <VBox/vmm/cpum.h>
|
---|
33 | #include <VBox/vmm/trpm.h>
|
---|
34 | #include <iprt/memobj.h>
|
---|
35 | #include <iprt/cpuset.h>
|
---|
36 | #include <iprt/mp.h>
|
---|
37 | #include <iprt/avl.h>
|
---|
38 | #include <iprt/string.h>
|
---|
39 |
|
---|
40 | #if HC_ARCH_BITS == 32 && defined(RT_OS_DARWIN)
|
---|
41 | # error "32-bit darwin is no longer supported. Go back to 4.3 or earlier!"
|
---|
42 | #endif
|
---|
43 |
|
---|
44 | #if HC_ARCH_BITS == 64 || defined(VBOX_WITH_64_BITS_GUESTS)
|
---|
45 | /* Enable 64 bits guest support. */
|
---|
46 | # define VBOX_ENABLE_64_BITS_GUESTS
|
---|
47 | #endif
|
---|
48 |
|
---|
49 | #if HC_ARCH_BITS == 32 && defined(VBOX_ENABLE_64_BITS_GUESTS)
|
---|
50 | # define VMX_USE_CACHED_VMCS_ACCESSES
|
---|
51 | #endif
|
---|
52 |
|
---|
53 | /** @def HM_PROFILE_EXIT_DISPATCH
|
---|
54 | * Enables profiling of the VM exit handler dispatching. */
|
---|
55 | #if 0 || defined(DOXYGEN_RUNNING)
|
---|
56 | # define HM_PROFILE_EXIT_DISPATCH
|
---|
57 | #endif
|
---|
58 |
|
---|
59 | RT_C_DECLS_BEGIN
|
---|
60 |
|
---|
61 |
|
---|
62 | /** @defgroup grp_hm_int Internal
|
---|
63 | * @ingroup grp_hm
|
---|
64 | * @internal
|
---|
65 | * @{
|
---|
66 | */
|
---|
67 |
|
---|
68 | /** @name HM_CHANGED_XXX
|
---|
69 | * HM CPU-context changed flags.
|
---|
70 | *
|
---|
71 | * These flags are used to keep track of which registers and state has been
|
---|
72 | * modified since they were imported back into the guest-CPU context.
|
---|
73 | *
|
---|
74 | * @{
|
---|
75 | */
|
---|
76 | #define HM_CHANGED_HOST_CONTEXT UINT64_C(0x0000000000000001)
|
---|
77 | #define HM_CHANGED_GUEST_RIP UINT64_C(0x0000000000000004)
|
---|
78 | #define HM_CHANGED_GUEST_RFLAGS UINT64_C(0x0000000000000008)
|
---|
79 |
|
---|
80 | #define HM_CHANGED_GUEST_RAX UINT64_C(0x0000000000000010)
|
---|
81 | #define HM_CHANGED_GUEST_RCX UINT64_C(0x0000000000000020)
|
---|
82 | #define HM_CHANGED_GUEST_RDX UINT64_C(0x0000000000000040)
|
---|
83 | #define HM_CHANGED_GUEST_RBX UINT64_C(0x0000000000000080)
|
---|
84 | #define HM_CHANGED_GUEST_RSP UINT64_C(0x0000000000000100)
|
---|
85 | #define HM_CHANGED_GUEST_RBP UINT64_C(0x0000000000000200)
|
---|
86 | #define HM_CHANGED_GUEST_RSI UINT64_C(0x0000000000000400)
|
---|
87 | #define HM_CHANGED_GUEST_RDI UINT64_C(0x0000000000000800)
|
---|
88 | #define HM_CHANGED_GUEST_R8_R15 UINT64_C(0x0000000000001000)
|
---|
89 | #define HM_CHANGED_GUEST_GPRS_MASK UINT64_C(0x0000000000001ff0)
|
---|
90 |
|
---|
91 | #define HM_CHANGED_GUEST_ES UINT64_C(0x0000000000002000)
|
---|
92 | #define HM_CHANGED_GUEST_CS UINT64_C(0x0000000000004000)
|
---|
93 | #define HM_CHANGED_GUEST_SS UINT64_C(0x0000000000008000)
|
---|
94 | #define HM_CHANGED_GUEST_DS UINT64_C(0x0000000000010000)
|
---|
95 | #define HM_CHANGED_GUEST_FS UINT64_C(0x0000000000020000)
|
---|
96 | #define HM_CHANGED_GUEST_GS UINT64_C(0x0000000000040000)
|
---|
97 | #define HM_CHANGED_GUEST_SREG_MASK UINT64_C(0x000000000007e000)
|
---|
98 |
|
---|
99 | #define HM_CHANGED_GUEST_GDTR UINT64_C(0x0000000000080000)
|
---|
100 | #define HM_CHANGED_GUEST_IDTR UINT64_C(0x0000000000100000)
|
---|
101 | #define HM_CHANGED_GUEST_LDTR UINT64_C(0x0000000000200000)
|
---|
102 | #define HM_CHANGED_GUEST_TR UINT64_C(0x0000000000400000)
|
---|
103 | #define HM_CHANGED_GUEST_TABLE_MASK UINT64_C(0x0000000000780000)
|
---|
104 |
|
---|
105 | #define HM_CHANGED_GUEST_CR0 UINT64_C(0x0000000000800000)
|
---|
106 | #define HM_CHANGED_GUEST_CR2 UINT64_C(0x0000000001000000)
|
---|
107 | #define HM_CHANGED_GUEST_CR3 UINT64_C(0x0000000002000000)
|
---|
108 | #define HM_CHANGED_GUEST_CR4 UINT64_C(0x0000000004000000)
|
---|
109 | #define HM_CHANGED_GUEST_CR_MASK UINT64_C(0x0000000007800000)
|
---|
110 |
|
---|
111 | #define HM_CHANGED_GUEST_APIC_TPR UINT64_C(0x0000000008000000)
|
---|
112 | #define HM_CHANGED_GUEST_EFER_MSR UINT64_C(0x0000000010000000)
|
---|
113 |
|
---|
114 | #define HM_CHANGED_GUEST_DR0_DR3 UINT64_C(0x0000000020000000)
|
---|
115 | #define HM_CHANGED_GUEST_DR6 UINT64_C(0x0000000040000000)
|
---|
116 | #define HM_CHANGED_GUEST_DR7 UINT64_C(0x0000000080000000)
|
---|
117 | #define HM_CHANGED_GUEST_DR_MASK UINT64_C(0x00000000e0000000)
|
---|
118 |
|
---|
119 | #define HM_CHANGED_GUEST_X87 UINT64_C(0x0000000100000000)
|
---|
120 | #define HM_CHANGED_GUEST_SSE_AVX UINT64_C(0x0000000200000000)
|
---|
121 | #define HM_CHANGED_GUEST_OTHER_XSAVE UINT64_C(0x0000000400000000)
|
---|
122 | #define HM_CHANGED_GUEST_XCRx UINT64_C(0x0000000800000000)
|
---|
123 |
|
---|
124 | #define HM_CHANGED_GUEST_KERNEL_GS_BASE UINT64_C(0x0000001000000000)
|
---|
125 | #define HM_CHANGED_GUEST_SYSCALL_MSRS UINT64_C(0x0000002000000000)
|
---|
126 | #define HM_CHANGED_GUEST_SYSENTER_CS_MSR UINT64_C(0x0000004000000000)
|
---|
127 | #define HM_CHANGED_GUEST_SYSENTER_EIP_MSR UINT64_C(0x0000008000000000)
|
---|
128 | #define HM_CHANGED_GUEST_SYSENTER_ESP_MSR UINT64_C(0x0000010000000000)
|
---|
129 | #define HM_CHANGED_GUEST_SYSENTER_MSR_MASK UINT64_C(0x000001c000000000)
|
---|
130 | #define HM_CHANGED_GUEST_TSC_AUX UINT64_C(0x0000020000000000)
|
---|
131 | #define HM_CHANGED_GUEST_OTHER_MSRS UINT64_C(0x0000040000000000)
|
---|
132 | #define HM_CHANGED_GUEST_ALL_MSRS ( HM_CHANGED_GUEST_EFER \
|
---|
133 | | HM_CHANGED_GUEST_KERNEL_GS_BASE \
|
---|
134 | | HM_CHANGED_GUEST_SYSCALL_MSRS \
|
---|
135 | | HM_CHANGED_GUEST_SYSENTER_MSR_MASK \
|
---|
136 | | HM_CHANGED_GUEST_TSC_AUX \
|
---|
137 | | HM_CHANGED_GUEST_OTHER_MSRS)
|
---|
138 |
|
---|
139 | #define HM_CHANGED_GUEST_HWVIRT UINT64_C(0x0000080000000000)
|
---|
140 | #define HM_CHANGED_GUEST_MASK UINT64_C(0x00000ffffffffffc)
|
---|
141 |
|
---|
142 | #define HM_CHANGED_KEEPER_STATE_MASK UINT64_C(0xffff000000000000)
|
---|
143 |
|
---|
144 | #define HM_CHANGED_VMX_GUEST_XCPT_INTERCEPTS UINT64_C(0x0001000000000000)
|
---|
145 | #define HM_CHANGED_VMX_GUEST_AUTO_MSRS UINT64_C(0x0002000000000000)
|
---|
146 | #define HM_CHANGED_VMX_GUEST_LAZY_MSRS UINT64_C(0x0004000000000000)
|
---|
147 | #define HM_CHANGED_VMX_ENTRY_CTLS UINT64_C(0x0008000000000000)
|
---|
148 | #define HM_CHANGED_VMX_EXIT_CTLS UINT64_C(0x0010000000000000)
|
---|
149 | #define HM_CHANGED_VMX_MASK UINT64_C(0x001f000000000000)
|
---|
150 | #define HM_CHANGED_VMX_HOST_GUEST_SHARED_STATE ( HM_CHANGED_GUEST_DR_MASK \
|
---|
151 | | HM_CHANGED_VMX_GUEST_LAZY_MSRS)
|
---|
152 |
|
---|
153 | #define HM_CHANGED_SVM_GUEST_XCPT_INTERCEPTS UINT64_C(0x0001000000000000)
|
---|
154 | #define HM_CHANGED_SVM_MASK UINT64_C(0x0001000000000000)
|
---|
155 | #define HM_CHANGED_SVM_HOST_GUEST_SHARED_STATE HM_CHANGED_GUEST_DR_MASK
|
---|
156 |
|
---|
157 | #define HM_CHANGED_ALL_GUEST ( HM_CHANGED_GUEST_MASK \
|
---|
158 | | HM_CHANGED_KEEPER_STATE_MASK)
|
---|
159 |
|
---|
160 | /** Mask of what state might have changed when IEM raised an exception.
|
---|
161 | * This is a based on IEM_CPUMCTX_EXTRN_XCPT_MASK. */
|
---|
162 | #define HM_CHANGED_RAISED_XCPT_MASK ( HM_CHANGED_GUEST_GPRS_MASK \
|
---|
163 | | HM_CHANGED_GUEST_RIP \
|
---|
164 | | HM_CHANGED_GUEST_RFLAGS \
|
---|
165 | | HM_CHANGED_GUEST_SS \
|
---|
166 | | HM_CHANGED_GUEST_CS \
|
---|
167 | | HM_CHANGED_GUEST_CR0 \
|
---|
168 | | HM_CHANGED_GUEST_CR3 \
|
---|
169 | | HM_CHANGED_GUEST_CR4 \
|
---|
170 | | HM_CHANGED_GUEST_APIC_TPR \
|
---|
171 | | HM_CHANGED_GUEST_EFER_MSR \
|
---|
172 | | HM_CHANGED_GUEST_DR7 \
|
---|
173 | | HM_CHANGED_GUEST_CR2 \
|
---|
174 | | HM_CHANGED_GUEST_SREG_MASK \
|
---|
175 | | HM_CHANGED_GUEST_TABLE_MASK)
|
---|
176 |
|
---|
177 | #ifdef VBOX_WITH_NESTED_HWVIRT_SVM
|
---|
178 | /** Mask of what state might have changed when \#VMEXIT is emulated. */
|
---|
179 | # define HM_CHANGED_SVM_VMEXIT_MASK ( HM_CHANGED_GUEST_RSP \
|
---|
180 | | HM_CHANGED_GUEST_RAX \
|
---|
181 | | HM_CHANGED_GUEST_RIP \
|
---|
182 | | HM_CHANGED_GUEST_RFLAGS \
|
---|
183 | | HM_CHANGED_GUEST_CS \
|
---|
184 | | HM_CHANGED_GUEST_SS \
|
---|
185 | | HM_CHANGED_GUEST_DS \
|
---|
186 | | HM_CHANGED_GUEST_ES \
|
---|
187 | | HM_CHANGED_GUEST_GDTR \
|
---|
188 | | HM_CHANGED_GUEST_IDTR \
|
---|
189 | | HM_CHANGED_GUEST_CR_MASK \
|
---|
190 | | HM_CHANGED_GUEST_EFER_MSR \
|
---|
191 | | HM_CHANGED_GUEST_DR6 \
|
---|
192 | | HM_CHANGED_GUEST_DR7 \
|
---|
193 | | HM_CHANGED_GUEST_OTHER_MSRS \
|
---|
194 | | HM_CHANGED_GUEST_HWVIRT \
|
---|
195 | | HM_CHANGED_SVM_MASK \
|
---|
196 | | HM_CHANGED_GUEST_APIC_TPR)
|
---|
197 |
|
---|
198 | /** Mask of what state might have changed when \#VMEXIT is emulated. */
|
---|
199 | # define HM_CHANGED_SVM_VMRUN_MASK HM_CHANGED_SVM_VMEXIT_MASK
|
---|
200 | #endif
|
---|
201 | /** @} */
|
---|
202 |
|
---|
203 | /** Maximum number of exit reason statistics counters. */
|
---|
204 | #define MAX_EXITREASON_STAT 0x100
|
---|
205 | #define MASK_EXITREASON_STAT 0xff
|
---|
206 | #define MASK_INJECT_IRQ_STAT 0xff
|
---|
207 |
|
---|
208 | /** Size for the EPT identity page table (1024 4 MB pages to cover the entire address space). */
|
---|
209 | #define HM_EPT_IDENTITY_PG_TABLE_SIZE PAGE_SIZE
|
---|
210 | /** Size of the TSS structure + 2 pages for the IO bitmap + end byte. */
|
---|
211 | #define HM_VTX_TSS_SIZE (sizeof(VBOXTSS) + 2 * PAGE_SIZE + 1)
|
---|
212 | /** Total guest mapped memory needed. */
|
---|
213 | #define HM_VTX_TOTAL_DEVHEAP_MEM (HM_EPT_IDENTITY_PG_TABLE_SIZE + HM_VTX_TSS_SIZE)
|
---|
214 |
|
---|
215 |
|
---|
216 | /** @name Macros for enabling and disabling preemption.
|
---|
217 | * These are really just for hiding the RTTHREADPREEMPTSTATE and asserting that
|
---|
218 | * preemption has already been disabled when there is no context hook.
|
---|
219 | * @{ */
|
---|
220 | #ifdef VBOX_STRICT
|
---|
221 | # define HM_DISABLE_PREEMPT(a_pVCpu) \
|
---|
222 | RTTHREADPREEMPTSTATE PreemptStateInternal = RTTHREADPREEMPTSTATE_INITIALIZER; \
|
---|
223 | Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD) || VMMR0ThreadCtxHookIsEnabled((a_pVCpu))); \
|
---|
224 | RTThreadPreemptDisable(&PreemptStateInternal)
|
---|
225 | #else
|
---|
226 | # define HM_DISABLE_PREEMPT(a_pVCpu) \
|
---|
227 | RTTHREADPREEMPTSTATE PreemptStateInternal = RTTHREADPREEMPTSTATE_INITIALIZER; \
|
---|
228 | RTThreadPreemptDisable(&PreemptStateInternal)
|
---|
229 | #endif /* VBOX_STRICT */
|
---|
230 | #define HM_RESTORE_PREEMPT() do { RTThreadPreemptRestore(&PreemptStateInternal); } while(0)
|
---|
231 | /** @} */
|
---|
232 |
|
---|
233 |
|
---|
234 | /** @name HM saved state versions.
|
---|
235 | * @{
|
---|
236 | */
|
---|
237 | #define HM_SAVED_STATE_VERSION HM_SAVED_STATE_VERSION_SVM_NESTED_HWVIRT
|
---|
238 | #define HM_SAVED_STATE_VERSION_SVM_NESTED_HWVIRT 6
|
---|
239 | #define HM_SAVED_STATE_VERSION_TPR_PATCHING 5
|
---|
240 | #define HM_SAVED_STATE_VERSION_NO_TPR_PATCHING 4
|
---|
241 | #define HM_SAVED_STATE_VERSION_2_0_X 3
|
---|
242 | /** @} */
|
---|
243 |
|
---|
244 |
|
---|
245 | /**
|
---|
246 | * HM physical (host) CPU information.
|
---|
247 | */
|
---|
248 | typedef struct HMPHYSCPU
|
---|
249 | {
|
---|
250 | /** The CPU ID. */
|
---|
251 | RTCPUID idCpu;
|
---|
252 | /** The VM_HSAVE_AREA (AMD-V) / VMXON region (Intel) memory backing. */
|
---|
253 | RTR0MEMOBJ hMemObj;
|
---|
254 | /** The physical address of the first page in hMemObj (it's a
|
---|
255 | * physcially contigous allocation if it spans multiple pages). */
|
---|
256 | RTHCPHYS HCPhysMemObj;
|
---|
257 | /** The address of the memory (for pfnEnable). */
|
---|
258 | void *pvMemObj;
|
---|
259 | /** Current ASID (AMD-V) / VPID (Intel). */
|
---|
260 | uint32_t uCurrentAsid;
|
---|
261 | /** TLB flush count. */
|
---|
262 | uint32_t cTlbFlushes;
|
---|
263 | /** Whether to flush each new ASID/VPID before use. */
|
---|
264 | bool fFlushAsidBeforeUse;
|
---|
265 | /** Configured for VT-x or AMD-V. */
|
---|
266 | bool fConfigured;
|
---|
267 | /** Set if the VBOX_HWVIRTEX_IGNORE_SVM_IN_USE hack is active. */
|
---|
268 | bool fIgnoreAMDVInUseError;
|
---|
269 | /** In use by our code. (for power suspend) */
|
---|
270 | bool volatile fInUse;
|
---|
271 | #ifdef VBOX_WITH_NESTED_HWVIRT_SVM
|
---|
272 | /** Nested-guest union (put data common to SVM/VMX outside the union). */
|
---|
273 | union
|
---|
274 | {
|
---|
275 | /** Nested-guest SVM data. */
|
---|
276 | struct
|
---|
277 | {
|
---|
278 | /** The active nested-guest MSR permission bitmap memory backing. */
|
---|
279 | RTR0MEMOBJ hNstGstMsrpm;
|
---|
280 | /** The physical address of the first page in hNstGstMsrpm (physcially
|
---|
281 | * contiguous allocation). */
|
---|
282 | RTHCPHYS HCPhysNstGstMsrpm;
|
---|
283 | /** The address of the active nested-guest MSRPM. */
|
---|
284 | void *pvNstGstMsrpm;
|
---|
285 | } svm;
|
---|
286 | /** @todo Nested-VMX. */
|
---|
287 | } n;
|
---|
288 | #endif
|
---|
289 | } HMPHYSCPU;
|
---|
290 | /** Pointer to HMPHYSCPU struct. */
|
---|
291 | typedef HMPHYSCPU *PHMPHYSCPU;
|
---|
292 | /** Pointer to a const HMPHYSCPU struct. */
|
---|
293 | typedef const HMPHYSCPU *PCHMPHYSCPU;
|
---|
294 |
|
---|
295 | /**
|
---|
296 | * TPR-instruction type.
|
---|
297 | */
|
---|
298 | typedef enum
|
---|
299 | {
|
---|
300 | HMTPRINSTR_INVALID,
|
---|
301 | HMTPRINSTR_READ,
|
---|
302 | HMTPRINSTR_READ_SHR4,
|
---|
303 | HMTPRINSTR_WRITE_REG,
|
---|
304 | HMTPRINSTR_WRITE_IMM,
|
---|
305 | HMTPRINSTR_JUMP_REPLACEMENT,
|
---|
306 | /** The usual 32-bit paranoia. */
|
---|
307 | HMTPRINSTR_32BIT_HACK = 0x7fffffff
|
---|
308 | } HMTPRINSTR;
|
---|
309 |
|
---|
310 | /**
|
---|
311 | * TPR patch information.
|
---|
312 | */
|
---|
313 | typedef struct
|
---|
314 | {
|
---|
315 | /** The key is the address of patched instruction. (32 bits GC ptr) */
|
---|
316 | AVLOU32NODECORE Core;
|
---|
317 | /** Original opcode. */
|
---|
318 | uint8_t aOpcode[16];
|
---|
319 | /** Instruction size. */
|
---|
320 | uint32_t cbOp;
|
---|
321 | /** Replacement opcode. */
|
---|
322 | uint8_t aNewOpcode[16];
|
---|
323 | /** Replacement instruction size. */
|
---|
324 | uint32_t cbNewOp;
|
---|
325 | /** Instruction type. */
|
---|
326 | HMTPRINSTR enmType;
|
---|
327 | /** Source operand. */
|
---|
328 | uint32_t uSrcOperand;
|
---|
329 | /** Destination operand. */
|
---|
330 | uint32_t uDstOperand;
|
---|
331 | /** Number of times the instruction caused a fault. */
|
---|
332 | uint32_t cFaults;
|
---|
333 | /** Patch address of the jump replacement. */
|
---|
334 | RTGCPTR32 pJumpTarget;
|
---|
335 | } HMTPRPATCH;
|
---|
336 | /** Pointer to HMTPRPATCH. */
|
---|
337 | typedef HMTPRPATCH *PHMTPRPATCH;
|
---|
338 | /** Pointer to a const HMTPRPATCH. */
|
---|
339 | typedef const HMTPRPATCH *PCHMTPRPATCH;
|
---|
340 |
|
---|
341 |
|
---|
342 | /**
|
---|
343 | * Makes a HMEXITSTAT::uKey value from a program counter and an exit code.
|
---|
344 | *
|
---|
345 | * @returns 64-bit key
|
---|
346 | * @param a_uPC The RIP + CS.BASE value of the exit.
|
---|
347 | * @param a_uExit The exit code.
|
---|
348 | * @todo Add CPL?
|
---|
349 | */
|
---|
350 | #define HMEXITSTAT_MAKE_KEY(a_uPC, a_uExit) (((a_uPC) & UINT64_C(0x0000ffffffffffff)) | (uint64_t)(a_uExit) << 48)
|
---|
351 |
|
---|
352 | typedef struct HMEXITINFO
|
---|
353 | {
|
---|
354 | /** See HMEXITSTAT_MAKE_KEY(). */
|
---|
355 | uint64_t uKey;
|
---|
356 | /** Number of recent hits (depreciates with time). */
|
---|
357 | uint32_t volatile cHits;
|
---|
358 | /** The age + lock. */
|
---|
359 | uint16_t volatile uAge;
|
---|
360 | /** Action or action table index. */
|
---|
361 | uint16_t iAction;
|
---|
362 | } HMEXITINFO;
|
---|
363 | AssertCompileSize(HMEXITINFO, 16); /* Lots of these guys, so don't add any unnecessary stuff! */
|
---|
364 |
|
---|
365 | typedef struct HMEXITHISTORY
|
---|
366 | {
|
---|
367 | /** The exit timestamp. */
|
---|
368 | uint64_t uTscExit;
|
---|
369 | /** The index of the corresponding HMEXITINFO entry.
|
---|
370 | * UINT32_MAX if none (too many collisions, race, whatever). */
|
---|
371 | uint32_t iExitInfo;
|
---|
372 | /** Figure out later, needed for padding now. */
|
---|
373 | uint32_t uSomeClueOrSomething;
|
---|
374 | } HMEXITHISTORY;
|
---|
375 |
|
---|
376 | /**
|
---|
377 | * Switcher function, HC to the special 64-bit RC.
|
---|
378 | *
|
---|
379 | * @param pVM The cross context VM structure.
|
---|
380 | * @param offCpumVCpu Offset from pVM->cpum to pVM->aCpus[idCpu].cpum.
|
---|
381 | * @returns Return code indicating the action to take.
|
---|
382 | */
|
---|
383 | typedef DECLCALLBACK(int) FNHMSWITCHERHC(PVM pVM, uint32_t offCpumVCpu);
|
---|
384 | /** Pointer to switcher function. */
|
---|
385 | typedef FNHMSWITCHERHC *PFNHMSWITCHERHC;
|
---|
386 |
|
---|
387 | /** @def HM_UNION_NM
|
---|
388 | * For compilers (like DTrace) that does not grok nameless unions, we have a
|
---|
389 | * little hack to make them palatable.
|
---|
390 | */
|
---|
391 | /** @def HM_STRUCT_NM
|
---|
392 | * For compilers (like DTrace) that does not grok nameless structs (it is
|
---|
393 | * non-standard C++), we have a little hack to make them palatable.
|
---|
394 | */
|
---|
395 | #ifdef VBOX_FOR_DTRACE_LIB
|
---|
396 | # define HM_UNION_NM(a_Nm) a_Nm
|
---|
397 | # define HM_STRUCT_NM(a_Nm) a_Nm
|
---|
398 | #elif defined(IPRT_WITHOUT_NAMED_UNIONS_AND_STRUCTS)
|
---|
399 | # define HM_UNION_NM(a_Nm) a_Nm
|
---|
400 | # define HM_STRUCT_NM(a_Nm) a_Nm
|
---|
401 | #else
|
---|
402 | # define HM_UNION_NM(a_Nm)
|
---|
403 | # define HM_STRUCT_NM(a_Nm)
|
---|
404 | #endif
|
---|
405 |
|
---|
406 | /**
|
---|
407 | * HM VM Instance data.
|
---|
408 | * Changes to this must checked against the padding of the hm union in VM!
|
---|
409 | */
|
---|
410 | typedef struct HM
|
---|
411 | {
|
---|
412 | /** Set when we've initialized VMX or SVM. */
|
---|
413 | bool fInitialized;
|
---|
414 | /** Set if nested paging is enabled. */
|
---|
415 | bool fNestedPaging;
|
---|
416 | /** Set if nested paging is allowed. */
|
---|
417 | bool fAllowNestedPaging;
|
---|
418 | /** Set if large pages are enabled (requires nested paging). */
|
---|
419 | bool fLargePages;
|
---|
420 | /** Set if we can support 64-bit guests or not. */
|
---|
421 | bool fAllow64BitGuests;
|
---|
422 | /** Set when TPR patching is allowed. */
|
---|
423 | bool fTprPatchingAllowed;
|
---|
424 | /** Set when we initialize VT-x or AMD-V once for all CPUs. */
|
---|
425 | bool fGlobalInit;
|
---|
426 | /** Set when TPR patching is active. */
|
---|
427 | bool fTPRPatchingActive;
|
---|
428 | /** Set when the debug facility has breakpoints/events enabled that requires
|
---|
429 | * us to use the debug execution loop in ring-0. */
|
---|
430 | bool fUseDebugLoop;
|
---|
431 | /** Set if hardware APIC virtualization is enabled. */
|
---|
432 | bool fVirtApicRegs;
|
---|
433 | /** Set if posted interrupt processing is enabled. */
|
---|
434 | bool fPostedIntrs;
|
---|
435 | /** Set if indirect branch prediction barrier on VM exit. */
|
---|
436 | bool fIbpbOnVmExit;
|
---|
437 | /** Set if indirect branch prediction barrier on VM entry. */
|
---|
438 | bool fIbpbOnVmEntry;
|
---|
439 | /** Set if level 1 data cache should be flushed on VM entry. */
|
---|
440 | bool fL1dFlushOnVmEntry;
|
---|
441 | /** Set if level 1 data cache should be flushed on EMT scheduling. */
|
---|
442 | bool fL1dFlushOnSched;
|
---|
443 | /** Set if host manages speculation control settings. */
|
---|
444 | bool fSpecCtrlByHost;
|
---|
445 |
|
---|
446 | /** Maximum ASID allowed. */
|
---|
447 | uint32_t uMaxAsid;
|
---|
448 | /** The maximum number of resumes loops allowed in ring-0 (safety precaution).
|
---|
449 | * This number is set much higher when RTThreadPreemptIsPending is reliable. */
|
---|
450 | uint32_t cMaxResumeLoops;
|
---|
451 |
|
---|
452 | /** Host kernel flags that HM might need to know (SUPKERNELFEATURES_XXX). */
|
---|
453 | uint32_t fHostKernelFeatures;
|
---|
454 |
|
---|
455 | /** Size of the guest patch memory block. */
|
---|
456 | uint32_t cbGuestPatchMem;
|
---|
457 | /** Guest allocated memory for patching purposes. */
|
---|
458 | RTGCPTR pGuestPatchMem;
|
---|
459 | /** Current free pointer inside the patch block. */
|
---|
460 | RTGCPTR pFreeGuestPatchMem;
|
---|
461 |
|
---|
462 | #if HC_ARCH_BITS == 32 && defined(VBOX_ENABLE_64_BITS_GUESTS)
|
---|
463 | /** 32 to 64 bits switcher entrypoint. */
|
---|
464 | R0PTRTYPE(PFNHMSWITCHERHC) pfnHost32ToGuest64R0;
|
---|
465 | RTR0PTR pvR0Alignment0;
|
---|
466 | #endif
|
---|
467 |
|
---|
468 | struct
|
---|
469 | {
|
---|
470 | /** Set by the ring-0 side of HM to indicate VMX is supported by the
|
---|
471 | * CPU. */
|
---|
472 | bool fSupported;
|
---|
473 | /** Set when we've enabled VMX. */
|
---|
474 | bool fEnabled;
|
---|
475 | /** Set if VPID is supported. */
|
---|
476 | bool fVpid;
|
---|
477 | /** Set if VT-x VPID is allowed. */
|
---|
478 | bool fAllowVpid;
|
---|
479 | /** Set if unrestricted guest execution is in use (real and protected mode without paging). */
|
---|
480 | bool fUnrestrictedGuest;
|
---|
481 | /** Set if unrestricted guest execution is allowed to be used. */
|
---|
482 | bool fAllowUnrestricted;
|
---|
483 | /** Set if the preemption timer is in use or not. */
|
---|
484 | bool fUsePreemptTimer;
|
---|
485 | /** The shift mask employed by the VMX-Preemption timer. */
|
---|
486 | uint8_t cPreemptTimerShift;
|
---|
487 |
|
---|
488 | /** Virtual address of the TSS page used for real mode emulation. */
|
---|
489 | R3PTRTYPE(PVBOXTSS) pRealModeTSS;
|
---|
490 | /** Virtual address of the identity page table used for real mode and protected mode without paging emulation in EPT mode. */
|
---|
491 | R3PTRTYPE(PX86PD) pNonPagingModeEPTPageTable;
|
---|
492 |
|
---|
493 | /** Physical address of the APIC-access page. */
|
---|
494 | RTHCPHYS HCPhysApicAccess;
|
---|
495 | /** R0 memory object for the APIC-access page. */
|
---|
496 | RTR0MEMOBJ hMemObjApicAccess;
|
---|
497 | /** Virtual address of the APIC-access page. */
|
---|
498 | R0PTRTYPE(uint8_t *) pbApicAccess;
|
---|
499 |
|
---|
500 | #ifdef VBOX_WITH_CRASHDUMP_MAGIC
|
---|
501 | RTHCPHYS HCPhysScratch;
|
---|
502 | RTR0MEMOBJ hMemObjScratch;
|
---|
503 | R0PTRTYPE(uint8_t *) pbScratch;
|
---|
504 | #endif
|
---|
505 |
|
---|
506 | /** Tagged-TLB flush type. */
|
---|
507 | VMXTLBFLUSHTYPE enmTlbFlushType;
|
---|
508 | /** Flush type to use for INVEPT. */
|
---|
509 | VMXTLBFLUSHEPT enmTlbFlushEpt;
|
---|
510 | /** Flush type to use for INVVPID. */
|
---|
511 | VMXTLBFLUSHVPID enmTlbFlushVpid;
|
---|
512 |
|
---|
513 | /** Pause-loop exiting (PLE) gap in ticks. */
|
---|
514 | uint32_t cPleGapTicks;
|
---|
515 | /** Pause-loop exiting (PLE) window in ticks. */
|
---|
516 | uint32_t cPleWindowTicks;
|
---|
517 | uint32_t u32Alignment0;
|
---|
518 |
|
---|
519 | /** Host CR4 value (set by ring-0 VMX init) */
|
---|
520 | uint64_t u64HostCr4;
|
---|
521 | /** Host SMM monitor control (set by ring-0 VMX init) */
|
---|
522 | uint64_t u64HostSmmMonitorCtl;
|
---|
523 | /** Host EFER value (set by ring-0 VMX init) */
|
---|
524 | uint64_t u64HostEfer;
|
---|
525 | /** Whether the CPU supports VMCS fields for swapping EFER. */
|
---|
526 | bool fSupportsVmcsEfer;
|
---|
527 | uint8_t u8Alignment2[7];
|
---|
528 |
|
---|
529 | /** VMX MSR values. */
|
---|
530 | VMXMSRS Msrs;
|
---|
531 |
|
---|
532 | /** Host-physical address for a failing VMXON instruction. */
|
---|
533 | RTHCPHYS HCPhysVmxEnableError;
|
---|
534 | } vmx;
|
---|
535 |
|
---|
536 | struct
|
---|
537 | {
|
---|
538 | /** Set by the ring-0 side of HM to indicate SVM is supported by the
|
---|
539 | * CPU. */
|
---|
540 | bool fSupported;
|
---|
541 | /** Set when we've enabled SVM. */
|
---|
542 | bool fEnabled;
|
---|
543 | /** Set if erratum 170 affects the AMD cpu. */
|
---|
544 | bool fAlwaysFlushTLB;
|
---|
545 | /** Set when the hack to ignore VERR_SVM_IN_USE is active. */
|
---|
546 | bool fIgnoreInUseError;
|
---|
547 | /** Whether to use virtualized VMSAVE/VMLOAD feature. */
|
---|
548 | bool fVirtVmsaveVmload;
|
---|
549 | /** Whether to use virtual GIF feature. */
|
---|
550 | bool fVGif;
|
---|
551 | uint8_t u8Alignment0[2];
|
---|
552 |
|
---|
553 | /** Physical address of the IO bitmap (12kb). */
|
---|
554 | RTHCPHYS HCPhysIOBitmap;
|
---|
555 | /** R0 memory object for the IO bitmap (12kb). */
|
---|
556 | RTR0MEMOBJ hMemObjIOBitmap;
|
---|
557 | /** Virtual address of the IO bitmap. */
|
---|
558 | R0PTRTYPE(void *) pvIOBitmap;
|
---|
559 |
|
---|
560 | /* HWCR MSR (for diagnostics) */
|
---|
561 | uint64_t u64MsrHwcr;
|
---|
562 |
|
---|
563 | /** SVM revision. */
|
---|
564 | uint32_t u32Rev;
|
---|
565 | /** SVM feature bits from cpuid 0x8000000a */
|
---|
566 | uint32_t u32Features;
|
---|
567 |
|
---|
568 | /** Pause filter counter. */
|
---|
569 | uint16_t cPauseFilter;
|
---|
570 | /** Pause filter treshold in ticks. */
|
---|
571 | uint16_t cPauseFilterThresholdTicks;
|
---|
572 | uint32_t u32Alignment0;
|
---|
573 | } svm;
|
---|
574 |
|
---|
575 | /**
|
---|
576 | * AVL tree with all patches (active or disabled) sorted by guest instruction
|
---|
577 | * address.
|
---|
578 | */
|
---|
579 | AVLOU32TREE PatchTree;
|
---|
580 | uint32_t cPatches;
|
---|
581 | HMTPRPATCH aPatches[64];
|
---|
582 |
|
---|
583 | /** Last recorded error code during HM ring-0 init. */
|
---|
584 | int32_t rcInit;
|
---|
585 |
|
---|
586 | /** HMR0Init was run */
|
---|
587 | bool fHMR0Init;
|
---|
588 | bool u8Alignment1[3];
|
---|
589 |
|
---|
590 | STAMCOUNTER StatTprPatchSuccess;
|
---|
591 | STAMCOUNTER StatTprPatchFailure;
|
---|
592 | STAMCOUNTER StatTprReplaceSuccessCr8;
|
---|
593 | STAMCOUNTER StatTprReplaceSuccessVmc;
|
---|
594 | STAMCOUNTER StatTprReplaceFailure;
|
---|
595 | } HM;
|
---|
596 | /** Pointer to HM VM instance data. */
|
---|
597 | typedef HM *PHM;
|
---|
598 |
|
---|
599 | AssertCompileMemberAlignment(HM, StatTprPatchSuccess, 8);
|
---|
600 |
|
---|
601 | /* Maximum number of cached entries. */
|
---|
602 | #define VMX_VMCS_BATCH_CACHE_MAX_ENTRY 128
|
---|
603 |
|
---|
604 | /**
|
---|
605 | * Cache of a VMCS for batch reads or writes.
|
---|
606 | */
|
---|
607 | typedef struct VMXVMCSBATCHCACHE
|
---|
608 | {
|
---|
609 | #ifdef VBOX_WITH_CRASHDUMP_MAGIC
|
---|
610 | /* Magic marker for searching in crash dumps. */
|
---|
611 | uint8_t aMagic[16];
|
---|
612 | uint64_t uMagic;
|
---|
613 | uint64_t u64TimeEntry;
|
---|
614 | uint64_t u64TimeSwitch;
|
---|
615 | uint64_t cResume;
|
---|
616 | uint64_t interPD;
|
---|
617 | uint64_t pSwitcher;
|
---|
618 | uint32_t uPos;
|
---|
619 | uint32_t idCpu;
|
---|
620 | #endif
|
---|
621 | /* CR2 is saved here for EPT syncing. */
|
---|
622 | uint64_t cr2;
|
---|
623 | struct
|
---|
624 | {
|
---|
625 | uint32_t cValidEntries;
|
---|
626 | uint32_t uAlignment;
|
---|
627 | uint32_t aField[VMX_VMCS_BATCH_CACHE_MAX_ENTRY];
|
---|
628 | uint64_t aFieldVal[VMX_VMCS_BATCH_CACHE_MAX_ENTRY];
|
---|
629 | } Write;
|
---|
630 | struct
|
---|
631 | {
|
---|
632 | uint32_t cValidEntries;
|
---|
633 | uint32_t uAlignment;
|
---|
634 | uint32_t aField[VMX_VMCS_BATCH_CACHE_MAX_ENTRY];
|
---|
635 | uint64_t aFieldVal[VMX_VMCS_BATCH_CACHE_MAX_ENTRY];
|
---|
636 | } Read;
|
---|
637 | #ifdef VBOX_STRICT
|
---|
638 | struct
|
---|
639 | {
|
---|
640 | RTHCPHYS HCPhysCpuPage;
|
---|
641 | RTHCPHYS HCPhysVmcs;
|
---|
642 | RTGCPTR pCache;
|
---|
643 | RTGCPTR pCtx;
|
---|
644 | } TestIn;
|
---|
645 | struct
|
---|
646 | {
|
---|
647 | RTHCPHYS HCPhysVmcs;
|
---|
648 | RTGCPTR pCache;
|
---|
649 | RTGCPTR pCtx;
|
---|
650 | uint64_t eflags;
|
---|
651 | uint64_t cr8;
|
---|
652 | } TestOut;
|
---|
653 | struct
|
---|
654 | {
|
---|
655 | uint64_t param1;
|
---|
656 | uint64_t param2;
|
---|
657 | uint64_t param3;
|
---|
658 | uint64_t param4;
|
---|
659 | } ScratchPad;
|
---|
660 | #endif
|
---|
661 | } VMXVMCSBATCHCACHE;
|
---|
662 | /** Pointer to VMXVMCSBATCHCACHE. */
|
---|
663 | typedef VMXVMCSBATCHCACHE *PVMXVMCSBATCHCACHE;
|
---|
664 | AssertCompileSizeAlignment(VMXVMCSBATCHCACHE, 8);
|
---|
665 |
|
---|
666 | /**
|
---|
667 | * VMX StartVM function.
|
---|
668 | *
|
---|
669 | * @returns VBox status code (no informational stuff).
|
---|
670 | * @param fResume Whether to use VMRESUME (true) or VMLAUNCH (false).
|
---|
671 | * @param pCtx The CPU register context.
|
---|
672 | * @param pVmcsCache The VMCS batch cache.
|
---|
673 | * @param pVM Pointer to the cross context VM structure.
|
---|
674 | * @param pVCpu Pointer to the cross context per-CPU structure.
|
---|
675 | */
|
---|
676 | typedef DECLCALLBACK(int) FNHMVMXSTARTVM(RTHCUINT fResume, PCPUMCTX pCtx, PVMXVMCSBATCHCACHE pVmcsCache, PVM pVM, PVMCPU pVCpu);
|
---|
677 | /** Pointer to a VMX StartVM function. */
|
---|
678 | typedef R0PTRTYPE(FNHMVMXSTARTVM *) PFNHMVMXSTARTVM;
|
---|
679 |
|
---|
680 | /** SVM VMRun function. */
|
---|
681 | typedef DECLCALLBACK(int) FNHMSVMVMRUN(RTHCPHYS pVmcbHostPhys, RTHCPHYS pVmcbPhys, PCPUMCTX pCtx, PVM pVM, PVMCPU pVCpu);
|
---|
682 | /** Pointer to a SVM VMRun function. */
|
---|
683 | typedef R0PTRTYPE(FNHMSVMVMRUN *) PFNHMSVMVMRUN;
|
---|
684 |
|
---|
685 | /**
|
---|
686 | * Cache of certain VMCS fields during execution of a guest or nested-guest.
|
---|
687 | */
|
---|
688 | typedef struct VMXVMCSCTLSCACHE
|
---|
689 | {
|
---|
690 | /** Cache of pin-based VM-execution controls. */
|
---|
691 | uint32_t u32PinCtls;
|
---|
692 | /** Cache of processor-based VM-execution controls. */
|
---|
693 | uint32_t u32ProcCtls;
|
---|
694 | /** Cache of secondary processor-based VM-execution controls. */
|
---|
695 | uint32_t u32ProcCtls2;
|
---|
696 | /** Cache of VM-entry controls. */
|
---|
697 | uint32_t u32EntryCtls;
|
---|
698 | /** Cache of VM-exit controls. */
|
---|
699 | uint32_t u32ExitCtls;
|
---|
700 | /** Cache of CR0 mask. */
|
---|
701 | uint32_t u32Cr0Mask;
|
---|
702 | /** Cache of CR4 mask. */
|
---|
703 | uint32_t u32Cr4Mask;
|
---|
704 | /** Cache of exception bitmap. */
|
---|
705 | uint32_t u32XcptBitmap;
|
---|
706 | /** Cache of TSC offset. */
|
---|
707 | uint64_t u64TscOffset;
|
---|
708 | } VMXVMCSCTLSCACHE;
|
---|
709 | /** Pointer to a VMXVMCSCTLSCACHE struct. */
|
---|
710 | typedef VMXVMCSCTLSCACHE *PVMXVMCSCTLSCACHE;
|
---|
711 | /** Pointer to a VMXVMCSCTLSCACHE struct. */
|
---|
712 | typedef const VMXVMCSCTLSCACHE *PCVMXVMCSCTLSCACHE;
|
---|
713 | AssertCompileSizeAlignment(VMXVMCSCTLSCACHE, 8);
|
---|
714 |
|
---|
715 | /**
|
---|
716 | * VMX VMCS information.
|
---|
717 | *
|
---|
718 | * This structure provides information maintained for and during the executing of a
|
---|
719 | * guest (or nested-guest) VMCS (VM control structure) using hardware-assisted VMX.
|
---|
720 | */
|
---|
721 | typedef struct VMXVMCSINFO
|
---|
722 | {
|
---|
723 | /** @name VMCS and related data structures.
|
---|
724 | * @{ */
|
---|
725 | /** Host-physical address of the VMCS. */
|
---|
726 | RTHCPHYS HCPhysVmcs;
|
---|
727 | /** R0 memory object for the VMCS. */
|
---|
728 | RTR0MEMOBJ hMemObjVmcs;
|
---|
729 | /** Host-virtual address of the VMCS. */
|
---|
730 | R0PTRTYPE(void *) pvVmcs;
|
---|
731 |
|
---|
732 | /** Host-physical address of the virtual APIC page. */
|
---|
733 | RTHCPHYS HCPhysVirtApic;
|
---|
734 | /** Padding. */
|
---|
735 | R0PTRTYPE(void *) pvAlignment0;
|
---|
736 | /** Host-virtual address of the virtual-APIC page. */
|
---|
737 | R0PTRTYPE(uint8_t *) pbVirtApic;
|
---|
738 |
|
---|
739 | /** Host-physical address of the MSR bitmap. */
|
---|
740 | RTHCPHYS HCPhysMsrBitmap;
|
---|
741 | /** R0 memory object for the MSR bitmap. */
|
---|
742 | RTR0MEMOBJ hMemObjMsrBitmap;
|
---|
743 | /** Host-virtual address of the MSR bitmap. */
|
---|
744 | R0PTRTYPE(void *) pvMsrBitmap;
|
---|
745 |
|
---|
746 | /** Host-physical address of the VM-entry MSR-load and VM-exit MSR-store area. */
|
---|
747 | RTHCPHYS HCPhysGuestMsr;
|
---|
748 | /** R0 memory object of the VM-entry MSR-load and VM-exit MSR-store area. */
|
---|
749 | RTR0MEMOBJ hMemObjGuestMsr;
|
---|
750 | /** Host-virtual address of the VM-entry MSR-load and VM-exit MSR-store area. */
|
---|
751 | R0PTRTYPE(void *) pvGuestMsr;
|
---|
752 |
|
---|
753 | /** Host-physical address of the VM-exit MSR-load area. */
|
---|
754 | RTHCPHYS HCPhysHostMsr;
|
---|
755 | /** R0 memory object for the VM-exit MSR-load area. */
|
---|
756 | RTR0MEMOBJ hMemObjHostMsr;
|
---|
757 | /** Host-virtual address of the VM-exit MSR-load area. */
|
---|
758 | R0PTRTYPE(void *) pvHostMsr;
|
---|
759 |
|
---|
760 | /** Host-physical address of the EPTP. */
|
---|
761 | RTHCPHYS HCPhysEPTP;
|
---|
762 | /** @} */
|
---|
763 |
|
---|
764 | /** @name Auxiliary information.
|
---|
765 | * @{ */
|
---|
766 | /** Number of guest/host MSR pairs in the auto-load/store area. */
|
---|
767 | uint32_t cMsrs;
|
---|
768 | /** The VMCS state, see VMX_V_VMCS_STATE_XXX. */
|
---|
769 | uint32_t fVmcsState;
|
---|
770 | /** @} */
|
---|
771 |
|
---|
772 | /** @name Cache of execution related VMCS fields.
|
---|
773 | * @{ */
|
---|
774 | /** Pin-based VM-execution controls. */
|
---|
775 | uint32_t u32PinCtls;
|
---|
776 | /** Processor-based VM-execution controls. */
|
---|
777 | uint32_t u32ProcCtls;
|
---|
778 | /** Secondary processor-based VM-execution controls. */
|
---|
779 | uint32_t u32ProcCtls2;
|
---|
780 | /** VM-entry controls. */
|
---|
781 | uint32_t u32EntryCtls;
|
---|
782 | /** VM-exit controls. */
|
---|
783 | uint32_t u32ExitCtls;
|
---|
784 | /** CR0 guest/host mask. */
|
---|
785 | uint32_t u32Cr0Mask;
|
---|
786 | /** CR4 guset/host mask. */
|
---|
787 | uint32_t u32Cr4Mask;
|
---|
788 | /** Exception bitmap. */
|
---|
789 | uint32_t u32XcptBitmap;
|
---|
790 | /** TSC offset. */
|
---|
791 | uint64_t u64TscOffset;
|
---|
792 | /** @} */
|
---|
793 |
|
---|
794 | /** Padding. */
|
---|
795 | uint64_t u64Padding[4];
|
---|
796 | } VMXVMCSINFO;
|
---|
797 | /** Pointer to a VMXVMCSINFO struct. */
|
---|
798 | typedef VMXVMCSINFO *PVMXVMCSINFO;
|
---|
799 | /** Pointer to a VMXVMCSINFO struct. */
|
---|
800 | typedef const VMXVMCSINFO *PCVMXVMCSINFO;
|
---|
801 | AssertCompileSizeAlignment(VMXVMCSINFO, 8);
|
---|
802 |
|
---|
803 | /**
|
---|
804 | * HM VMCPU Instance data.
|
---|
805 | *
|
---|
806 | * Note! If you change members of this struct, make sure to check if the
|
---|
807 | * assembly counterpart in HMInternal.mac needs to be updated as well.
|
---|
808 | */
|
---|
809 | typedef struct HMCPU
|
---|
810 | {
|
---|
811 | /** Set when the TLB has been checked until we return from the world switch. */
|
---|
812 | bool volatile fCheckedTLBFlush;
|
---|
813 | /** Set if we need to flush the TLB during the world switch. */
|
---|
814 | bool fForceTLBFlush;
|
---|
815 | /** Set when we're using VT-x or AMD-V at that moment. */
|
---|
816 | bool fActive;
|
---|
817 | /** Whether we've completed the inner HM leave function. */
|
---|
818 | bool fLeaveDone;
|
---|
819 | /** Whether we're using the hyper DR7 or guest DR7. */
|
---|
820 | bool fUsingHyperDR7;
|
---|
821 | /** Set if XCR0 needs to be saved/restored when entering/exiting guest code
|
---|
822 | * execution. */
|
---|
823 | bool fLoadSaveGuestXcr0;
|
---|
824 |
|
---|
825 | /** Whether we should use the debug loop because of single stepping or special
|
---|
826 | * debug breakpoints / events are armed. */
|
---|
827 | bool fUseDebugLoop;
|
---|
828 | /** Whether we are currently executing in the debug loop.
|
---|
829 | * Mainly for assertions. */
|
---|
830 | bool fUsingDebugLoop;
|
---|
831 | /** Set if we using the debug loop and wish to intercept RDTSC. */
|
---|
832 | bool fDebugWantRdTscExit;
|
---|
833 | /** Whether we're executing a single instruction. */
|
---|
834 | bool fSingleInstruction;
|
---|
835 | /** Set if we need to clear the trap flag because of single stepping. */
|
---|
836 | bool fClearTrapFlag;
|
---|
837 |
|
---|
838 | /** Whether \#UD needs to be intercepted (required by certain GIM providers). */
|
---|
839 | bool fGIMTrapXcptUD;
|
---|
840 | /** Whether \#GP needs to be intercept for mesa driver workaround. */
|
---|
841 | bool fTrapXcptGpForLovelyMesaDrv;
|
---|
842 | uint8_t u8Alignment0[3];
|
---|
843 |
|
---|
844 | /** World switch exit counter. */
|
---|
845 | uint32_t volatile cWorldSwitchExits;
|
---|
846 | /** The last CPU we were executing code on (NIL_RTCPUID for the first time). */
|
---|
847 | RTCPUID idLastCpu;
|
---|
848 | /** TLB flush count. */
|
---|
849 | uint32_t cTlbFlushes;
|
---|
850 | /** Current ASID in use by the VM. */
|
---|
851 | uint32_t uCurrentAsid;
|
---|
852 | /** An additional error code used for some gurus. */
|
---|
853 | uint32_t u32HMError;
|
---|
854 | /** The last exit-to-ring-3 reason. */
|
---|
855 | int32_t rcLastExitToR3;
|
---|
856 | /** CPU-context changed flags (see HM_CHANGED_xxx). */
|
---|
857 | uint64_t fCtxChanged;
|
---|
858 | /** Host's TSC_AUX MSR (used when RDTSCP doesn't cause VM-exits). */
|
---|
859 | uint64_t u64HostTscAux;
|
---|
860 |
|
---|
861 | union /* no tag! */
|
---|
862 | {
|
---|
863 | /** VT-x data. */
|
---|
864 | struct
|
---|
865 | {
|
---|
866 | /** Ring 0 handlers for VT-x. */
|
---|
867 | PFNHMVMXSTARTVM pfnStartVM;
|
---|
868 | #if HC_ARCH_BITS == 32
|
---|
869 | uint32_t u32Alignment0;
|
---|
870 | #endif
|
---|
871 |
|
---|
872 | /** Cache of the executing guest (or nested-guest) VMCS control fields. */
|
---|
873 | VMXVMCSCTLSCACHE Ctls;
|
---|
874 | /** Cache of guest (level 1) VMCS control fields when executing a nested-guest
|
---|
875 | * (level 2). */
|
---|
876 | VMXVMCSCTLSCACHE Level1Ctls;
|
---|
877 |
|
---|
878 | /** Physical address of the VM control structure (VMCS). */
|
---|
879 | RTHCPHYS HCPhysVmcs;
|
---|
880 | /** R0 memory object for the VM control structure (VMCS). */
|
---|
881 | RTR0MEMOBJ hMemObjVmcs;
|
---|
882 | /** Virtual address of the VM control structure (VMCS). */
|
---|
883 | R0PTRTYPE(void *) pvVmcs;
|
---|
884 |
|
---|
885 | /** Physical address of the virtual APIC page for TPR caching. */
|
---|
886 | RTHCPHYS HCPhysVirtApic;
|
---|
887 | /** Padding. */
|
---|
888 | R0PTRTYPE(void *) pvAlignment0;
|
---|
889 | /** Virtual address of the virtual APIC page for TPR caching. */
|
---|
890 | R0PTRTYPE(uint8_t *) pbVirtApic;
|
---|
891 |
|
---|
892 | /** Physical address of the MSR bitmap. */
|
---|
893 | RTHCPHYS HCPhysMsrBitmap;
|
---|
894 | /** R0 memory object for the MSR bitmap. */
|
---|
895 | RTR0MEMOBJ hMemObjMsrBitmap;
|
---|
896 | /** Virtual address of the MSR bitmap. */
|
---|
897 | R0PTRTYPE(void *) pvMsrBitmap;
|
---|
898 |
|
---|
899 | /** Physical address of the VM-entry MSR-load and VM-exit MSR-store area (used
|
---|
900 | * for guest MSRs). */
|
---|
901 | RTHCPHYS HCPhysGuestMsr;
|
---|
902 | /** R0 memory object of the VM-entry MSR-load and VM-exit MSR-store area
|
---|
903 | * (used for guest MSRs). */
|
---|
904 | RTR0MEMOBJ hMemObjGuestMsr;
|
---|
905 | /** Virtual address of the VM-entry MSR-load and VM-exit MSR-store area (used
|
---|
906 | * for guest MSRs). */
|
---|
907 | R0PTRTYPE(void *) pvGuestMsr;
|
---|
908 |
|
---|
909 | /** Physical address of the VM-exit MSR-load area (used for host MSRs). */
|
---|
910 | RTHCPHYS HCPhysHostMsr;
|
---|
911 | /** R0 memory object for the VM-exit MSR-load area (used for host MSRs). */
|
---|
912 | RTR0MEMOBJ hMemObjHostMsr;
|
---|
913 | /** Virtual address of the VM-exit MSR-load area (used for host MSRs). */
|
---|
914 | R0PTRTYPE(void *) pvHostMsr;
|
---|
915 |
|
---|
916 | /** Physical address of the current EPTP. */
|
---|
917 | RTHCPHYS HCPhysEPTP;
|
---|
918 |
|
---|
919 | /** Number of guest/host MSR pairs in the auto-load/store area. */
|
---|
920 | uint32_t cMsrs;
|
---|
921 | /** Whether the host MSR values are up-to-date in the auto-load/store area. */
|
---|
922 | bool fUpdatedHostMsrs;
|
---|
923 | uint8_t au8Alignment0[3];
|
---|
924 |
|
---|
925 | /** Host LSTAR MSR value to restore lazily while leaving VT-x. */
|
---|
926 | uint64_t u64HostLStarMsr;
|
---|
927 | /** Host STAR MSR value to restore lazily while leaving VT-x. */
|
---|
928 | uint64_t u64HostStarMsr;
|
---|
929 | /** Host SF_MASK MSR value to restore lazily while leaving VT-x. */
|
---|
930 | uint64_t u64HostSFMaskMsr;
|
---|
931 | /** Host KernelGS-Base MSR value to restore lazily while leaving VT-x. */
|
---|
932 | uint64_t u64HostKernelGSBaseMsr;
|
---|
933 | /** A mask of which MSRs have been swapped and need restoration. */
|
---|
934 | uint32_t fLazyMsrs;
|
---|
935 | uint32_t u32Alignment1;
|
---|
936 |
|
---|
937 | /** The cached APIC-base MSR used for identifying when to map the HC physical APIC-access page. */
|
---|
938 | uint64_t u64MsrApicBase;
|
---|
939 |
|
---|
940 | /** VMCS cache for batched vmread/vmwrites. */
|
---|
941 | VMXVMCSBATCHCACHE VmcsBatchCache;
|
---|
942 |
|
---|
943 | /** Real-mode emulation state. */
|
---|
944 | struct
|
---|
945 | {
|
---|
946 | X86DESCATTR AttrCS;
|
---|
947 | X86DESCATTR AttrDS;
|
---|
948 | X86DESCATTR AttrES;
|
---|
949 | X86DESCATTR AttrFS;
|
---|
950 | X86DESCATTR AttrGS;
|
---|
951 | X86DESCATTR AttrSS;
|
---|
952 | X86EFLAGS Eflags;
|
---|
953 | bool fRealOnV86Active;
|
---|
954 | } RealMode;
|
---|
955 |
|
---|
956 | /** VT-x error-reporting (mainly for ring-3 propagation). */
|
---|
957 | struct
|
---|
958 | {
|
---|
959 | uint64_t u64VmcsPhys;
|
---|
960 | uint32_t u32VmcsRev;
|
---|
961 | uint32_t u32InstrError;
|
---|
962 | uint32_t u32ExitReason;
|
---|
963 | uint32_t u32Alignment0;
|
---|
964 | RTCPUID idEnteredCpu;
|
---|
965 | RTCPUID idCurrentCpu;
|
---|
966 | } LastError;
|
---|
967 |
|
---|
968 | /** Current state of the VMCS. */
|
---|
969 | uint32_t fVmcsState;
|
---|
970 | /** Which host-state bits to restore before being preempted. */
|
---|
971 | uint32_t fRestoreHostFlags;
|
---|
972 | /** The host-state restoration structure. */
|
---|
973 | VMXRESTOREHOST RestoreHost;
|
---|
974 |
|
---|
975 | /** Set if guest was executing in real mode (extra checks). */
|
---|
976 | bool fWasInRealMode;
|
---|
977 | /** Set if guest switched to 64-bit mode on a 32-bit host. */
|
---|
978 | bool fSwitchedTo64on32;
|
---|
979 | /** Padding. */
|
---|
980 | uint8_t au8Alignment1[6];
|
---|
981 | } vmx;
|
---|
982 |
|
---|
983 | /** SVM data. */
|
---|
984 | struct
|
---|
985 | {
|
---|
986 | /** Ring 0 handlers for VT-x. */
|
---|
987 | PFNHMSVMVMRUN pfnVMRun;
|
---|
988 | #if HC_ARCH_BITS == 32
|
---|
989 | uint32_t u32Alignment0;
|
---|
990 | #endif
|
---|
991 |
|
---|
992 | /** Physical address of the host VMCB which holds additional host-state. */
|
---|
993 | RTHCPHYS HCPhysVmcbHost;
|
---|
994 | /** R0 memory object for the host VMCB which holds additional host-state. */
|
---|
995 | RTR0MEMOBJ hMemObjVmcbHost;
|
---|
996 | /** Padding. */
|
---|
997 | R0PTRTYPE(void *) pvPadding;
|
---|
998 |
|
---|
999 | /** Physical address of the guest VMCB. */
|
---|
1000 | RTHCPHYS HCPhysVmcb;
|
---|
1001 | /** R0 memory object for the guest VMCB. */
|
---|
1002 | RTR0MEMOBJ hMemObjVmcb;
|
---|
1003 | /** Pointer to the guest VMCB. */
|
---|
1004 | R0PTRTYPE(PSVMVMCB) pVmcb;
|
---|
1005 |
|
---|
1006 | /** Physical address of the MSR bitmap (8 KB). */
|
---|
1007 | RTHCPHYS HCPhysMsrBitmap;
|
---|
1008 | /** R0 memory object for the MSR bitmap (8 KB). */
|
---|
1009 | RTR0MEMOBJ hMemObjMsrBitmap;
|
---|
1010 | /** Pointer to the MSR bitmap. */
|
---|
1011 | R0PTRTYPE(void *) pvMsrBitmap;
|
---|
1012 |
|
---|
1013 | /** Whether VTPR with V_INTR_MASKING set is in effect, indicating
|
---|
1014 | * we should check if the VTPR changed on every VM-exit. */
|
---|
1015 | bool fSyncVTpr;
|
---|
1016 | uint8_t au8Alignment0[7];
|
---|
1017 |
|
---|
1018 | /** Cache of the nested-guest's VMCB fields that we modify in order to run the
|
---|
1019 | * nested-guest using AMD-V. This will be restored on \#VMEXIT. */
|
---|
1020 | SVMNESTEDVMCBCACHE NstGstVmcbCache;
|
---|
1021 | } svm;
|
---|
1022 | } HM_UNION_NM(u);
|
---|
1023 |
|
---|
1024 | /** Event injection state. */
|
---|
1025 | struct
|
---|
1026 | {
|
---|
1027 | uint32_t fPending;
|
---|
1028 | uint32_t u32ErrCode;
|
---|
1029 | uint32_t cbInstr;
|
---|
1030 | uint32_t u32Padding; /**< Explicit alignment padding. */
|
---|
1031 | uint64_t u64IntInfo;
|
---|
1032 | RTGCUINTPTR GCPtrFaultAddress;
|
---|
1033 | } Event;
|
---|
1034 |
|
---|
1035 | /** The PAE PDPEs used with Nested Paging (only valid when
|
---|
1036 | * VMCPU_FF_HM_UPDATE_PAE_PDPES is set). */
|
---|
1037 | X86PDPE aPdpes[4];
|
---|
1038 |
|
---|
1039 | /** Current shadow paging mode for updating CR4. */
|
---|
1040 | PGMMODE enmShadowMode;
|
---|
1041 |
|
---|
1042 | /** The CPU ID of the CPU currently owning the VMCS. Set in
|
---|
1043 | * HMR0Enter and cleared in HMR0Leave. */
|
---|
1044 | RTCPUID idEnteredCpu;
|
---|
1045 |
|
---|
1046 | /** For saving stack space, the disassembler state is allocated here instead of
|
---|
1047 | * on the stack. */
|
---|
1048 | DISCPUSTATE DisState;
|
---|
1049 |
|
---|
1050 | STAMPROFILEADV StatEntry;
|
---|
1051 | STAMPROFILEADV StatPreExit;
|
---|
1052 | STAMPROFILEADV StatExitHandling;
|
---|
1053 | STAMPROFILEADV StatExitIO;
|
---|
1054 | STAMPROFILEADV StatExitMovCRx;
|
---|
1055 | STAMPROFILEADV StatExitXcptNmi;
|
---|
1056 | STAMPROFILEADV StatImportGuestState;
|
---|
1057 | STAMPROFILEADV StatExportGuestState;
|
---|
1058 | STAMPROFILEADV StatLoadGuestFpuState;
|
---|
1059 | STAMPROFILEADV StatInGC;
|
---|
1060 | #if HC_ARCH_BITS == 32 && defined(VBOX_ENABLE_64_BITS_GUESTS)
|
---|
1061 | STAMPROFILEADV StatWorldSwitch3264;
|
---|
1062 | #endif
|
---|
1063 | STAMPROFILEADV StatPoke;
|
---|
1064 | STAMPROFILEADV StatSpinPoke;
|
---|
1065 | STAMPROFILEADV StatSpinPokeFailed;
|
---|
1066 |
|
---|
1067 | STAMCOUNTER StatInjectInterrupt;
|
---|
1068 | STAMCOUNTER StatInjectXcpt;
|
---|
1069 | STAMCOUNTER StatInjectPendingReflect;
|
---|
1070 | STAMCOUNTER StatInjectPendingInterpret;
|
---|
1071 |
|
---|
1072 | STAMCOUNTER StatExitAll;
|
---|
1073 | STAMCOUNTER StatExitShadowNM;
|
---|
1074 | STAMCOUNTER StatExitGuestNM;
|
---|
1075 | STAMCOUNTER StatExitShadowPF; /**< Misleading, currently used for MMIO \#PFs as well. */
|
---|
1076 | STAMCOUNTER StatExitShadowPFEM;
|
---|
1077 | STAMCOUNTER StatExitGuestPF;
|
---|
1078 | STAMCOUNTER StatExitGuestUD;
|
---|
1079 | STAMCOUNTER StatExitGuestSS;
|
---|
1080 | STAMCOUNTER StatExitGuestNP;
|
---|
1081 | STAMCOUNTER StatExitGuestTS;
|
---|
1082 | STAMCOUNTER StatExitGuestGP;
|
---|
1083 | STAMCOUNTER StatExitGuestDE;
|
---|
1084 | STAMCOUNTER StatExitGuestDB;
|
---|
1085 | STAMCOUNTER StatExitGuestMF;
|
---|
1086 | STAMCOUNTER StatExitGuestBP;
|
---|
1087 | STAMCOUNTER StatExitGuestXF;
|
---|
1088 | STAMCOUNTER StatExitGuestXcpUnk;
|
---|
1089 | STAMCOUNTER StatExitCli;
|
---|
1090 | STAMCOUNTER StatExitSti;
|
---|
1091 | STAMCOUNTER StatExitPushf;
|
---|
1092 | STAMCOUNTER StatExitPopf;
|
---|
1093 | STAMCOUNTER StatExitIret;
|
---|
1094 | STAMCOUNTER StatExitInt;
|
---|
1095 | STAMCOUNTER StatExitHlt;
|
---|
1096 | STAMCOUNTER StatExitDRxWrite;
|
---|
1097 | STAMCOUNTER StatExitDRxRead;
|
---|
1098 | STAMCOUNTER StatExitCR0Read;
|
---|
1099 | STAMCOUNTER StatExitCR2Read;
|
---|
1100 | STAMCOUNTER StatExitCR3Read;
|
---|
1101 | STAMCOUNTER StatExitCR4Read;
|
---|
1102 | STAMCOUNTER StatExitCR8Read;
|
---|
1103 | STAMCOUNTER StatExitCR0Write;
|
---|
1104 | STAMCOUNTER StatExitCR2Write;
|
---|
1105 | STAMCOUNTER StatExitCR3Write;
|
---|
1106 | STAMCOUNTER StatExitCR4Write;
|
---|
1107 | STAMCOUNTER StatExitCR8Write;
|
---|
1108 | STAMCOUNTER StatExitRdmsr;
|
---|
1109 | STAMCOUNTER StatExitWrmsr;
|
---|
1110 | STAMCOUNTER StatExitClts;
|
---|
1111 | STAMCOUNTER StatExitXdtrAccess;
|
---|
1112 | STAMCOUNTER StatExitMwait;
|
---|
1113 | STAMCOUNTER StatExitMonitor;
|
---|
1114 | STAMCOUNTER StatExitLmsw;
|
---|
1115 | STAMCOUNTER StatExitIOWrite;
|
---|
1116 | STAMCOUNTER StatExitIORead;
|
---|
1117 | STAMCOUNTER StatExitIOStringWrite;
|
---|
1118 | STAMCOUNTER StatExitIOStringRead;
|
---|
1119 | STAMCOUNTER StatExitIntWindow;
|
---|
1120 | STAMCOUNTER StatExitExtInt;
|
---|
1121 | STAMCOUNTER StatExitHostNmiInGC;
|
---|
1122 | STAMCOUNTER StatExitPreemptTimer;
|
---|
1123 | STAMCOUNTER StatExitTprBelowThreshold;
|
---|
1124 | STAMCOUNTER StatExitTaskSwitch;
|
---|
1125 | STAMCOUNTER StatExitMtf;
|
---|
1126 | STAMCOUNTER StatExitApicAccess;
|
---|
1127 | STAMCOUNTER StatExitReasonNpf;
|
---|
1128 |
|
---|
1129 | STAMCOUNTER StatNestedExitReasonNpf;
|
---|
1130 |
|
---|
1131 | STAMCOUNTER StatFlushPage;
|
---|
1132 | STAMCOUNTER StatFlushPageManual;
|
---|
1133 | STAMCOUNTER StatFlushPhysPageManual;
|
---|
1134 | STAMCOUNTER StatFlushTlb;
|
---|
1135 | STAMCOUNTER StatFlushTlbManual;
|
---|
1136 | STAMCOUNTER StatFlushTlbWorldSwitch;
|
---|
1137 | STAMCOUNTER StatNoFlushTlbWorldSwitch;
|
---|
1138 | STAMCOUNTER StatFlushEntire;
|
---|
1139 | STAMCOUNTER StatFlushAsid;
|
---|
1140 | STAMCOUNTER StatFlushNestedPaging;
|
---|
1141 | STAMCOUNTER StatFlushTlbInvlpgVirt;
|
---|
1142 | STAMCOUNTER StatFlushTlbInvlpgPhys;
|
---|
1143 | STAMCOUNTER StatTlbShootdown;
|
---|
1144 | STAMCOUNTER StatTlbShootdownFlush;
|
---|
1145 |
|
---|
1146 | STAMCOUNTER StatSwitchPendingHostIrq;
|
---|
1147 | STAMCOUNTER StatSwitchTprMaskedIrq;
|
---|
1148 | STAMCOUNTER StatSwitchGuestIrq;
|
---|
1149 | STAMCOUNTER StatSwitchHmToR3FF;
|
---|
1150 | STAMCOUNTER StatSwitchExitToR3;
|
---|
1151 | STAMCOUNTER StatSwitchLongJmpToR3;
|
---|
1152 | STAMCOUNTER StatSwitchMaxResumeLoops;
|
---|
1153 | STAMCOUNTER StatSwitchHltToR3;
|
---|
1154 | STAMCOUNTER StatSwitchApicAccessToR3;
|
---|
1155 | STAMCOUNTER StatSwitchPreempt;
|
---|
1156 | STAMCOUNTER StatSwitchPreemptExportHostState;
|
---|
1157 |
|
---|
1158 | STAMCOUNTER StatTscParavirt;
|
---|
1159 | STAMCOUNTER StatTscOffset;
|
---|
1160 | STAMCOUNTER StatTscIntercept;
|
---|
1161 |
|
---|
1162 | STAMCOUNTER StatDRxArmed;
|
---|
1163 | STAMCOUNTER StatDRxContextSwitch;
|
---|
1164 | STAMCOUNTER StatDRxIoCheck;
|
---|
1165 |
|
---|
1166 | STAMCOUNTER StatExportMinimal;
|
---|
1167 | STAMCOUNTER StatExportFull;
|
---|
1168 | STAMCOUNTER StatLoadGuestFpu;
|
---|
1169 |
|
---|
1170 | STAMCOUNTER StatVmxCheckBadRmSelBase;
|
---|
1171 | STAMCOUNTER StatVmxCheckBadRmSelLimit;
|
---|
1172 | STAMCOUNTER StatVmxCheckBadRmSelAttr;
|
---|
1173 | STAMCOUNTER StatVmxCheckBadV86SelBase;
|
---|
1174 | STAMCOUNTER StatVmxCheckBadV86SelLimit;
|
---|
1175 | STAMCOUNTER StatVmxCheckBadV86SelAttr;
|
---|
1176 | STAMCOUNTER StatVmxCheckRmOk;
|
---|
1177 | STAMCOUNTER StatVmxCheckBadSel;
|
---|
1178 | STAMCOUNTER StatVmxCheckBadRpl;
|
---|
1179 | STAMCOUNTER StatVmxCheckPmOk;
|
---|
1180 |
|
---|
1181 | #if HC_ARCH_BITS == 32 && defined(VBOX_ENABLE_64_BITS_GUESTS)
|
---|
1182 | STAMCOUNTER StatFpu64SwitchBack;
|
---|
1183 | STAMCOUNTER StatDebug64SwitchBack;
|
---|
1184 | #endif
|
---|
1185 | #ifdef VBOX_WITH_STATISTICS
|
---|
1186 | R3PTRTYPE(PSTAMCOUNTER) paStatExitReason;
|
---|
1187 | R0PTRTYPE(PSTAMCOUNTER) paStatExitReasonR0;
|
---|
1188 | R3PTRTYPE(PSTAMCOUNTER) paStatInjectedIrqs;
|
---|
1189 | R0PTRTYPE(PSTAMCOUNTER) paStatInjectedIrqsR0;
|
---|
1190 | R3PTRTYPE(PSTAMCOUNTER) paStatNestedExitReason;
|
---|
1191 | R0PTRTYPE(PSTAMCOUNTER) paStatNestedExitReasonR0;
|
---|
1192 | #endif
|
---|
1193 | #ifdef HM_PROFILE_EXIT_DISPATCH
|
---|
1194 | STAMPROFILEADV StatExitDispatch;
|
---|
1195 | #endif
|
---|
1196 | } HMCPU;
|
---|
1197 | /** Pointer to HM VMCPU instance data. */
|
---|
1198 | typedef HMCPU *PHMCPU;
|
---|
1199 | AssertCompileMemberAlignment(HMCPU, cWorldSwitchExits, 4);
|
---|
1200 | AssertCompileMemberAlignment(HMCPU, fCtxChanged, 8);
|
---|
1201 | AssertCompileMemberAlignment(HMCPU, HM_UNION_NM(u.) vmx, 8);
|
---|
1202 | AssertCompileMemberAlignment(HMCPU, HM_UNION_NM(u.) svm, 8);
|
---|
1203 | AssertCompileMemberAlignment(HMCPU, Event, 8);
|
---|
1204 |
|
---|
1205 | #ifdef IN_RING0
|
---|
1206 | VMMR0_INT_DECL(PHMPHYSCPU) hmR0GetCurrentCpu(void);
|
---|
1207 | VMMR0_INT_DECL(int) hmR0EnterCpu(PVMCPU pVCpu);
|
---|
1208 |
|
---|
1209 | # ifdef VBOX_STRICT
|
---|
1210 | VMMR0_INT_DECL(void) hmR0DumpRegs(PVMCPU pVCpu);
|
---|
1211 | VMMR0_INT_DECL(void) hmR0DumpDescriptor(PCX86DESCHC pDesc, RTSEL Sel, const char *pszMsg);
|
---|
1212 | # endif
|
---|
1213 |
|
---|
1214 | # ifdef VBOX_WITH_KERNEL_USING_XMM
|
---|
1215 | DECLASM(int) hmR0VMXStartVMWrapXMM(RTHCUINT fResume, PCPUMCTX pCtx, PVMXVMCSBATCHCACHE pVmcsCache, PVM pVM, PVMCPU pVCpu,
|
---|
1216 | PFNHMVMXSTARTVM pfnStartVM);
|
---|
1217 | DECLASM(int) hmR0SVMRunWrapXMM(RTHCPHYS pVmcbHostPhys, RTHCPHYS pVmcbPhys, PCPUMCTX pCtx, PVM pVM, PVMCPU pVCpu,
|
---|
1218 | PFNHMSVMVMRUN pfnVMRun);
|
---|
1219 | # endif
|
---|
1220 | #endif /* IN_RING0 */
|
---|
1221 |
|
---|
1222 | VMM_INT_DECL(int) hmEmulateSvmMovTpr(PVMCPU pVCpu);
|
---|
1223 |
|
---|
1224 | /** @} */
|
---|
1225 |
|
---|
1226 | RT_C_DECLS_END
|
---|
1227 |
|
---|
1228 | #endif /* !VMM_INCLUDED_SRC_include_HMInternal_h */
|
---|
1229 |
|
---|