1 | /* $Id: VMMInternal.h 80019 2019-07-26 18:34:14Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VMM - Internal header file.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2019 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef VMM_INCLUDED_SRC_include_VMMInternal_h
|
---|
19 | #define VMM_INCLUDED_SRC_include_VMMInternal_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include <VBox/cdefs.h>
|
---|
25 | #include <VBox/sup.h>
|
---|
26 | #include <VBox/vmm/stam.h>
|
---|
27 | #include <VBox/vmm/vmm.h>
|
---|
28 | #include <VBox/log.h>
|
---|
29 | #include <iprt/critsect.h>
|
---|
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 | #if HC_ARCH_BITS == 32
|
---|
35 | # error "32-bit hosts are no longer supported. Go back to 6.0 or earlier!"
|
---|
36 | #endif
|
---|
37 |
|
---|
38 |
|
---|
39 |
|
---|
40 | /** @defgroup grp_vmm_int Internals
|
---|
41 | * @ingroup grp_vmm
|
---|
42 | * @internal
|
---|
43 | * @{
|
---|
44 | */
|
---|
45 |
|
---|
46 | /** @def VBOX_WITH_RC_RELEASE_LOGGING
|
---|
47 | * Enables RC release logging. */
|
---|
48 | #define VBOX_WITH_RC_RELEASE_LOGGING
|
---|
49 |
|
---|
50 | /** @def VBOX_WITH_R0_LOGGING
|
---|
51 | * Enables Ring-0 logging (non-release).
|
---|
52 | *
|
---|
53 | * Ring-0 logging isn't 100% safe yet (thread id reuse / process exit cleanup),
|
---|
54 | * so you have to sign up here by adding your defined(DEBUG_<userid>) to the
|
---|
55 | * \#if, or by adding VBOX_WITH_R0_LOGGING to your LocalConfig.kmk.
|
---|
56 | */
|
---|
57 | #if defined(DEBUG_sandervl) || defined(DEBUG_frank) || defined(DEBUG_ramshankar) || defined(DOXYGEN_RUNNING)
|
---|
58 | # define VBOX_WITH_R0_LOGGING
|
---|
59 | #endif
|
---|
60 |
|
---|
61 | /** @def VBOX_STRICT_VMM_STACK
|
---|
62 | * Enables VMM stack guard pages to catch stack over- and underruns. */
|
---|
63 | #if defined(VBOX_STRICT) || defined(DOXYGEN_RUNNING)
|
---|
64 | # define VBOX_STRICT_VMM_STACK
|
---|
65 | #endif
|
---|
66 |
|
---|
67 |
|
---|
68 | /**
|
---|
69 | * The ring-0 logger instance wrapper.
|
---|
70 | *
|
---|
71 | * We need to be able to find the VM handle from the logger instance, so we wrap
|
---|
72 | * it in this structure.
|
---|
73 | */
|
---|
74 | typedef struct VMMR0LOGGER
|
---|
75 | {
|
---|
76 | /** Pointer to Pointer to the VM. */
|
---|
77 | R0PTRTYPE(PVM) pVM;
|
---|
78 | /** Size of the allocated logger instance (Logger). */
|
---|
79 | uint32_t cbLogger;
|
---|
80 | /** Flag indicating whether we've create the logger Ring-0 instance yet. */
|
---|
81 | bool fCreated;
|
---|
82 | /** Flag indicating whether we've disabled flushing (world switch) or not. */
|
---|
83 | bool fFlushingDisabled;
|
---|
84 | /** Flag indicating whether we've registered the instance already. */
|
---|
85 | bool fRegistered;
|
---|
86 | bool a8Alignment;
|
---|
87 | /** The CPU ID. */
|
---|
88 | VMCPUID idCpu;
|
---|
89 | #if HC_ARCH_BITS == 64
|
---|
90 | uint32_t u32Alignment;
|
---|
91 | #endif
|
---|
92 | /** The ring-0 logger instance. This extends beyond the size. */
|
---|
93 | RTLOGGER Logger;
|
---|
94 | } VMMR0LOGGER;
|
---|
95 | /** Pointer to a ring-0 logger instance wrapper. */
|
---|
96 | typedef VMMR0LOGGER *PVMMR0LOGGER;
|
---|
97 |
|
---|
98 |
|
---|
99 | /**
|
---|
100 | * Jump buffer for the setjmp/longjmp like constructs used to
|
---|
101 | * quickly 'call' back into Ring-3.
|
---|
102 | */
|
---|
103 | typedef struct VMMR0JMPBUF
|
---|
104 | {
|
---|
105 | /** Traditional jmp_buf stuff
|
---|
106 | * @{ */
|
---|
107 | #if HC_ARCH_BITS == 32
|
---|
108 | uint32_t ebx;
|
---|
109 | uint32_t esi;
|
---|
110 | uint32_t edi;
|
---|
111 | uint32_t ebp;
|
---|
112 | uint32_t esp;
|
---|
113 | uint32_t eip;
|
---|
114 | uint32_t eflags;
|
---|
115 | #endif
|
---|
116 | #if HC_ARCH_BITS == 64
|
---|
117 | uint64_t rbx;
|
---|
118 | # ifdef RT_OS_WINDOWS
|
---|
119 | uint64_t rsi;
|
---|
120 | uint64_t rdi;
|
---|
121 | # endif
|
---|
122 | uint64_t rbp;
|
---|
123 | uint64_t r12;
|
---|
124 | uint64_t r13;
|
---|
125 | uint64_t r14;
|
---|
126 | uint64_t r15;
|
---|
127 | uint64_t rsp;
|
---|
128 | uint64_t rip;
|
---|
129 | # ifdef RT_OS_WINDOWS
|
---|
130 | uint128_t xmm6;
|
---|
131 | uint128_t xmm7;
|
---|
132 | uint128_t xmm8;
|
---|
133 | uint128_t xmm9;
|
---|
134 | uint128_t xmm10;
|
---|
135 | uint128_t xmm11;
|
---|
136 | uint128_t xmm12;
|
---|
137 | uint128_t xmm13;
|
---|
138 | uint128_t xmm14;
|
---|
139 | uint128_t xmm15;
|
---|
140 | # endif
|
---|
141 | uint64_t rflags;
|
---|
142 | #endif
|
---|
143 | /** @} */
|
---|
144 |
|
---|
145 | /** Flag that indicates that we've done a ring-3 call. */
|
---|
146 | bool fInRing3Call;
|
---|
147 | /** The number of bytes we've saved. */
|
---|
148 | uint32_t cbSavedStack;
|
---|
149 | /** Pointer to the buffer used to save the stack.
|
---|
150 | * This is assumed to be 8KB. */
|
---|
151 | RTR0PTR pvSavedStack;
|
---|
152 | /** Esp we we match against esp on resume to make sure the stack wasn't relocated. */
|
---|
153 | RTHCUINTREG SpCheck;
|
---|
154 | /** The esp we should resume execution with after the restore. */
|
---|
155 | RTHCUINTREG SpResume;
|
---|
156 | /** ESP/RSP at the time of the jump to ring 3. */
|
---|
157 | RTHCUINTREG SavedEsp;
|
---|
158 | /** EBP/RBP at the time of the jump to ring 3. */
|
---|
159 | RTHCUINTREG SavedEbp;
|
---|
160 | /** EIP/RIP within vmmR0CallRing3LongJmp for assisting unwinding. */
|
---|
161 | RTHCUINTREG SavedEipForUnwind;
|
---|
162 | /** Unwind: The vmmR0CallRing3SetJmp return address value. */
|
---|
163 | RTHCUINTREG UnwindRetPcValue;
|
---|
164 | /** Unwind: The vmmR0CallRing3SetJmp return address stack location. */
|
---|
165 | RTHCUINTREG UnwindRetPcLocation;
|
---|
166 | #if HC_ARCH_BITS == 32
|
---|
167 | /** Alignment padding. */
|
---|
168 | uint32_t uPadding;
|
---|
169 | #endif
|
---|
170 |
|
---|
171 | /** Stats: Max amount of stack used. */
|
---|
172 | uint32_t cbUsedMax;
|
---|
173 | /** Stats: Average stack usage. (Avg = cbUsedTotal / cUsedTotal) */
|
---|
174 | uint32_t cbUsedAvg;
|
---|
175 | /** Stats: Total amount of stack used. */
|
---|
176 | uint64_t cbUsedTotal;
|
---|
177 | /** Stats: Number of stack usages. */
|
---|
178 | uint64_t cUsedTotal;
|
---|
179 | } VMMR0JMPBUF;
|
---|
180 | /** Pointer to a ring-0 jump buffer. */
|
---|
181 | typedef VMMR0JMPBUF *PVMMR0JMPBUF;
|
---|
182 |
|
---|
183 |
|
---|
184 | /**
|
---|
185 | * VMM Data (part of VM)
|
---|
186 | */
|
---|
187 | typedef struct VMM
|
---|
188 | {
|
---|
189 | /** Whether we should use the periodic preemption timers. */
|
---|
190 | bool fUsePeriodicPreemptionTimers;
|
---|
191 | /** Alignment padding. */
|
---|
192 | bool afPadding0[7];
|
---|
193 |
|
---|
194 | /** The EMT yield timer. */
|
---|
195 | PTMTIMERR3 pYieldTimer;
|
---|
196 | /** The period to the next timeout when suspended or stopped.
|
---|
197 | * This is 0 when running. */
|
---|
198 | uint32_t cYieldResumeMillies;
|
---|
199 | /** The EMT yield timer interval (milliseconds). */
|
---|
200 | uint32_t cYieldEveryMillies;
|
---|
201 | /** The timestamp of the previous yield. (nano) */
|
---|
202 | uint64_t u64LastYield;
|
---|
203 |
|
---|
204 | /** @name EMT Rendezvous
|
---|
205 | * @{ */
|
---|
206 | /** Semaphore to wait on upon entering ordered execution. */
|
---|
207 | R3PTRTYPE(PRTSEMEVENT) pahEvtRendezvousEnterOrdered;
|
---|
208 | /** Semaphore to wait on upon entering for one-by-one execution. */
|
---|
209 | RTSEMEVENT hEvtRendezvousEnterOneByOne;
|
---|
210 | /** Semaphore to wait on upon entering for all-at-once execution. */
|
---|
211 | RTSEMEVENTMULTI hEvtMulRendezvousEnterAllAtOnce;
|
---|
212 | /** Semaphore to wait on when done. */
|
---|
213 | RTSEMEVENTMULTI hEvtMulRendezvousDone;
|
---|
214 | /** Semaphore the VMMR3EmtRendezvous caller waits on at the end. */
|
---|
215 | RTSEMEVENT hEvtRendezvousDoneCaller;
|
---|
216 | /** Semaphore to wait on upon recursing. */
|
---|
217 | RTSEMEVENTMULTI hEvtMulRendezvousRecursionPush;
|
---|
218 | /** Semaphore to wait on after done with recursion (caller restoring state). */
|
---|
219 | RTSEMEVENTMULTI hEvtMulRendezvousRecursionPop;
|
---|
220 | /** Semaphore the initiator waits on while the EMTs are getting into position
|
---|
221 | * on hEvtMulRendezvousRecursionPush. */
|
---|
222 | RTSEMEVENT hEvtRendezvousRecursionPushCaller;
|
---|
223 | /** Semaphore the initiator waits on while the EMTs sitting on
|
---|
224 | * hEvtMulRendezvousRecursionPop wakes up and leave. */
|
---|
225 | RTSEMEVENT hEvtRendezvousRecursionPopCaller;
|
---|
226 | /** Callback. */
|
---|
227 | R3PTRTYPE(PFNVMMEMTRENDEZVOUS) volatile pfnRendezvous;
|
---|
228 | /** The user argument for the callback. */
|
---|
229 | RTR3PTR volatile pvRendezvousUser;
|
---|
230 | /** Flags. */
|
---|
231 | volatile uint32_t fRendezvousFlags;
|
---|
232 | /** The number of EMTs that has entered. */
|
---|
233 | volatile uint32_t cRendezvousEmtsEntered;
|
---|
234 | /** The number of EMTs that has done their job. */
|
---|
235 | volatile uint32_t cRendezvousEmtsDone;
|
---|
236 | /** The number of EMTs that has returned. */
|
---|
237 | volatile uint32_t cRendezvousEmtsReturned;
|
---|
238 | /** The status code. */
|
---|
239 | volatile int32_t i32RendezvousStatus;
|
---|
240 | /** Spin lock. */
|
---|
241 | volatile uint32_t u32RendezvousLock;
|
---|
242 | /** The recursion depth. */
|
---|
243 | volatile uint32_t cRendezvousRecursions;
|
---|
244 | /** The number of EMTs that have entered the recursion routine. */
|
---|
245 | volatile uint32_t cRendezvousEmtsRecursingPush;
|
---|
246 | /** The number of EMTs that have leaft the recursion routine. */
|
---|
247 | volatile uint32_t cRendezvousEmtsRecursingPop;
|
---|
248 | /** Triggers rendezvous recursion in the other threads. */
|
---|
249 | volatile bool fRendezvousRecursion;
|
---|
250 |
|
---|
251 | /** @} */
|
---|
252 |
|
---|
253 | /** RTThreadPreemptIsPendingTrusty() result, set by vmmR0InitVM() for
|
---|
254 | * release logging purposes. */
|
---|
255 | bool fIsPreemptPendingApiTrusty : 1;
|
---|
256 | /** The RTThreadPreemptIsPossible() result, set by vmmR0InitVM() for
|
---|
257 | * release logging purposes. */
|
---|
258 | bool fIsPreemptPossible : 1;
|
---|
259 |
|
---|
260 | bool afAlignment2[2]; /**< Alignment padding. */
|
---|
261 |
|
---|
262 | /** Buffer for storing the standard assertion message for a ring-0 assertion.
|
---|
263 | * Used for saving the assertion message text for the release log and guru
|
---|
264 | * meditation dump. */
|
---|
265 | char szRing0AssertMsg1[512];
|
---|
266 | /** Buffer for storing the custom message for a ring-0 assertion. */
|
---|
267 | char szRing0AssertMsg2[256];
|
---|
268 |
|
---|
269 | /** Number of VMMR0_DO_HM_RUN or VMMR0_DO_NEM_RUN calls. */
|
---|
270 | STAMCOUNTER StatRunGC;
|
---|
271 |
|
---|
272 | /** Statistics for each of the RC/R0 return codes.
|
---|
273 | * @{ */
|
---|
274 | STAMCOUNTER StatRZRetNormal;
|
---|
275 | STAMCOUNTER StatRZRetInterrupt;
|
---|
276 | STAMCOUNTER StatRZRetInterruptHyper;
|
---|
277 | STAMCOUNTER StatRZRetGuestTrap;
|
---|
278 | STAMCOUNTER StatRZRetRingSwitch;
|
---|
279 | STAMCOUNTER StatRZRetRingSwitchInt;
|
---|
280 | STAMCOUNTER StatRZRetStaleSelector;
|
---|
281 | STAMCOUNTER StatRZRetIRETTrap;
|
---|
282 | STAMCOUNTER StatRZRetEmulate;
|
---|
283 | STAMCOUNTER StatRZRetPatchEmulate;
|
---|
284 | STAMCOUNTER StatRZRetIORead;
|
---|
285 | STAMCOUNTER StatRZRetIOWrite;
|
---|
286 | STAMCOUNTER StatRZRetIOCommitWrite;
|
---|
287 | STAMCOUNTER StatRZRetMMIORead;
|
---|
288 | STAMCOUNTER StatRZRetMMIOWrite;
|
---|
289 | STAMCOUNTER StatRZRetMMIOCommitWrite;
|
---|
290 | STAMCOUNTER StatRZRetMMIOPatchRead;
|
---|
291 | STAMCOUNTER StatRZRetMMIOPatchWrite;
|
---|
292 | STAMCOUNTER StatRZRetMMIOReadWrite;
|
---|
293 | STAMCOUNTER StatRZRetMSRRead;
|
---|
294 | STAMCOUNTER StatRZRetMSRWrite;
|
---|
295 | STAMCOUNTER StatRZRetLDTFault;
|
---|
296 | STAMCOUNTER StatRZRetGDTFault;
|
---|
297 | STAMCOUNTER StatRZRetIDTFault;
|
---|
298 | STAMCOUNTER StatRZRetTSSFault;
|
---|
299 | STAMCOUNTER StatRZRetCSAMTask;
|
---|
300 | STAMCOUNTER StatRZRetSyncCR3;
|
---|
301 | STAMCOUNTER StatRZRetMisc;
|
---|
302 | STAMCOUNTER StatRZRetPatchInt3;
|
---|
303 | STAMCOUNTER StatRZRetPatchPF;
|
---|
304 | STAMCOUNTER StatRZRetPatchGP;
|
---|
305 | STAMCOUNTER StatRZRetPatchIretIRQ;
|
---|
306 | STAMCOUNTER StatRZRetRescheduleREM;
|
---|
307 | STAMCOUNTER StatRZRetToR3Total;
|
---|
308 | STAMCOUNTER StatRZRetToR3FF;
|
---|
309 | STAMCOUNTER StatRZRetToR3Unknown;
|
---|
310 | STAMCOUNTER StatRZRetToR3TMVirt;
|
---|
311 | STAMCOUNTER StatRZRetToR3HandyPages;
|
---|
312 | STAMCOUNTER StatRZRetToR3PDMQueues;
|
---|
313 | STAMCOUNTER StatRZRetToR3Rendezvous;
|
---|
314 | STAMCOUNTER StatRZRetToR3Timer;
|
---|
315 | STAMCOUNTER StatRZRetToR3DMA;
|
---|
316 | STAMCOUNTER StatRZRetToR3CritSect;
|
---|
317 | STAMCOUNTER StatRZRetToR3Iem;
|
---|
318 | STAMCOUNTER StatRZRetToR3Iom;
|
---|
319 | STAMCOUNTER StatRZRetTimerPending;
|
---|
320 | STAMCOUNTER StatRZRetInterruptPending;
|
---|
321 | STAMCOUNTER StatRZRetCallRing3;
|
---|
322 | STAMCOUNTER StatRZRetPATMDuplicateFn;
|
---|
323 | STAMCOUNTER StatRZRetPGMChangeMode;
|
---|
324 | STAMCOUNTER StatRZRetPendingRequest;
|
---|
325 | STAMCOUNTER StatRZRetPGMFlushPending;
|
---|
326 | STAMCOUNTER StatRZRetPatchTPR;
|
---|
327 | STAMCOUNTER StatRZCallPDMCritSectEnter;
|
---|
328 | STAMCOUNTER StatRZCallPDMLock;
|
---|
329 | STAMCOUNTER StatRZCallLogFlush;
|
---|
330 | STAMCOUNTER StatRZCallPGMPoolGrow;
|
---|
331 | STAMCOUNTER StatRZCallPGMMapChunk;
|
---|
332 | STAMCOUNTER StatRZCallPGMAllocHandy;
|
---|
333 | STAMCOUNTER StatRZCallRemReplay;
|
---|
334 | STAMCOUNTER StatRZCallVMSetError;
|
---|
335 | STAMCOUNTER StatRZCallVMSetRuntimeError;
|
---|
336 | STAMCOUNTER StatRZCallPGMLock;
|
---|
337 | /** @} */
|
---|
338 | } VMM;
|
---|
339 | /** Pointer to VMM. */
|
---|
340 | typedef VMM *PVMM;
|
---|
341 |
|
---|
342 |
|
---|
343 | /**
|
---|
344 | * VMMCPU Data (part of VMCPU)
|
---|
345 | */
|
---|
346 | typedef struct VMMCPU
|
---|
347 | {
|
---|
348 | /** The last RC/R0 return code. */
|
---|
349 | int32_t iLastGZRc;
|
---|
350 | /** Alignment padding. */
|
---|
351 | uint32_t u32Padding0;
|
---|
352 |
|
---|
353 | /** VMM stack, pointer to the top of the stack in R3.
|
---|
354 | * Stack is allocated from the hypervisor heap and is page aligned
|
---|
355 | * and always writable in RC. */
|
---|
356 | R3PTRTYPE(uint8_t *) pbEMTStackR3;
|
---|
357 |
|
---|
358 | /** Pointer to the R0 logger instance - R3 Ptr.
|
---|
359 | * This is NULL if logging is disabled. */
|
---|
360 | R3PTRTYPE(PVMMR0LOGGER) pR0LoggerR3;
|
---|
361 | /** Pointer to the R0 logger instance - R0 Ptr.
|
---|
362 | * This is NULL if logging is disabled. */
|
---|
363 | R0PTRTYPE(PVMMR0LOGGER) pR0LoggerR0;
|
---|
364 |
|
---|
365 | /** Pointer to the R0 release logger instance - R3 Ptr.
|
---|
366 | * This is NULL if logging is disabled. */
|
---|
367 | R3PTRTYPE(PVMMR0LOGGER) pR0RelLoggerR3;
|
---|
368 | /** Pointer to the R0 release instance - R0 Ptr.
|
---|
369 | * This is NULL if logging is disabled. */
|
---|
370 | R0PTRTYPE(PVMMR0LOGGER) pR0RelLoggerR0;
|
---|
371 |
|
---|
372 | /** Thread context switching hook (ring-0). */
|
---|
373 | RTTHREADCTXHOOK hCtxHook;
|
---|
374 |
|
---|
375 | /** @name Rendezvous
|
---|
376 | * @{ */
|
---|
377 | /** Whether the EMT is executing a rendezvous right now. For detecting
|
---|
378 | * attempts at recursive rendezvous. */
|
---|
379 | bool volatile fInRendezvous;
|
---|
380 | bool afPadding1[10];
|
---|
381 | /** @} */
|
---|
382 |
|
---|
383 | /** Whether we can HLT in VMMR0 rather than having to return to EM.
|
---|
384 | * Updated by vmR3SetHaltMethodU(). */
|
---|
385 | bool fMayHaltInRing0;
|
---|
386 | /** The minimum delta for which we can HLT in ring-0 for.
|
---|
387 | * The deadlines we can calculate are from TM, so, if it's too close
|
---|
388 | * we should just return to ring-3 and run the timer wheel, no point
|
---|
389 | * in spinning in ring-0.
|
---|
390 | * Updated by vmR3SetHaltMethodU(). */
|
---|
391 | uint32_t cNsSpinBlockThreshold;
|
---|
392 | /** Number of ring-0 halts (used for depreciating following values). */
|
---|
393 | uint32_t cR0Halts;
|
---|
394 | /** Number of ring-0 halts succeeding (VINF_SUCCESS) recently. */
|
---|
395 | uint32_t cR0HaltsSucceeded;
|
---|
396 | /** Number of ring-0 halts failing (VINF_EM_HALT) recently. */
|
---|
397 | uint32_t cR0HaltsToRing3;
|
---|
398 | /** Padding */
|
---|
399 | uint32_t u32Padding2;
|
---|
400 |
|
---|
401 | /** @name Raw-mode context tracing data.
|
---|
402 | * @{ */
|
---|
403 | SUPDRVTRACERUSRCTX TracerCtx;
|
---|
404 | /** @} */
|
---|
405 |
|
---|
406 | /** Alignment padding, making sure u64CallRing3Arg and CallRing3JmpBufR0 are nicely aligned. */
|
---|
407 | uint32_t au32Padding3[1];
|
---|
408 |
|
---|
409 | /** @name Call Ring-3
|
---|
410 | * Formerly known as host calls.
|
---|
411 | * @{ */
|
---|
412 | /** The disable counter. */
|
---|
413 | uint32_t cCallRing3Disabled;
|
---|
414 | /** The pending operation. */
|
---|
415 | VMMCALLRING3 enmCallRing3Operation;
|
---|
416 | /** The result of the last operation. */
|
---|
417 | int32_t rcCallRing3;
|
---|
418 | /** The argument to the operation. */
|
---|
419 | uint64_t u64CallRing3Arg;
|
---|
420 | /** The Ring-0 notification callback. */
|
---|
421 | R0PTRTYPE(PFNVMMR0CALLRING3NOTIFICATION) pfnCallRing3CallbackR0;
|
---|
422 | /** The Ring-0 notification callback user argument. */
|
---|
423 | R0PTRTYPE(void *) pvCallRing3CallbackUserR0;
|
---|
424 | /** The Ring-0 jmp buffer.
|
---|
425 | * @remarks The size of this type isn't stable in assembly, so don't put
|
---|
426 | * anything that needs to be accessed from assembly after it. */
|
---|
427 | VMMR0JMPBUF CallRing3JmpBufR0;
|
---|
428 | /** @} */
|
---|
429 |
|
---|
430 | STAMPROFILE StatR0HaltBlock;
|
---|
431 | STAMPROFILE StatR0HaltBlockOnTime;
|
---|
432 | STAMPROFILE StatR0HaltBlockOverslept;
|
---|
433 | STAMPROFILE StatR0HaltBlockInsomnia;
|
---|
434 | STAMCOUNTER StatR0HaltExec;
|
---|
435 | STAMCOUNTER StatR0HaltExecFromBlock;
|
---|
436 | STAMCOUNTER StatR0HaltExecFromSpin;
|
---|
437 | STAMCOUNTER StatR0HaltToR3FromSpin;
|
---|
438 | } VMMCPU;
|
---|
439 | AssertCompileMemberAlignment(VMMCPU, TracerCtx, 8);
|
---|
440 | /** Pointer to VMMCPU. */
|
---|
441 | typedef VMMCPU *PVMMCPU;
|
---|
442 |
|
---|
443 |
|
---|
444 |
|
---|
445 | RT_C_DECLS_BEGIN
|
---|
446 |
|
---|
447 | int vmmInitFormatTypes(void);
|
---|
448 | void vmmTermFormatTypes(void);
|
---|
449 | uint32_t vmmGetBuildType(void);
|
---|
450 |
|
---|
451 | #ifdef IN_RING3
|
---|
452 | int vmmR3SwitcherInit(PVM pVM);
|
---|
453 | void vmmR3SwitcherRelocate(PVM pVM, RTGCINTPTR offDelta);
|
---|
454 | #endif /* IN_RING3 */
|
---|
455 |
|
---|
456 | #ifdef IN_RING0
|
---|
457 |
|
---|
458 | /**
|
---|
459 | * World switcher assembly routine.
|
---|
460 | * It will call VMMRCEntry().
|
---|
461 | *
|
---|
462 | * @returns return code from VMMRCEntry().
|
---|
463 | * @param pVM The cross context VM structure.
|
---|
464 | * @param uArg See VMMRCEntry().
|
---|
465 | * @internal
|
---|
466 | */
|
---|
467 | DECLASM(int) vmmR0WorldSwitch(PVM pVM, unsigned uArg);
|
---|
468 |
|
---|
469 | /**
|
---|
470 | * Callback function for vmmR0CallRing3SetJmp.
|
---|
471 | *
|
---|
472 | * @returns VBox status code.
|
---|
473 | * @param pVM The cross context VM structure.
|
---|
474 | */
|
---|
475 | typedef DECLCALLBACK(int) FNVMMR0SETJMP(PVM pVM, PVMCPU pVCpu);
|
---|
476 | /** Pointer to FNVMMR0SETJMP(). */
|
---|
477 | typedef FNVMMR0SETJMP *PFNVMMR0SETJMP;
|
---|
478 |
|
---|
479 | /**
|
---|
480 | * The setjmp variant used for calling Ring-3.
|
---|
481 | *
|
---|
482 | * This differs from the normal setjmp in that it will resume VMMRZCallRing3 if we're
|
---|
483 | * in the middle of a ring-3 call. Another differences is the function pointer and
|
---|
484 | * argument. This has to do with resuming code and the stack frame of the caller.
|
---|
485 | *
|
---|
486 | * @returns VINF_SUCCESS on success or whatever is passed to vmmR0CallRing3LongJmp.
|
---|
487 | * @param pJmpBuf The jmp_buf to set.
|
---|
488 | * @param pfn The function to be called when not resuming.
|
---|
489 | * @param pVM The cross context VM structure.
|
---|
490 | * @param pVCpu The cross context virtual CPU structure of the calling EMT.
|
---|
491 | */
|
---|
492 | DECLASM(int) vmmR0CallRing3SetJmp(PVMMR0JMPBUF pJmpBuf, PFNVMMR0SETJMP pfn, PVM pVM, PVMCPU pVCpu);
|
---|
493 |
|
---|
494 |
|
---|
495 | /**
|
---|
496 | * Callback function for vmmR0CallRing3SetJmp2.
|
---|
497 | *
|
---|
498 | * @returns VBox status code.
|
---|
499 | * @param pvUser The user argument.
|
---|
500 | */
|
---|
501 | typedef DECLCALLBACK(int) FNVMMR0SETJMP2(PGVM pGVM, VMCPUID idCpu);
|
---|
502 | /** Pointer to FNVMMR0SETJMP2(). */
|
---|
503 | typedef FNVMMR0SETJMP2 *PFNVMMR0SETJMP2;
|
---|
504 |
|
---|
505 | /**
|
---|
506 | * Same as vmmR0CallRing3SetJmp except for the function signature.
|
---|
507 | *
|
---|
508 | * @returns VINF_SUCCESS on success or whatever is passed to vmmR0CallRing3LongJmp.
|
---|
509 | * @param pJmpBuf The jmp_buf to set.
|
---|
510 | * @param pfn The function to be called when not resuming.
|
---|
511 | * @param pGVM The ring-0 VM structure.
|
---|
512 | * @param idCpu The ID of the calling EMT.
|
---|
513 | */
|
---|
514 | DECLASM(int) vmmR0CallRing3SetJmp2(PVMMR0JMPBUF pJmpBuf, PFNVMMR0SETJMP2 pfn, PGVM pGVM, VMCPUID idCpu);
|
---|
515 |
|
---|
516 |
|
---|
517 | /**
|
---|
518 | * Callback function for vmmR0CallRing3SetJmpEx.
|
---|
519 | *
|
---|
520 | * @returns VBox status code.
|
---|
521 | * @param pvUser The user argument.
|
---|
522 | */
|
---|
523 | typedef DECLCALLBACK(int) FNVMMR0SETJMPEX(void *pvUser);
|
---|
524 | /** Pointer to FNVMMR0SETJMPEX(). */
|
---|
525 | typedef FNVMMR0SETJMPEX *PFNVMMR0SETJMPEX;
|
---|
526 |
|
---|
527 | /**
|
---|
528 | * Same as vmmR0CallRing3SetJmp except for the function signature.
|
---|
529 | *
|
---|
530 | * @returns VINF_SUCCESS on success or whatever is passed to vmmR0CallRing3LongJmp.
|
---|
531 | * @param pJmpBuf The jmp_buf to set.
|
---|
532 | * @param pfn The function to be called when not resuming.
|
---|
533 | * @param pvUser The argument of that function.
|
---|
534 | */
|
---|
535 | DECLASM(int) vmmR0CallRing3SetJmpEx(PVMMR0JMPBUF pJmpBuf, PFNVMMR0SETJMPEX pfn, void *pvUser);
|
---|
536 |
|
---|
537 |
|
---|
538 | /**
|
---|
539 | * Worker for VMMRZCallRing3.
|
---|
540 | * This will save the stack and registers.
|
---|
541 | *
|
---|
542 | * @returns rc.
|
---|
543 | * @param pJmpBuf Pointer to the jump buffer.
|
---|
544 | * @param rc The return code.
|
---|
545 | */
|
---|
546 | DECLASM(int) vmmR0CallRing3LongJmp(PVMMR0JMPBUF pJmpBuf, int rc);
|
---|
547 |
|
---|
548 | /**
|
---|
549 | * Internal R0 logger worker: Logger wrapper.
|
---|
550 | */
|
---|
551 | VMMR0DECL(void) vmmR0LoggerWrapper(const char *pszFormat, ...);
|
---|
552 |
|
---|
553 | /**
|
---|
554 | * Internal R0 logger worker: Flush logger.
|
---|
555 | *
|
---|
556 | * @param pLogger The logger instance to flush.
|
---|
557 | * @remark This function must be exported!
|
---|
558 | */
|
---|
559 | VMMR0DECL(void) vmmR0LoggerFlush(PRTLOGGER pLogger);
|
---|
560 |
|
---|
561 | /**
|
---|
562 | * Internal R0 logger worker: Custom prefix.
|
---|
563 | *
|
---|
564 | * @returns Number of chars written.
|
---|
565 | *
|
---|
566 | * @param pLogger The logger instance.
|
---|
567 | * @param pchBuf The output buffer.
|
---|
568 | * @param cchBuf The size of the buffer.
|
---|
569 | * @param pvUser User argument (ignored).
|
---|
570 | */
|
---|
571 | VMMR0DECL(size_t) vmmR0LoggerPrefix(PRTLOGGER pLogger, char *pchBuf, size_t cchBuf, void *pvUser);
|
---|
572 |
|
---|
573 | # ifdef VBOX_WITH_TRIPLE_FAULT_HACK
|
---|
574 | int vmmR0TripleFaultHackInit(void);
|
---|
575 | void vmmR0TripleFaultHackTerm(void);
|
---|
576 | # endif
|
---|
577 |
|
---|
578 | #endif /* IN_RING0 */
|
---|
579 |
|
---|
580 | RT_C_DECLS_END
|
---|
581 |
|
---|
582 | /** @} */
|
---|
583 |
|
---|
584 | #endif /* !VMM_INCLUDED_SRC_include_VMMInternal_h */
|
---|