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