1 | /* $Id: VMM.cpp 14683 2008-11-27 02:09:19Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VMM - The Virtual Machine Monitor Core.
|
---|
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 | //#define NO_SUPCALLR0VMM
|
---|
23 |
|
---|
24 | /** @page pg_vmm VMM - The Virtual Machine Monitor
|
---|
25 | *
|
---|
26 | * The VMM component is two things at the moment, it's a component doing a few
|
---|
27 | * management and routing tasks, and it's the whole virtual machine monitor
|
---|
28 | * thing. For hysterical reasons, it is not doing all the management that one
|
---|
29 | * would expect, this is instead done by @ref pg_vm. We'll address this
|
---|
30 | * misdesign eventually.
|
---|
31 | *
|
---|
32 | * @see grp_vmm, grp_vm
|
---|
33 | *
|
---|
34 | *
|
---|
35 | * @section sec_vmmstate VMM State
|
---|
36 | *
|
---|
37 | * @image html VM_Statechart_Diagram.gif
|
---|
38 | *
|
---|
39 | * To be written.
|
---|
40 | *
|
---|
41 | *
|
---|
42 | * @subsection subsec_vmm_init VMM Initialization
|
---|
43 | *
|
---|
44 | * To be written.
|
---|
45 | *
|
---|
46 | *
|
---|
47 | * @subsection subsec_vmm_term VMM Termination
|
---|
48 | *
|
---|
49 | * To be written.
|
---|
50 | *
|
---|
51 | */
|
---|
52 |
|
---|
53 | /*******************************************************************************
|
---|
54 | * Header Files *
|
---|
55 | *******************************************************************************/
|
---|
56 | #define LOG_GROUP LOG_GROUP_VMM
|
---|
57 | #include <VBox/vmm.h>
|
---|
58 | #include <VBox/vmapi.h>
|
---|
59 | #include <VBox/pgm.h>
|
---|
60 | #include <VBox/cfgm.h>
|
---|
61 | #include <VBox/pdmqueue.h>
|
---|
62 | #include <VBox/pdmapi.h>
|
---|
63 | #include <VBox/cpum.h>
|
---|
64 | #include <VBox/mm.h>
|
---|
65 | #include <VBox/iom.h>
|
---|
66 | #include <VBox/trpm.h>
|
---|
67 | #include <VBox/selm.h>
|
---|
68 | #include <VBox/em.h>
|
---|
69 | #include <VBox/sup.h>
|
---|
70 | #include <VBox/dbgf.h>
|
---|
71 | #include <VBox/csam.h>
|
---|
72 | #include <VBox/patm.h>
|
---|
73 | #include <VBox/rem.h>
|
---|
74 | #include <VBox/ssm.h>
|
---|
75 | #include <VBox/tm.h>
|
---|
76 | #include "VMMInternal.h"
|
---|
77 | #include "VMMSwitcher/VMMSwitcher.h"
|
---|
78 | #include <VBox/vm.h>
|
---|
79 |
|
---|
80 | #include <VBox/err.h>
|
---|
81 | #include <VBox/param.h>
|
---|
82 | #include <VBox/version.h>
|
---|
83 | #include <VBox/x86.h>
|
---|
84 | #include <VBox/hwaccm.h>
|
---|
85 | #include <iprt/assert.h>
|
---|
86 | #include <iprt/alloc.h>
|
---|
87 | #include <iprt/asm.h>
|
---|
88 | #include <iprt/time.h>
|
---|
89 | #include <iprt/stream.h>
|
---|
90 | #include <iprt/string.h>
|
---|
91 | #include <iprt/stdarg.h>
|
---|
92 | #include <iprt/ctype.h>
|
---|
93 |
|
---|
94 |
|
---|
95 |
|
---|
96 | /** The saved state version. */
|
---|
97 | #define VMM_SAVED_STATE_VERSION 3
|
---|
98 |
|
---|
99 |
|
---|
100 | /*******************************************************************************
|
---|
101 | * Internal Functions *
|
---|
102 | *******************************************************************************/
|
---|
103 | static int vmmR3InitStacks(PVM pVM);
|
---|
104 | static int vmmR3InitLoggers(PVM pVM);
|
---|
105 | static void vmmR3InitRegisterStats(PVM pVM);
|
---|
106 | static DECLCALLBACK(int) vmmR3Save(PVM pVM, PSSMHANDLE pSSM);
|
---|
107 | static DECLCALLBACK(int) vmmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version);
|
---|
108 | static DECLCALLBACK(void) vmmR3YieldEMT(PVM pVM, PTMTIMER pTimer, void *pvUser);
|
---|
109 | static int vmmR3ServiceCallHostRequest(PVM pVM);
|
---|
110 | static DECLCALLBACK(void) vmmR3InfoFF(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
|
---|
111 |
|
---|
112 |
|
---|
113 | /**
|
---|
114 | * Initializes the VMM.
|
---|
115 | *
|
---|
116 | * @returns VBox status code.
|
---|
117 | * @param pVM The VM to operate on.
|
---|
118 | */
|
---|
119 | VMMR3DECL(int) VMMR3Init(PVM pVM)
|
---|
120 | {
|
---|
121 | LogFlow(("VMMR3Init\n"));
|
---|
122 |
|
---|
123 | /*
|
---|
124 | * Assert alignment, sizes and order.
|
---|
125 | */
|
---|
126 | AssertMsg(pVM->vmm.s.offVM == 0, ("Already initialized!\n"));
|
---|
127 | AssertMsg(sizeof(pVM->vmm.padding) >= sizeof(pVM->vmm.s),
|
---|
128 | ("pVM->vmm.padding is too small! vmm.padding %d while vmm.s is %d\n",
|
---|
129 | sizeof(pVM->vmm.padding), sizeof(pVM->vmm.s)));
|
---|
130 |
|
---|
131 | /*
|
---|
132 | * Init basic VM VMM members.
|
---|
133 | */
|
---|
134 | pVM->vmm.s.offVM = RT_OFFSETOF(VM, vmm);
|
---|
135 | int rc = CFGMR3QueryU32(CFGMR3GetRoot(pVM), "YieldEMTInterval", &pVM->vmm.s.cYieldEveryMillies);
|
---|
136 | if (rc == VERR_CFGM_VALUE_NOT_FOUND)
|
---|
137 | pVM->vmm.s.cYieldEveryMillies = 23; /* Value arrived at after experimenting with the grub boot prompt. */
|
---|
138 | //pVM->vmm.s.cYieldEveryMillies = 8; //debugging
|
---|
139 | else
|
---|
140 | AssertMsgRCReturn(rc, ("Configuration error. Failed to query \"YieldEMTInterval\", rc=%Rrc\n", rc), rc);
|
---|
141 |
|
---|
142 | /* GC switchers are enabled by default. Turned off by HWACCM. */
|
---|
143 | pVM->vmm.s.fSwitcherDisabled = false;
|
---|
144 |
|
---|
145 | /*
|
---|
146 | * Register the saved state data unit.
|
---|
147 | */
|
---|
148 | rc = SSMR3RegisterInternal(pVM, "vmm", 1, VMM_SAVED_STATE_VERSION, VMM_STACK_SIZE + sizeof(RTGCPTR),
|
---|
149 | NULL, vmmR3Save, NULL,
|
---|
150 | NULL, vmmR3Load, NULL);
|
---|
151 | if (RT_FAILURE(rc))
|
---|
152 | return rc;
|
---|
153 |
|
---|
154 | /*
|
---|
155 | * Register the Ring-0 VM handle with the session for fast ioctl calls.
|
---|
156 | */
|
---|
157 | rc = SUPSetVMForFastIOCtl(pVM->pVMR0);
|
---|
158 | if (RT_FAILURE(rc))
|
---|
159 | return rc;
|
---|
160 |
|
---|
161 | /*
|
---|
162 | * Init various sub-components.
|
---|
163 | */
|
---|
164 | rc = vmmR3SwitcherInit(pVM);
|
---|
165 | if (RT_SUCCESS(rc))
|
---|
166 | {
|
---|
167 | rc = vmmR3InitStacks(pVM);
|
---|
168 | if (RT_SUCCESS(rc))
|
---|
169 | {
|
---|
170 | rc = vmmR3InitLoggers(pVM);
|
---|
171 |
|
---|
172 | #ifdef VBOX_WITH_NMI
|
---|
173 | /*
|
---|
174 | * Allocate mapping for the host APIC.
|
---|
175 | */
|
---|
176 | if (RT_SUCCESS(rc))
|
---|
177 | {
|
---|
178 | rc = MMR3HyperReserve(pVM, PAGE_SIZE, "Host APIC", &pVM->vmm.s.GCPtrApicBase);
|
---|
179 | AssertRC(rc);
|
---|
180 | }
|
---|
181 | #endif
|
---|
182 | if (RT_SUCCESS(rc))
|
---|
183 | {
|
---|
184 | rc = RTCritSectInit(&pVM->vmm.s.CritSectVMLock);
|
---|
185 | if (RT_SUCCESS(rc))
|
---|
186 | {
|
---|
187 | /*
|
---|
188 | * Debug info and statistics.
|
---|
189 | */
|
---|
190 | DBGFR3InfoRegisterInternal(pVM, "ff", "Displays the current Forced actions Flags.", vmmR3InfoFF);
|
---|
191 | vmmR3InitRegisterStats(pVM);
|
---|
192 |
|
---|
193 | return VINF_SUCCESS;
|
---|
194 | }
|
---|
195 | }
|
---|
196 | }
|
---|
197 | /** @todo: Need failure cleanup. */
|
---|
198 |
|
---|
199 | //more todo in here?
|
---|
200 | //if (RT_SUCCESS(rc))
|
---|
201 | //{
|
---|
202 | //}
|
---|
203 | //int rc2 = vmmR3TermCoreCode(pVM);
|
---|
204 | //AssertRC(rc2));
|
---|
205 | }
|
---|
206 |
|
---|
207 | return rc;
|
---|
208 | }
|
---|
209 |
|
---|
210 |
|
---|
211 | /**
|
---|
212 | * Allocate & setup the VMM RC stack(s) (for EMTs).
|
---|
213 | *
|
---|
214 | * The stacks are also used for long jumps in Ring-0.
|
---|
215 | *
|
---|
216 | * @returns VBox status code.
|
---|
217 | * @param pVM Pointer to the shared VM structure.
|
---|
218 | *
|
---|
219 | * @remarks The optional guard page gets it protection setup up during R3 init
|
---|
220 | * completion because of init order issues.
|
---|
221 | */
|
---|
222 | static int vmmR3InitStacks(PVM pVM)
|
---|
223 | {
|
---|
224 | /** @todo SMP: On stack per vCPU. */
|
---|
225 | #ifdef VBOX_STRICT_VMM_STACK
|
---|
226 | int rc = MMHyperAlloc(pVM, VMM_STACK_SIZE + PAGE_SIZE + PAGE_SIZE, PAGE_SIZE, MM_TAG_VMM, (void **)&pVM->vmm.s.pbEMTStackR3);
|
---|
227 | #else
|
---|
228 | int rc = MMHyperAlloc(pVM, VMM_STACK_SIZE, PAGE_SIZE, MM_TAG_VMM, (void **)&pVM->vmm.s.pbEMTStackR3);
|
---|
229 | #endif
|
---|
230 | if (RT_SUCCESS(rc))
|
---|
231 | {
|
---|
232 | #ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
|
---|
233 | /* MMHyperR3ToR0 returns R3 when not doing hardware assisted virtualization. */
|
---|
234 | if (!VMMIsHwVirtExtForced(pVM))
|
---|
235 | pVM->vmm.s.CallHostR0JmpBuf.pvSavedStack = NIL_RTR0PTR;
|
---|
236 | else
|
---|
237 | #endif
|
---|
238 | pVM->vmm.s.CallHostR0JmpBuf.pvSavedStack = MMHyperR3ToR0(pVM, pVM->vmm.s.pbEMTStackR3);
|
---|
239 | pVM->vmm.s.pbEMTStackRC = MMHyperR3ToRC(pVM, pVM->vmm.s.pbEMTStackR3);
|
---|
240 | pVM->vmm.s.pbEMTStackBottomRC = pVM->vmm.s.pbEMTStackRC + VMM_STACK_SIZE;
|
---|
241 | AssertRelease(pVM->vmm.s.pbEMTStackRC);
|
---|
242 |
|
---|
243 | CPUMSetHyperESP(pVM, pVM->vmm.s.pbEMTStackBottomRC);
|
---|
244 | }
|
---|
245 |
|
---|
246 | return rc;
|
---|
247 | }
|
---|
248 |
|
---|
249 |
|
---|
250 | /**
|
---|
251 | * Initialize the loggers.
|
---|
252 | *
|
---|
253 | * @returns VBox status code.
|
---|
254 | * @param pVM Pointer to the shared VM structure.
|
---|
255 | */
|
---|
256 | static int vmmR3InitLoggers(PVM pVM)
|
---|
257 | {
|
---|
258 | int rc;
|
---|
259 |
|
---|
260 | /*
|
---|
261 | * Allocate RC & R0 Logger instances (they are finalized in the relocator).
|
---|
262 | */
|
---|
263 | #ifdef LOG_ENABLED
|
---|
264 | PRTLOGGER pLogger = RTLogDefaultInstance();
|
---|
265 | if (pLogger)
|
---|
266 | {
|
---|
267 | pVM->vmm.s.cbRCLogger = RT_OFFSETOF(RTLOGGERRC, afGroups[pLogger->cGroups]);
|
---|
268 | rc = MMHyperAlloc(pVM, pVM->vmm.s.cbRCLogger, 0, MM_TAG_VMM, (void **)&pVM->vmm.s.pRCLoggerR3);
|
---|
269 | if (RT_FAILURE(rc))
|
---|
270 | return rc;
|
---|
271 | pVM->vmm.s.pRCLoggerRC = MMHyperR3ToRC(pVM, pVM->vmm.s.pRCLoggerR3);
|
---|
272 |
|
---|
273 | # ifdef VBOX_WITH_R0_LOGGING
|
---|
274 | rc = MMHyperAlloc(pVM, RT_OFFSETOF(VMMR0LOGGER, Logger.afGroups[pLogger->cGroups]),
|
---|
275 | 0, MM_TAG_VMM, (void **)&pVM->vmm.s.pR0LoggerR3);
|
---|
276 | if (RT_FAILURE(rc))
|
---|
277 | return rc;
|
---|
278 | pVM->vmm.s.pR0LoggerR3->pVM = pVM->pVMR0;
|
---|
279 | //pVM->vmm.s.pR0LoggerR3->fCreated = false;
|
---|
280 | pVM->vmm.s.pR0LoggerR3->cbLogger = RT_OFFSETOF(RTLOGGER, afGroups[pLogger->cGroups]);
|
---|
281 | pVM->vmm.s.pR0LoggerR0 = MMHyperR3ToR0(pVM, pVM->vmm.s.pR0LoggerR3);
|
---|
282 | # endif
|
---|
283 | }
|
---|
284 | #endif /* LOG_ENABLED */
|
---|
285 |
|
---|
286 | #ifdef VBOX_WITH_RC_RELEASE_LOGGING
|
---|
287 | /*
|
---|
288 | * Allocate RC release logger instances (finalized in the relocator).
|
---|
289 | */
|
---|
290 | PRTLOGGER pRelLogger = RTLogRelDefaultInstance();
|
---|
291 | if (pRelLogger)
|
---|
292 | {
|
---|
293 | pVM->vmm.s.cbRCRelLogger = RT_OFFSETOF(RTLOGGERRC, afGroups[pRelLogger->cGroups]);
|
---|
294 | rc = MMHyperAlloc(pVM, pVM->vmm.s.cbRCRelLogger, 0, MM_TAG_VMM, (void **)&pVM->vmm.s.pRCRelLoggerR3);
|
---|
295 | if (RT_FAILURE(rc))
|
---|
296 | return rc;
|
---|
297 | pVM->vmm.s.pRCRelLoggerRC = MMHyperR3ToRC(pVM, pVM->vmm.s.pRCRelLoggerR3);
|
---|
298 | }
|
---|
299 | #endif /* VBOX_WITH_RC_RELEASE_LOGGING */
|
---|
300 | return VINF_SUCCESS;
|
---|
301 | }
|
---|
302 |
|
---|
303 |
|
---|
304 | /**
|
---|
305 | * VMMR3Init worker that register the statistics with STAM.
|
---|
306 | *
|
---|
307 | * @param pVM The shared VM structure.
|
---|
308 | */
|
---|
309 | static void vmmR3InitRegisterStats(PVM pVM)
|
---|
310 | {
|
---|
311 | /*
|
---|
312 | * Statistics.
|
---|
313 | */
|
---|
314 | STAM_REG(pVM, &pVM->vmm.s.StatRunRC, STAMTYPE_COUNTER, "/VMM/RunRC", STAMUNIT_OCCURENCES, "Number of context switches.");
|
---|
315 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetNormal, STAMTYPE_COUNTER, "/VMM/RZRet/Normal", STAMUNIT_OCCURENCES, "Number of VINF_SUCCESS returns.");
|
---|
316 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetInterrupt, STAMTYPE_COUNTER, "/VMM/RZRet/Interrupt", STAMUNIT_OCCURENCES, "Number of VINF_EM_RAW_INTERRUPT returns.");
|
---|
317 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetInterruptHyper, STAMTYPE_COUNTER, "/VMM/RZRet/InterruptHyper", STAMUNIT_OCCURENCES, "Number of VINF_EM_RAW_INTERRUPT_HYPER returns.");
|
---|
318 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetGuestTrap, STAMTYPE_COUNTER, "/VMM/RZRet/GuestTrap", STAMUNIT_OCCURENCES, "Number of VINF_EM_RAW_GUEST_TRAP returns.");
|
---|
319 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetRingSwitch, STAMTYPE_COUNTER, "/VMM/RZRet/RingSwitch", STAMUNIT_OCCURENCES, "Number of VINF_EM_RAW_RING_SWITCH returns.");
|
---|
320 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetRingSwitchInt, STAMTYPE_COUNTER, "/VMM/RZRet/RingSwitchInt", STAMUNIT_OCCURENCES, "Number of VINF_EM_RAW_RING_SWITCH_INT returns.");
|
---|
321 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetExceptionPrivilege, STAMTYPE_COUNTER, "/VMM/RZRet/ExceptionPrivilege", STAMUNIT_OCCURENCES, "Number of VINF_EM_RAW_EXCEPTION_PRIVILEGED returns.");
|
---|
322 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetStaleSelector, STAMTYPE_COUNTER, "/VMM/RZRet/StaleSelector", STAMUNIT_OCCURENCES, "Number of VINF_EM_RAW_STALE_SELECTOR returns.");
|
---|
323 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetIRETTrap, STAMTYPE_COUNTER, "/VMM/RZRet/IRETTrap", STAMUNIT_OCCURENCES, "Number of VINF_EM_RAW_IRET_TRAP returns.");
|
---|
324 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetEmulate, STAMTYPE_COUNTER, "/VMM/RZRet/Emulate", STAMUNIT_OCCURENCES, "Number of VINF_EM_EXECUTE_INSTRUCTION returns.");
|
---|
325 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetPatchEmulate, STAMTYPE_COUNTER, "/VMM/RZRet/PatchEmulate", STAMUNIT_OCCURENCES, "Number of VINF_PATCH_EMULATE_INSTR returns.");
|
---|
326 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetIORead, STAMTYPE_COUNTER, "/VMM/RZRet/IORead", STAMUNIT_OCCURENCES, "Number of VINF_IOM_HC_IOPORT_READ returns.");
|
---|
327 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetIOWrite, STAMTYPE_COUNTER, "/VMM/RZRet/IOWrite", STAMUNIT_OCCURENCES, "Number of VINF_IOM_HC_IOPORT_WRITE returns.");
|
---|
328 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetMMIORead, STAMTYPE_COUNTER, "/VMM/RZRet/MMIORead", STAMUNIT_OCCURENCES, "Number of VINF_IOM_HC_MMIO_READ returns.");
|
---|
329 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetMMIOWrite, STAMTYPE_COUNTER, "/VMM/RZRet/MMIOWrite", STAMUNIT_OCCURENCES, "Number of VINF_IOM_HC_MMIO_WRITE returns.");
|
---|
330 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetMMIOReadWrite, STAMTYPE_COUNTER, "/VMM/RZRet/MMIOReadWrite", STAMUNIT_OCCURENCES, "Number of VINF_IOM_HC_MMIO_READ_WRITE returns.");
|
---|
331 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetMMIOPatchRead, STAMTYPE_COUNTER, "/VMM/RZRet/MMIOPatchRead", STAMUNIT_OCCURENCES, "Number of VINF_IOM_HC_MMIO_PATCH_READ returns.");
|
---|
332 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetMMIOPatchWrite, STAMTYPE_COUNTER, "/VMM/RZRet/MMIOPatchWrite", STAMUNIT_OCCURENCES, "Number of VINF_IOM_HC_MMIO_PATCH_WRITE returns.");
|
---|
333 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetLDTFault, STAMTYPE_COUNTER, "/VMM/RZRet/LDTFault", STAMUNIT_OCCURENCES, "Number of VINF_EM_EXECUTE_INSTRUCTION_GDT_FAULT returns.");
|
---|
334 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetGDTFault, STAMTYPE_COUNTER, "/VMM/RZRet/GDTFault", STAMUNIT_OCCURENCES, "Number of VINF_EM_EXECUTE_INSTRUCTION_LDT_FAULT returns.");
|
---|
335 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetIDTFault, STAMTYPE_COUNTER, "/VMM/RZRet/IDTFault", STAMUNIT_OCCURENCES, "Number of VINF_EM_EXECUTE_INSTRUCTION_IDT_FAULT returns.");
|
---|
336 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetTSSFault, STAMTYPE_COUNTER, "/VMM/RZRet/TSSFault", STAMUNIT_OCCURENCES, "Number of VINF_EM_EXECUTE_INSTRUCTION_TSS_FAULT returns.");
|
---|
337 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetPDFault, STAMTYPE_COUNTER, "/VMM/RZRet/PDFault", STAMUNIT_OCCURENCES, "Number of VINF_EM_EXECUTE_INSTRUCTION_PD_FAULT returns.");
|
---|
338 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetCSAMTask, STAMTYPE_COUNTER, "/VMM/RZRet/CSAMTask", STAMUNIT_OCCURENCES, "Number of VINF_CSAM_PENDING_ACTION returns.");
|
---|
339 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetSyncCR3, STAMTYPE_COUNTER, "/VMM/RZRet/SyncCR", STAMUNIT_OCCURENCES, "Number of VINF_PGM_SYNC_CR3 returns.");
|
---|
340 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetMisc, STAMTYPE_COUNTER, "/VMM/RZRet/Misc", STAMUNIT_OCCURENCES, "Number of misc returns.");
|
---|
341 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetPatchInt3, STAMTYPE_COUNTER, "/VMM/RZRet/PatchInt3", STAMUNIT_OCCURENCES, "Number of VINF_PATM_PATCH_INT3 returns.");
|
---|
342 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetPatchPF, STAMTYPE_COUNTER, "/VMM/RZRet/PatchPF", STAMUNIT_OCCURENCES, "Number of VINF_PATM_PATCH_TRAP_PF returns.");
|
---|
343 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetPatchGP, STAMTYPE_COUNTER, "/VMM/RZRet/PatchGP", STAMUNIT_OCCURENCES, "Number of VINF_PATM_PATCH_TRAP_GP returns.");
|
---|
344 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetPatchIretIRQ, STAMTYPE_COUNTER, "/VMM/RZRet/PatchIret", STAMUNIT_OCCURENCES, "Number of VINF_PATM_PENDING_IRQ_AFTER_IRET returns.");
|
---|
345 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetPageOverflow, STAMTYPE_COUNTER, "/VMM/RZRet/InvlpgOverflow", STAMUNIT_OCCURENCES, "Number of VERR_REM_FLUSHED_PAGES_OVERFLOW returns.");
|
---|
346 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetRescheduleREM, STAMTYPE_COUNTER, "/VMM/RZRet/ScheduleREM", STAMUNIT_OCCURENCES, "Number of VINF_EM_RESCHEDULE_REM returns.");
|
---|
347 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetToR3, STAMTYPE_COUNTER, "/VMM/RZRet/ToR3", STAMUNIT_OCCURENCES, "Number of VINF_EM_RAW_TO_R3 returns.");
|
---|
348 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetTimerPending, STAMTYPE_COUNTER, "/VMM/RZRet/TimerPending", STAMUNIT_OCCURENCES, "Number of VINF_EM_RAW_TIMER_PENDING returns.");
|
---|
349 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetInterruptPending, STAMTYPE_COUNTER, "/VMM/RZRet/InterruptPending", STAMUNIT_OCCURENCES, "Number of VINF_EM_RAW_INTERRUPT_PENDING returns.");
|
---|
350 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetPATMDuplicateFn, STAMTYPE_COUNTER, "/VMM/RZRet/PATMDuplicateFn", STAMUNIT_OCCURENCES, "Number of VINF_PATM_DUPLICATE_FUNCTION returns.");
|
---|
351 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetPGMChangeMode, STAMTYPE_COUNTER, "/VMM/RZRet/PGMChangeMode", STAMUNIT_OCCURENCES, "Number of VINF_PGM_CHANGE_MODE returns.");
|
---|
352 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetEmulHlt, STAMTYPE_COUNTER, "/VMM/RZRet/EmulHlt", STAMUNIT_OCCURENCES, "Number of VINF_EM_RAW_EMULATE_INSTR_HLT returns.");
|
---|
353 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetPendingRequest, STAMTYPE_COUNTER, "/VMM/RZRet/PendingRequest", STAMUNIT_OCCURENCES, "Number of VINF_EM_PENDING_REQUEST returns.");
|
---|
354 |
|
---|
355 | STAM_REG(pVM, &pVM->vmm.s.StatRZRetCallHost, STAMTYPE_COUNTER, "/VMM/RZCallR3/Misc", STAMUNIT_OCCURENCES, "Number of Other ring-3 calls.");
|
---|
356 | STAM_REG(pVM, &pVM->vmm.s.StatRZCallPDMLock, STAMTYPE_COUNTER, "/VMM/RZCallR3/PDMLock", STAMUNIT_OCCURENCES, "Number of VMMCALLHOST_PDM_LOCK calls.");
|
---|
357 | STAM_REG(pVM, &pVM->vmm.s.StatRZCallPDMQueueFlush, STAMTYPE_COUNTER, "/VMM/RZCallR3/PDMQueueFlush", STAMUNIT_OCCURENCES, "Number of VMMCALLHOST_PDM_QUEUE_FLUSH calls.");
|
---|
358 | STAM_REG(pVM, &pVM->vmm.s.StatRZCallPGMLock, STAMTYPE_COUNTER, "/VMM/RZCallR3/PGMLock", STAMUNIT_OCCURENCES, "Number of VMMCALLHOST_PGM_LOCK calls.");
|
---|
359 | STAM_REG(pVM, &pVM->vmm.s.StatRZCallPGMPoolGrow, STAMTYPE_COUNTER, "/VMM/RZCallR3/PGMPoolGrow", STAMUNIT_OCCURENCES, "Number of VMMCALLHOST_PGM_POOL_GROW calls.");
|
---|
360 | STAM_REG(pVM, &pVM->vmm.s.StatRZCallPGMMapChunk, STAMTYPE_COUNTER, "/VMM/RZCallR3/PGMMapChunk", STAMUNIT_OCCURENCES, "Number of VMMCALLHOST_PGM_MAP_CHUNK calls.");
|
---|
361 | STAM_REG(pVM, &pVM->vmm.s.StatRZCallPGMAllocHandy, STAMTYPE_COUNTER, "/VMM/RZCallR3/PGMAllocHandy", STAMUNIT_OCCURENCES, "Number of VMMCALLHOST_PGM_ALLOCATE_HANDY_PAGES calls.");
|
---|
362 | #ifndef VBOX_WITH_NEW_PHYS_CODE
|
---|
363 | STAM_REG(pVM, &pVM->vmm.s.StatRZCallPGMGrowRAM, STAMTYPE_COUNTER, "/VMM/RZCallR3/PGMGrowRAM", STAMUNIT_OCCURENCES, "Number of VMMCALLHOST_PGM_RAM_GROW_RANGE calls.");
|
---|
364 | #endif
|
---|
365 | STAM_REG(pVM, &pVM->vmm.s.StatRZCallRemReplay, STAMTYPE_COUNTER, "/VMM/RZCallR3/REMReplay", STAMUNIT_OCCURENCES, "Number of VMMCALLHOST_REM_REPLAY_HANDLER_NOTIFICATIONS calls.");
|
---|
366 | STAM_REG(pVM, &pVM->vmm.s.StatRZCallLogFlush, STAMTYPE_COUNTER, "/VMM/RZCallR3/VMMLogFlush", STAMUNIT_OCCURENCES, "Number of VMMCALLHOST_VMM_LOGGER_FLUSH calls.");
|
---|
367 | STAM_REG(pVM, &pVM->vmm.s.StatRZCallVMSetError, STAMTYPE_COUNTER, "/VMM/RZCallR3/VMSetError", STAMUNIT_OCCURENCES, "Number of VMMCALLHOST_VM_SET_ERROR calls.");
|
---|
368 | STAM_REG(pVM, &pVM->vmm.s.StatRZCallVMSetRuntimeError, STAMTYPE_COUNTER, "/VMM/RZCallR3/VMRuntimeError", STAMUNIT_OCCURENCES, "Number of VMMCALLHOST_VM_SET_RUNTIME_ERROR calls.");
|
---|
369 | }
|
---|
370 |
|
---|
371 |
|
---|
372 | /**
|
---|
373 | * Initializes the per-VCPU VMM.
|
---|
374 | *
|
---|
375 | * @returns VBox status code.
|
---|
376 | * @param pVM The VM to operate on.
|
---|
377 | */
|
---|
378 | VMMR3DECL(int) VMMR3InitCPU(PVM pVM)
|
---|
379 | {
|
---|
380 | LogFlow(("VMMR3InitCPU\n"));
|
---|
381 | return VINF_SUCCESS;
|
---|
382 | }
|
---|
383 |
|
---|
384 |
|
---|
385 | /**
|
---|
386 | * Ring-3 init finalizing.
|
---|
387 | *
|
---|
388 | * @returns VBox status code.
|
---|
389 | * @param pVM The VM handle.
|
---|
390 | */
|
---|
391 | VMMR3DECL(int) VMMR3InitFinalize(PVM pVM)
|
---|
392 | {
|
---|
393 | #ifdef VBOX_STRICT_VMM_STACK
|
---|
394 | /*
|
---|
395 | * Two inaccessible pages at each sides of the stack to catch over/under-flows.
|
---|
396 | */
|
---|
397 | memset(pVM->vmm.s.pbEMTStackR3 - PAGE_SIZE, 0xcc, PAGE_SIZE);
|
---|
398 | PGMMapSetPage(pVM, MMHyperR3ToRC(pVM, pVM->vmm.s.pbEMTStackR3 - PAGE_SIZE), PAGE_SIZE, 0);
|
---|
399 | RTMemProtect(pVM->vmm.s.pbEMTStackR3 - PAGE_SIZE, PAGE_SIZE, RTMEM_PROT_NONE);
|
---|
400 |
|
---|
401 | memset(pVM->vmm.s.pbEMTStackR3 + VMM_STACK_SIZE, 0xcc, PAGE_SIZE);
|
---|
402 | PGMMapSetPage(pVM, MMHyperR3ToRC(pVM, pVM->vmm.s.pbEMTStackR3 + VMM_STACK_SIZE), PAGE_SIZE, 0);
|
---|
403 | RTMemProtect(pVM->vmm.s.pbEMTStackR3 + VMM_STACK_SIZE, PAGE_SIZE, RTMEM_PROT_NONE);
|
---|
404 | #endif
|
---|
405 |
|
---|
406 | /*
|
---|
407 | * Set page attributes to r/w for stack pages.
|
---|
408 | */
|
---|
409 | int rc = PGMMapSetPage(pVM, pVM->vmm.s.pbEMTStackRC, VMM_STACK_SIZE, X86_PTE_P | X86_PTE_A | X86_PTE_D | X86_PTE_RW);
|
---|
410 | AssertRC(rc);
|
---|
411 | if (RT_SUCCESS(rc))
|
---|
412 | {
|
---|
413 | /*
|
---|
414 | * Create the EMT yield timer.
|
---|
415 | */
|
---|
416 | rc = TMR3TimerCreateInternal(pVM, TMCLOCK_REAL, vmmR3YieldEMT, NULL, "EMT Yielder", &pVM->vmm.s.pYieldTimer);
|
---|
417 | if (RT_SUCCESS(rc))
|
---|
418 | rc = TMTimerSetMillies(pVM->vmm.s.pYieldTimer, pVM->vmm.s.cYieldEveryMillies);
|
---|
419 | }
|
---|
420 |
|
---|
421 | #ifdef VBOX_WITH_NMI
|
---|
422 | /*
|
---|
423 | * Map the host APIC into GC - This is AMD/Intel + Host OS specific!
|
---|
424 | */
|
---|
425 | if (RT_SUCCESS(rc))
|
---|
426 | rc = PGMMap(pVM, pVM->vmm.s.GCPtrApicBase, 0xfee00000, PAGE_SIZE,
|
---|
427 | X86_PTE_P | X86_PTE_RW | X86_PTE_PWT | X86_PTE_PCD | X86_PTE_A | X86_PTE_D);
|
---|
428 | #endif
|
---|
429 | return rc;
|
---|
430 | }
|
---|
431 |
|
---|
432 |
|
---|
433 | /**
|
---|
434 | * Initializes the R0 VMM.
|
---|
435 | *
|
---|
436 | * @returns VBox status code.
|
---|
437 | * @param pVM The VM to operate on.
|
---|
438 | */
|
---|
439 | VMMR3DECL(int) VMMR3InitR0(PVM pVM)
|
---|
440 | {
|
---|
441 | int rc;
|
---|
442 |
|
---|
443 | /*
|
---|
444 | * Initialize the ring-0 logger if we haven't done so yet.
|
---|
445 | */
|
---|
446 | if ( pVM->vmm.s.pR0LoggerR3
|
---|
447 | && !pVM->vmm.s.pR0LoggerR3->fCreated)
|
---|
448 | {
|
---|
449 | rc = VMMR3UpdateLoggers(pVM);
|
---|
450 | if (RT_FAILURE(rc))
|
---|
451 | return rc;
|
---|
452 | }
|
---|
453 |
|
---|
454 | /*
|
---|
455 | * Call Ring-0 entry with init code.
|
---|
456 | */
|
---|
457 | for (;;)
|
---|
458 | {
|
---|
459 | #ifdef NO_SUPCALLR0VMM
|
---|
460 | //rc = VERR_GENERAL_FAILURE;
|
---|
461 | rc = VINF_SUCCESS;
|
---|
462 | #else
|
---|
463 | rc = SUPCallVMMR0Ex(pVM->pVMR0, VMMR0_DO_VMMR0_INIT, VMMGetSvnRev(), NULL);
|
---|
464 | #endif
|
---|
465 | if ( pVM->vmm.s.pR0LoggerR3
|
---|
466 | && pVM->vmm.s.pR0LoggerR3->Logger.offScratch > 0)
|
---|
467 | RTLogFlushToLogger(&pVM->vmm.s.pR0LoggerR3->Logger, NULL);
|
---|
468 | if (rc != VINF_VMM_CALL_HOST)
|
---|
469 | break;
|
---|
470 | rc = vmmR3ServiceCallHostRequest(pVM);
|
---|
471 | if (RT_FAILURE(rc) || (rc >= VINF_EM_FIRST && rc <= VINF_EM_LAST))
|
---|
472 | break;
|
---|
473 | /* Resume R0 */
|
---|
474 | }
|
---|
475 |
|
---|
476 | if (RT_FAILURE(rc) || (rc >= VINF_EM_FIRST && rc <= VINF_EM_LAST))
|
---|
477 | {
|
---|
478 | LogRel(("R0 init failed, rc=%Rra\n", rc));
|
---|
479 | if (RT_SUCCESS(rc))
|
---|
480 | rc = VERR_INTERNAL_ERROR;
|
---|
481 | }
|
---|
482 | return rc;
|
---|
483 | }
|
---|
484 |
|
---|
485 |
|
---|
486 | /**
|
---|
487 | * Initializes the RC VMM.
|
---|
488 | *
|
---|
489 | * @returns VBox status code.
|
---|
490 | * @param pVM The VM to operate on.
|
---|
491 | */
|
---|
492 | VMMR3DECL(int) VMMR3InitRC(PVM pVM)
|
---|
493 | {
|
---|
494 | /* In VMX mode, there's no need to init RC. */
|
---|
495 | if (pVM->vmm.s.fSwitcherDisabled)
|
---|
496 | return VINF_SUCCESS;
|
---|
497 |
|
---|
498 | /*
|
---|
499 | * Call VMMGCInit():
|
---|
500 | * -# resolve the address.
|
---|
501 | * -# setup stackframe and EIP to use the trampoline.
|
---|
502 | * -# do a generic hypervisor call.
|
---|
503 | */
|
---|
504 | RTRCPTR RCPtrEP;
|
---|
505 | int rc = PDMR3LdrGetSymbolRC(pVM, VMMGC_MAIN_MODULE_NAME, "VMMGCEntry", &RCPtrEP);
|
---|
506 | if (RT_SUCCESS(rc))
|
---|
507 | {
|
---|
508 | CPUMHyperSetCtxCore(pVM, NULL);
|
---|
509 | CPUMSetHyperESP(pVM, pVM->vmm.s.pbEMTStackBottomRC); /* Clear the stack. */
|
---|
510 | uint64_t u64TS = RTTimeProgramStartNanoTS();
|
---|
511 | CPUMPushHyper(pVM, (uint32_t)(u64TS >> 32)); /* Param 3: The program startup TS - Hi. */
|
---|
512 | CPUMPushHyper(pVM, (uint32_t)u64TS); /* Param 3: The program startup TS - Lo. */
|
---|
513 | CPUMPushHyper(pVM, VMMGetSvnRev()); /* Param 2: Version argument. */
|
---|
514 | CPUMPushHyper(pVM, VMMGC_DO_VMMGC_INIT); /* Param 1: Operation. */
|
---|
515 | CPUMPushHyper(pVM, pVM->pVMRC); /* Param 0: pVM */
|
---|
516 | CPUMPushHyper(pVM, 5 * sizeof(RTRCPTR)); /* trampoline param: stacksize. */
|
---|
517 | CPUMPushHyper(pVM, RCPtrEP); /* Call EIP. */
|
---|
518 | CPUMSetHyperEIP(pVM, pVM->vmm.s.pfnCallTrampolineRC);
|
---|
519 |
|
---|
520 | for (;;)
|
---|
521 | {
|
---|
522 | #ifdef NO_SUPCALLR0VMM
|
---|
523 | //rc = VERR_GENERAL_FAILURE;
|
---|
524 | rc = VINF_SUCCESS;
|
---|
525 | #else
|
---|
526 | rc = SUPCallVMMR0(pVM->pVMR0, VMMR0_DO_CALL_HYPERVISOR, NULL);
|
---|
527 | #endif
|
---|
528 | #ifdef LOG_ENABLED
|
---|
529 | PRTLOGGERRC pLogger = pVM->vmm.s.pRCLoggerR3;
|
---|
530 | if ( pLogger
|
---|
531 | && pLogger->offScratch > 0)
|
---|
532 | RTLogFlushRC(NULL, pLogger);
|
---|
533 | #endif
|
---|
534 | #ifdef VBOX_WITH_RC_RELEASE_LOGGING
|
---|
535 | PRTLOGGERRC pRelLogger = pVM->vmm.s.pRCRelLoggerR3;
|
---|
536 | if (RT_UNLIKELY(pRelLogger && pRelLogger->offScratch > 0))
|
---|
537 | RTLogFlushRC(RTLogRelDefaultInstance(), pRelLogger);
|
---|
538 | #endif
|
---|
539 | if (rc != VINF_VMM_CALL_HOST)
|
---|
540 | break;
|
---|
541 | rc = vmmR3ServiceCallHostRequest(pVM);
|
---|
542 | if (RT_FAILURE(rc) || (rc >= VINF_EM_FIRST && rc <= VINF_EM_LAST))
|
---|
543 | break;
|
---|
544 | }
|
---|
545 |
|
---|
546 | if (RT_FAILURE(rc) || (rc >= VINF_EM_FIRST && rc <= VINF_EM_LAST))
|
---|
547 | {
|
---|
548 | VMMR3FatalDump(pVM, rc);
|
---|
549 | if (rc >= VINF_EM_FIRST && rc <= VINF_EM_LAST)
|
---|
550 | rc = VERR_INTERNAL_ERROR;
|
---|
551 | }
|
---|
552 | AssertRC(rc);
|
---|
553 | }
|
---|
554 | return rc;
|
---|
555 | }
|
---|
556 |
|
---|
557 |
|
---|
558 | /**
|
---|
559 | * Terminate the VMM bits.
|
---|
560 | *
|
---|
561 | * @returns VINF_SUCCESS.
|
---|
562 | * @param pVM The VM handle.
|
---|
563 | */
|
---|
564 | VMMR3DECL(int) VMMR3Term(PVM pVM)
|
---|
565 | {
|
---|
566 | /*
|
---|
567 | * Call Ring-0 entry with termination code.
|
---|
568 | */
|
---|
569 | int rc;
|
---|
570 | for (;;)
|
---|
571 | {
|
---|
572 | #ifdef NO_SUPCALLR0VMM
|
---|
573 | //rc = VERR_GENERAL_FAILURE;
|
---|
574 | rc = VINF_SUCCESS;
|
---|
575 | #else
|
---|
576 | rc = SUPCallVMMR0Ex(pVM->pVMR0, VMMR0_DO_VMMR0_TERM, 0, NULL);
|
---|
577 | #endif
|
---|
578 | if ( pVM->vmm.s.pR0LoggerR3
|
---|
579 | && pVM->vmm.s.pR0LoggerR3->Logger.offScratch > 0)
|
---|
580 | RTLogFlushToLogger(&pVM->vmm.s.pR0LoggerR3->Logger, NULL);
|
---|
581 | if (rc != VINF_VMM_CALL_HOST)
|
---|
582 | break;
|
---|
583 | rc = vmmR3ServiceCallHostRequest(pVM);
|
---|
584 | if (RT_FAILURE(rc) || (rc >= VINF_EM_FIRST && rc <= VINF_EM_LAST))
|
---|
585 | break;
|
---|
586 | /* Resume R0 */
|
---|
587 | }
|
---|
588 | if (RT_FAILURE(rc) || (rc >= VINF_EM_FIRST && rc <= VINF_EM_LAST))
|
---|
589 | {
|
---|
590 | LogRel(("VMMR3Term: R0 term failed, rc=%Rra. (warning)\n", rc));
|
---|
591 | if (RT_SUCCESS(rc))
|
---|
592 | rc = VERR_INTERNAL_ERROR;
|
---|
593 | }
|
---|
594 |
|
---|
595 | #ifdef VBOX_STRICT_VMM_STACK
|
---|
596 | /*
|
---|
597 | * Make the two stack guard pages present again.
|
---|
598 | */
|
---|
599 | RTMemProtect(pVM->vmm.s.pbEMTStackR3 - PAGE_SIZE, PAGE_SIZE, RTMEM_PROT_READ | RTMEM_PROT_WRITE);
|
---|
600 | RTMemProtect(pVM->vmm.s.pbEMTStackR3 + VMM_STACK_SIZE, PAGE_SIZE, RTMEM_PROT_READ | RTMEM_PROT_WRITE);
|
---|
601 | #endif
|
---|
602 | return rc;
|
---|
603 | }
|
---|
604 |
|
---|
605 |
|
---|
606 | /**
|
---|
607 | * Terminates the per-VCPU VMM.
|
---|
608 | *
|
---|
609 | * Termination means cleaning up and freeing all resources,
|
---|
610 | * the VM it self is at this point powered off or suspended.
|
---|
611 | *
|
---|
612 | * @returns VBox status code.
|
---|
613 | * @param pVM The VM to operate on.
|
---|
614 | */
|
---|
615 | VMMR3DECL(int) VMMR3TermCPU(PVM pVM)
|
---|
616 | {
|
---|
617 | return VINF_SUCCESS;
|
---|
618 | }
|
---|
619 |
|
---|
620 |
|
---|
621 | /**
|
---|
622 | * Applies relocations to data and code managed by this
|
---|
623 | * component. This function will be called at init and
|
---|
624 | * whenever the VMM need to relocate it self inside the GC.
|
---|
625 | *
|
---|
626 | * The VMM will need to apply relocations to the core code.
|
---|
627 | *
|
---|
628 | * @param pVM The VM handle.
|
---|
629 | * @param offDelta The relocation delta.
|
---|
630 | */
|
---|
631 | VMMR3DECL(void) VMMR3Relocate(PVM pVM, RTGCINTPTR offDelta)
|
---|
632 | {
|
---|
633 | LogFlow(("VMMR3Relocate: offDelta=%RGv\n", offDelta));
|
---|
634 |
|
---|
635 | /*
|
---|
636 | * Recalc the RC address.
|
---|
637 | */
|
---|
638 | pVM->vmm.s.pvCoreCodeRC = MMHyperR3ToRC(pVM, pVM->vmm.s.pvCoreCodeR3);
|
---|
639 |
|
---|
640 | /*
|
---|
641 | * The stack.
|
---|
642 | */
|
---|
643 | CPUMSetHyperESP(pVM, CPUMGetHyperESP(pVM) + offDelta);
|
---|
644 | pVM->vmm.s.pbEMTStackRC = MMHyperR3ToRC(pVM, pVM->vmm.s.pbEMTStackR3);
|
---|
645 | pVM->vmm.s.pbEMTStackBottomRC = pVM->vmm.s.pbEMTStackRC + VMM_STACK_SIZE;
|
---|
646 |
|
---|
647 | /*
|
---|
648 | * All the switchers.
|
---|
649 | */
|
---|
650 | vmmR3SwitcherRelocate(pVM, offDelta);
|
---|
651 |
|
---|
652 | /*
|
---|
653 | * Get other RC entry points.
|
---|
654 | */
|
---|
655 | int rc = PDMR3LdrGetSymbolRC(pVM, VMMGC_MAIN_MODULE_NAME, "CPUMGCResumeGuest", &pVM->vmm.s.pfnCPUMRCResumeGuest);
|
---|
656 | AssertReleaseMsgRC(rc, ("CPUMGCResumeGuest not found! rc=%Rra\n", rc));
|
---|
657 |
|
---|
658 | rc = PDMR3LdrGetSymbolRC(pVM, VMMGC_MAIN_MODULE_NAME, "CPUMGCResumeGuestV86", &pVM->vmm.s.pfnCPUMRCResumeGuestV86);
|
---|
659 | AssertReleaseMsgRC(rc, ("CPUMGCResumeGuestV86 not found! rc=%Rra\n", rc));
|
---|
660 |
|
---|
661 | /*
|
---|
662 | * Update the logger.
|
---|
663 | */
|
---|
664 | VMMR3UpdateLoggers(pVM);
|
---|
665 | }
|
---|
666 |
|
---|
667 |
|
---|
668 | /**
|
---|
669 | * Updates the settings for the RC and R0 loggers.
|
---|
670 | *
|
---|
671 | * @returns VBox status code.
|
---|
672 | * @param pVM The VM handle.
|
---|
673 | */
|
---|
674 | VMMR3DECL(int) VMMR3UpdateLoggers(PVM pVM)
|
---|
675 | {
|
---|
676 | /*
|
---|
677 | * Simply clone the logger instance (for RC).
|
---|
678 | */
|
---|
679 | int rc = VINF_SUCCESS;
|
---|
680 | RTRCPTR RCPtrLoggerFlush = 0;
|
---|
681 |
|
---|
682 | if (pVM->vmm.s.pRCLoggerR3
|
---|
683 | #ifdef VBOX_WITH_RC_RELEASE_LOGGING
|
---|
684 | || pVM->vmm.s.pRCRelLoggerR3
|
---|
685 | #endif
|
---|
686 | )
|
---|
687 | {
|
---|
688 | rc = PDMR3LdrGetSymbolRC(pVM, VMMGC_MAIN_MODULE_NAME, "vmmGCLoggerFlush", &RCPtrLoggerFlush);
|
---|
689 | AssertReleaseMsgRC(rc, ("vmmGCLoggerFlush not found! rc=%Rra\n", rc));
|
---|
690 | }
|
---|
691 |
|
---|
692 | if (pVM->vmm.s.pRCLoggerR3)
|
---|
693 | {
|
---|
694 | RTRCPTR RCPtrLoggerWrapper = 0;
|
---|
695 | rc = PDMR3LdrGetSymbolRC(pVM, VMMGC_MAIN_MODULE_NAME, "vmmGCLoggerWrapper", &RCPtrLoggerWrapper);
|
---|
696 | AssertReleaseMsgRC(rc, ("vmmGCLoggerWrapper not found! rc=%Rra\n", rc));
|
---|
697 |
|
---|
698 | pVM->vmm.s.pRCLoggerRC = MMHyperR3ToRC(pVM, pVM->vmm.s.pRCLoggerR3);
|
---|
699 | rc = RTLogCloneRC(NULL /* default */, pVM->vmm.s.pRCLoggerR3, pVM->vmm.s.cbRCLogger,
|
---|
700 | RCPtrLoggerWrapper, RCPtrLoggerFlush, RTLOGFLAGS_BUFFERED);
|
---|
701 | AssertReleaseMsgRC(rc, ("RTLogCloneRC failed! rc=%Rra\n", rc));
|
---|
702 | }
|
---|
703 |
|
---|
704 | #ifdef VBOX_WITH_RC_RELEASE_LOGGING
|
---|
705 | if (pVM->vmm.s.pRCRelLoggerR3)
|
---|
706 | {
|
---|
707 | RTRCPTR RCPtrLoggerWrapper = 0;
|
---|
708 | rc = PDMR3LdrGetSymbolRC(pVM, VMMGC_MAIN_MODULE_NAME, "vmmGCRelLoggerWrapper", &RCPtrLoggerWrapper);
|
---|
709 | AssertReleaseMsgRC(rc, ("vmmGCRelLoggerWrapper not found! rc=%Rra\n", rc));
|
---|
710 |
|
---|
711 | pVM->vmm.s.pRCRelLoggerRC = MMHyperR3ToRC(pVM, pVM->vmm.s.pRCRelLoggerR3);
|
---|
712 | rc = RTLogCloneRC(RTLogRelDefaultInstance(), pVM->vmm.s.pRCRelLoggerR3, pVM->vmm.s.cbRCRelLogger,
|
---|
713 | RCPtrLoggerWrapper, RCPtrLoggerFlush, RTLOGFLAGS_BUFFERED);
|
---|
714 | AssertReleaseMsgRC(rc, ("RTLogCloneRC failed! rc=%Rra\n", rc));
|
---|
715 | }
|
---|
716 | #endif /* VBOX_WITH_RC_RELEASE_LOGGING */
|
---|
717 |
|
---|
718 | /*
|
---|
719 | * For the ring-0 EMT logger, we use a per-thread logger instance
|
---|
720 | * in ring-0. Only initialize it once.
|
---|
721 | */
|
---|
722 | PVMMR0LOGGER pR0LoggerR3 = pVM->vmm.s.pR0LoggerR3;
|
---|
723 | if (pR0LoggerR3)
|
---|
724 | {
|
---|
725 | if (!pR0LoggerR3->fCreated)
|
---|
726 | {
|
---|
727 | RTR0PTR pfnLoggerWrapper = NIL_RTR0PTR;
|
---|
728 | rc = PDMR3LdrGetSymbolR0(pVM, VMMR0_MAIN_MODULE_NAME, "vmmR0LoggerWrapper", &pfnLoggerWrapper);
|
---|
729 | AssertReleaseMsgRCReturn(rc, ("VMMLoggerWrapper not found! rc=%Rra\n", rc), rc);
|
---|
730 |
|
---|
731 | RTR0PTR pfnLoggerFlush = NIL_RTR0PTR;
|
---|
732 | rc = PDMR3LdrGetSymbolR0(pVM, VMMR0_MAIN_MODULE_NAME, "vmmR0LoggerFlush", &pfnLoggerFlush);
|
---|
733 | AssertReleaseMsgRCReturn(rc, ("VMMLoggerFlush not found! rc=%Rra\n", rc), rc);
|
---|
734 |
|
---|
735 | rc = RTLogCreateForR0(&pR0LoggerR3->Logger, pR0LoggerR3->cbLogger,
|
---|
736 | *(PFNRTLOGGER *)&pfnLoggerWrapper, *(PFNRTLOGFLUSH *)&pfnLoggerFlush,
|
---|
737 | RTLOGFLAGS_BUFFERED, RTLOGDEST_DUMMY);
|
---|
738 | AssertReleaseMsgRCReturn(rc, ("RTLogCreateForR0 failed! rc=%Rra\n", rc), rc);
|
---|
739 | pR0LoggerR3->fCreated = true;
|
---|
740 | pR0LoggerR3->fFlushingDisabled = false;
|
---|
741 | }
|
---|
742 |
|
---|
743 | rc = RTLogCopyGroupsAndFlags(&pR0LoggerR3->Logger, NULL /* default */, pVM->vmm.s.pRCLoggerR3->fFlags, RTLOGFLAGS_BUFFERED);
|
---|
744 | AssertRC(rc);
|
---|
745 | }
|
---|
746 |
|
---|
747 | return rc;
|
---|
748 | }
|
---|
749 |
|
---|
750 |
|
---|
751 | /**
|
---|
752 | * Gets the pointer to a buffer containing the R0/RC AssertMsg1 output.
|
---|
753 | *
|
---|
754 | * @returns Pointer to the buffer.
|
---|
755 | * @param pVM The VM handle.
|
---|
756 | */
|
---|
757 | VMMR3DECL(const char *) VMMR3GetRZAssertMsg1(PVM pVM)
|
---|
758 | {
|
---|
759 | if (HWACCMIsEnabled(pVM))
|
---|
760 | return pVM->vmm.s.szRing0AssertMsg1;
|
---|
761 |
|
---|
762 | RTRCPTR RCPtr;
|
---|
763 | int rc = PDMR3LdrGetSymbolRC(pVM, NULL, "g_szRTAssertMsg1", &RCPtr);
|
---|
764 | if (RT_SUCCESS(rc))
|
---|
765 | return (const char *)MMHyperRCToR3(pVM, RCPtr);
|
---|
766 |
|
---|
767 | return NULL;
|
---|
768 | }
|
---|
769 |
|
---|
770 |
|
---|
771 | /**
|
---|
772 | * Gets the pointer to a buffer containing the R0/RC AssertMsg2 output.
|
---|
773 | *
|
---|
774 | * @returns Pointer to the buffer.
|
---|
775 | * @param pVM The VM handle.
|
---|
776 | */
|
---|
777 | VMMR3DECL(const char *) VMMR3GetRZAssertMsg2(PVM pVM)
|
---|
778 | {
|
---|
779 | if (HWACCMIsEnabled(pVM))
|
---|
780 | return pVM->vmm.s.szRing0AssertMsg2;
|
---|
781 |
|
---|
782 | RTRCPTR RCPtr;
|
---|
783 | int rc = PDMR3LdrGetSymbolRC(pVM, NULL, "g_szRTAssertMsg2", &RCPtr);
|
---|
784 | if (RT_SUCCESS(rc))
|
---|
785 | return (const char *)MMHyperRCToR3(pVM, RCPtr);
|
---|
786 |
|
---|
787 | return NULL;
|
---|
788 | }
|
---|
789 |
|
---|
790 |
|
---|
791 | /**
|
---|
792 | * Execute state save operation.
|
---|
793 | *
|
---|
794 | * @returns VBox status code.
|
---|
795 | * @param pVM VM Handle.
|
---|
796 | * @param pSSM SSM operation handle.
|
---|
797 | */
|
---|
798 | static DECLCALLBACK(int) vmmR3Save(PVM pVM, PSSMHANDLE pSSM)
|
---|
799 | {
|
---|
800 | LogFlow(("vmmR3Save:\n"));
|
---|
801 |
|
---|
802 | /*
|
---|
803 | * The hypervisor stack.
|
---|
804 | * Note! See not in vmmR3Load.
|
---|
805 | */
|
---|
806 | SSMR3PutRCPtr(pSSM, pVM->vmm.s.pbEMTStackBottomRC);
|
---|
807 | RTRCPTR RCPtrESP = CPUMGetHyperESP(pVM);
|
---|
808 | AssertMsg(pVM->vmm.s.pbEMTStackBottomRC - RCPtrESP <= VMM_STACK_SIZE, ("Bottom %RRv ESP=%RRv\n", pVM->vmm.s.pbEMTStackBottomRC, RCPtrESP));
|
---|
809 | SSMR3PutRCPtr(pSSM, RCPtrESP);
|
---|
810 | SSMR3PutMem(pSSM, pVM->vmm.s.pbEMTStackR3, VMM_STACK_SIZE);
|
---|
811 | return SSMR3PutU32(pSSM, ~0); /* terminator */
|
---|
812 | }
|
---|
813 |
|
---|
814 |
|
---|
815 | /**
|
---|
816 | * Execute state load operation.
|
---|
817 | *
|
---|
818 | * @returns VBox status code.
|
---|
819 | * @param pVM VM Handle.
|
---|
820 | * @param pSSM SSM operation handle.
|
---|
821 | * @param u32Version Data layout version.
|
---|
822 | */
|
---|
823 | static DECLCALLBACK(int) vmmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version)
|
---|
824 | {
|
---|
825 | LogFlow(("vmmR3Load:\n"));
|
---|
826 |
|
---|
827 | /*
|
---|
828 | * Validate version.
|
---|
829 | */
|
---|
830 | if (u32Version != VMM_SAVED_STATE_VERSION)
|
---|
831 | {
|
---|
832 | AssertMsgFailed(("vmmR3Load: Invalid version u32Version=%d!\n", u32Version));
|
---|
833 | return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
|
---|
834 | }
|
---|
835 |
|
---|
836 | /*
|
---|
837 | * Check that the stack is in the same place, or that it's fearly empty.
|
---|
838 | *
|
---|
839 | * Note! This can be skipped next time we update saved state as we will
|
---|
840 | * never be in a R0/RC -> ring-3 call when saving the state. The
|
---|
841 | * stack and the two associated pointers are not required.
|
---|
842 | */
|
---|
843 | RTRCPTR RCPtrStackBottom;
|
---|
844 | SSMR3GetRCPtr(pSSM, &RCPtrStackBottom);
|
---|
845 | RTRCPTR RCPtrESP;
|
---|
846 | int rc = SSMR3GetRCPtr(pSSM, &RCPtrESP);
|
---|
847 | if (RT_FAILURE(rc))
|
---|
848 | return rc;
|
---|
849 |
|
---|
850 | /* restore the stack. */
|
---|
851 | SSMR3GetMem(pSSM, pVM->vmm.s.pbEMTStackR3, VMM_STACK_SIZE);
|
---|
852 |
|
---|
853 | /* terminator */
|
---|
854 | uint32_t u32;
|
---|
855 | rc = SSMR3GetU32(pSSM, &u32);
|
---|
856 | if (RT_FAILURE(rc))
|
---|
857 | return rc;
|
---|
858 | if (u32 != ~0U)
|
---|
859 | {
|
---|
860 | AssertMsgFailed(("u32=%#x\n", u32));
|
---|
861 | return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
|
---|
862 | }
|
---|
863 | return VINF_SUCCESS;
|
---|
864 | }
|
---|
865 |
|
---|
866 |
|
---|
867 | /**
|
---|
868 | * Resolve a builtin RC symbol.
|
---|
869 | *
|
---|
870 | * Called by PDM when loading or relocating RC modules.
|
---|
871 | *
|
---|
872 | * @returns VBox status
|
---|
873 | * @param pVM VM Handle.
|
---|
874 | * @param pszSymbol Symbol to resolv
|
---|
875 | * @param pRCPtrValue Where to store the symbol value.
|
---|
876 | *
|
---|
877 | * @remark This has to work before VMMR3Relocate() is called.
|
---|
878 | */
|
---|
879 | VMMR3DECL(int) VMMR3GetImportRC(PVM pVM, const char *pszSymbol, PRTRCPTR pRCPtrValue)
|
---|
880 | {
|
---|
881 | if (!strcmp(pszSymbol, "g_Logger"))
|
---|
882 | {
|
---|
883 | if (pVM->vmm.s.pRCLoggerR3)
|
---|
884 | pVM->vmm.s.pRCLoggerRC = MMHyperR3ToRC(pVM, pVM->vmm.s.pRCLoggerR3);
|
---|
885 | *pRCPtrValue = pVM->vmm.s.pRCLoggerRC;
|
---|
886 | }
|
---|
887 | else if (!strcmp(pszSymbol, "g_RelLogger"))
|
---|
888 | {
|
---|
889 | #ifdef VBOX_WITH_RC_RELEASE_LOGGING
|
---|
890 | if (pVM->vmm.s.pRCRelLoggerR3)
|
---|
891 | pVM->vmm.s.pRCRelLoggerRC = MMHyperR3ToRC(pVM, pVM->vmm.s.pRCRelLoggerR3);
|
---|
892 | *pRCPtrValue = pVM->vmm.s.pRCRelLoggerRC;
|
---|
893 | #else
|
---|
894 | *pRCPtrValue = NIL_RTRCPTR;
|
---|
895 | #endif
|
---|
896 | }
|
---|
897 | else
|
---|
898 | return VERR_SYMBOL_NOT_FOUND;
|
---|
899 | return VINF_SUCCESS;
|
---|
900 | }
|
---|
901 |
|
---|
902 |
|
---|
903 | /**
|
---|
904 | * Suspends the CPU yielder.
|
---|
905 | *
|
---|
906 | * @param pVM The VM handle.
|
---|
907 | */
|
---|
908 | VMMR3DECL(void) VMMR3YieldSuspend(PVM pVM)
|
---|
909 | {
|
---|
910 | if (!pVM->vmm.s.cYieldResumeMillies)
|
---|
911 | {
|
---|
912 | uint64_t u64Now = TMTimerGet(pVM->vmm.s.pYieldTimer);
|
---|
913 | uint64_t u64Expire = TMTimerGetExpire(pVM->vmm.s.pYieldTimer);
|
---|
914 | if (u64Now >= u64Expire || u64Expire == ~(uint64_t)0)
|
---|
915 | pVM->vmm.s.cYieldResumeMillies = pVM->vmm.s.cYieldEveryMillies;
|
---|
916 | else
|
---|
917 | pVM->vmm.s.cYieldResumeMillies = TMTimerToMilli(pVM->vmm.s.pYieldTimer, u64Expire - u64Now);
|
---|
918 | TMTimerStop(pVM->vmm.s.pYieldTimer);
|
---|
919 | }
|
---|
920 | pVM->vmm.s.u64LastYield = RTTimeNanoTS();
|
---|
921 | }
|
---|
922 |
|
---|
923 |
|
---|
924 | /**
|
---|
925 | * Stops the CPU yielder.
|
---|
926 | *
|
---|
927 | * @param pVM The VM handle.
|
---|
928 | */
|
---|
929 | VMMR3DECL(void) VMMR3YieldStop(PVM pVM)
|
---|
930 | {
|
---|
931 | if (!pVM->vmm.s.cYieldResumeMillies)
|
---|
932 | TMTimerStop(pVM->vmm.s.pYieldTimer);
|
---|
933 | pVM->vmm.s.cYieldResumeMillies = pVM->vmm.s.cYieldEveryMillies;
|
---|
934 | pVM->vmm.s.u64LastYield = RTTimeNanoTS();
|
---|
935 | }
|
---|
936 |
|
---|
937 |
|
---|
938 | /**
|
---|
939 | * Resumes the CPU yielder when it has been a suspended or stopped.
|
---|
940 | *
|
---|
941 | * @param pVM The VM handle.
|
---|
942 | */
|
---|
943 | VMMR3DECL(void) VMMR3YieldResume(PVM pVM)
|
---|
944 | {
|
---|
945 | if (pVM->vmm.s.cYieldResumeMillies)
|
---|
946 | {
|
---|
947 | TMTimerSetMillies(pVM->vmm.s.pYieldTimer, pVM->vmm.s.cYieldResumeMillies);
|
---|
948 | pVM->vmm.s.cYieldResumeMillies = 0;
|
---|
949 | }
|
---|
950 | }
|
---|
951 |
|
---|
952 |
|
---|
953 | /**
|
---|
954 | * Internal timer callback function.
|
---|
955 | *
|
---|
956 | * @param pVM The VM.
|
---|
957 | * @param pTimer The timer handle.
|
---|
958 | * @param pvUser User argument specified upon timer creation.
|
---|
959 | */
|
---|
960 | static DECLCALLBACK(void) vmmR3YieldEMT(PVM pVM, PTMTIMER pTimer, void *pvUser)
|
---|
961 | {
|
---|
962 | /*
|
---|
963 | * This really needs some careful tuning. While we shouldn't be too greedy since
|
---|
964 | * that'll cause the rest of the system to stop up, we shouldn't be too nice either
|
---|
965 | * because that'll cause us to stop up.
|
---|
966 | *
|
---|
967 | * The current logic is to use the default interval when there is no lag worth
|
---|
968 | * mentioning, but when we start accumulating lag we don't bother yielding at all.
|
---|
969 | *
|
---|
970 | * (This depends on the TMCLOCK_VIRTUAL_SYNC to be scheduled before TMCLOCK_REAL
|
---|
971 | * so the lag is up to date.)
|
---|
972 | */
|
---|
973 | const uint64_t u64Lag = TMVirtualSyncGetLag(pVM);
|
---|
974 | if ( u64Lag < 50000000 /* 50ms */
|
---|
975 | || ( u64Lag < 1000000000 /* 1s */
|
---|
976 | && RTTimeNanoTS() - pVM->vmm.s.u64LastYield < 500000000 /* 500 ms */)
|
---|
977 | )
|
---|
978 | {
|
---|
979 | uint64_t u64Elapsed = RTTimeNanoTS();
|
---|
980 | pVM->vmm.s.u64LastYield = u64Elapsed;
|
---|
981 |
|
---|
982 | RTThreadYield();
|
---|
983 |
|
---|
984 | #ifdef LOG_ENABLED
|
---|
985 | u64Elapsed = RTTimeNanoTS() - u64Elapsed;
|
---|
986 | Log(("vmmR3YieldEMT: %RI64 ns\n", u64Elapsed));
|
---|
987 | #endif
|
---|
988 | }
|
---|
989 | TMTimerSetMillies(pTimer, pVM->vmm.s.cYieldEveryMillies);
|
---|
990 | }
|
---|
991 |
|
---|
992 |
|
---|
993 | /**
|
---|
994 | * Acquire global VM lock.
|
---|
995 | *
|
---|
996 | * @returns VBox status code
|
---|
997 | * @param pVM The VM to operate on.
|
---|
998 | *
|
---|
999 | * @remarks The global VMM lock isn't really used for anything any longer.
|
---|
1000 | */
|
---|
1001 | VMMR3DECL(int) VMMR3Lock(PVM pVM)
|
---|
1002 | {
|
---|
1003 | return RTCritSectEnter(&pVM->vmm.s.CritSectVMLock);
|
---|
1004 | }
|
---|
1005 |
|
---|
1006 |
|
---|
1007 | /**
|
---|
1008 | * Release global VM lock.
|
---|
1009 | *
|
---|
1010 | * @returns VBox status code
|
---|
1011 | * @param pVM The VM to operate on.
|
---|
1012 | *
|
---|
1013 | * @remarks The global VMM lock isn't really used for anything any longer.
|
---|
1014 | */
|
---|
1015 | VMMR3DECL(int) VMMR3Unlock(PVM pVM)
|
---|
1016 | {
|
---|
1017 | return RTCritSectLeave(&pVM->vmm.s.CritSectVMLock);
|
---|
1018 | }
|
---|
1019 |
|
---|
1020 |
|
---|
1021 | /**
|
---|
1022 | * Return global VM lock owner.
|
---|
1023 | *
|
---|
1024 | * @returns Thread id of owner.
|
---|
1025 | * @returns NIL_RTTHREAD if no owner.
|
---|
1026 | * @param pVM The VM to operate on.
|
---|
1027 | *
|
---|
1028 | * @remarks The global VMM lock isn't really used for anything any longer.
|
---|
1029 | */
|
---|
1030 | VMMR3DECL(RTNATIVETHREAD) VMMR3LockGetOwner(PVM pVM)
|
---|
1031 | {
|
---|
1032 | return RTCritSectGetOwner(&pVM->vmm.s.CritSectVMLock);
|
---|
1033 | }
|
---|
1034 |
|
---|
1035 |
|
---|
1036 | /**
|
---|
1037 | * Checks if the current thread is the owner of the global VM lock.
|
---|
1038 | *
|
---|
1039 | * @returns true if owner.
|
---|
1040 | * @returns false if not owner.
|
---|
1041 | * @param pVM The VM to operate on.
|
---|
1042 | *
|
---|
1043 | * @remarks The global VMM lock isn't really used for anything any longer.
|
---|
1044 | */
|
---|
1045 | VMMR3DECL(bool) VMMR3LockIsOwner(PVM pVM)
|
---|
1046 | {
|
---|
1047 | return RTCritSectIsOwner(&pVM->vmm.s.CritSectVMLock);
|
---|
1048 | }
|
---|
1049 |
|
---|
1050 |
|
---|
1051 | /**
|
---|
1052 | * Executes guest code in the raw-mode context.
|
---|
1053 | *
|
---|
1054 | * @param pVM VM handle.
|
---|
1055 | */
|
---|
1056 | VMMR3DECL(int) VMMR3RawRunGC(PVM pVM)
|
---|
1057 | {
|
---|
1058 | Log2(("VMMR3RawRunGC: (cs:eip=%04x:%08x)\n", CPUMGetGuestCS(pVM), CPUMGetGuestEIP(pVM)));
|
---|
1059 |
|
---|
1060 | /*
|
---|
1061 | * Set the EIP and ESP.
|
---|
1062 | */
|
---|
1063 | CPUMSetHyperEIP(pVM, CPUMGetGuestEFlags(pVM) & X86_EFL_VM
|
---|
1064 | ? pVM->vmm.s.pfnCPUMRCResumeGuestV86
|
---|
1065 | : pVM->vmm.s.pfnCPUMRCResumeGuest);
|
---|
1066 | CPUMSetHyperESP(pVM, pVM->vmm.s.pbEMTStackBottomRC);
|
---|
1067 |
|
---|
1068 | /*
|
---|
1069 | * We hide log flushes (outer) and hypervisor interrupts (inner).
|
---|
1070 | */
|
---|
1071 | for (;;)
|
---|
1072 | {
|
---|
1073 | int rc;
|
---|
1074 | do
|
---|
1075 | {
|
---|
1076 | #ifdef NO_SUPCALLR0VMM
|
---|
1077 | rc = VERR_GENERAL_FAILURE;
|
---|
1078 | #else
|
---|
1079 | rc = SUPCallVMMR0Fast(pVM->pVMR0, VMMR0_DO_RAW_RUN, 0);
|
---|
1080 | if (RT_LIKELY(rc == VINF_SUCCESS))
|
---|
1081 | rc = pVM->vmm.s.iLastGZRc;
|
---|
1082 | #endif
|
---|
1083 | } while (rc == VINF_EM_RAW_INTERRUPT_HYPER);
|
---|
1084 |
|
---|
1085 | /*
|
---|
1086 | * Flush the logs.
|
---|
1087 | */
|
---|
1088 | #ifdef LOG_ENABLED
|
---|
1089 | PRTLOGGERRC pLogger = pVM->vmm.s.pRCLoggerR3;
|
---|
1090 | if ( pLogger
|
---|
1091 | && pLogger->offScratch > 0)
|
---|
1092 | RTLogFlushRC(NULL, pLogger);
|
---|
1093 | #endif
|
---|
1094 | #ifdef VBOX_WITH_RC_RELEASE_LOGGING
|
---|
1095 | PRTLOGGERRC pRelLogger = pVM->vmm.s.pRCRelLoggerR3;
|
---|
1096 | if (RT_UNLIKELY(pRelLogger && pRelLogger->offScratch > 0))
|
---|
1097 | RTLogFlushRC(RTLogRelDefaultInstance(), pRelLogger);
|
---|
1098 | #endif
|
---|
1099 | if (rc != VINF_VMM_CALL_HOST)
|
---|
1100 | {
|
---|
1101 | Log2(("VMMR3RawRunGC: returns %Rrc (cs:eip=%04x:%08x)\n", rc, CPUMGetGuestCS(pVM), CPUMGetGuestEIP(pVM)));
|
---|
1102 | return rc;
|
---|
1103 | }
|
---|
1104 | rc = vmmR3ServiceCallHostRequest(pVM);
|
---|
1105 | if (RT_FAILURE(rc))
|
---|
1106 | return rc;
|
---|
1107 | /* Resume GC */
|
---|
1108 | }
|
---|
1109 | }
|
---|
1110 |
|
---|
1111 |
|
---|
1112 | /**
|
---|
1113 | * Executes guest code (Intel VT-x and AMD-V).
|
---|
1114 | *
|
---|
1115 | * @param pVM VM handle.
|
---|
1116 | * @param idCpu VMCPU id.
|
---|
1117 | */
|
---|
1118 | VMMR3DECL(int) VMMR3HwAccRunGC(PVM pVM, RTCPUID idCpu)
|
---|
1119 | {
|
---|
1120 | Log2(("VMMR3HwAccRunGC: (cs:eip=%04x:%08x)\n", CPUMGetGuestCS(pVM), CPUMGetGuestEIP(pVM)));
|
---|
1121 |
|
---|
1122 | for (;;)
|
---|
1123 | {
|
---|
1124 | int rc;
|
---|
1125 | do
|
---|
1126 | {
|
---|
1127 | #ifdef NO_SUPCALLR0VMM
|
---|
1128 | rc = VERR_GENERAL_FAILURE;
|
---|
1129 | #else
|
---|
1130 | rc = SUPCallVMMR0Fast(pVM->pVMR0, VMMR0_DO_HWACC_RUN, idCpu);
|
---|
1131 | if (RT_LIKELY(rc == VINF_SUCCESS))
|
---|
1132 | rc = pVM->vmm.s.iLastGZRc;
|
---|
1133 | #endif
|
---|
1134 | } while (rc == VINF_EM_RAW_INTERRUPT_HYPER);
|
---|
1135 |
|
---|
1136 | #ifdef LOG_ENABLED
|
---|
1137 | /*
|
---|
1138 | * Flush the log
|
---|
1139 | */
|
---|
1140 | PVMMR0LOGGER pR0LoggerR3 = pVM->vmm.s.pR0LoggerR3;
|
---|
1141 | if ( pR0LoggerR3
|
---|
1142 | && pR0LoggerR3->Logger.offScratch > 0)
|
---|
1143 | RTLogFlushToLogger(&pR0LoggerR3->Logger, NULL);
|
---|
1144 | #endif /* !LOG_ENABLED */
|
---|
1145 | if (rc != VINF_VMM_CALL_HOST)
|
---|
1146 | {
|
---|
1147 | Log2(("VMMR3HwAccRunGC: returns %Rrc (cs:eip=%04x:%08x)\n", rc, CPUMGetGuestCS(pVM), CPUMGetGuestEIP(pVM)));
|
---|
1148 | return rc;
|
---|
1149 | }
|
---|
1150 | rc = vmmR3ServiceCallHostRequest(pVM);
|
---|
1151 | if (RT_FAILURE(rc))
|
---|
1152 | return rc;
|
---|
1153 | /* Resume R0 */
|
---|
1154 | }
|
---|
1155 | }
|
---|
1156 |
|
---|
1157 |
|
---|
1158 | /**
|
---|
1159 | * Calls a RC function.
|
---|
1160 | *
|
---|
1161 | * @param pVM The VM handle.
|
---|
1162 | * @param RCPtrEntry The address of the RC function.
|
---|
1163 | * @param cArgs The number of arguments in the ....
|
---|
1164 | * @param ... Arguments to the function.
|
---|
1165 | */
|
---|
1166 | VMMR3DECL(int) VMMR3CallRC(PVM pVM, RTRCPTR RCPtrEntry, unsigned cArgs, ...)
|
---|
1167 | {
|
---|
1168 | va_list args;
|
---|
1169 | va_start(args, cArgs);
|
---|
1170 | int rc = VMMR3CallRCV(pVM, RCPtrEntry, cArgs, args);
|
---|
1171 | va_end(args);
|
---|
1172 | return rc;
|
---|
1173 | }
|
---|
1174 |
|
---|
1175 |
|
---|
1176 | /**
|
---|
1177 | * Calls a RC function.
|
---|
1178 | *
|
---|
1179 | * @param pVM The VM handle.
|
---|
1180 | * @param RCPtrEntry The address of the RC function.
|
---|
1181 | * @param cArgs The number of arguments in the ....
|
---|
1182 | * @param args Arguments to the function.
|
---|
1183 | */
|
---|
1184 | VMMR3DECL(int) VMMR3CallRCV(PVM pVM, RTRCPTR RCPtrEntry, unsigned cArgs, va_list args)
|
---|
1185 | {
|
---|
1186 | Log2(("VMMR3CallGCV: RCPtrEntry=%RRv cArgs=%d\n", RCPtrEntry, cArgs));
|
---|
1187 |
|
---|
1188 | /*
|
---|
1189 | * Setup the call frame using the trampoline.
|
---|
1190 | */
|
---|
1191 | CPUMHyperSetCtxCore(pVM, NULL);
|
---|
1192 | memset(pVM->vmm.s.pbEMTStackR3, 0xaa, VMM_STACK_SIZE); /* Clear the stack. */
|
---|
1193 | CPUMSetHyperESP(pVM, pVM->vmm.s.pbEMTStackBottomRC - cArgs * sizeof(RTGCUINTPTR32));
|
---|
1194 | PRTGCUINTPTR32 pFrame = (PRTGCUINTPTR32)(pVM->vmm.s.pbEMTStackR3 + VMM_STACK_SIZE) - cArgs;
|
---|
1195 | int i = cArgs;
|
---|
1196 | while (i-- > 0)
|
---|
1197 | *pFrame++ = va_arg(args, RTGCUINTPTR32);
|
---|
1198 |
|
---|
1199 | CPUMPushHyper(pVM, cArgs * sizeof(RTGCUINTPTR32)); /* stack frame size */
|
---|
1200 | CPUMPushHyper(pVM, RCPtrEntry); /* what to call */
|
---|
1201 | CPUMSetHyperEIP(pVM, pVM->vmm.s.pfnCallTrampolineRC);
|
---|
1202 |
|
---|
1203 | /*
|
---|
1204 | * We hide log flushes (outer) and hypervisor interrupts (inner).
|
---|
1205 | */
|
---|
1206 | for (;;)
|
---|
1207 | {
|
---|
1208 | int rc;
|
---|
1209 | do
|
---|
1210 | {
|
---|
1211 | #ifdef NO_SUPCALLR0VMM
|
---|
1212 | rc = VERR_GENERAL_FAILURE;
|
---|
1213 | #else
|
---|
1214 | rc = SUPCallVMMR0Fast(pVM->pVMR0, VMMR0_DO_RAW_RUN, 0);
|
---|
1215 | if (RT_LIKELY(rc == VINF_SUCCESS))
|
---|
1216 | rc = pVM->vmm.s.iLastGZRc;
|
---|
1217 | #endif
|
---|
1218 | } while (rc == VINF_EM_RAW_INTERRUPT_HYPER);
|
---|
1219 |
|
---|
1220 | /*
|
---|
1221 | * Flush the logs.
|
---|
1222 | */
|
---|
1223 | #ifdef LOG_ENABLED
|
---|
1224 | PRTLOGGERRC pLogger = pVM->vmm.s.pRCLoggerR3;
|
---|
1225 | if ( pLogger
|
---|
1226 | && pLogger->offScratch > 0)
|
---|
1227 | RTLogFlushRC(NULL, pLogger);
|
---|
1228 | #endif
|
---|
1229 | #ifdef VBOX_WITH_RC_RELEASE_LOGGING
|
---|
1230 | PRTLOGGERRC pRelLogger = pVM->vmm.s.pRCRelLoggerR3;
|
---|
1231 | if (RT_UNLIKELY(pRelLogger && pRelLogger->offScratch > 0))
|
---|
1232 | RTLogFlushRC(RTLogRelDefaultInstance(), pRelLogger);
|
---|
1233 | #endif
|
---|
1234 | if (rc == VERR_TRPM_PANIC || rc == VERR_TRPM_DONT_PANIC)
|
---|
1235 | VMMR3FatalDump(pVM, rc);
|
---|
1236 | if (rc != VINF_VMM_CALL_HOST)
|
---|
1237 | {
|
---|
1238 | Log2(("VMMR3CallGCV: returns %Rrc (cs:eip=%04x:%08x)\n", rc, CPUMGetGuestCS(pVM), CPUMGetGuestEIP(pVM)));
|
---|
1239 | return rc;
|
---|
1240 | }
|
---|
1241 | rc = vmmR3ServiceCallHostRequest(pVM);
|
---|
1242 | if (RT_FAILURE(rc))
|
---|
1243 | return rc;
|
---|
1244 | }
|
---|
1245 | }
|
---|
1246 |
|
---|
1247 |
|
---|
1248 | /**
|
---|
1249 | * Resumes executing hypervisor code when interrupted by a queue flush or a
|
---|
1250 | * debug event.
|
---|
1251 | *
|
---|
1252 | * @returns VBox status code.
|
---|
1253 | * @param pVM VM handle.
|
---|
1254 | */
|
---|
1255 | VMMR3DECL(int) VMMR3ResumeHyper(PVM pVM)
|
---|
1256 | {
|
---|
1257 | Log(("VMMR3ResumeHyper: eip=%RRv esp=%RRv\n", CPUMGetHyperEIP(pVM), CPUMGetHyperESP(pVM)));
|
---|
1258 |
|
---|
1259 | /*
|
---|
1260 | * We hide log flushes (outer) and hypervisor interrupts (inner).
|
---|
1261 | */
|
---|
1262 | for (;;)
|
---|
1263 | {
|
---|
1264 | int rc;
|
---|
1265 | do
|
---|
1266 | {
|
---|
1267 | #ifdef NO_SUPCALLR0VMM
|
---|
1268 | rc = VERR_GENERAL_FAILURE;
|
---|
1269 | #else
|
---|
1270 | rc = SUPCallVMMR0Fast(pVM->pVMR0, VMMR0_DO_RAW_RUN, 0);
|
---|
1271 | if (RT_LIKELY(rc == VINF_SUCCESS))
|
---|
1272 | rc = pVM->vmm.s.iLastGZRc;
|
---|
1273 | #endif
|
---|
1274 | } while (rc == VINF_EM_RAW_INTERRUPT_HYPER);
|
---|
1275 |
|
---|
1276 | /*
|
---|
1277 | * Flush the loggers,
|
---|
1278 | */
|
---|
1279 | #ifdef LOG_ENABLED
|
---|
1280 | PRTLOGGERRC pLogger = pVM->vmm.s.pRCLoggerR3;
|
---|
1281 | if ( pLogger
|
---|
1282 | && pLogger->offScratch > 0)
|
---|
1283 | RTLogFlushRC(NULL, pLogger);
|
---|
1284 | #endif
|
---|
1285 | #ifdef VBOX_WITH_RC_RELEASE_LOGGING
|
---|
1286 | PRTLOGGERRC pRelLogger = pVM->vmm.s.pRCRelLoggerR3;
|
---|
1287 | if (RT_UNLIKELY(pRelLogger && pRelLogger->offScratch > 0))
|
---|
1288 | RTLogFlushRC(RTLogRelDefaultInstance(), pRelLogger);
|
---|
1289 | #endif
|
---|
1290 | if (rc == VERR_TRPM_PANIC || rc == VERR_TRPM_DONT_PANIC)
|
---|
1291 | VMMR3FatalDump(pVM, rc);
|
---|
1292 | if (rc != VINF_VMM_CALL_HOST)
|
---|
1293 | {
|
---|
1294 | Log(("VMMR3ResumeHyper: returns %Rrc\n", rc));
|
---|
1295 | return rc;
|
---|
1296 | }
|
---|
1297 | rc = vmmR3ServiceCallHostRequest(pVM);
|
---|
1298 | if (RT_FAILURE(rc))
|
---|
1299 | return rc;
|
---|
1300 | }
|
---|
1301 | }
|
---|
1302 |
|
---|
1303 |
|
---|
1304 | /**
|
---|
1305 | * Service a call to the ring-3 host code.
|
---|
1306 | *
|
---|
1307 | * @returns VBox status code.
|
---|
1308 | * @param pVM VM handle.
|
---|
1309 | * @remark Careful with critsects.
|
---|
1310 | */
|
---|
1311 | static int vmmR3ServiceCallHostRequest(PVM pVM)
|
---|
1312 | {
|
---|
1313 | switch (pVM->vmm.s.enmCallHostOperation)
|
---|
1314 | {
|
---|
1315 | /*
|
---|
1316 | * Acquire the PDM lock.
|
---|
1317 | */
|
---|
1318 | case VMMCALLHOST_PDM_LOCK:
|
---|
1319 | {
|
---|
1320 | pVM->vmm.s.rcCallHost = PDMR3LockCall(pVM);
|
---|
1321 | break;
|
---|
1322 | }
|
---|
1323 |
|
---|
1324 | /*
|
---|
1325 | * Flush a PDM queue.
|
---|
1326 | */
|
---|
1327 | case VMMCALLHOST_PDM_QUEUE_FLUSH:
|
---|
1328 | {
|
---|
1329 | PDMR3QueueFlushWorker(pVM, NULL);
|
---|
1330 | pVM->vmm.s.rcCallHost = VINF_SUCCESS;
|
---|
1331 | break;
|
---|
1332 | }
|
---|
1333 |
|
---|
1334 | /*
|
---|
1335 | * Grow the PGM pool.
|
---|
1336 | */
|
---|
1337 | case VMMCALLHOST_PGM_POOL_GROW:
|
---|
1338 | {
|
---|
1339 | pVM->vmm.s.rcCallHost = PGMR3PoolGrow(pVM);
|
---|
1340 | break;
|
---|
1341 | }
|
---|
1342 |
|
---|
1343 | /*
|
---|
1344 | * Maps an page allocation chunk into ring-3 so ring-0 can use it.
|
---|
1345 | */
|
---|
1346 | case VMMCALLHOST_PGM_MAP_CHUNK:
|
---|
1347 | {
|
---|
1348 | pVM->vmm.s.rcCallHost = PGMR3PhysChunkMap(pVM, pVM->vmm.s.u64CallHostArg);
|
---|
1349 | break;
|
---|
1350 | }
|
---|
1351 |
|
---|
1352 | /*
|
---|
1353 | * Allocates more handy pages.
|
---|
1354 | */
|
---|
1355 | case VMMCALLHOST_PGM_ALLOCATE_HANDY_PAGES:
|
---|
1356 | {
|
---|
1357 | pVM->vmm.s.rcCallHost = PGMR3PhysAllocateHandyPages(pVM);
|
---|
1358 | break;
|
---|
1359 | }
|
---|
1360 | #ifndef VBOX_WITH_NEW_PHYS_CODE
|
---|
1361 |
|
---|
1362 | case VMMCALLHOST_PGM_RAM_GROW_RANGE:
|
---|
1363 | {
|
---|
1364 | const RTGCPHYS GCPhys = pVM->vmm.s.u64CallHostArg;
|
---|
1365 | pVM->vmm.s.rcCallHost = PGM3PhysGrowRange(pVM, &GCPhys);
|
---|
1366 | break;
|
---|
1367 | }
|
---|
1368 | #endif
|
---|
1369 |
|
---|
1370 | /*
|
---|
1371 | * Acquire the PGM lock.
|
---|
1372 | */
|
---|
1373 | case VMMCALLHOST_PGM_LOCK:
|
---|
1374 | {
|
---|
1375 | pVM->vmm.s.rcCallHost = PGMR3LockCall(pVM);
|
---|
1376 | break;
|
---|
1377 | }
|
---|
1378 |
|
---|
1379 | /*
|
---|
1380 | * Flush REM handler notifications.
|
---|
1381 | */
|
---|
1382 | case VMMCALLHOST_REM_REPLAY_HANDLER_NOTIFICATIONS:
|
---|
1383 | {
|
---|
1384 | REMR3ReplayHandlerNotifications(pVM);
|
---|
1385 | pVM->vmm.s.rcCallHost = VINF_SUCCESS;
|
---|
1386 | break;
|
---|
1387 | }
|
---|
1388 |
|
---|
1389 | /*
|
---|
1390 | * This is a noop. We just take this route to avoid unnecessary
|
---|
1391 | * tests in the loops.
|
---|
1392 | */
|
---|
1393 | case VMMCALLHOST_VMM_LOGGER_FLUSH:
|
---|
1394 | pVM->vmm.s.rcCallHost = VINF_SUCCESS;
|
---|
1395 | break;
|
---|
1396 |
|
---|
1397 | /*
|
---|
1398 | * Set the VM error message.
|
---|
1399 | */
|
---|
1400 | case VMMCALLHOST_VM_SET_ERROR:
|
---|
1401 | VMR3SetErrorWorker(pVM);
|
---|
1402 | pVM->vmm.s.rcCallHost = VINF_SUCCESS;
|
---|
1403 | break;
|
---|
1404 |
|
---|
1405 | /*
|
---|
1406 | * Set the VM runtime error message.
|
---|
1407 | */
|
---|
1408 | case VMMCALLHOST_VM_SET_RUNTIME_ERROR:
|
---|
1409 | VMR3SetRuntimeErrorWorker(pVM);
|
---|
1410 | pVM->vmm.s.rcCallHost = VINF_SUCCESS;
|
---|
1411 | break;
|
---|
1412 |
|
---|
1413 | /*
|
---|
1414 | * Signal a ring 0 hypervisor assertion.
|
---|
1415 | * Cancel the longjmp operation that's in progress.
|
---|
1416 | */
|
---|
1417 | case VMMCALLHOST_VM_R0_ASSERTION:
|
---|
1418 | pVM->vmm.s.enmCallHostOperation = VMMCALLHOST_INVALID;
|
---|
1419 | pVM->vmm.s.CallHostR0JmpBuf.fInRing3Call = false;
|
---|
1420 | #ifdef RT_ARCH_X86
|
---|
1421 | pVM->vmm.s.CallHostR0JmpBuf.eip = 0;
|
---|
1422 | #else
|
---|
1423 | pVM->vmm.s.CallHostR0JmpBuf.rip = 0;
|
---|
1424 | #endif
|
---|
1425 | LogRel((pVM->vmm.s.szRing0AssertMsg1));
|
---|
1426 | LogRel((pVM->vmm.s.szRing0AssertMsg2));
|
---|
1427 | return VERR_VMM_RING0_ASSERTION;
|
---|
1428 |
|
---|
1429 | default:
|
---|
1430 | AssertMsgFailed(("enmCallHostOperation=%d\n", pVM->vmm.s.enmCallHostOperation));
|
---|
1431 | return VERR_INTERNAL_ERROR;
|
---|
1432 | }
|
---|
1433 |
|
---|
1434 | pVM->vmm.s.enmCallHostOperation = VMMCALLHOST_INVALID;
|
---|
1435 | return VINF_SUCCESS;
|
---|
1436 | }
|
---|
1437 |
|
---|
1438 |
|
---|
1439 | /**
|
---|
1440 | * Displays the Force action Flags.
|
---|
1441 | *
|
---|
1442 | * @param pVM The VM handle.
|
---|
1443 | * @param pHlp The output helpers.
|
---|
1444 | * @param pszArgs The additional arguments (ignored).
|
---|
1445 | */
|
---|
1446 | static DECLCALLBACK(void) vmmR3InfoFF(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs)
|
---|
1447 | {
|
---|
1448 | const uint32_t fForcedActions = pVM->fForcedActions;
|
---|
1449 |
|
---|
1450 | pHlp->pfnPrintf(pHlp, "Forced action Flags: %#RX32", fForcedActions);
|
---|
1451 |
|
---|
1452 | /* show the flag mnemonics */
|
---|
1453 | int c = 0;
|
---|
1454 | uint32_t f = fForcedActions;
|
---|
1455 | #define PRINT_FLAG(flag) do { \
|
---|
1456 | if (f & (flag)) \
|
---|
1457 | { \
|
---|
1458 | static const char *s_psz = #flag; \
|
---|
1459 | if (!(c % 6)) \
|
---|
1460 | pHlp->pfnPrintf(pHlp, "%s\n %s", c ? "," : "", s_psz + 6); \
|
---|
1461 | else \
|
---|
1462 | pHlp->pfnPrintf(pHlp, ", %s", s_psz + 6); \
|
---|
1463 | c++; \
|
---|
1464 | f &= ~(flag); \
|
---|
1465 | } \
|
---|
1466 | } while (0)
|
---|
1467 | PRINT_FLAG(VM_FF_INTERRUPT_APIC);
|
---|
1468 | PRINT_FLAG(VM_FF_INTERRUPT_PIC);
|
---|
1469 | PRINT_FLAG(VM_FF_TIMER);
|
---|
1470 | PRINT_FLAG(VM_FF_PDM_QUEUES);
|
---|
1471 | PRINT_FLAG(VM_FF_PDM_DMA);
|
---|
1472 | PRINT_FLAG(VM_FF_PDM_CRITSECT);
|
---|
1473 | PRINT_FLAG(VM_FF_DBGF);
|
---|
1474 | PRINT_FLAG(VM_FF_REQUEST);
|
---|
1475 | PRINT_FLAG(VM_FF_TERMINATE);
|
---|
1476 | PRINT_FLAG(VM_FF_RESET);
|
---|
1477 | PRINT_FLAG(VM_FF_PGM_SYNC_CR3);
|
---|
1478 | PRINT_FLAG(VM_FF_PGM_SYNC_CR3_NON_GLOBAL);
|
---|
1479 | PRINT_FLAG(VM_FF_TRPM_SYNC_IDT);
|
---|
1480 | PRINT_FLAG(VM_FF_SELM_SYNC_TSS);
|
---|
1481 | PRINT_FLAG(VM_FF_SELM_SYNC_GDT);
|
---|
1482 | PRINT_FLAG(VM_FF_SELM_SYNC_LDT);
|
---|
1483 | PRINT_FLAG(VM_FF_INHIBIT_INTERRUPTS);
|
---|
1484 | PRINT_FLAG(VM_FF_CSAM_SCAN_PAGE);
|
---|
1485 | PRINT_FLAG(VM_FF_CSAM_PENDING_ACTION);
|
---|
1486 | PRINT_FLAG(VM_FF_TO_R3);
|
---|
1487 | PRINT_FLAG(VM_FF_DEBUG_SUSPEND);
|
---|
1488 | if (f)
|
---|
1489 | pHlp->pfnPrintf(pHlp, "%s\n Unknown bits: %#RX32\n", c ? "," : "", f);
|
---|
1490 | else
|
---|
1491 | pHlp->pfnPrintf(pHlp, "\n");
|
---|
1492 | #undef PRINT_FLAG
|
---|
1493 |
|
---|
1494 | /* the groups */
|
---|
1495 | c = 0;
|
---|
1496 | #define PRINT_GROUP(grp) do { \
|
---|
1497 | if (fForcedActions & (grp)) \
|
---|
1498 | { \
|
---|
1499 | static const char *s_psz = #grp; \
|
---|
1500 | if (!(c % 5)) \
|
---|
1501 | pHlp->pfnPrintf(pHlp, "%s %s", c ? ",\n" : "Groups:\n", s_psz + 6); \
|
---|
1502 | else \
|
---|
1503 | pHlp->pfnPrintf(pHlp, ", %s", s_psz + 6); \
|
---|
1504 | c++; \
|
---|
1505 | } \
|
---|
1506 | } while (0)
|
---|
1507 | PRINT_GROUP(VM_FF_EXTERNAL_SUSPENDED_MASK);
|
---|
1508 | PRINT_GROUP(VM_FF_EXTERNAL_HALTED_MASK);
|
---|
1509 | PRINT_GROUP(VM_FF_HIGH_PRIORITY_PRE_MASK);
|
---|
1510 | PRINT_GROUP(VM_FF_HIGH_PRIORITY_PRE_RAW_MASK);
|
---|
1511 | PRINT_GROUP(VM_FF_HIGH_PRIORITY_POST_MASK);
|
---|
1512 | PRINT_GROUP(VM_FF_NORMAL_PRIORITY_POST_MASK);
|
---|
1513 | PRINT_GROUP(VM_FF_NORMAL_PRIORITY_MASK);
|
---|
1514 | PRINT_GROUP(VM_FF_RESUME_GUEST_MASK);
|
---|
1515 | PRINT_GROUP(VM_FF_ALL_BUT_RAW_MASK);
|
---|
1516 | if (c)
|
---|
1517 | pHlp->pfnPrintf(pHlp, "\n");
|
---|
1518 | #undef PRINT_GROUP
|
---|
1519 | }
|
---|
1520 |
|
---|