VirtualBox

source: vbox/trunk/src/VBox/VMM/include/VMMInternal.h@ 55909

Last change on this file since 55909 was 55863, checked in by vboxsync, 10 years ago

IPRT,SUPDrv,VMM: Revised the context switching hook interface. Do less work when enabling the hook (formerly 'registration'). Drop the reference counting (kept internally for solaris) as it complicates restrictions wrt destroying enabled hooks. Bumped support driver version.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette