1 | /* $Id: VMMInternal.h 81153 2019-10-08 13:59:03Z 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(PVMCC) 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 StatRZCallVMSetError;
|
---|
334 | STAMCOUNTER StatRZCallVMSetRuntimeError;
|
---|
335 | STAMCOUNTER StatRZCallPGMLock;
|
---|
336 | /** @} */
|
---|
337 | } VMM;
|
---|
338 | /** Pointer to VMM. */
|
---|
339 | typedef VMM *PVMM;
|
---|
340 |
|
---|
341 |
|
---|
342 | /**
|
---|
343 | * VMMCPU Data (part of VMCPU)
|
---|
344 | */
|
---|
345 | typedef struct VMMCPU
|
---|
346 | {
|
---|
347 | /** The last RC/R0 return code. */
|
---|
348 | int32_t iLastGZRc;
|
---|
349 | /** Alignment padding. */
|
---|
350 | uint32_t u32Padding0;
|
---|
351 |
|
---|
352 | /** VMM stack, pointer to the top of the stack in R3.
|
---|
353 | * Stack is allocated from the hypervisor heap and is page aligned
|
---|
354 | * and always writable in RC. */
|
---|
355 | R3PTRTYPE(uint8_t *) pbEMTStackR3;
|
---|
356 |
|
---|
357 | /** Pointer to the R0 logger instance - R3 Ptr.
|
---|
358 | * This is NULL if logging is disabled. */
|
---|
359 | R3PTRTYPE(PVMMR0LOGGER) pR0LoggerR3;
|
---|
360 | /** Pointer to the R0 logger instance - R0 Ptr.
|
---|
361 | * This is NULL if logging is disabled. */
|
---|
362 | R0PTRTYPE(PVMMR0LOGGER) pR0LoggerR0;
|
---|
363 |
|
---|
364 | /** Pointer to the R0 release logger instance - R3 Ptr.
|
---|
365 | * This is NULL if logging is disabled. */
|
---|
366 | R3PTRTYPE(PVMMR0LOGGER) pR0RelLoggerR3;
|
---|
367 | /** Pointer to the R0 release instance - R0 Ptr.
|
---|
368 | * This is NULL if logging is disabled. */
|
---|
369 | R0PTRTYPE(PVMMR0LOGGER) pR0RelLoggerR0;
|
---|
370 |
|
---|
371 | /** Thread context switching hook (ring-0). */
|
---|
372 | RTTHREADCTXHOOK hCtxHook;
|
---|
373 |
|
---|
374 | /** @name Rendezvous
|
---|
375 | * @{ */
|
---|
376 | /** Whether the EMT is executing a rendezvous right now. For detecting
|
---|
377 | * attempts at recursive rendezvous. */
|
---|
378 | bool volatile fInRendezvous;
|
---|
379 | bool afPadding1[10];
|
---|
380 | /** @} */
|
---|
381 |
|
---|
382 | /** Whether we can HLT in VMMR0 rather than having to return to EM.
|
---|
383 | * Updated by vmR3SetHaltMethodU(). */
|
---|
384 | bool fMayHaltInRing0;
|
---|
385 | /** The minimum delta for which we can HLT in ring-0 for.
|
---|
386 | * The deadlines we can calculate are from TM, so, if it's too close
|
---|
387 | * we should just return to ring-3 and run the timer wheel, no point
|
---|
388 | * in spinning in ring-0.
|
---|
389 | * Updated by vmR3SetHaltMethodU(). */
|
---|
390 | uint32_t cNsSpinBlockThreshold;
|
---|
391 | /** Number of ring-0 halts (used for depreciating following values). */
|
---|
392 | uint32_t cR0Halts;
|
---|
393 | /** Number of ring-0 halts succeeding (VINF_SUCCESS) recently. */
|
---|
394 | uint32_t cR0HaltsSucceeded;
|
---|
395 | /** Number of ring-0 halts failing (VINF_EM_HALT) recently. */
|
---|
396 | uint32_t cR0HaltsToRing3;
|
---|
397 | /** Padding */
|
---|
398 | uint32_t u32Padding2;
|
---|
399 |
|
---|
400 | /** @name Raw-mode context tracing data.
|
---|
401 | * @{ */
|
---|
402 | SUPDRVTRACERUSRCTX TracerCtx;
|
---|
403 | /** @} */
|
---|
404 |
|
---|
405 | /** Alignment padding, making sure u64CallRing3Arg and CallRing3JmpBufR0 are nicely aligned. */
|
---|
406 | uint32_t au32Padding3[1];
|
---|
407 |
|
---|
408 | /** @name Call Ring-3
|
---|
409 | * Formerly known as host calls.
|
---|
410 | * @{ */
|
---|
411 | /** The disable counter. */
|
---|
412 | uint32_t cCallRing3Disabled;
|
---|
413 | /** The pending operation. */
|
---|
414 | VMMCALLRING3 enmCallRing3Operation;
|
---|
415 | /** The result of the last operation. */
|
---|
416 | int32_t rcCallRing3;
|
---|
417 | /** The argument to the operation. */
|
---|
418 | uint64_t u64CallRing3Arg;
|
---|
419 | /** The Ring-0 notification callback. */
|
---|
420 | R0PTRTYPE(PFNVMMR0CALLRING3NOTIFICATION) pfnCallRing3CallbackR0;
|
---|
421 | /** The Ring-0 notification callback user argument. */
|
---|
422 | R0PTRTYPE(void *) pvCallRing3CallbackUserR0;
|
---|
423 | /** The Ring-0 jmp buffer.
|
---|
424 | * @remarks The size of this type isn't stable in assembly, so don't put
|
---|
425 | * anything that needs to be accessed from assembly after it. */
|
---|
426 | VMMR0JMPBUF CallRing3JmpBufR0;
|
---|
427 | /** @} */
|
---|
428 |
|
---|
429 | STAMPROFILE StatR0HaltBlock;
|
---|
430 | STAMPROFILE StatR0HaltBlockOnTime;
|
---|
431 | STAMPROFILE StatR0HaltBlockOverslept;
|
---|
432 | STAMPROFILE StatR0HaltBlockInsomnia;
|
---|
433 | STAMCOUNTER StatR0HaltExec;
|
---|
434 | STAMCOUNTER StatR0HaltExecFromBlock;
|
---|
435 | STAMCOUNTER StatR0HaltExecFromSpin;
|
---|
436 | STAMCOUNTER StatR0HaltToR3FromSpin;
|
---|
437 | } VMMCPU;
|
---|
438 | AssertCompileMemberAlignment(VMMCPU, TracerCtx, 8);
|
---|
439 | /** Pointer to VMMCPU. */
|
---|
440 | typedef VMMCPU *PVMMCPU;
|
---|
441 |
|
---|
442 |
|
---|
443 |
|
---|
444 | RT_C_DECLS_BEGIN
|
---|
445 |
|
---|
446 | int vmmInitFormatTypes(void);
|
---|
447 | void vmmTermFormatTypes(void);
|
---|
448 | uint32_t vmmGetBuildType(void);
|
---|
449 |
|
---|
450 | #ifdef IN_RING3
|
---|
451 | int vmmR3SwitcherInit(PVM pVM);
|
---|
452 | void vmmR3SwitcherRelocate(PVM pVM, RTGCINTPTR offDelta);
|
---|
453 | #endif /* IN_RING3 */
|
---|
454 |
|
---|
455 | #ifdef IN_RING0
|
---|
456 |
|
---|
457 | /**
|
---|
458 | * World switcher assembly routine.
|
---|
459 | * It will call VMMRCEntry().
|
---|
460 | *
|
---|
461 | * @returns return code from VMMRCEntry().
|
---|
462 | * @param pVM The cross context VM structure.
|
---|
463 | * @param uArg See VMMRCEntry().
|
---|
464 | * @internal
|
---|
465 | */
|
---|
466 | DECLASM(int) vmmR0WorldSwitch(PVM pVM, unsigned uArg);
|
---|
467 |
|
---|
468 | /**
|
---|
469 | * Callback function for vmmR0CallRing3SetJmp.
|
---|
470 | *
|
---|
471 | * @returns VBox status code.
|
---|
472 | * @param pVM The cross context VM structure.
|
---|
473 | */
|
---|
474 | typedef DECLCALLBACK(int) FNVMMR0SETJMP(PVMCC pVM, PVMCPUCC pVCpu);
|
---|
475 | /** Pointer to FNVMMR0SETJMP(). */
|
---|
476 | typedef FNVMMR0SETJMP *PFNVMMR0SETJMP;
|
---|
477 |
|
---|
478 | /**
|
---|
479 | * The setjmp variant used for calling Ring-3.
|
---|
480 | *
|
---|
481 | * This differs from the normal setjmp in that it will resume VMMRZCallRing3 if we're
|
---|
482 | * in the middle of a ring-3 call. Another differences is the function pointer and
|
---|
483 | * argument. This has to do with resuming code and the stack frame of the caller.
|
---|
484 | *
|
---|
485 | * @returns VINF_SUCCESS on success or whatever is passed to vmmR0CallRing3LongJmp.
|
---|
486 | * @param pJmpBuf The jmp_buf to set.
|
---|
487 | * @param pfn The function to be called when not resuming.
|
---|
488 | * @param pVM The cross context VM structure.
|
---|
489 | * @param pVCpu The cross context virtual CPU structure of the calling EMT.
|
---|
490 | */
|
---|
491 | DECLASM(int) vmmR0CallRing3SetJmp(PVMMR0JMPBUF pJmpBuf, PFNVMMR0SETJMP pfn, PVM pVM, PVMCPU pVCpu);
|
---|
492 |
|
---|
493 |
|
---|
494 | /**
|
---|
495 | * Callback function for vmmR0CallRing3SetJmp2.
|
---|
496 | *
|
---|
497 | * @returns VBox status code.
|
---|
498 | * @param pvUser The user argument.
|
---|
499 | */
|
---|
500 | typedef DECLCALLBACK(int) FNVMMR0SETJMP2(PGVM pGVM, VMCPUID idCpu);
|
---|
501 | /** Pointer to FNVMMR0SETJMP2(). */
|
---|
502 | typedef FNVMMR0SETJMP2 *PFNVMMR0SETJMP2;
|
---|
503 |
|
---|
504 | /**
|
---|
505 | * Same as vmmR0CallRing3SetJmp except for the function signature.
|
---|
506 | *
|
---|
507 | * @returns VINF_SUCCESS on success or whatever is passed to vmmR0CallRing3LongJmp.
|
---|
508 | * @param pJmpBuf The jmp_buf to set.
|
---|
509 | * @param pfn The function to be called when not resuming.
|
---|
510 | * @param pGVM The ring-0 VM structure.
|
---|
511 | * @param idCpu The ID of the calling EMT.
|
---|
512 | */
|
---|
513 | DECLASM(int) vmmR0CallRing3SetJmp2(PVMMR0JMPBUF pJmpBuf, PFNVMMR0SETJMP2 pfn, PGVM pGVM, VMCPUID idCpu);
|
---|
514 |
|
---|
515 |
|
---|
516 | /**
|
---|
517 | * Callback function for vmmR0CallRing3SetJmpEx.
|
---|
518 | *
|
---|
519 | * @returns VBox status code.
|
---|
520 | * @param pvUser The user argument.
|
---|
521 | */
|
---|
522 | typedef DECLCALLBACK(int) FNVMMR0SETJMPEX(void *pvUser);
|
---|
523 | /** Pointer to FNVMMR0SETJMPEX(). */
|
---|
524 | typedef FNVMMR0SETJMPEX *PFNVMMR0SETJMPEX;
|
---|
525 |
|
---|
526 | /**
|
---|
527 | * Same as vmmR0CallRing3SetJmp except for the function signature.
|
---|
528 | *
|
---|
529 | * @returns VINF_SUCCESS on success or whatever is passed to vmmR0CallRing3LongJmp.
|
---|
530 | * @param pJmpBuf The jmp_buf to set.
|
---|
531 | * @param pfn The function to be called when not resuming.
|
---|
532 | * @param pvUser The argument of that function.
|
---|
533 | */
|
---|
534 | DECLASM(int) vmmR0CallRing3SetJmpEx(PVMMR0JMPBUF pJmpBuf, PFNVMMR0SETJMPEX pfn, void *pvUser);
|
---|
535 |
|
---|
536 |
|
---|
537 | /**
|
---|
538 | * Worker for VMMRZCallRing3.
|
---|
539 | * This will save the stack and registers.
|
---|
540 | *
|
---|
541 | * @returns rc.
|
---|
542 | * @param pJmpBuf Pointer to the jump buffer.
|
---|
543 | * @param rc The return code.
|
---|
544 | */
|
---|
545 | DECLASM(int) vmmR0CallRing3LongJmp(PVMMR0JMPBUF pJmpBuf, int rc);
|
---|
546 |
|
---|
547 | /**
|
---|
548 | * Internal R0 logger worker: Logger wrapper.
|
---|
549 | */
|
---|
550 | VMMR0DECL(void) vmmR0LoggerWrapper(const char *pszFormat, ...);
|
---|
551 |
|
---|
552 | /**
|
---|
553 | * Internal R0 logger worker: Flush logger.
|
---|
554 | *
|
---|
555 | * @param pLogger The logger instance to flush.
|
---|
556 | * @remark This function must be exported!
|
---|
557 | */
|
---|
558 | VMMR0DECL(void) vmmR0LoggerFlush(PRTLOGGER pLogger);
|
---|
559 |
|
---|
560 | /**
|
---|
561 | * Internal R0 logger worker: Custom prefix.
|
---|
562 | *
|
---|
563 | * @returns Number of chars written.
|
---|
564 | *
|
---|
565 | * @param pLogger The logger instance.
|
---|
566 | * @param pchBuf The output buffer.
|
---|
567 | * @param cchBuf The size of the buffer.
|
---|
568 | * @param pvUser User argument (ignored).
|
---|
569 | */
|
---|
570 | VMMR0DECL(size_t) vmmR0LoggerPrefix(PRTLOGGER pLogger, char *pchBuf, size_t cchBuf, void *pvUser);
|
---|
571 |
|
---|
572 | # ifdef VBOX_WITH_TRIPLE_FAULT_HACK
|
---|
573 | int vmmR0TripleFaultHackInit(void);
|
---|
574 | void vmmR0TripleFaultHackTerm(void);
|
---|
575 | # endif
|
---|
576 |
|
---|
577 | #endif /* IN_RING0 */
|
---|
578 |
|
---|
579 | RT_C_DECLS_END
|
---|
580 |
|
---|
581 | /** @} */
|
---|
582 |
|
---|
583 | #endif /* !VMM_INCLUDED_SRC_include_VMMInternal_h */
|
---|