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