1 | /* $Id: HMInternal.h 45235 2013-03-28 14:36:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * HM - Internal header file.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2013 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 ___HMInternal_h
|
---|
19 | #define ___HMInternal_h
|
---|
20 |
|
---|
21 | #include <VBox/cdefs.h>
|
---|
22 | #include <VBox/types.h>
|
---|
23 | #include <VBox/vmm/em.h>
|
---|
24 | #include <VBox/vmm/stam.h>
|
---|
25 | #include <VBox/dis.h>
|
---|
26 | #include <VBox/vmm/hm.h>
|
---|
27 | #include <VBox/vmm/hm_vmx.h>
|
---|
28 | #include <VBox/vmm/pgm.h>
|
---|
29 | #include <VBox/vmm/cpum.h>
|
---|
30 | #include <iprt/memobj.h>
|
---|
31 | #include <iprt/cpuset.h>
|
---|
32 | #include <iprt/mp.h>
|
---|
33 | #include <iprt/avl.h>
|
---|
34 |
|
---|
35 | #if HC_ARCH_BITS == 64 || defined(VBOX_WITH_HYBRID_32BIT_KERNEL) || defined (VBOX_WITH_64_BITS_GUESTS)
|
---|
36 | /* Enable 64 bits guest support. */
|
---|
37 | # define VBOX_ENABLE_64_BITS_GUESTS
|
---|
38 | #endif
|
---|
39 |
|
---|
40 | #ifdef VBOX_WITH_OLD_VTX_CODE
|
---|
41 | # define VMX_USE_CACHED_VMCS_ACCESSES
|
---|
42 | #elif HC_ARCH_BITS == 32 && !defined(VBOX_WITH_HYBRID_32BIT_KERNEL)
|
---|
43 | # define VMX_USE_CACHED_VMCS_ACCESSES
|
---|
44 | #endif
|
---|
45 |
|
---|
46 | #define HM_VMX_EMULATE_REALMODE
|
---|
47 |
|
---|
48 | /* The MSR auto load/store does not work for KERNEL_GS_BASE MSR, thus we
|
---|
49 | * handle this MSR manually. See @bugref{6208}. This is clearly visible while
|
---|
50 | * booting Solaris 11 (11.1 b19) VMs with 2 Cpus.
|
---|
51 | *
|
---|
52 | * Note: don't forget to update the assembly files while modifying this!
|
---|
53 | */
|
---|
54 | # define VBOX_WITH_AUTO_MSR_LOAD_RESTORE
|
---|
55 |
|
---|
56 | RT_C_DECLS_BEGIN
|
---|
57 |
|
---|
58 |
|
---|
59 | /** @defgroup grp_hm_int Internal
|
---|
60 | * @ingroup grp_hm
|
---|
61 | * @internal
|
---|
62 | * @{
|
---|
63 | */
|
---|
64 |
|
---|
65 |
|
---|
66 | /** Maximum number of exit reason statistics counters. */
|
---|
67 | #define MAX_EXITREASON_STAT 0x100
|
---|
68 | #define MASK_EXITREASON_STAT 0xff
|
---|
69 | #define MASK_INJECT_IRQ_STAT 0xff
|
---|
70 |
|
---|
71 | /** @name Changed flags
|
---|
72 | * These flags are used to keep track of which important registers that
|
---|
73 | * have been changed since last they were reset.
|
---|
74 | * @{
|
---|
75 | */
|
---|
76 | #ifdef VBOX_WITH_OLD_VTX_CODE
|
---|
77 | # define HM_CHANGED_GUEST_FPU RT_BIT(0)
|
---|
78 | # define HM_CHANGED_GUEST_CR0 RT_BIT(1)
|
---|
79 | # define HM_CHANGED_GUEST_CR3 RT_BIT(2)
|
---|
80 | # define HM_CHANGED_GUEST_CR4 RT_BIT(3)
|
---|
81 | # define HM_CHANGED_GUEST_GDTR RT_BIT(4)
|
---|
82 | # define HM_CHANGED_GUEST_IDTR RT_BIT(5)
|
---|
83 | # define HM_CHANGED_GUEST_LDTR RT_BIT(6)
|
---|
84 | # define HM_CHANGED_GUEST_TR RT_BIT(7)
|
---|
85 | # define HM_CHANGED_GUEST_MSR RT_BIT(8)
|
---|
86 | # define HM_CHANGED_GUEST_SEGMENT_REGS RT_BIT(9)
|
---|
87 | # define HM_CHANGED_GUEST_DEBUG RT_BIT(10)
|
---|
88 | # define HM_CHANGED_HOST_CONTEXT RT_BIT(11)
|
---|
89 | # define HM_CHANGED_ALL_GUEST ( HM_CHANGED_GUEST_SEGMENT_REGS \
|
---|
90 | | HM_CHANGED_GUEST_CR0 \
|
---|
91 | | HM_CHANGED_GUEST_CR3 \
|
---|
92 | | HM_CHANGED_GUEST_CR4 \
|
---|
93 | | HM_CHANGED_GUEST_GDTR \
|
---|
94 | | HM_CHANGED_GUEST_IDTR \
|
---|
95 | | HM_CHANGED_GUEST_LDTR \
|
---|
96 | | HM_CHANGED_GUEST_TR \
|
---|
97 | | HM_CHANGED_GUEST_MSR \
|
---|
98 | | HM_CHANGED_GUEST_DEBUG \
|
---|
99 | | HM_CHANGED_GUEST_FPU)
|
---|
100 | #else
|
---|
101 | # define HM_CHANGED_GUEST_RIP RT_BIT(0)
|
---|
102 | # define HM_CHANGED_GUEST_RSP RT_BIT(1)
|
---|
103 | # define HM_CHANGED_GUEST_RFLAGS RT_BIT(2)
|
---|
104 | # define HM_CHANGED_GUEST_FPU RT_BIT(3)
|
---|
105 | # define HM_CHANGED_GUEST_CR0 RT_BIT(4)
|
---|
106 | # define HM_CHANGED_GUEST_CR2 RT_BIT(5)
|
---|
107 | # define HM_CHANGED_GUEST_CR3 RT_BIT(6)
|
---|
108 | # define HM_CHANGED_GUEST_CR4 RT_BIT(7)
|
---|
109 | # define HM_CHANGED_GUEST_GDTR RT_BIT(8)
|
---|
110 | # define HM_CHANGED_GUEST_IDTR RT_BIT(9)
|
---|
111 | # define HM_CHANGED_GUEST_LDTR RT_BIT(10)
|
---|
112 | # define HM_CHANGED_GUEST_TR RT_BIT(11)
|
---|
113 | # define HM_CHANGED_GUEST_SEGMENT_REGS RT_BIT(12)
|
---|
114 | # define HM_CHANGED_GUEST_DEBUG RT_BIT(13)
|
---|
115 | # define HM_CHANGED_GUEST_FS_BASE_MSR RT_BIT(14)
|
---|
116 | # define HM_CHANGED_GUEST_GS_BASE_MSR RT_BIT(15)
|
---|
117 | # define HM_CHANGED_GUEST_SYSENTER_CS_MSR RT_BIT(16)
|
---|
118 | # define HM_CHANGED_GUEST_SYSENTER_EIP_MSR RT_BIT(17)
|
---|
119 | # define HM_CHANGED_GUEST_SYSENTER_ESP_MSR RT_BIT(18)
|
---|
120 | # define HM_CHANGED_GUEST_INTR_STATE RT_BIT(19)
|
---|
121 | # define HM_CHANGED_VMX_GUEST_AUTO_MSRS RT_BIT(20)
|
---|
122 | # define HM_CHANGED_VMX_GUEST_ACTIVITY_STATE RT_BIT(21)
|
---|
123 | # define HM_CHANGED_VMX_GUEST_APIC_STATE RT_BIT(22)
|
---|
124 | # define HM_CHANGED_VMX_ENTRY_CTLS RT_BIT(23)
|
---|
125 | # define HM_CHANGED_VMX_EXIT_CTLS RT_BIT(24)
|
---|
126 |
|
---|
127 | # define HM_CHANGED_HOST_CONTEXT RT_BIT(25)
|
---|
128 |
|
---|
129 | # define HM_CHANGED_ALL_GUEST ( HM_CHANGED_GUEST_RIP \
|
---|
130 | | HM_CHANGED_GUEST_RSP \
|
---|
131 | | HM_CHANGED_GUEST_RFLAGS \
|
---|
132 | | HM_CHANGED_GUEST_FPU \
|
---|
133 | | HM_CHANGED_GUEST_CR0 \
|
---|
134 | | HM_CHANGED_GUEST_CR2 \
|
---|
135 | | HM_CHANGED_GUEST_CR3 \
|
---|
136 | | HM_CHANGED_GUEST_CR4 \
|
---|
137 | | HM_CHANGED_GUEST_GDTR \
|
---|
138 | | HM_CHANGED_GUEST_IDTR \
|
---|
139 | | HM_CHANGED_GUEST_LDTR \
|
---|
140 | | HM_CHANGED_GUEST_TR \
|
---|
141 | | HM_CHANGED_GUEST_SEGMENT_REGS \
|
---|
142 | | HM_CHANGED_GUEST_DEBUG \
|
---|
143 | | HM_CHANGED_GUEST_FS_BASE_MSR \
|
---|
144 | | HM_CHANGED_GUEST_GS_BASE_MSR \
|
---|
145 | | HM_CHANGED_GUEST_SYSENTER_CS_MSR \
|
---|
146 | | HM_CHANGED_GUEST_SYSENTER_EIP_MSR \
|
---|
147 | | HM_CHANGED_GUEST_SYSENTER_ESP_MSR \
|
---|
148 | | HM_CHANGED_GUEST_INTR_STATE \
|
---|
149 | | HM_CHANGED_VMX_GUEST_AUTO_MSRS \
|
---|
150 | | HM_CHANGED_VMX_GUEST_ACTIVITY_STATE \
|
---|
151 | | HM_CHANGED_VMX_GUEST_APIC_STATE \
|
---|
152 | | HM_CHANGED_VMX_ENTRY_CTLS \
|
---|
153 | | HM_CHANGED_VMX_EXIT_CTLS)
|
---|
154 | #endif
|
---|
155 |
|
---|
156 | #define HM_CHANGED_ALL (HM_CHANGED_ALL_GUEST | HM_CHANGED_HOST_CONTEXT)
|
---|
157 | /** @} */
|
---|
158 |
|
---|
159 | /** Maximum number of page flushes we are willing to remember before considering a full TLB flush. */
|
---|
160 | #define HM_MAX_TLB_SHOOTDOWN_PAGES 8
|
---|
161 |
|
---|
162 | /** Size for the EPT identity page table (1024 4 MB pages to cover the entire address space). */
|
---|
163 | #define HM_EPT_IDENTITY_PG_TABLE_SIZE PAGE_SIZE
|
---|
164 | /** Size of the TSS structure + 2 pages for the IO bitmap + end byte. */
|
---|
165 | #define HM_VTX_TSS_SIZE (sizeof(VBOXTSS) + 2 * PAGE_SIZE + 1)
|
---|
166 | /** Total guest mapped memory needed. */
|
---|
167 | #define HM_VTX_TOTAL_DEVHEAP_MEM (HM_EPT_IDENTITY_PG_TABLE_SIZE + HM_VTX_TSS_SIZE)
|
---|
168 |
|
---|
169 | /** Enable for TPR guest patching. */
|
---|
170 | #define VBOX_HM_WITH_GUEST_PATCHING
|
---|
171 |
|
---|
172 | /** HM SSM version
|
---|
173 | */
|
---|
174 | #ifdef VBOX_HM_WITH_GUEST_PATCHING
|
---|
175 | # define HM_SSM_VERSION 5
|
---|
176 | # define HM_SSM_VERSION_NO_PATCHING 4
|
---|
177 | #else
|
---|
178 | # define HM_SSM_VERSION 4
|
---|
179 | # define HM_SSM_VERSION_NO_PATCHING 4
|
---|
180 | #endif
|
---|
181 | #define HM_SSM_VERSION_2_0_X 3
|
---|
182 |
|
---|
183 | /**
|
---|
184 | * Global per-cpu information. (host)
|
---|
185 | */
|
---|
186 | typedef struct HMGLOBLCPUINFO
|
---|
187 | {
|
---|
188 | /** The CPU ID. */
|
---|
189 | RTCPUID idCpu;
|
---|
190 | /** The memory object */
|
---|
191 | RTR0MEMOBJ hMemObj;
|
---|
192 | /** Current ASID (AMD-V) / VPID (Intel). */
|
---|
193 | uint32_t uCurrentAsid;
|
---|
194 | /** TLB flush count. */
|
---|
195 | uint32_t cTlbFlushes;
|
---|
196 | /** Whether to flush each new ASID/VPID before use. */
|
---|
197 | bool fFlushAsidBeforeUse;
|
---|
198 | /** Configured for VT-x or AMD-V. */
|
---|
199 | bool fConfigured;
|
---|
200 | /** Set if the VBOX_HWVIRTEX_IGNORE_SVM_IN_USE hack is active. */
|
---|
201 | bool fIgnoreAMDVInUseError;
|
---|
202 | /** In use by our code. (for power suspend) */
|
---|
203 | volatile bool fInUse;
|
---|
204 | } HMGLOBLCPUINFO;
|
---|
205 | /** Pointer to the per-cpu global information. */
|
---|
206 | typedef HMGLOBLCPUINFO *PHMGLOBLCPUINFO;
|
---|
207 |
|
---|
208 | typedef enum
|
---|
209 | {
|
---|
210 | HMPENDINGIO_INVALID = 0,
|
---|
211 | HMPENDINGIO_PORT_READ,
|
---|
212 | HMPENDINGIO_PORT_WRITE,
|
---|
213 | HMPENDINGIO_STRING_READ,
|
---|
214 | HMPENDINGIO_STRING_WRITE,
|
---|
215 | /** The usual 32-bit paranoia. */
|
---|
216 | HMPENDINGIO_32BIT_HACK = 0x7fffffff
|
---|
217 | } HMPENDINGIO;
|
---|
218 |
|
---|
219 |
|
---|
220 | typedef enum
|
---|
221 | {
|
---|
222 | HMTPRINSTR_INVALID,
|
---|
223 | HMTPRINSTR_READ,
|
---|
224 | HMTPRINSTR_READ_SHR4,
|
---|
225 | HMTPRINSTR_WRITE_REG,
|
---|
226 | HMTPRINSTR_WRITE_IMM,
|
---|
227 | HMTPRINSTR_JUMP_REPLACEMENT,
|
---|
228 | /** The usual 32-bit paranoia. */
|
---|
229 | HMTPRINSTR_32BIT_HACK = 0x7fffffff
|
---|
230 | } HMTPRINSTR;
|
---|
231 |
|
---|
232 | typedef struct
|
---|
233 | {
|
---|
234 | /** The key is the address of patched instruction. (32 bits GC ptr) */
|
---|
235 | AVLOU32NODECORE Core;
|
---|
236 | /** Original opcode. */
|
---|
237 | uint8_t aOpcode[16];
|
---|
238 | /** Instruction size. */
|
---|
239 | uint32_t cbOp;
|
---|
240 | /** Replacement opcode. */
|
---|
241 | uint8_t aNewOpcode[16];
|
---|
242 | /** Replacement instruction size. */
|
---|
243 | uint32_t cbNewOp;
|
---|
244 | /** Instruction type. */
|
---|
245 | HMTPRINSTR enmType;
|
---|
246 | /** Source operand. */
|
---|
247 | uint32_t uSrcOperand;
|
---|
248 | /** Destination operand. */
|
---|
249 | uint32_t uDstOperand;
|
---|
250 | /** Number of times the instruction caused a fault. */
|
---|
251 | uint32_t cFaults;
|
---|
252 | /** Patch address of the jump replacement. */
|
---|
253 | RTGCPTR32 pJumpTarget;
|
---|
254 | } HMTPRPATCH;
|
---|
255 | /** Pointer to HMTPRPATCH. */
|
---|
256 | typedef HMTPRPATCH *PHMTPRPATCH;
|
---|
257 |
|
---|
258 | /**
|
---|
259 | * Switcher function, HC to RC.
|
---|
260 | *
|
---|
261 | * @param pVM Pointer to the VM.
|
---|
262 | * @param uOffsetVMCPU VMCPU offset from pVM
|
---|
263 | * @returns Return code indicating the action to take.
|
---|
264 | */
|
---|
265 | typedef DECLCALLBACK (int) FNHMSWITCHERHC(PVM pVM, uint32_t uOffsetVMCPU);
|
---|
266 | /** Pointer to switcher function. */
|
---|
267 | typedef FNHMSWITCHERHC *PFNHMSWITCHERHC;
|
---|
268 |
|
---|
269 | /**
|
---|
270 | * HM VM Instance data.
|
---|
271 | * Changes to this must checked against the padding of the hm union in VM!
|
---|
272 | */
|
---|
273 | typedef struct HM
|
---|
274 | {
|
---|
275 | /** Set when we've initialized VMX or SVM. */
|
---|
276 | bool fInitialized;
|
---|
277 |
|
---|
278 | /** Set when hardware acceleration is allowed. */
|
---|
279 | bool fAllowed;
|
---|
280 |
|
---|
281 | /** Set if nested paging is enabled. */
|
---|
282 | bool fNestedPaging;
|
---|
283 |
|
---|
284 | /** Set if nested paging is allowed. */
|
---|
285 | bool fAllowNestedPaging;
|
---|
286 |
|
---|
287 | /** Set if large pages are enabled (requires nested paging). */
|
---|
288 | bool fLargePages;
|
---|
289 |
|
---|
290 | /** Set if we can support 64-bit guests or not. */
|
---|
291 | bool fAllow64BitGuests;
|
---|
292 |
|
---|
293 | /** Set if an IO-APIC is configured for this VM. */
|
---|
294 | bool fHasIoApic;
|
---|
295 |
|
---|
296 | /** Set when TPR patching is allowed. */
|
---|
297 | bool fTRPPatchingAllowed;
|
---|
298 |
|
---|
299 | /** Set when we initialize VT-x or AMD-V once for all CPUs. */
|
---|
300 | bool fGlobalInit;
|
---|
301 |
|
---|
302 | /** Set when TPR patching is active. */
|
---|
303 | bool fTPRPatchingActive;
|
---|
304 | bool u8Alignment[6];
|
---|
305 |
|
---|
306 | /** And mask for copying register contents. */
|
---|
307 | uint64_t u64RegisterMask;
|
---|
308 |
|
---|
309 | /** Maximum ASID allowed. */
|
---|
310 | uint32_t uMaxAsid;
|
---|
311 |
|
---|
312 | /** The maximum number of resumes loops allowed in ring-0 (safety precaution).
|
---|
313 | * This number is set much higher when RTThreadPreemptIsPending is reliable. */
|
---|
314 | uint32_t cMaxResumeLoops;
|
---|
315 |
|
---|
316 | /** Guest allocated memory for patching purposes. */
|
---|
317 | RTGCPTR pGuestPatchMem;
|
---|
318 | /** Current free pointer inside the patch block. */
|
---|
319 | RTGCPTR pFreeGuestPatchMem;
|
---|
320 | /** Size of the guest patch memory block. */
|
---|
321 | uint32_t cbGuestPatchMem;
|
---|
322 | uint32_t uPadding1;
|
---|
323 |
|
---|
324 | #if HC_ARCH_BITS == 32 && defined(VBOX_ENABLE_64_BITS_GUESTS) && !defined(VBOX_WITH_HYBRID_32BIT_KERNEL)
|
---|
325 | /** 32 to 64 bits switcher entrypoint. */
|
---|
326 | R0PTRTYPE(PFNHMSWITCHERHC) pfnHost32ToGuest64R0;
|
---|
327 |
|
---|
328 | /* AMD-V 64 bits vmrun handler */
|
---|
329 | RTRCPTR pfnSVMGCVMRun64;
|
---|
330 |
|
---|
331 | /* VT-x 64 bits vmlaunch handler */
|
---|
332 | RTRCPTR pfnVMXGCStartVM64;
|
---|
333 |
|
---|
334 | /* RC handler to setup the 64 bits FPU state. */
|
---|
335 | RTRCPTR pfnSaveGuestFPU64;
|
---|
336 |
|
---|
337 | /* RC handler to setup the 64 bits debug state. */
|
---|
338 | RTRCPTR pfnSaveGuestDebug64;
|
---|
339 |
|
---|
340 | /* Test handler */
|
---|
341 | RTRCPTR pfnTest64;
|
---|
342 |
|
---|
343 | RTRCPTR uAlignment[2];
|
---|
344 | /*#elif defined(VBOX_WITH_HYBRID_32BIT_KERNEL)
|
---|
345 | uint32_t u32Alignment[1]; */
|
---|
346 | #endif
|
---|
347 |
|
---|
348 | struct
|
---|
349 | {
|
---|
350 | /** Set by the ring-0 side of HM to indicate VMX is supported by the
|
---|
351 | * CPU. */
|
---|
352 | bool fSupported;
|
---|
353 |
|
---|
354 | /** Set when we've enabled VMX. */
|
---|
355 | bool fEnabled;
|
---|
356 |
|
---|
357 | /** Set if VPID is supported. */
|
---|
358 | bool fVpid;
|
---|
359 |
|
---|
360 | /** Set if VT-x VPID is allowed. */
|
---|
361 | bool fAllowVpid;
|
---|
362 |
|
---|
363 | /** Set if unrestricted guest execution is allowed (real and protected mode without paging). */
|
---|
364 | bool fUnrestrictedGuest;
|
---|
365 |
|
---|
366 | /** Whether we're using the preemption timer or not. */
|
---|
367 | bool fUsePreemptTimer;
|
---|
368 | /** The shift mask employed by the VMX-Preemption timer. */
|
---|
369 | uint8_t cPreemptTimerShift;
|
---|
370 |
|
---|
371 | bool uAlignment[1];
|
---|
372 |
|
---|
373 | /** Virtual address of the TSS page used for real mode emulation. */
|
---|
374 | R3PTRTYPE(PVBOXTSS) pRealModeTSS;
|
---|
375 |
|
---|
376 | /** Virtual address of the identity page table used for real mode and protected mode without paging emulation in EPT mode. */
|
---|
377 | R3PTRTYPE(PX86PD) pNonPagingModeEPTPageTable;
|
---|
378 |
|
---|
379 | /** R0 memory object for the APIC-access page. */
|
---|
380 | RTR0MEMOBJ hMemObjApicAccess;
|
---|
381 | /** Physical address of the APIC-access page. */
|
---|
382 | RTHCPHYS HCPhysApicAccess;
|
---|
383 | /** Virtual address of the APIC-access page. */
|
---|
384 | R0PTRTYPE(uint8_t *) pbApicAccess;
|
---|
385 |
|
---|
386 | #ifdef VBOX_WITH_CRASHDUMP_MAGIC
|
---|
387 | RTR0MEMOBJ hMemObjScratch;
|
---|
388 | RTHCPHYS HCPhysScratch;
|
---|
389 | R0PTRTYPE(uint8_t *) pbScratch;
|
---|
390 | #endif
|
---|
391 | /** Ring 0 handlers for VT-x. */
|
---|
392 | DECLR0CALLBACKMEMBER(void, pfnFlushTaggedTlb, (PVM pVM, PVMCPU pVCpu));
|
---|
393 |
|
---|
394 | #if HC_ARCH_BITS == 32 && defined(VBOX_ENABLE_64_BITS_GUESTS)
|
---|
395 | uint32_t u32Alignment;
|
---|
396 | #endif
|
---|
397 | /** Host CR4 value (set by ring-0 VMX init) */
|
---|
398 | uint64_t hostCR4;
|
---|
399 |
|
---|
400 | /** Host EFER value (set by ring-0 VMX init) */
|
---|
401 | uint64_t hostEFER;
|
---|
402 |
|
---|
403 | /** VMX MSR values */
|
---|
404 | struct
|
---|
405 | {
|
---|
406 | uint64_t feature_ctrl;
|
---|
407 | uint64_t vmx_basic_info;
|
---|
408 | VMX_CAPABILITY vmx_pin_ctls;
|
---|
409 | VMX_CAPABILITY vmx_proc_ctls;
|
---|
410 | VMX_CAPABILITY vmx_proc_ctls2;
|
---|
411 | VMX_CAPABILITY vmx_exit;
|
---|
412 | VMX_CAPABILITY vmx_entry;
|
---|
413 | uint64_t vmx_misc;
|
---|
414 | uint64_t vmx_cr0_fixed0;
|
---|
415 | uint64_t vmx_cr0_fixed1;
|
---|
416 | uint64_t vmx_cr4_fixed0;
|
---|
417 | uint64_t vmx_cr4_fixed1;
|
---|
418 | uint64_t vmx_vmcs_enum;
|
---|
419 | uint64_t vmx_ept_vpid_caps;
|
---|
420 | } msr;
|
---|
421 |
|
---|
422 | /** Flush types for invept & invvpid; they depend on capabilities. */
|
---|
423 | VMX_FLUSH_EPT enmFlushEpt;
|
---|
424 | VMX_FLUSH_VPID enmFlushVpid;
|
---|
425 | } vmx;
|
---|
426 |
|
---|
427 | struct
|
---|
428 | {
|
---|
429 | /** Set by the ring-0 side of HM to indicate SVM is supported by the
|
---|
430 | * CPU. */
|
---|
431 | bool fSupported;
|
---|
432 | /** Set when we've enabled SVM. */
|
---|
433 | bool fEnabled;
|
---|
434 | /** Set if erratum 170 affects the AMD cpu. */
|
---|
435 | bool fAlwaysFlushTLB;
|
---|
436 | /** Set when the hack to ignore VERR_SVM_IN_USE is active. */
|
---|
437 | bool fIgnoreInUseError;
|
---|
438 |
|
---|
439 | /** R0 memory object for the IO bitmap (12kb). */
|
---|
440 | RTR0MEMOBJ hMemObjIOBitmap;
|
---|
441 | /** Physical address of the IO bitmap (12kb). */
|
---|
442 | RTHCPHYS HCPhysIOBitmap;
|
---|
443 | /** Virtual address of the IO bitmap. */
|
---|
444 | R0PTRTYPE(void *) pvIOBitmap;
|
---|
445 |
|
---|
446 | /* HWCR MSR (for diagnostics) */
|
---|
447 | uint64_t msrHwcr;
|
---|
448 |
|
---|
449 | /** SVM revision. */
|
---|
450 | uint32_t u32Rev;
|
---|
451 |
|
---|
452 | /** SVM feature bits from cpuid 0x8000000a */
|
---|
453 | uint32_t u32Features;
|
---|
454 | } svm;
|
---|
455 |
|
---|
456 | /**
|
---|
457 | * AVL tree with all patches (active or disabled) sorted by guest instruction address
|
---|
458 | */
|
---|
459 | AVLOU32TREE PatchTree;
|
---|
460 | uint32_t cPatches;
|
---|
461 | HMTPRPATCH aPatches[64];
|
---|
462 |
|
---|
463 | struct
|
---|
464 | {
|
---|
465 | uint32_t u32AMDFeatureECX;
|
---|
466 | uint32_t u32AMDFeatureEDX;
|
---|
467 | } cpuid;
|
---|
468 |
|
---|
469 | /** Saved error from detection */
|
---|
470 | int32_t lLastError;
|
---|
471 |
|
---|
472 | /** HMR0Init was run */
|
---|
473 | bool fHMR0Init;
|
---|
474 | bool u8Alignment1[7];
|
---|
475 |
|
---|
476 | STAMCOUNTER StatTprPatchSuccess;
|
---|
477 | STAMCOUNTER StatTprPatchFailure;
|
---|
478 | STAMCOUNTER StatTprReplaceSuccess;
|
---|
479 | STAMCOUNTER StatTprReplaceFailure;
|
---|
480 | } HM;
|
---|
481 | /** Pointer to HM VM instance data. */
|
---|
482 | typedef HM *PHM;
|
---|
483 |
|
---|
484 | /* Maximum number of cached entries. */
|
---|
485 | #define VMCSCACHE_MAX_ENTRY 128
|
---|
486 |
|
---|
487 | /* Structure for storing read and write VMCS actions. */
|
---|
488 | typedef struct VMCSCACHE
|
---|
489 | {
|
---|
490 | #ifdef VBOX_WITH_CRASHDUMP_MAGIC
|
---|
491 | /* Magic marker for searching in crash dumps. */
|
---|
492 | uint8_t aMagic[16];
|
---|
493 | uint64_t uMagic;
|
---|
494 | uint64_t u64TimeEntry;
|
---|
495 | uint64_t u64TimeSwitch;
|
---|
496 | uint64_t cResume;
|
---|
497 | uint64_t interPD;
|
---|
498 | uint64_t pSwitcher;
|
---|
499 | uint32_t uPos;
|
---|
500 | uint32_t idCpu;
|
---|
501 | #endif
|
---|
502 | /* CR2 is saved here for EPT syncing. */
|
---|
503 | uint64_t cr2;
|
---|
504 | struct
|
---|
505 | {
|
---|
506 | uint32_t cValidEntries;
|
---|
507 | uint32_t uAlignment;
|
---|
508 | uint32_t aField[VMCSCACHE_MAX_ENTRY];
|
---|
509 | uint64_t aFieldVal[VMCSCACHE_MAX_ENTRY];
|
---|
510 | } Write;
|
---|
511 | struct
|
---|
512 | {
|
---|
513 | uint32_t cValidEntries;
|
---|
514 | uint32_t uAlignment;
|
---|
515 | uint32_t aField[VMCSCACHE_MAX_ENTRY];
|
---|
516 | uint64_t aFieldVal[VMCSCACHE_MAX_ENTRY];
|
---|
517 | } Read;
|
---|
518 | #ifdef DEBUG
|
---|
519 | struct
|
---|
520 | {
|
---|
521 | RTHCPHYS HCPhysCpuPage;
|
---|
522 | RTHCPHYS HCPhysVmcs;
|
---|
523 | RTGCPTR pCache;
|
---|
524 | RTGCPTR pCtx;
|
---|
525 | } TestIn;
|
---|
526 | struct
|
---|
527 | {
|
---|
528 | RTHCPHYS HCPhysVmcs;
|
---|
529 | RTGCPTR pCache;
|
---|
530 | RTGCPTR pCtx;
|
---|
531 | uint64_t eflags;
|
---|
532 | uint64_t cr8;
|
---|
533 | } TestOut;
|
---|
534 | struct
|
---|
535 | {
|
---|
536 | uint64_t param1;
|
---|
537 | uint64_t param2;
|
---|
538 | uint64_t param3;
|
---|
539 | uint64_t param4;
|
---|
540 | } ScratchPad;
|
---|
541 | #endif
|
---|
542 | } VMCSCACHE;
|
---|
543 | /** Pointer to VMCSCACHE. */
|
---|
544 | typedef VMCSCACHE *PVMCSCACHE;
|
---|
545 |
|
---|
546 | /** VMX StartVM function. */
|
---|
547 | typedef DECLCALLBACK(int) FNHMVMXSTARTVM(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM, PVMCPU pVCpu);
|
---|
548 | /** Pointer to a VMX StartVM function. */
|
---|
549 | typedef R0PTRTYPE(FNHMVMXSTARTVM *) PFNHMVMXSTARTVM;
|
---|
550 |
|
---|
551 | /** SVM VMRun function. */
|
---|
552 | typedef DECLCALLBACK(int) FNHMSVMVMRUN(RTHCPHYS pVMCBHostPhys, RTHCPHYS pVMCBPhys, PCPUMCTX pCtx, PVM pVM, PVMCPU pVCpu);
|
---|
553 | /** Pointer to a SVM VMRun function. */
|
---|
554 | typedef R0PTRTYPE(FNHMSVMVMRUN *) PFNHMSVMVMRUN;
|
---|
555 |
|
---|
556 | /**
|
---|
557 | * HM VMCPU Instance data.
|
---|
558 | */
|
---|
559 | typedef struct HMCPU
|
---|
560 | {
|
---|
561 | /** Old style FPU reporting trap mask override performed (optimization) */
|
---|
562 | bool fFPUOldStyleOverride;
|
---|
563 | /** Set if we don't have to flush the TLB on VM entry. */
|
---|
564 | bool fResumeVM;
|
---|
565 | /** Set if we need to flush the TLB during the world switch. */
|
---|
566 | bool fForceTLBFlush;
|
---|
567 | /** Set when we're using VT-x or AMD-V at that moment. */
|
---|
568 | bool fActive;
|
---|
569 | /** Set when the TLB has been checked until we return from the world switch. */
|
---|
570 | volatile bool fCheckedTLBFlush;
|
---|
571 | uint8_t u8Alignment[3];
|
---|
572 |
|
---|
573 | /** World switch exit counter. */
|
---|
574 | volatile uint32_t cWorldSwitchExits;
|
---|
575 | /** HM_CHANGED_* flags. */
|
---|
576 | uint32_t fContextUseFlags;
|
---|
577 | /** Id of the last cpu we were executing code on (NIL_RTCPUID for the first time) */
|
---|
578 | RTCPUID idLastCpu;
|
---|
579 | /** TLB flush count */
|
---|
580 | uint32_t cTlbFlushes;
|
---|
581 | /** Current ASID in use by the VM */
|
---|
582 | uint32_t uCurrentAsid;
|
---|
583 | uint32_t u32Alignment;
|
---|
584 |
|
---|
585 | /* Host's TSC_AUX MSR (used when RDTSCP doesn't cause VM-exits). */
|
---|
586 | uint64_t u64HostTscAux;
|
---|
587 |
|
---|
588 | struct
|
---|
589 | {
|
---|
590 | /** Physical address of the VM control structure (VMCS). */
|
---|
591 | RTHCPHYS HCPhysVmcs;
|
---|
592 | /** R0 memory object for the VM control structure (VMCS). */
|
---|
593 | RTR0MEMOBJ hMemObjVmcs;
|
---|
594 | /** Virtual address of the VM control structure (VMCS). */
|
---|
595 | R0PTRTYPE(void *) pvVmcs;
|
---|
596 | /** Ring 0 handlers for VT-x. */
|
---|
597 | PFNHMVMXSTARTVM pfnStartVM;
|
---|
598 | #if HC_ARCH_BITS == 32
|
---|
599 | uint32_t u32Alignment1;
|
---|
600 | #endif
|
---|
601 |
|
---|
602 | /** Current VMX_VMCS32_CTRL_PIN_EXEC_CONTROLS. */
|
---|
603 | uint32_t u32PinCtls;
|
---|
604 | /** Current VMX_VMCS32_CTRL_PROC_EXEC_CONTROLS. */
|
---|
605 | uint32_t u32ProcCtls;
|
---|
606 | /** Current VMX_VMCS32_CTRL_PROC_EXEC2_CONTROLS. */
|
---|
607 | uint32_t u32ProcCtls2;
|
---|
608 | /** Current VMX_VMCS32_CTRL_EXIT_CONTROLS. */
|
---|
609 | uint32_t u32ExitCtls;
|
---|
610 | /** Current VMX_VMCS32_CTRL_ENTRY_CONTROLS. */
|
---|
611 | uint32_t u32EntryCtls;
|
---|
612 | /** Physical address of the virtual APIC page for TPR caching. */
|
---|
613 | RTHCPHYS HCPhysVirtApic;
|
---|
614 | /** R0 memory object for the virtual APIC page for TPR caching. */
|
---|
615 | RTR0MEMOBJ hMemObjVirtApic;
|
---|
616 | /** Virtual address of the virtual APIC page for TPR caching. */
|
---|
617 | R0PTRTYPE(uint8_t *) pbVirtApic;
|
---|
618 | #if HC_ARCH_BITS == 32
|
---|
619 | uint32_t u32Alignment2;
|
---|
620 | #endif
|
---|
621 |
|
---|
622 | /** Current CR0 mask. */
|
---|
623 | uint64_t cr0_mask;
|
---|
624 | /** Current CR4 mask. */
|
---|
625 | uint64_t cr4_mask;
|
---|
626 | /** Current exception bitmap. */
|
---|
627 | uint32_t u32XcptBitmap;
|
---|
628 | /** The updated-guest-state mask. */
|
---|
629 | uint32_t fUpdatedGuestState;
|
---|
630 | /** Current EPTP. */
|
---|
631 | RTHCPHYS GCPhysEPTP;
|
---|
632 |
|
---|
633 | /** Physical address of the MSR bitmap. */
|
---|
634 | RTHCPHYS HCPhysMsrBitmap;
|
---|
635 | /** R0 memory object for the MSR bitmap. */
|
---|
636 | RTR0MEMOBJ hMemObjMsrBitmap;
|
---|
637 | /** Virtual address of the MSR bitmap. */
|
---|
638 | R0PTRTYPE(void *) pvMsrBitmap;
|
---|
639 |
|
---|
640 | #ifdef VBOX_WITH_AUTO_MSR_LOAD_RESTORE
|
---|
641 | /** Physical address of the VM-entry MSR-load and VM-exit MSR-store area (used
|
---|
642 | * for guest MSRs). */
|
---|
643 | RTHCPHYS HCPhysGuestMsr;
|
---|
644 | /** R0 memory object of the VM-entry MSR-load and VM-exit MSR-store area
|
---|
645 | * (used for guest MSRs). */
|
---|
646 | RTR0MEMOBJ hMemObjGuestMsr;
|
---|
647 | /** Virtual address of the VM-entry MSR-load and VM-exit MSR-store area (used
|
---|
648 | * for guest MSRs). */
|
---|
649 | R0PTRTYPE(void *) pvGuestMsr;
|
---|
650 |
|
---|
651 | /** Physical address of the VM-exit MSR-load area (used for host MSRs). */
|
---|
652 | RTHCPHYS HCPhysHostMsr;
|
---|
653 | /** R0 memory object for the VM-exit MSR-load area (used for host MSRs). */
|
---|
654 | RTR0MEMOBJ hMemObjHostMsr;
|
---|
655 | /** Virtual address of the VM-exit MSR-load area (used for host MSRs). */
|
---|
656 | R0PTRTYPE(void *) pvHostMsr;
|
---|
657 |
|
---|
658 | /* Number of automatically loaded/restored guest MSRs during the world switch. */
|
---|
659 | uint32_t cGuestMsrs;
|
---|
660 | uint32_t uAlignment;
|
---|
661 | #endif /* VBOX_WITH_AUTO_MSR_LOAD_RESTORE */
|
---|
662 |
|
---|
663 | /* The cached APIC-base MSR used for identifying when to map the HC physical APIC-access page. */
|
---|
664 | uint64_t u64MsrApicBase;
|
---|
665 | /* Last use TSC offset value. (cached) */
|
---|
666 | uint64_t u64TSCOffset;
|
---|
667 | /** VMCS cache. */
|
---|
668 | VMCSCACHE VMCSCache;
|
---|
669 |
|
---|
670 | /** Real-mode emulation state. */
|
---|
671 | struct
|
---|
672 | {
|
---|
673 | X86DESCATTR uAttrCS;
|
---|
674 | X86DESCATTR uAttrDS;
|
---|
675 | X86DESCATTR uAttrES;
|
---|
676 | X86DESCATTR uAttrFS;
|
---|
677 | X86DESCATTR uAttrGS;
|
---|
678 | X86DESCATTR uAttrSS;
|
---|
679 | X86EFLAGS eflags;
|
---|
680 | uint32_t fRealOnV86Active;
|
---|
681 | } RealMode;
|
---|
682 |
|
---|
683 | struct
|
---|
684 | {
|
---|
685 | uint64_t u64VMCSPhys;
|
---|
686 | uint32_t u32VMCSRevision;
|
---|
687 | uint32_t u32InstrError;
|
---|
688 | uint32_t u32ExitReason;
|
---|
689 | RTCPUID idEnteredCpu;
|
---|
690 | RTCPUID idCurrentCpu;
|
---|
691 | uint32_t padding;
|
---|
692 | } lasterror;
|
---|
693 |
|
---|
694 | /** The last seen guest paging mode (by VT-x). */
|
---|
695 | PGMMODE enmLastSeenGuestMode;
|
---|
696 | /** Current guest paging mode (as seen by HMR3PagingModeChanged). */
|
---|
697 | PGMMODE enmCurrGuestMode;
|
---|
698 | /** Previous guest paging mode (as seen by HMR3PagingModeChanged). */
|
---|
699 | PGMMODE enmPrevGuestMode;
|
---|
700 | } vmx;
|
---|
701 |
|
---|
702 | struct
|
---|
703 | {
|
---|
704 | /** R0 memory object for the host VM control block (VMCB). */
|
---|
705 | RTR0MEMOBJ hMemObjVMCBHost;
|
---|
706 | /** Physical address of the host VM control block (VMCB). */
|
---|
707 | RTHCPHYS HCPhysVMCBHost;
|
---|
708 | /** Virtual address of the host VM control block (VMCB). */
|
---|
709 | R0PTRTYPE(void *) pvVMCBHost;
|
---|
710 |
|
---|
711 | /** R0 memory object for the VM control block (VMCB). */
|
---|
712 | RTR0MEMOBJ hMemObjVMCB;
|
---|
713 | /** Physical address of the VM control block (VMCB). */
|
---|
714 | RTHCPHYS HCPhysVMCB;
|
---|
715 | /** Virtual address of the VM control block (VMCB). */
|
---|
716 | R0PTRTYPE(void *) pvVMCB;
|
---|
717 |
|
---|
718 | /** Ring 0 handlers for VT-x. */
|
---|
719 | PFNHMSVMVMRUN pfnVMRun;
|
---|
720 |
|
---|
721 | /** R0 memory object for the MSR bitmap (8kb). */
|
---|
722 | RTR0MEMOBJ hMemObjMsrBitmap;
|
---|
723 | /** Physical address of the MSR bitmap (8kb). */
|
---|
724 | RTHCPHYS HCPhysMsrBitmap;
|
---|
725 | /** Virtual address of the MSR bitmap. */
|
---|
726 | R0PTRTYPE(void *) pvMsrBitmap;
|
---|
727 | } svm;
|
---|
728 |
|
---|
729 | /** Event injection state. */
|
---|
730 | struct
|
---|
731 | {
|
---|
732 | uint32_t fPending;
|
---|
733 | uint32_t u32ErrCode;
|
---|
734 | uint64_t u64IntrInfo;
|
---|
735 | } Event;
|
---|
736 |
|
---|
737 | /** IO Block emulation state. */
|
---|
738 | struct
|
---|
739 | {
|
---|
740 | bool fEnabled;
|
---|
741 | uint8_t u8Align[7];
|
---|
742 |
|
---|
743 | /** RIP at the start of the io code we wish to emulate in the recompiler. */
|
---|
744 | RTGCPTR GCPtrFunctionEip;
|
---|
745 |
|
---|
746 | uint64_t cr0;
|
---|
747 | } EmulateIoBlock;
|
---|
748 |
|
---|
749 | struct
|
---|
750 | {
|
---|
751 | /* Pending IO operation type. */
|
---|
752 | HMPENDINGIO enmType;
|
---|
753 | uint32_t uPadding;
|
---|
754 | RTGCPTR GCPtrRip;
|
---|
755 | RTGCPTR GCPtrRipNext;
|
---|
756 | union
|
---|
757 | {
|
---|
758 | struct
|
---|
759 | {
|
---|
760 | unsigned uPort;
|
---|
761 | unsigned uAndVal;
|
---|
762 | unsigned cbSize;
|
---|
763 | } Port;
|
---|
764 | uint64_t aRaw[2];
|
---|
765 | } s;
|
---|
766 | } PendingIO;
|
---|
767 |
|
---|
768 | /** The PAE PDPEs used with Nested Paging (only valid when
|
---|
769 | * VMCPU_FF_HM_UPDATE_PAE_PDPES is set). */
|
---|
770 | X86PDPE aPdpes[4];
|
---|
771 |
|
---|
772 | /** Current shadow paging mode. */
|
---|
773 | PGMMODE enmShadowMode;
|
---|
774 |
|
---|
775 | /** The CPU ID of the CPU currently owning the VMCS. Set in
|
---|
776 | * HMR0Enter and cleared in HMR0Leave. */
|
---|
777 | RTCPUID idEnteredCpu;
|
---|
778 |
|
---|
779 | /** To keep track of pending TLB shootdown pages. (SMP guest only) */
|
---|
780 | struct
|
---|
781 | {
|
---|
782 | RTGCPTR aPages[HM_MAX_TLB_SHOOTDOWN_PAGES];
|
---|
783 | unsigned cPages;
|
---|
784 | } TlbShootdown;
|
---|
785 |
|
---|
786 | /** For saving stack space, the disassembler state is allocated here instead of
|
---|
787 | * on the stack. */
|
---|
788 | DISCPUSTATE DisState;
|
---|
789 |
|
---|
790 | uint32_t padding2[1];
|
---|
791 |
|
---|
792 | STAMPROFILEADV StatEntry;
|
---|
793 | STAMPROFILEADV StatExit1;
|
---|
794 | STAMPROFILEADV StatExit2;
|
---|
795 | #if 1 /* temporary for tracking down darwin issues. */
|
---|
796 | STAMPROFILEADV StatExit2Sub1;
|
---|
797 | STAMPROFILEADV StatExit2Sub2;
|
---|
798 | STAMPROFILEADV StatExit2Sub3;
|
---|
799 | #endif
|
---|
800 | STAMPROFILEADV StatInGC;
|
---|
801 |
|
---|
802 | #if HC_ARCH_BITS == 32 && defined(VBOX_ENABLE_64_BITS_GUESTS) && !defined(VBOX_WITH_HYBRID_32BIT_KERNEL)
|
---|
803 | STAMPROFILEADV StatWorldSwitch3264;
|
---|
804 | #endif
|
---|
805 | STAMPROFILEADV StatPoke;
|
---|
806 | STAMPROFILEADV StatSpinPoke;
|
---|
807 | STAMPROFILEADV StatSpinPokeFailed;
|
---|
808 |
|
---|
809 | STAMCOUNTER StatIntInject;
|
---|
810 |
|
---|
811 | STAMCOUNTER StatExitShadowNM;
|
---|
812 | STAMCOUNTER StatExitGuestNM;
|
---|
813 | STAMCOUNTER StatExitShadowPF; /* Misleading, currently used for MMIO #PFs as well. */
|
---|
814 | STAMCOUNTER StatExitShadowPFEM;
|
---|
815 | STAMCOUNTER StatExitGuestPF;
|
---|
816 | STAMCOUNTER StatExitGuestUD;
|
---|
817 | STAMCOUNTER StatExitGuestSS;
|
---|
818 | STAMCOUNTER StatExitGuestNP;
|
---|
819 | STAMCOUNTER StatExitGuestGP;
|
---|
820 | STAMCOUNTER StatExitGuestDE;
|
---|
821 | STAMCOUNTER StatExitGuestDB;
|
---|
822 | STAMCOUNTER StatExitGuestMF;
|
---|
823 | STAMCOUNTER StatExitGuestBP;
|
---|
824 | STAMCOUNTER StatExitGuestXF;
|
---|
825 | STAMCOUNTER StatExitGuestXcpUnk;
|
---|
826 | STAMCOUNTER StatExitInvlpg;
|
---|
827 | STAMCOUNTER StatExitInvd;
|
---|
828 | STAMCOUNTER StatExitWbinvd;
|
---|
829 | STAMCOUNTER StatExitPause;
|
---|
830 | STAMCOUNTER StatExitCpuid;
|
---|
831 | STAMCOUNTER StatExitRdtsc;
|
---|
832 | STAMCOUNTER StatExitRdtscp;
|
---|
833 | STAMCOUNTER StatExitRdpmc;
|
---|
834 | STAMCOUNTER StatExitRdrand;
|
---|
835 | STAMCOUNTER StatExitCli;
|
---|
836 | STAMCOUNTER StatExitSti;
|
---|
837 | STAMCOUNTER StatExitPushf;
|
---|
838 | STAMCOUNTER StatExitPopf;
|
---|
839 | STAMCOUNTER StatExitIret;
|
---|
840 | STAMCOUNTER StatExitInt;
|
---|
841 | STAMCOUNTER StatExitCRxWrite[16];
|
---|
842 | STAMCOUNTER StatExitCRxRead[16];
|
---|
843 | STAMCOUNTER StatExitDRxWrite;
|
---|
844 | STAMCOUNTER StatExitDRxRead;
|
---|
845 | STAMCOUNTER StatExitRdmsr;
|
---|
846 | STAMCOUNTER StatExitWrmsr;
|
---|
847 | STAMCOUNTER StatExitClts;
|
---|
848 | STAMCOUNTER StatExitXdtrAccess;
|
---|
849 | STAMCOUNTER StatExitHlt;
|
---|
850 | STAMCOUNTER StatExitMwait;
|
---|
851 | STAMCOUNTER StatExitMonitor;
|
---|
852 | STAMCOUNTER StatExitLmsw;
|
---|
853 | STAMCOUNTER StatExitIOWrite;
|
---|
854 | STAMCOUNTER StatExitIORead;
|
---|
855 | STAMCOUNTER StatExitIOStringWrite;
|
---|
856 | STAMCOUNTER StatExitIOStringRead;
|
---|
857 | STAMCOUNTER StatExitIntWindow;
|
---|
858 | STAMCOUNTER StatExitMaxResume;
|
---|
859 | STAMCOUNTER StatExitPreemptPending;
|
---|
860 | STAMCOUNTER StatExitPreemptTimer;
|
---|
861 | STAMCOUNTER StatExitTprBelowThreshold;
|
---|
862 | STAMCOUNTER StatExitTaskSwitch;
|
---|
863 | STAMCOUNTER StatExitMtf;
|
---|
864 | STAMCOUNTER StatExitApicAccess;
|
---|
865 | STAMCOUNTER StatIntReinject;
|
---|
866 | STAMCOUNTER StatPendingHostIrq;
|
---|
867 |
|
---|
868 | STAMCOUNTER StatFlushPage;
|
---|
869 | STAMCOUNTER StatFlushPageManual;
|
---|
870 | STAMCOUNTER StatFlushPhysPageManual;
|
---|
871 | STAMCOUNTER StatFlushTlb;
|
---|
872 | STAMCOUNTER StatFlushTlbManual;
|
---|
873 | STAMCOUNTER StatFlushTlbWorldSwitch;
|
---|
874 | STAMCOUNTER StatNoFlushTlbWorldSwitch;
|
---|
875 | STAMCOUNTER StatFlushAsid;
|
---|
876 | STAMCOUNTER StatFlushNestedPaging;
|
---|
877 | STAMCOUNTER StatFlushTlbInvlpgVirt;
|
---|
878 | STAMCOUNTER StatFlushTlbInvlpgPhys;
|
---|
879 | STAMCOUNTER StatTlbShootdown;
|
---|
880 | STAMCOUNTER StatTlbShootdownFlush;
|
---|
881 |
|
---|
882 | STAMCOUNTER StatSwitchGuestIrq;
|
---|
883 | STAMCOUNTER StatSwitchHmToR3FF;
|
---|
884 | STAMCOUNTER StatSwitchToR3;
|
---|
885 |
|
---|
886 | STAMCOUNTER StatTscOffset;
|
---|
887 | STAMCOUNTER StatTscIntercept;
|
---|
888 | STAMCOUNTER StatTscInterceptOverFlow;
|
---|
889 |
|
---|
890 | STAMCOUNTER StatExitReasonNpf;
|
---|
891 | STAMCOUNTER StatDRxArmed;
|
---|
892 | STAMCOUNTER StatDRxContextSwitch;
|
---|
893 | STAMCOUNTER StatDRxIoCheck;
|
---|
894 |
|
---|
895 | STAMCOUNTER StatLoadMinimal;
|
---|
896 | STAMCOUNTER StatLoadFull;
|
---|
897 |
|
---|
898 | #if HC_ARCH_BITS == 32 && defined(VBOX_ENABLE_64_BITS_GUESTS) && !defined(VBOX_WITH_HYBRID_32BIT_KERNEL)
|
---|
899 | STAMCOUNTER StatFpu64SwitchBack;
|
---|
900 | STAMCOUNTER StatDebug64SwitchBack;
|
---|
901 | #endif
|
---|
902 |
|
---|
903 | #ifdef VBOX_WITH_STATISTICS
|
---|
904 | R3PTRTYPE(PSTAMCOUNTER) paStatExitReason;
|
---|
905 | R0PTRTYPE(PSTAMCOUNTER) paStatExitReasonR0;
|
---|
906 | R3PTRTYPE(PSTAMCOUNTER) paStatInjectedIrqs;
|
---|
907 | R0PTRTYPE(PSTAMCOUNTER) paStatInjectedIrqsR0;
|
---|
908 | #endif
|
---|
909 | } HMCPU;
|
---|
910 | /** Pointer to HM VM instance data. */
|
---|
911 | typedef HMCPU *PHMCPU;
|
---|
912 |
|
---|
913 |
|
---|
914 | #ifdef IN_RING0
|
---|
915 |
|
---|
916 | VMMR0DECL(PHMGLOBLCPUINFO) HMR0GetCurrentCpu(void);
|
---|
917 | VMMR0DECL(PHMGLOBLCPUINFO) HMR0GetCurrentCpuEx(RTCPUID idCpu);
|
---|
918 |
|
---|
919 |
|
---|
920 | #ifdef VBOX_STRICT
|
---|
921 | VMMR0DECL(void) HMDumpRegs(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
|
---|
922 | VMMR0DECL(void) HMR0DumpDescriptor(PCX86DESCHC pDesc, RTSEL Sel, const char *pszMsg);
|
---|
923 | #else
|
---|
924 | # define HMDumpRegs(a, b ,c) do { } while (0)
|
---|
925 | # define HMR0DumpDescriptor(a, b, c) do { } while (0)
|
---|
926 | #endif
|
---|
927 |
|
---|
928 | # ifdef VBOX_WITH_KERNEL_USING_XMM
|
---|
929 | DECLASM(int) hmR0VMXStartVMWrapXMM(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM, PVMCPU pVCpu, PFNHMVMXSTARTVM pfnStartVM);
|
---|
930 | DECLASM(int) hmR0SVMRunWrapXMM(RTHCPHYS pVMCBHostPhys, RTHCPHYS pVMCBPhys, PCPUMCTX pCtx, PVM pVM, PVMCPU pVCpu, PFNHMSVMVMRUN pfnVMRun);
|
---|
931 | # endif
|
---|
932 |
|
---|
933 | # ifdef VBOX_WITH_HYBRID_32BIT_KERNEL
|
---|
934 | /**
|
---|
935 | * Gets 64-bit GDTR and IDTR on darwin.
|
---|
936 | * @param pGdtr Where to store the 64-bit GDTR.
|
---|
937 | * @param pIdtr Where to store the 64-bit IDTR.
|
---|
938 | */
|
---|
939 | DECLASM(void) hmR0Get64bitGdtrAndIdtr(PX86XDTR64 pGdtr, PX86XDTR64 pIdtr);
|
---|
940 |
|
---|
941 | /**
|
---|
942 | * Gets 64-bit CR3 on darwin.
|
---|
943 | * @returns CR3
|
---|
944 | */
|
---|
945 | DECLASM(uint64_t) hmR0Get64bitCR3(void);
|
---|
946 | # endif
|
---|
947 |
|
---|
948 | #endif /* IN_RING0 */
|
---|
949 |
|
---|
950 | /** @} */
|
---|
951 |
|
---|
952 | RT_C_DECLS_END
|
---|
953 |
|
---|
954 | #endif
|
---|
955 |
|
---|