1 | /* $Id: VMMInternal.h 20545 2009-06-13 23:56:48Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VMM - Internal header file.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | * additional information or have any questions.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef ___VMMInternal_h
|
---|
23 | #define ___VMMInternal_h
|
---|
24 |
|
---|
25 | #include <VBox/cdefs.h>
|
---|
26 | #include <VBox/stam.h>
|
---|
27 | #include <VBox/log.h>
|
---|
28 | #include <iprt/critsect.h>
|
---|
29 |
|
---|
30 |
|
---|
31 | #if !defined(IN_VMM_R3) && !defined(IN_VMM_R0) && !defined(IN_VMM_RC)
|
---|
32 | # error "Not in VMM! This is an internal header!"
|
---|
33 | #endif
|
---|
34 |
|
---|
35 |
|
---|
36 | /** @defgroup grp_vmm_int Internals
|
---|
37 | * @ingroup grp_vmm
|
---|
38 | * @internal
|
---|
39 | * @{
|
---|
40 | */
|
---|
41 |
|
---|
42 | /** @def VBOX_WITH_RC_RELEASE_LOGGING
|
---|
43 | * Enables RC release logging. */
|
---|
44 | #define VBOX_WITH_RC_RELEASE_LOGGING
|
---|
45 |
|
---|
46 | /** @def VBOX_WITH_R0_LOGGING
|
---|
47 | * Enables Ring-0 logging (non-release).
|
---|
48 | *
|
---|
49 | * Ring-0 logging isn't 100% safe yet (thread id reuse / process exit cleanup),
|
---|
50 | * so you have to sign up here by adding your defined(DEBUG_<userid>) to the
|
---|
51 | * #if, or by adding VBOX_WITH_R0_LOGGING to your LocalConfig.kmk.
|
---|
52 | *
|
---|
53 | * You might also wish to enable the AssertMsg1/2 overrides in VMMR0.cpp when
|
---|
54 | * enabling this.
|
---|
55 | */
|
---|
56 | #if defined(DEBUG_sandervl) || defined(DEBUG_frank) || defined(DOXYGEN_RUNNING)
|
---|
57 | # define VBOX_WITH_R0_LOGGING
|
---|
58 | #endif
|
---|
59 |
|
---|
60 | /** @def VBOX_STRICT_VMM_STACK
|
---|
61 | * Enables VMM stack guard pages to catch stack over- and underruns. */
|
---|
62 | #if defined(VBOX_STRICT) || defined(DOXYGEN_RUNNING)
|
---|
63 | # define VBOX_STRICT_VMM_STACK
|
---|
64 | #endif
|
---|
65 |
|
---|
66 |
|
---|
67 | /**
|
---|
68 | * Converts a VMM pointer into a VM pointer.
|
---|
69 | * @returns Pointer to the VM structure the VMM is part of.
|
---|
70 | * @param pVMM Pointer to VMM instance data.
|
---|
71 | */
|
---|
72 | #define VMM2VM(pVMM) ( (PVM)((char*)pVMM - pVMM->offVM) )
|
---|
73 |
|
---|
74 |
|
---|
75 | /**
|
---|
76 | * Switcher function, HC to RC.
|
---|
77 | *
|
---|
78 | * @param pVM The VM handle.
|
---|
79 | * @returns Return code indicating the action to take.
|
---|
80 | */
|
---|
81 | typedef DECLASMTYPE(int) FNVMMSWITCHERHC(PVM pVM);
|
---|
82 | /** Pointer to switcher function. */
|
---|
83 | typedef FNVMMSWITCHERHC *PFNVMMSWITCHERHC;
|
---|
84 |
|
---|
85 | /**
|
---|
86 | * Switcher function, RC to HC.
|
---|
87 | *
|
---|
88 | * @param rc VBox status code.
|
---|
89 | */
|
---|
90 | typedef DECLASMTYPE(void) FNVMMSWITCHERRC(int rc);
|
---|
91 | /** Pointer to switcher function. */
|
---|
92 | typedef FNVMMSWITCHERRC *PFNVMMSWITCHERRC;
|
---|
93 |
|
---|
94 |
|
---|
95 | /**
|
---|
96 | * The ring-0 logger instance wrapper.
|
---|
97 | *
|
---|
98 | * We need to be able to find the VM handle from the logger instance, so we wrap
|
---|
99 | * it in this structure.
|
---|
100 | */
|
---|
101 | typedef struct VMMR0LOGGER
|
---|
102 | {
|
---|
103 | /** Pointer to the VM handle. */
|
---|
104 | R0PTRTYPE(PVM) pVM;
|
---|
105 | /** Size of the allocated logger instance (Logger). */
|
---|
106 | uint32_t cbLogger;
|
---|
107 | /** Flag indicating whether we've create the logger Ring-0 instance yet. */
|
---|
108 | bool fCreated;
|
---|
109 | /** Flag indicating whether we've disabled flushing (world switch) or not. */
|
---|
110 | bool fFlushingDisabled;
|
---|
111 | /** Flag indicating whether we've registered the instance already. */
|
---|
112 | bool fRegistered;
|
---|
113 | bool a8Alignment;
|
---|
114 | #if HC_ARCH_BITS == 32
|
---|
115 | uint32_t u32Alignment;
|
---|
116 | #endif
|
---|
117 | /** The ring-0 logger instance. This extends beyond the size. */
|
---|
118 | RTLOGGER Logger;
|
---|
119 | } VMMR0LOGGER;
|
---|
120 | /** Pointer to a ring-0 logger instance wrapper. */
|
---|
121 | typedef VMMR0LOGGER *PVMMR0LOGGER;
|
---|
122 |
|
---|
123 |
|
---|
124 | /**
|
---|
125 | * Jump buffer for the setjmp/longjmp like constructs used to
|
---|
126 | * quickly 'call' back into Ring-3.
|
---|
127 | */
|
---|
128 | typedef struct VMMR0JMPBUF
|
---|
129 | {
|
---|
130 | /** Traditional jmp_buf stuff
|
---|
131 | * @{ */
|
---|
132 | #if HC_ARCH_BITS == 32
|
---|
133 | uint32_t ebx;
|
---|
134 | uint32_t esi;
|
---|
135 | uint32_t edi;
|
---|
136 | uint32_t ebp;
|
---|
137 | uint32_t esp;
|
---|
138 | uint32_t eip;
|
---|
139 | uint32_t u32Padding;
|
---|
140 | #endif
|
---|
141 | #if HC_ARCH_BITS == 64
|
---|
142 | uint64_t rbx;
|
---|
143 | # ifdef RT_OS_WINDOWS
|
---|
144 | uint64_t rsi;
|
---|
145 | uint64_t rdi;
|
---|
146 | # endif
|
---|
147 | uint64_t rbp;
|
---|
148 | uint64_t r12;
|
---|
149 | uint64_t r13;
|
---|
150 | uint64_t r14;
|
---|
151 | uint64_t r15;
|
---|
152 | uint64_t rsp;
|
---|
153 | uint64_t rip;
|
---|
154 | #endif
|
---|
155 | /** @} */
|
---|
156 |
|
---|
157 | /** Flag that indicates that we've done a ring-3 call. */
|
---|
158 | bool fInRing3Call;
|
---|
159 | /** The number of bytes we've saved. */
|
---|
160 | uint32_t cbSavedStack;
|
---|
161 | /** Pointer to the buffer used to save the stack.
|
---|
162 | * This is assumed to be 8KB. */
|
---|
163 | RTR0PTR pvSavedStack;
|
---|
164 | /** Esp we we match against esp on resume to make sure the stack wasn't relocated. */
|
---|
165 | RTHCUINTREG SpCheck;
|
---|
166 | /** The esp we should resume execution with after the restore. */
|
---|
167 | RTHCUINTREG SpResume;
|
---|
168 | /** ESP/RSP at the time of the jump to ring 3. */
|
---|
169 | RTHCUINTREG SavedEsp;
|
---|
170 | /** EBP/RBP at the time of the jump to ring 3. */
|
---|
171 | RTHCUINTREG SavedEbp;
|
---|
172 |
|
---|
173 | /** Stats: Max amount of stack used. */
|
---|
174 | uint32_t cbUsedMax;
|
---|
175 | /** Stats: Average stack usage. (Avg = cbUsedTotal / cUsedTotal) */
|
---|
176 | uint32_t cbUsedAvg;
|
---|
177 | /** Stats: Total amount of stack used. */
|
---|
178 | uint64_t cbUsedTotal;
|
---|
179 | /** Stats: Number of stack usages. */
|
---|
180 | uint64_t cUsedTotal;
|
---|
181 | } VMMR0JMPBUF;
|
---|
182 | /** Pointer to a ring-0 jump buffer. */
|
---|
183 | typedef VMMR0JMPBUF *PVMMR0JMPBUF;
|
---|
184 |
|
---|
185 |
|
---|
186 | /**
|
---|
187 | * VMM Data (part of VM)
|
---|
188 | */
|
---|
189 | typedef struct VMM
|
---|
190 | {
|
---|
191 | /** Offset to the VM structure.
|
---|
192 | * See VMM2VM(). */
|
---|
193 | RTINT offVM;
|
---|
194 |
|
---|
195 | /** @name World Switcher and Related
|
---|
196 | * @{
|
---|
197 | */
|
---|
198 | /** Size of the core code. */
|
---|
199 | RTUINT cbCoreCode;
|
---|
200 | /** Physical address of core code. */
|
---|
201 | RTHCPHYS HCPhysCoreCode;
|
---|
202 | /** Pointer to core code ring-3 mapping - contiguous memory.
|
---|
203 | * At present this only means the context switcher code. */
|
---|
204 | RTR3PTR pvCoreCodeR3;
|
---|
205 | /** Pointer to core code ring-0 mapping - contiguous memory.
|
---|
206 | * At present this only means the context switcher code. */
|
---|
207 | RTR0PTR pvCoreCodeR0;
|
---|
208 | /** Pointer to core code guest context mapping. */
|
---|
209 | RTRCPTR pvCoreCodeRC;
|
---|
210 | RTRCPTR pRCPadding0; /**< Alignment padding */
|
---|
211 | #ifdef VBOX_WITH_NMI
|
---|
212 | /** The guest context address of the APIC (host) mapping. */
|
---|
213 | RTRCPTR GCPtrApicBase;
|
---|
214 | RTRCPTR pRCPadding1; /**< Alignment padding */
|
---|
215 | #endif
|
---|
216 | /** The current switcher.
|
---|
217 | * This will be set before the VMM is fully initialized. */
|
---|
218 | VMMSWITCHER enmSwitcher;
|
---|
219 | /** Flag to disable the switcher permanently (VMX) (boolean) */
|
---|
220 | bool fSwitcherDisabled;
|
---|
221 | /** Array of offsets to the different switchers within the core code. */
|
---|
222 | RTUINT aoffSwitchers[VMMSWITCHER_MAX];
|
---|
223 |
|
---|
224 | /** Resume Guest Execution. See CPUMGCResumeGuest(). */
|
---|
225 | RTRCPTR pfnCPUMRCResumeGuest;
|
---|
226 | /** Resume Guest Execution in V86 mode. See CPUMGCResumeGuestV86(). */
|
---|
227 | RTRCPTR pfnCPUMRCResumeGuestV86;
|
---|
228 | /** Call Trampoline. See vmmGCCallTrampoline(). */
|
---|
229 | RTRCPTR pfnCallTrampolineRC;
|
---|
230 | /** Guest to host switcher entry point. */
|
---|
231 | RCPTRTYPE(PFNVMMSWITCHERRC) pfnGuestToHostRC;
|
---|
232 | /** Host to guest switcher entry point. */
|
---|
233 | R0PTRTYPE(PFNVMMSWITCHERHC) pfnHostToGuestR0;
|
---|
234 | /** @} */
|
---|
235 |
|
---|
236 | /** @name Logging
|
---|
237 | * @{
|
---|
238 | */
|
---|
239 | /** Size of the allocated logger instance (pRCLoggerRC/pRCLoggerR3). */
|
---|
240 | uint32_t cbRCLogger;
|
---|
241 | /** Pointer to the RC logger instance - RC Ptr.
|
---|
242 | * This is NULL if logging is disabled. */
|
---|
243 | RCPTRTYPE(PRTLOGGERRC) pRCLoggerRC;
|
---|
244 | /** Pointer to the GC logger instance - R3 Ptr.
|
---|
245 | * This is NULL if logging is disabled. */
|
---|
246 | R3PTRTYPE(PRTLOGGERRC) pRCLoggerR3;
|
---|
247 | /** Pointer to the GC release logger instance - R3 Ptr. */
|
---|
248 | R3PTRTYPE(PRTLOGGERRC) pRCRelLoggerR3;
|
---|
249 | /** Pointer to the GC release logger instance - RC Ptr. */
|
---|
250 | RCPTRTYPE(PRTLOGGERRC) pRCRelLoggerRC;
|
---|
251 | /** Size of the allocated release logger instance (pRCRelLoggerRC/pRCRelLoggerR3).
|
---|
252 | * This may differ from cbRCLogger. */
|
---|
253 | uint32_t cbRCRelLogger;
|
---|
254 | /** @} */
|
---|
255 |
|
---|
256 | /** The EMT yield timer. */
|
---|
257 | PTMTIMERR3 pYieldTimer;
|
---|
258 | /** The period to the next timeout when suspended or stopped.
|
---|
259 | * This is 0 when running. */
|
---|
260 | uint32_t cYieldResumeMillies;
|
---|
261 | /** The EMT yield timer interval (milliseconds). */
|
---|
262 | uint32_t cYieldEveryMillies;
|
---|
263 | /** The timestamp of the previous yield. (nano) */
|
---|
264 | uint64_t u64LastYield;
|
---|
265 |
|
---|
266 | /** Critical section.
|
---|
267 | * Use for synchronizing all VCPUs
|
---|
268 | */
|
---|
269 | RTCRITSECT CritSectSync;
|
---|
270 |
|
---|
271 | /** Buffer for storing the standard assertion message for a ring-0 assertion.
|
---|
272 | * Used for saving the assertion message text for the release log and guru
|
---|
273 | * meditation dump. */
|
---|
274 | char szRing0AssertMsg1[512];
|
---|
275 | /** Buffer for storing the custom message for a ring-0 assertion. */
|
---|
276 | char szRing0AssertMsg2[256];
|
---|
277 |
|
---|
278 | /** Number of VMMR0_DO_RUN_GC calls. */
|
---|
279 | STAMCOUNTER StatRunRC;
|
---|
280 |
|
---|
281 | /** Statistics for each of the RC/R0 return codes.
|
---|
282 | * @{ */
|
---|
283 | STAMCOUNTER StatRZRetNormal;
|
---|
284 | STAMCOUNTER StatRZRetInterrupt;
|
---|
285 | STAMCOUNTER StatRZRetInterruptHyper;
|
---|
286 | STAMCOUNTER StatRZRetGuestTrap;
|
---|
287 | STAMCOUNTER StatRZRetRingSwitch;
|
---|
288 | STAMCOUNTER StatRZRetRingSwitchInt;
|
---|
289 | STAMCOUNTER StatRZRetExceptionPrivilege;
|
---|
290 | STAMCOUNTER StatRZRetStaleSelector;
|
---|
291 | STAMCOUNTER StatRZRetIRETTrap;
|
---|
292 | STAMCOUNTER StatRZRetEmulate;
|
---|
293 | STAMCOUNTER StatRZRetIOBlockEmulate;
|
---|
294 | STAMCOUNTER StatRZRetPatchEmulate;
|
---|
295 | STAMCOUNTER StatRZRetIORead;
|
---|
296 | STAMCOUNTER StatRZRetIOWrite;
|
---|
297 | STAMCOUNTER StatRZRetMMIORead;
|
---|
298 | STAMCOUNTER StatRZRetMMIOWrite;
|
---|
299 | STAMCOUNTER StatRZRetMMIOPatchRead;
|
---|
300 | STAMCOUNTER StatRZRetMMIOPatchWrite;
|
---|
301 | STAMCOUNTER StatRZRetMMIOReadWrite;
|
---|
302 | STAMCOUNTER StatRZRetLDTFault;
|
---|
303 | STAMCOUNTER StatRZRetGDTFault;
|
---|
304 | STAMCOUNTER StatRZRetIDTFault;
|
---|
305 | STAMCOUNTER StatRZRetTSSFault;
|
---|
306 | STAMCOUNTER StatRZRetPDFault;
|
---|
307 | STAMCOUNTER StatRZRetCSAMTask;
|
---|
308 | STAMCOUNTER StatRZRetSyncCR3;
|
---|
309 | STAMCOUNTER StatRZRetMisc;
|
---|
310 | STAMCOUNTER StatRZRetPatchInt3;
|
---|
311 | STAMCOUNTER StatRZRetPatchPF;
|
---|
312 | STAMCOUNTER StatRZRetPatchGP;
|
---|
313 | STAMCOUNTER StatRZRetPatchIretIRQ;
|
---|
314 | STAMCOUNTER StatRZRetRescheduleREM;
|
---|
315 | STAMCOUNTER StatRZRetToR3;
|
---|
316 | STAMCOUNTER StatRZRetTimerPending;
|
---|
317 | STAMCOUNTER StatRZRetInterruptPending;
|
---|
318 | STAMCOUNTER StatRZRetCallHost;
|
---|
319 | STAMCOUNTER StatRZRetPATMDuplicateFn;
|
---|
320 | STAMCOUNTER StatRZRetPGMChangeMode;
|
---|
321 | STAMCOUNTER StatRZRetEmulHlt;
|
---|
322 | STAMCOUNTER StatRZRetPendingRequest;
|
---|
323 | STAMCOUNTER StatRZCallPDMLock;
|
---|
324 | STAMCOUNTER StatRZCallLogFlush;
|
---|
325 | STAMCOUNTER StatRZCallPDMQueueFlush;
|
---|
326 | STAMCOUNTER StatRZCallPGMPoolGrow;
|
---|
327 | STAMCOUNTER StatRZCallPGMMapChunk;
|
---|
328 | STAMCOUNTER StatRZCallPGMAllocHandy;
|
---|
329 | STAMCOUNTER StatRZCallRemReplay;
|
---|
330 | STAMCOUNTER StatRZCallVMSetError;
|
---|
331 | STAMCOUNTER StatRZCallVMSetRuntimeError;
|
---|
332 | STAMCOUNTER StatRZCallPGMLock;
|
---|
333 | /** @} */
|
---|
334 | } VMM;
|
---|
335 | /** Pointer to VMM. */
|
---|
336 | typedef VMM *PVMM;
|
---|
337 |
|
---|
338 |
|
---|
339 | /**
|
---|
340 | * VMMCPU Data (part of VMCPU)
|
---|
341 | */
|
---|
342 | typedef struct VMMCPU
|
---|
343 | {
|
---|
344 | /** Offset to the VMCPU structure.
|
---|
345 | * See VMM2VMCPU(). */
|
---|
346 | RTINT offVMCPU;
|
---|
347 |
|
---|
348 | /** The last RC/R0 return code. */
|
---|
349 | int32_t iLastGZRc;
|
---|
350 |
|
---|
351 | /** VMM stack, pointer to the top of the stack in R3.
|
---|
352 | * Stack is allocated from the hypervisor heap and is page aligned
|
---|
353 | * and always writable in RC. */
|
---|
354 | R3PTRTYPE(uint8_t *) pbEMTStackR3;
|
---|
355 | /** Pointer to the bottom of the stack - needed for doing relocations. */
|
---|
356 | RCPTRTYPE(uint8_t *) pbEMTStackRC;
|
---|
357 | /** Pointer to the bottom of the stack - needed for doing relocations. */
|
---|
358 | RCPTRTYPE(uint8_t *) pbEMTStackBottomRC;
|
---|
359 |
|
---|
360 | #ifdef LOG_ENABLED
|
---|
361 | /** Pointer to the R0 logger instance - R3 Ptr.
|
---|
362 | * This is NULL if logging is disabled. */
|
---|
363 | R3PTRTYPE(PVMMR0LOGGER) pR0LoggerR3;
|
---|
364 | /** Pointer to the R0 logger instance - R0 Ptr.
|
---|
365 | * This is NULL if logging is disabled. */
|
---|
366 | R0PTRTYPE(PVMMR0LOGGER) pR0LoggerR0;
|
---|
367 | #endif
|
---|
368 |
|
---|
369 | /** @name CallHost
|
---|
370 | * @{ */
|
---|
371 | /** The pending operation. */
|
---|
372 | VMMCALLHOST enmCallHostOperation;
|
---|
373 | /** The result of the last operation. */
|
---|
374 | int32_t rcCallHost;
|
---|
375 | #if HC_ARCH_BITS == 32
|
---|
376 | uint32_t padding;
|
---|
377 | #endif
|
---|
378 | /** The argument to the operation. */
|
---|
379 | uint64_t u64CallHostArg;
|
---|
380 | /** The Ring-0 jmp buffer. */
|
---|
381 | VMMR0JMPBUF CallHostR0JmpBuf;
|
---|
382 | /** @} */
|
---|
383 |
|
---|
384 | } VMMCPU;
|
---|
385 | /** Pointer to VMMCPU. */
|
---|
386 | typedef VMMCPU *PVMMCPU;
|
---|
387 |
|
---|
388 |
|
---|
389 | /**
|
---|
390 | * The VMMGCEntry() codes.
|
---|
391 | */
|
---|
392 | typedef enum VMMGCOPERATION
|
---|
393 | {
|
---|
394 | /** Do GC module init. */
|
---|
395 | VMMGC_DO_VMMGC_INIT = 1,
|
---|
396 |
|
---|
397 | /** The first Trap testcase. */
|
---|
398 | VMMGC_DO_TESTCASE_TRAP_FIRST = 0x0dead000,
|
---|
399 | /** Trap 0 testcases, uArg selects the variation. */
|
---|
400 | VMMGC_DO_TESTCASE_TRAP_0 = VMMGC_DO_TESTCASE_TRAP_FIRST,
|
---|
401 | /** Trap 1 testcases, uArg selects the variation. */
|
---|
402 | VMMGC_DO_TESTCASE_TRAP_1,
|
---|
403 | /** Trap 2 testcases, uArg selects the variation. */
|
---|
404 | VMMGC_DO_TESTCASE_TRAP_2,
|
---|
405 | /** Trap 3 testcases, uArg selects the variation. */
|
---|
406 | VMMGC_DO_TESTCASE_TRAP_3,
|
---|
407 | /** Trap 4 testcases, uArg selects the variation. */
|
---|
408 | VMMGC_DO_TESTCASE_TRAP_4,
|
---|
409 | /** Trap 5 testcases, uArg selects the variation. */
|
---|
410 | VMMGC_DO_TESTCASE_TRAP_5,
|
---|
411 | /** Trap 6 testcases, uArg selects the variation. */
|
---|
412 | VMMGC_DO_TESTCASE_TRAP_6,
|
---|
413 | /** Trap 7 testcases, uArg selects the variation. */
|
---|
414 | VMMGC_DO_TESTCASE_TRAP_7,
|
---|
415 | /** Trap 8 testcases, uArg selects the variation. */
|
---|
416 | VMMGC_DO_TESTCASE_TRAP_8,
|
---|
417 | /** Trap 9 testcases, uArg selects the variation. */
|
---|
418 | VMMGC_DO_TESTCASE_TRAP_9,
|
---|
419 | /** Trap 0a testcases, uArg selects the variation. */
|
---|
420 | VMMGC_DO_TESTCASE_TRAP_0A,
|
---|
421 | /** Trap 0b testcases, uArg selects the variation. */
|
---|
422 | VMMGC_DO_TESTCASE_TRAP_0B,
|
---|
423 | /** Trap 0c testcases, uArg selects the variation. */
|
---|
424 | VMMGC_DO_TESTCASE_TRAP_0C,
|
---|
425 | /** Trap 0d testcases, uArg selects the variation. */
|
---|
426 | VMMGC_DO_TESTCASE_TRAP_0D,
|
---|
427 | /** Trap 0e testcases, uArg selects the variation. */
|
---|
428 | VMMGC_DO_TESTCASE_TRAP_0E,
|
---|
429 | /** The last trap testcase (exclusive). */
|
---|
430 | VMMGC_DO_TESTCASE_TRAP_LAST,
|
---|
431 | /** Testcase for checking interrupt forwarding. */
|
---|
432 | VMMGC_DO_TESTCASE_HYPER_INTERRUPT,
|
---|
433 | /** Switching testing and profiling stub. */
|
---|
434 | VMMGC_DO_TESTCASE_NOP,
|
---|
435 | /** Testcase for checking interrupt masking.. */
|
---|
436 | VMMGC_DO_TESTCASE_INTERRUPT_MASKING,
|
---|
437 | /** Switching testing and profiling stub. */
|
---|
438 | VMMGC_DO_TESTCASE_HWACCM_NOP,
|
---|
439 |
|
---|
440 | /** The usual 32-bit hack. */
|
---|
441 | VMMGC_DO_32_BIT_HACK = 0x7fffffff
|
---|
442 | } VMMGCOPERATION;
|
---|
443 |
|
---|
444 |
|
---|
445 | RT_C_DECLS_BEGIN
|
---|
446 |
|
---|
447 | #ifdef IN_RING3
|
---|
448 | int vmmR3SwitcherInit(PVM pVM);
|
---|
449 | void vmmR3SwitcherRelocate(PVM pVM, RTGCINTPTR offDelta);
|
---|
450 | #endif /* IN_RING3 */
|
---|
451 |
|
---|
452 | #ifdef IN_RING0
|
---|
453 | /**
|
---|
454 | * World switcher assembly routine.
|
---|
455 | * It will call VMMGCEntry().
|
---|
456 | *
|
---|
457 | * @returns return code from VMMGCEntry().
|
---|
458 | * @param pVM The VM in question.
|
---|
459 | * @param uArg See VMMGCEntry().
|
---|
460 | * @internal
|
---|
461 | */
|
---|
462 | DECLASM(int) vmmR0WorldSwitch(PVM pVM, unsigned uArg);
|
---|
463 |
|
---|
464 | /**
|
---|
465 | * Callback function for vmmR0CallHostSetJmp.
|
---|
466 | *
|
---|
467 | * @returns VBox status code.
|
---|
468 | * @param pVM The VM handle.
|
---|
469 | */
|
---|
470 | typedef DECLCALLBACK(int) FNVMMR0SETJMP(PVM pVM, PVMCPU pVCpu);
|
---|
471 | /** Pointer to FNVMMR0SETJMP(). */
|
---|
472 | typedef FNVMMR0SETJMP *PFNVMMR0SETJMP;
|
---|
473 |
|
---|
474 | /**
|
---|
475 | * The setjmp variant used for calling Ring-3.
|
---|
476 | *
|
---|
477 | * This differs from the normal setjmp in that it will resume VMMR0CallHost if we're
|
---|
478 | * in the middle of a ring-3 call. Another differences is the function pointer and
|
---|
479 | * argument. This has to do with resuming code and the stack frame of the caller.
|
---|
480 | *
|
---|
481 | * @returns VINF_SUCCESS on success or whatever is passed to vmmR0CallHostLongJmp.
|
---|
482 | * @param pJmpBuf The jmp_buf to set.
|
---|
483 | * @param pfn The function to be called when not resuming..
|
---|
484 | * @param pVM The argument of that function.
|
---|
485 | */
|
---|
486 | DECLASM(int) vmmR0CallHostSetJmp(PVMMR0JMPBUF pJmpBuf, PFNVMMR0SETJMP pfn, PVM pVM, PVMCPU pVCpu);
|
---|
487 |
|
---|
488 | /**
|
---|
489 | * Callback function for vmmR0CallHostSetJmpEx.
|
---|
490 | *
|
---|
491 | * @returns VBox status code.
|
---|
492 | * @param pvUser The user argument.
|
---|
493 | */
|
---|
494 | typedef DECLCALLBACK(int) FNVMMR0SETJMPEX(void *pvUser);
|
---|
495 | /** Pointer to FNVMMR0SETJMP(). */
|
---|
496 | typedef FNVMMR0SETJMPEX *PFNVMMR0SETJMPEX;
|
---|
497 |
|
---|
498 | /**
|
---|
499 | * Same as vmmR0CallHostSetJmp except for the function signature.
|
---|
500 | *
|
---|
501 | * @returns VINF_SUCCESS on success or whatever is passed to vmmR0CallHostLongJmp.
|
---|
502 | * @param pJmpBuf The jmp_buf to set.
|
---|
503 | * @param pfn The function to be called when not resuming..
|
---|
504 | * @param pvUser The argument of that function.
|
---|
505 | */
|
---|
506 | DECLASM(int) vmmR0CallHostSetJmpEx(PVMMR0JMPBUF pJmpBuf, PFNVMMR0SETJMPEX pfn, void *pvUser);
|
---|
507 |
|
---|
508 |
|
---|
509 | /**
|
---|
510 | * Worker for VMMR0CallHost.
|
---|
511 | * This will save the stack and registers.
|
---|
512 | *
|
---|
513 | * @returns rc.
|
---|
514 | * @param pJmpBuf Pointer to the jump buffer.
|
---|
515 | * @param rc The return code.
|
---|
516 | */
|
---|
517 | DECLASM(int) vmmR0CallHostLongJmp(PVMMR0JMPBUF pJmpBuf, int rc);
|
---|
518 |
|
---|
519 | /**
|
---|
520 | * Internal R0 logger worker: Logger wrapper.
|
---|
521 | */
|
---|
522 | VMMR0DECL(void) vmmR0LoggerWrapper(const char *pszFormat, ...);
|
---|
523 |
|
---|
524 | /**
|
---|
525 | * Internal R0 logger worker: Flush logger.
|
---|
526 | *
|
---|
527 | * @param pLogger The logger instance to flush.
|
---|
528 | * @remark This function must be exported!
|
---|
529 | */
|
---|
530 | VMMR0DECL(void) vmmR0LoggerFlush(PRTLOGGER pLogger);
|
---|
531 |
|
---|
532 | #endif /* IN_RING0 */
|
---|
533 | #ifdef IN_RC
|
---|
534 |
|
---|
535 | /**
|
---|
536 | * Internal GC logger worker: Logger wrapper.
|
---|
537 | */
|
---|
538 | VMMRCDECL(void) vmmGCLoggerWrapper(const char *pszFormat, ...);
|
---|
539 |
|
---|
540 | /**
|
---|
541 | * Internal GC release logger worker: Logger wrapper.
|
---|
542 | */
|
---|
543 | VMMRCDECL(void) vmmGCRelLoggerWrapper(const char *pszFormat, ...);
|
---|
544 |
|
---|
545 | /**
|
---|
546 | * Internal GC logger worker: Flush logger.
|
---|
547 | *
|
---|
548 | * @returns VINF_SUCCESS.
|
---|
549 | * @param pLogger The logger instance to flush.
|
---|
550 | * @remark This function must be exported!
|
---|
551 | */
|
---|
552 | VMMRCDECL(int) vmmGCLoggerFlush(PRTLOGGERRC pLogger);
|
---|
553 |
|
---|
554 | /** @name Trap testcases and related labels.
|
---|
555 | * @{ */
|
---|
556 | DECLASM(void) vmmGCEnableWP(void);
|
---|
557 | DECLASM(void) vmmGCDisableWP(void);
|
---|
558 | DECLASM(int) vmmGCTestTrap3(void);
|
---|
559 | DECLASM(int) vmmGCTestTrap8(void);
|
---|
560 | DECLASM(int) vmmGCTestTrap0d(void);
|
---|
561 | DECLASM(int) vmmGCTestTrap0e(void);
|
---|
562 | DECLASM(int) vmmGCTestTrap0e_FaultEIP(void); /**< a label */
|
---|
563 | DECLASM(int) vmmGCTestTrap0e_ResumeEIP(void); /**< a label */
|
---|
564 | /** @} */
|
---|
565 |
|
---|
566 | #endif /* IN_RC */
|
---|
567 |
|
---|
568 | RT_C_DECLS_END
|
---|
569 |
|
---|
570 | /** @} */
|
---|
571 |
|
---|
572 | #endif
|
---|