1 | /* $Id: HWACCMInternal.h 14649 2008-11-26 15:01:53Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * HWACCM - Internal header file.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
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 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | * additional information or have any questions.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef ___HWACCMInternal_h
|
---|
23 | #define ___HWACCMInternal_h
|
---|
24 |
|
---|
25 | #include <VBox/cdefs.h>
|
---|
26 | #include <VBox/types.h>
|
---|
27 | #include <VBox/em.h>
|
---|
28 | #include <VBox/stam.h>
|
---|
29 | #include <VBox/dis.h>
|
---|
30 | #include <VBox/hwaccm.h>
|
---|
31 | #include <VBox/pgm.h>
|
---|
32 | #include <VBox/cpum.h>
|
---|
33 | #include <iprt/memobj.h>
|
---|
34 | #include <iprt/cpuset.h>
|
---|
35 | #include <iprt/mp.h>
|
---|
36 |
|
---|
37 | #if HC_ARCH_BITS == 64
|
---|
38 | /* Enable 64 bits guest support. */
|
---|
39 | # define VBOX_ENABLE_64_BITS_GUESTS
|
---|
40 | #endif
|
---|
41 |
|
---|
42 | #define HWACCM_VMX_EMULATE_REALMODE
|
---|
43 | #define HWACCM_VTX_WITH_EPT
|
---|
44 | #define HWACCM_VTX_WITH_VPID
|
---|
45 |
|
---|
46 | __BEGIN_DECLS
|
---|
47 |
|
---|
48 |
|
---|
49 | /** @defgroup grp_hwaccm_int Internal
|
---|
50 | * @ingroup grp_hwaccm
|
---|
51 | * @internal
|
---|
52 | * @{
|
---|
53 | */
|
---|
54 |
|
---|
55 |
|
---|
56 | /** Maximum number of exit reason statistics counters. */
|
---|
57 | #define MAX_EXITREASON_STAT 0x100
|
---|
58 | #define MASK_EXITREASON_STAT 0xff
|
---|
59 |
|
---|
60 | /** @name Changed flags
|
---|
61 | * These flags are used to keep track of which important registers that
|
---|
62 | * have been changed since last they were reset.
|
---|
63 | * @{
|
---|
64 | */
|
---|
65 | #define HWACCM_CHANGED_GUEST_FPU RT_BIT(0)
|
---|
66 | #define HWACCM_CHANGED_GUEST_CR0 RT_BIT(1)
|
---|
67 | #define HWACCM_CHANGED_GUEST_CR3 RT_BIT(2)
|
---|
68 | #define HWACCM_CHANGED_GUEST_CR4 RT_BIT(3)
|
---|
69 | #define HWACCM_CHANGED_GUEST_GDTR RT_BIT(4)
|
---|
70 | #define HWACCM_CHANGED_GUEST_IDTR RT_BIT(5)
|
---|
71 | #define HWACCM_CHANGED_GUEST_LDTR RT_BIT(6)
|
---|
72 | #define HWACCM_CHANGED_GUEST_TR RT_BIT(7)
|
---|
73 | #define HWACCM_CHANGED_GUEST_SYSENTER_MSR RT_BIT(8)
|
---|
74 | #define HWACCM_CHANGED_GUEST_SEGMENT_REGS RT_BIT(9)
|
---|
75 | #define HWACCM_CHANGED_GUEST_DEBUG RT_BIT(10)
|
---|
76 | #define HWACCM_CHANGED_HOST_CONTEXT RT_BIT(11)
|
---|
77 |
|
---|
78 | #define HWACCM_CHANGED_ALL ( HWACCM_CHANGED_GUEST_SEGMENT_REGS \
|
---|
79 | | HWACCM_CHANGED_GUEST_CR0 \
|
---|
80 | | HWACCM_CHANGED_GUEST_CR3 \
|
---|
81 | | HWACCM_CHANGED_GUEST_CR4 \
|
---|
82 | | HWACCM_CHANGED_GUEST_GDTR \
|
---|
83 | | HWACCM_CHANGED_GUEST_IDTR \
|
---|
84 | | HWACCM_CHANGED_GUEST_LDTR \
|
---|
85 | | HWACCM_CHANGED_GUEST_TR \
|
---|
86 | | HWACCM_CHANGED_GUEST_SYSENTER_MSR \
|
---|
87 | | HWACCM_CHANGED_GUEST_FPU \
|
---|
88 | | HWACCM_CHANGED_GUEST_DEBUG \
|
---|
89 | | HWACCM_CHANGED_HOST_CONTEXT)
|
---|
90 |
|
---|
91 | #define HWACCM_CHANGED_ALL_GUEST ( HWACCM_CHANGED_GUEST_SEGMENT_REGS \
|
---|
92 | | HWACCM_CHANGED_GUEST_CR0 \
|
---|
93 | | HWACCM_CHANGED_GUEST_CR3 \
|
---|
94 | | HWACCM_CHANGED_GUEST_CR4 \
|
---|
95 | | HWACCM_CHANGED_GUEST_GDTR \
|
---|
96 | | HWACCM_CHANGED_GUEST_IDTR \
|
---|
97 | | HWACCM_CHANGED_GUEST_LDTR \
|
---|
98 | | HWACCM_CHANGED_GUEST_TR \
|
---|
99 | | HWACCM_CHANGED_GUEST_SYSENTER_MSR \
|
---|
100 | | HWACCM_CHANGED_GUEST_DEBUG \
|
---|
101 | | HWACCM_CHANGED_GUEST_FPU)
|
---|
102 |
|
---|
103 | /** @} */
|
---|
104 |
|
---|
105 | /** @name Intercepted traps
|
---|
106 | * Traps that need to be intercepted so we can correctly dispatch them to the guest if required.
|
---|
107 | * Currently #NM and #PF only
|
---|
108 | */
|
---|
109 | #ifdef VBOX_STRICT
|
---|
110 | #define HWACCM_VMX_TRAP_MASK RT_BIT(X86_XCPT_DE) | RT_BIT(X86_XCPT_NM) | RT_BIT(X86_XCPT_PF) | RT_BIT(X86_XCPT_UD) | RT_BIT(X86_XCPT_NP) | RT_BIT(X86_XCPT_SS) | RT_BIT(X86_XCPT_GP) | RT_BIT(X86_XCPT_MF)
|
---|
111 | #define HWACCM_SVM_TRAP_MASK HWACCM_VMX_TRAP_MASK
|
---|
112 | #else
|
---|
113 | #define HWACCM_VMX_TRAP_MASK RT_BIT(X86_XCPT_NM) | RT_BIT(X86_XCPT_PF)
|
---|
114 | #define HWACCM_SVM_TRAP_MASK RT_BIT(X86_XCPT_NM) | RT_BIT(X86_XCPT_PF)
|
---|
115 | #endif
|
---|
116 | /* All exceptions have to be intercept in emulated real-mode (minues NM & PF as they are always intercepted. */
|
---|
117 | #define HWACCM_VMX_TRAP_MASK_REALMODE RT_BIT(X86_XCPT_DE) | RT_BIT(X86_XCPT_DB) | RT_BIT(X86_XCPT_NMI) | RT_BIT(X86_XCPT_BP) | RT_BIT(X86_XCPT_OF) | RT_BIT(X86_XCPT_BR) | RT_BIT(X86_XCPT_UD) | RT_BIT(X86_XCPT_DF) | RT_BIT(X86_XCPT_CO_SEG_OVERRUN) | RT_BIT(X86_XCPT_TS) | RT_BIT(X86_XCPT_NP) | RT_BIT(X86_XCPT_SS) | RT_BIT(X86_XCPT_GP) | RT_BIT(X86_XCPT_MF) | RT_BIT(X86_XCPT_AC) | RT_BIT(X86_XCPT_MC) | RT_BIT(X86_XCPT_XF)
|
---|
118 | /** @} */
|
---|
119 |
|
---|
120 |
|
---|
121 | /** Maxium resume loops allowed in ring 0 (safety precaution) */
|
---|
122 | #define HWACCM_MAX_RESUME_LOOPS 1024
|
---|
123 |
|
---|
124 | /** Size for the EPT identity page table (1024 4 MB pages to cover the entire address space). */
|
---|
125 | #define HWACCM_EPT_IDENTITY_PG_TABLE_SIZE PAGE_SIZE
|
---|
126 | /** Size of the TSS structure + 2 pages for the IO bitmap + end byte. */
|
---|
127 | #define HWACCM_VTX_TSS_SIZE (sizeof(VBOXTSS) + 2*PAGE_SIZE + 1)
|
---|
128 | /** Total guest mapped memory needed. */
|
---|
129 | #define HWACCM_VTX_TOTAL_DEVHEAP_MEM (HWACCM_EPT_IDENTITY_PG_TABLE_SIZE + HWACCM_VTX_TSS_SIZE)
|
---|
130 |
|
---|
131 | /** HWACCM SSM version
|
---|
132 | */
|
---|
133 | #define HWACCM_SSM_VERSION 3
|
---|
134 |
|
---|
135 | /* Per-cpu information. (host) */
|
---|
136 | typedef struct
|
---|
137 | {
|
---|
138 | RTCPUID idCpu;
|
---|
139 |
|
---|
140 | RTR0MEMOBJ pMemObj;
|
---|
141 | /* Current ASID (AMD-V)/VPID (Intel) */
|
---|
142 | uint32_t uCurrentASID;
|
---|
143 | /* TLB flush count */
|
---|
144 | uint32_t cTLBFlushes;
|
---|
145 |
|
---|
146 | /* Set the first time a cpu is used to make sure we start with a clean TLB. */
|
---|
147 | bool fFlushTLB;
|
---|
148 |
|
---|
149 | /** Configured for VT-x or AMD-V. */
|
---|
150 | bool fConfigured;
|
---|
151 |
|
---|
152 | /** In use by our code. (for power suspend) */
|
---|
153 | volatile bool fInUse;
|
---|
154 | } HWACCM_CPUINFO;
|
---|
155 | typedef HWACCM_CPUINFO *PHWACCM_CPUINFO;
|
---|
156 |
|
---|
157 | /* VT-x capability qword. */
|
---|
158 | typedef union
|
---|
159 | {
|
---|
160 | struct
|
---|
161 | {
|
---|
162 | uint32_t disallowed0;
|
---|
163 | uint32_t allowed1;
|
---|
164 | } n;
|
---|
165 | uint64_t u;
|
---|
166 | } VMX_CAPABILITY;
|
---|
167 |
|
---|
168 | /**
|
---|
169 | * HWACCM VM Instance data.
|
---|
170 | * Changes to this must checked against the padding of the cfgm union in VM!
|
---|
171 | */
|
---|
172 | typedef struct HWACCM
|
---|
173 | {
|
---|
174 | /** Set when we've initialized VMX or SVM. */
|
---|
175 | bool fInitialized;
|
---|
176 | /** Set when we're using VMX/SVN at that moment. */
|
---|
177 | bool fActive;
|
---|
178 |
|
---|
179 | /** Set when hardware acceleration is allowed. */
|
---|
180 | bool fAllowed;
|
---|
181 |
|
---|
182 | /** Set if nested paging is enabled. */
|
---|
183 | bool fNestedPaging;
|
---|
184 |
|
---|
185 | /** Set if nested paging is allowed. */
|
---|
186 | bool fAllowNestedPaging;
|
---|
187 |
|
---|
188 | /** Set if we're supposed to inject an NMI. */
|
---|
189 | bool fInjectNMI;
|
---|
190 |
|
---|
191 | /** Explicit alignment padding to make 32-bit gcc align u64RegisterMask
|
---|
192 | * naturally. */
|
---|
193 | bool padding[1];
|
---|
194 |
|
---|
195 | /** And mask for copying register contents. */
|
---|
196 | uint64_t u64RegisterMask;
|
---|
197 |
|
---|
198 | /** Maximum ASID allowed. */
|
---|
199 | RTUINT uMaxASID;
|
---|
200 |
|
---|
201 | #if HC_ARCH_BITS == 32
|
---|
202 | uint32_t Alignment0;
|
---|
203 | #endif
|
---|
204 |
|
---|
205 | struct
|
---|
206 | {
|
---|
207 | /** Set by the ring-0 driver to indicate VMX is supported by the CPU. */
|
---|
208 | bool fSupported;
|
---|
209 |
|
---|
210 | /** Set when we've enabled VMX. */
|
---|
211 | bool fEnabled;
|
---|
212 |
|
---|
213 | /** Set if VPID is supported. */
|
---|
214 | bool fVPID;
|
---|
215 |
|
---|
216 | /** Set if VT-x VPID is allowed. */
|
---|
217 | bool fAllowVPID;
|
---|
218 |
|
---|
219 | /** Virtual address of the TSS page used for real mode emulation. */
|
---|
220 | R3PTRTYPE(PVBOXTSS) pRealModeTSS;
|
---|
221 |
|
---|
222 | /** Virtual address of the identity page table used for real mode and protected mode without paging emulation in EPT mode. */
|
---|
223 | R3PTRTYPE(PX86PD) pNonPagingModeEPTPageTable;
|
---|
224 |
|
---|
225 | /** R0 memory object for the virtual APIC mmio cache. */
|
---|
226 | RTR0MEMOBJ pMemObjAPIC;
|
---|
227 | /** Physical address of the virtual APIC mmio cache. */
|
---|
228 | RTHCPHYS pAPICPhys;
|
---|
229 | /** Virtual address of the virtual APIC mmio cache. */
|
---|
230 | R0PTRTYPE(uint8_t *) pAPIC;
|
---|
231 |
|
---|
232 | /** R0 memory object for the MSR bitmap (1 page). */
|
---|
233 | RTR0MEMOBJ pMemObjMSRBitmap;
|
---|
234 | /** Physical address of the MSR bitmap (1 page). */
|
---|
235 | RTHCPHYS pMSRBitmapPhys;
|
---|
236 | /** Virtual address of the MSR bitmap (1 page). */
|
---|
237 | R0PTRTYPE(uint8_t *) pMSRBitmap;
|
---|
238 |
|
---|
239 | /** R0 memory object for the MSR entry load page (guest MSRs). */
|
---|
240 | RTR0MEMOBJ pMemObjMSREntryLoad;
|
---|
241 | /** Physical address of the MSR entry load page (guest MSRs). */
|
---|
242 | RTHCPHYS pMSREntryLoadPhys;
|
---|
243 | /** Virtual address of the MSR entry load page (guest MSRs). */
|
---|
244 | R0PTRTYPE(uint8_t *) pMSREntryLoad;
|
---|
245 |
|
---|
246 | /** R0 memory object for the MSR exit store page (guest MSRs). */
|
---|
247 | RTR0MEMOBJ pMemObjMSRExitStore;
|
---|
248 | /** Physical address of the MSR exit store page (guest MSRs). */
|
---|
249 | RTHCPHYS pMSRExitStorePhys;
|
---|
250 | /** Virtual address of the MSR exit store page (guest MSRs). */
|
---|
251 | R0PTRTYPE(uint8_t *) pMSRExitStore;
|
---|
252 |
|
---|
253 | /** R0 memory object for the MSR exit load page (host MSRs). */
|
---|
254 | RTR0MEMOBJ pMemObjMSRExitLoad;
|
---|
255 | /** Physical address of the MSR exit load page (host MSRs). */
|
---|
256 | RTHCPHYS pMSRExitLoadPhys;
|
---|
257 | /** Virtual address of the MSR exit load page (host MSRs). */
|
---|
258 | R0PTRTYPE(uint8_t *) pMSRExitLoad;
|
---|
259 |
|
---|
260 | /** Ring 0 handlers for VT-x. */
|
---|
261 | DECLR0CALLBACKMEMBER(void, pfnSetupTaggedTLB, (PVM pVM, PVMCPU pVCpu));
|
---|
262 |
|
---|
263 | /** Host CR4 value (set by ring-0 VMX init) */
|
---|
264 | uint64_t hostCR4;
|
---|
265 |
|
---|
266 | /** VMX MSR values */
|
---|
267 | struct
|
---|
268 | {
|
---|
269 | uint64_t feature_ctrl;
|
---|
270 | uint64_t vmx_basic_info;
|
---|
271 | VMX_CAPABILITY vmx_pin_ctls;
|
---|
272 | VMX_CAPABILITY vmx_proc_ctls;
|
---|
273 | VMX_CAPABILITY vmx_proc_ctls2;
|
---|
274 | VMX_CAPABILITY vmx_exit;
|
---|
275 | VMX_CAPABILITY vmx_entry;
|
---|
276 | uint64_t vmx_misc;
|
---|
277 | uint64_t vmx_cr0_fixed0;
|
---|
278 | uint64_t vmx_cr0_fixed1;
|
---|
279 | uint64_t vmx_cr4_fixed0;
|
---|
280 | uint64_t vmx_cr4_fixed1;
|
---|
281 | uint64_t vmx_vmcs_enum;
|
---|
282 | uint64_t vmx_eptcaps;
|
---|
283 | } msr;
|
---|
284 |
|
---|
285 | /** Flush types for invept & invvpid; they depend on capabilities. */
|
---|
286 | VMX_FLUSH enmFlushPage;
|
---|
287 | VMX_FLUSH enmFlushContext;
|
---|
288 | } vmx;
|
---|
289 |
|
---|
290 | struct
|
---|
291 | {
|
---|
292 | /** Set by the ring-0 driver to indicate SVM is supported by the CPU. */
|
---|
293 | bool fSupported;
|
---|
294 | /** Set when we've enabled SVM. */
|
---|
295 | bool fEnabled;
|
---|
296 | /** Set if erratum 170 affects the AMD cpu. */
|
---|
297 | bool fAlwaysFlushTLB;
|
---|
298 | /** Explicit alignment padding to make 32-bit gcc align u64RegisterMask
|
---|
299 | * naturally. */
|
---|
300 | bool padding[1];
|
---|
301 |
|
---|
302 | /** R0 memory object for the host VM control block (VMCB). */
|
---|
303 | RTR0MEMOBJ pMemObjVMCBHost;
|
---|
304 | /** Physical address of the host VM control block (VMCB). */
|
---|
305 | RTHCPHYS pVMCBHostPhys;
|
---|
306 | /** Virtual address of the host VM control block (VMCB). */
|
---|
307 | R0PTRTYPE(void *) pVMCBHost;
|
---|
308 |
|
---|
309 | /** R0 memory object for the IO bitmap (12kb). */
|
---|
310 | RTR0MEMOBJ pMemObjIOBitmap;
|
---|
311 | /** Physical address of the IO bitmap (12kb). */
|
---|
312 | RTHCPHYS pIOBitmapPhys;
|
---|
313 | /** Virtual address of the IO bitmap. */
|
---|
314 | R0PTRTYPE(void *) pIOBitmap;
|
---|
315 |
|
---|
316 | /** R0 memory object for the MSR bitmap (8kb). */
|
---|
317 | RTR0MEMOBJ pMemObjMSRBitmap;
|
---|
318 | /** Physical address of the MSR bitmap (8kb). */
|
---|
319 | RTHCPHYS pMSRBitmapPhys;
|
---|
320 | /** Virtual address of the MSR bitmap. */
|
---|
321 | R0PTRTYPE(void *) pMSRBitmap;
|
---|
322 |
|
---|
323 | /** SVM revision. */
|
---|
324 | uint32_t u32Rev;
|
---|
325 |
|
---|
326 | /** SVM feature bits from cpuid 0x8000000a */
|
---|
327 | uint32_t u32Features;
|
---|
328 | } svm;
|
---|
329 |
|
---|
330 | struct
|
---|
331 | {
|
---|
332 | uint32_t u32AMDFeatureECX;
|
---|
333 | uint32_t u32AMDFeatureEDX;
|
---|
334 | } cpuid;
|
---|
335 |
|
---|
336 | /** Saved error from detection */
|
---|
337 | int32_t lLastError;
|
---|
338 |
|
---|
339 | /** HWACCMR0Init was run */
|
---|
340 | bool fHWACCMR0Init;
|
---|
341 | } HWACCM;
|
---|
342 | /** Pointer to HWACCM VM instance data. */
|
---|
343 | typedef HWACCM *PHWACCM;
|
---|
344 |
|
---|
345 | /**
|
---|
346 | * HWACCM VMCPU Instance data.
|
---|
347 | */
|
---|
348 | typedef struct HWACCMCPU
|
---|
349 | {
|
---|
350 | /** Old style FPU reporting trap mask override performed (optimization) */
|
---|
351 | bool fFPUOldStyleOverride;
|
---|
352 |
|
---|
353 | /** Set if we don't have to flush the TLB on VM entry. */
|
---|
354 | bool fResumeVM;
|
---|
355 |
|
---|
356 | /** Set if we need to flush the TLB during the world switch. */
|
---|
357 | bool fForceTLBFlush;
|
---|
358 |
|
---|
359 | /** Explicit alignment padding to make 32-bit gcc align u64RegisterMask
|
---|
360 | * naturally. */
|
---|
361 | bool padding[1];
|
---|
362 |
|
---|
363 | /** HWACCM_CHANGED_* flags. */
|
---|
364 | RTUINT fContextUseFlags;
|
---|
365 |
|
---|
366 | /* Id of the last cpu we were executing code on (NIL_RTCPUID for the first time) */
|
---|
367 | RTCPUID idLastCpu;
|
---|
368 |
|
---|
369 | /* TLB flush count */
|
---|
370 | RTUINT cTLBFlushes;
|
---|
371 |
|
---|
372 | /* Current ASID in use by the VM */
|
---|
373 | RTUINT uCurrentASID;
|
---|
374 |
|
---|
375 | struct
|
---|
376 | {
|
---|
377 | /** R0 memory object for the VM control structure (VMCS). */
|
---|
378 | RTR0MEMOBJ pMemObjVMCS;
|
---|
379 | /** Physical address of the VM control structure (VMCS). */
|
---|
380 | RTHCPHYS pVMCSPhys;
|
---|
381 | /** Virtual address of the VM control structure (VMCS). */
|
---|
382 | R0PTRTYPE(void *) pVMCS;
|
---|
383 |
|
---|
384 | /** Ring 0 handlers for VT-x. */
|
---|
385 | DECLR0CALLBACKMEMBER(int, pfnStartVM,(RTHCUINT fResume, PCPUMCTX pCtx));
|
---|
386 |
|
---|
387 | /** Current VMX_VMCS_CTRL_PROC_EXEC_CONTROLS. */
|
---|
388 | uint64_t proc_ctls;
|
---|
389 |
|
---|
390 | /** Current CR0 mask. */
|
---|
391 | uint64_t cr0_mask;
|
---|
392 | /** Current CR4 mask. */
|
---|
393 | uint64_t cr4_mask;
|
---|
394 |
|
---|
395 | /** Current EPTP. */
|
---|
396 | RTHCPHYS GCPhysEPTP;
|
---|
397 |
|
---|
398 | /** Real-mode emulation state. */
|
---|
399 | struct
|
---|
400 | {
|
---|
401 | X86EFLAGS eflags;
|
---|
402 | uint32_t fValid;
|
---|
403 | } RealMode;
|
---|
404 |
|
---|
405 | struct
|
---|
406 | {
|
---|
407 | uint64_t u64VMCSPhys;
|
---|
408 | uint32_t ulVMCSRevision;
|
---|
409 | uint32_t ulInstrError;
|
---|
410 | uint32_t ulExitReason;
|
---|
411 | RTCPUID idEnteredCpu;
|
---|
412 | RTCPUID idCurrentCpu;
|
---|
413 | uint32_t padding;
|
---|
414 | } lasterror;
|
---|
415 |
|
---|
416 | /** The last known guest paging mode. */
|
---|
417 | PGMMODE enmCurrGuestMode;
|
---|
418 | } vmx;
|
---|
419 |
|
---|
420 | struct
|
---|
421 | {
|
---|
422 | /** R0 memory object for the VM control block (VMCB). */
|
---|
423 | RTR0MEMOBJ pMemObjVMCB;
|
---|
424 | /** Physical address of the VM control block (VMCB). */
|
---|
425 | RTHCPHYS pVMCBPhys;
|
---|
426 | /** Virtual address of the VM control block (VMCB). */
|
---|
427 | R0PTRTYPE(void *) pVMCB;
|
---|
428 |
|
---|
429 | /** Ring 0 handlers for VT-x. */
|
---|
430 | DECLR0CALLBACKMEMBER(int, pfnVMRun,(RTHCPHYS pVMCBHostPhys, RTHCPHYS pVMCBPhys, PCPUMCTX pCtx));
|
---|
431 |
|
---|
432 | } svm;
|
---|
433 |
|
---|
434 | /** Event injection state. */
|
---|
435 | struct
|
---|
436 | {
|
---|
437 | uint32_t fPending;
|
---|
438 | uint32_t errCode;
|
---|
439 | uint64_t intInfo;
|
---|
440 | } Event;
|
---|
441 |
|
---|
442 | /** Currenty shadow paging mode. */
|
---|
443 | PGMMODE enmShadowMode;
|
---|
444 |
|
---|
445 | /** The CPU ID of the CPU currently owning the VMCS. Set in
|
---|
446 | * HWACCMR0Enter and cleared in HWACCMR0Leave. */
|
---|
447 | RTCPUID idEnteredCpu;
|
---|
448 |
|
---|
449 | STAMPROFILEADV StatEntry;
|
---|
450 | STAMPROFILEADV StatExit;
|
---|
451 | STAMPROFILEADV StatInGC;
|
---|
452 |
|
---|
453 | STAMCOUNTER StatIntInject;
|
---|
454 |
|
---|
455 | STAMCOUNTER StatExitShadowNM;
|
---|
456 | STAMCOUNTER StatExitGuestNM;
|
---|
457 | STAMCOUNTER StatExitShadowPF;
|
---|
458 | STAMCOUNTER StatExitGuestPF;
|
---|
459 | STAMCOUNTER StatExitGuestUD;
|
---|
460 | STAMCOUNTER StatExitGuestSS;
|
---|
461 | STAMCOUNTER StatExitGuestNP;
|
---|
462 | STAMCOUNTER StatExitGuestGP;
|
---|
463 | STAMCOUNTER StatExitGuestDE;
|
---|
464 | STAMCOUNTER StatExitGuestDB;
|
---|
465 | STAMCOUNTER StatExitGuestMF;
|
---|
466 | STAMCOUNTER StatExitInvpg;
|
---|
467 | STAMCOUNTER StatExitInvd;
|
---|
468 | STAMCOUNTER StatExitCpuid;
|
---|
469 | STAMCOUNTER StatExitRdtsc;
|
---|
470 | STAMCOUNTER StatExitCRxWrite;
|
---|
471 | STAMCOUNTER StatExitCRxRead;
|
---|
472 | STAMCOUNTER StatExitDRxWrite;
|
---|
473 | STAMCOUNTER StatExitDRxRead;
|
---|
474 | STAMCOUNTER StatExitCLTS;
|
---|
475 | STAMCOUNTER StatExitLMSW;
|
---|
476 | STAMCOUNTER StatExitIOWrite;
|
---|
477 | STAMCOUNTER StatExitIORead;
|
---|
478 | STAMCOUNTER StatExitIOStringWrite;
|
---|
479 | STAMCOUNTER StatExitIOStringRead;
|
---|
480 | STAMCOUNTER StatExitIrqWindow;
|
---|
481 | STAMCOUNTER StatExitMaxResume;
|
---|
482 | STAMCOUNTER StatIntReinject;
|
---|
483 | STAMCOUNTER StatPendingHostIrq;
|
---|
484 |
|
---|
485 | STAMCOUNTER StatFlushPageManual;
|
---|
486 | STAMCOUNTER StatFlushPhysPageManual;
|
---|
487 | STAMCOUNTER StatFlushTLBManual;
|
---|
488 | STAMCOUNTER StatFlushPageInvlpg;
|
---|
489 | STAMCOUNTER StatFlushTLBWorldSwitch;
|
---|
490 | STAMCOUNTER StatNoFlushTLBWorldSwitch;
|
---|
491 | STAMCOUNTER StatFlushTLBCRxChange;
|
---|
492 | STAMCOUNTER StatFlushASID;
|
---|
493 | STAMCOUNTER StatFlushTLBInvlpga;
|
---|
494 |
|
---|
495 | STAMCOUNTER StatSwitchGuestIrq;
|
---|
496 | STAMCOUNTER StatSwitchToR3;
|
---|
497 |
|
---|
498 | STAMCOUNTER StatTSCOffset;
|
---|
499 | STAMCOUNTER StatTSCIntercept;
|
---|
500 |
|
---|
501 | STAMCOUNTER StatExitReasonNPF;
|
---|
502 | STAMCOUNTER StatDRxArmed;
|
---|
503 | STAMCOUNTER StatDRxContextSwitch;
|
---|
504 | STAMCOUNTER StatDRxIOCheck;
|
---|
505 |
|
---|
506 |
|
---|
507 | R3PTRTYPE(PSTAMCOUNTER) paStatExitReason;
|
---|
508 | R0PTRTYPE(PSTAMCOUNTER) paStatExitReasonR0;
|
---|
509 | } HWACCMCPU;
|
---|
510 | /** Pointer to HWACCM VM instance data. */
|
---|
511 | typedef HWACCMCPU *PHWACCMCPU;
|
---|
512 |
|
---|
513 |
|
---|
514 | #ifdef IN_RING0
|
---|
515 |
|
---|
516 | VMMR0DECL(PHWACCM_CPUINFO) HWACCMR0GetCurrentCpu();
|
---|
517 |
|
---|
518 |
|
---|
519 | #ifdef VBOX_STRICT
|
---|
520 | VMMR0DECL(void) HWACCMDumpRegs(PVM pVM, PCPUMCTX pCtx);
|
---|
521 | VMMR0DECL(void) HWACCMR0DumpDescriptor(PX86DESCHC Desc, RTSEL Sel, const char *pszMsg);
|
---|
522 | #else
|
---|
523 | #define HWACCMDumpRegs(a, b) do { } while (0)
|
---|
524 | #define HWACCMR0DumpDescriptor(a, b, c) do { } while (0)
|
---|
525 | #endif
|
---|
526 |
|
---|
527 | /* Dummy callback handlers. */
|
---|
528 | VMMR0DECL(int) HWACCMR0DummyEnter(PVM pVM, PVMCPU pVCpu, PHWACCM_CPUINFO pCpu);
|
---|
529 | VMMR0DECL(int) HWACCMR0DummyLeave(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
|
---|
530 | VMMR0DECL(int) HWACCMR0DummyEnableCpu(PHWACCM_CPUINFO pCpu, PVM pVM, void *pvPageCpu, RTHCPHYS pPageCpuPhys);
|
---|
531 | VMMR0DECL(int) HWACCMR0DummyDisableCpu(PHWACCM_CPUINFO pCpu, void *pvPageCpu, RTHCPHYS pPageCpuPhys);
|
---|
532 | VMMR0DECL(int) HWACCMR0DummyInitVM(PVM pVM);
|
---|
533 | VMMR0DECL(int) HWACCMR0DummyTermVM(PVM pVM);
|
---|
534 | VMMR0DECL(int) HWACCMR0DummySetupVM(PVM pVM);
|
---|
535 | VMMR0DECL(int) HWACCMR0DummyRunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
|
---|
536 | VMMR0DECL(int) HWACCMR0DummySaveHostState(PVM pVM, PVMCPU pVCpu);
|
---|
537 | VMMR0DECL(int) HWACCMR0DummyLoadGuestState(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
|
---|
538 |
|
---|
539 | #endif /* IN_RING0 */
|
---|
540 |
|
---|
541 | /** @} */
|
---|
542 |
|
---|
543 | __END_DECLS
|
---|
544 |
|
---|
545 | #endif
|
---|
546 |
|
---|