VMMInternal.h revision 590912f31b9cb162cc45569736a9d08763e4c47b
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync * VMM - Internal header file.
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync * Copyright (C) 2006-2012 Oracle Corporation
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync * available from http://www.virtualbox.org. This file is free software;
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync * you can redistribute it and/or modify it under the terms of the GNU
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync * General Public License (GPL) as published by the Free Software
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
e470d654059e0c976fe3ce83874ac6e8fd2338a6vboxsync#if !defined(IN_VMM_R3) && !defined(IN_VMM_R0) && !defined(IN_VMM_RC)
e470d654059e0c976fe3ce83874ac6e8fd2338a6vboxsync/** @defgroup grp_vmm_int Internals
e470d654059e0c976fe3ce83874ac6e8fd2338a6vboxsync * @ingroup grp_vmm
e470d654059e0c976fe3ce83874ac6e8fd2338a6vboxsync * @internal
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync/** @def VBOX_WITH_RC_RELEASE_LOGGING
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync * Enables RC release logging. */
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync/** @def VBOX_WITH_R0_LOGGING
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync * Enables Ring-0 logging (non-release).
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync * Ring-0 logging isn't 100% safe yet (thread id reuse / process exit cleanup),
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync * so you have to sign up here by adding your defined(DEBUG_<userid>) to the
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync * #if, or by adding VBOX_WITH_R0_LOGGING to your LocalConfig.kmk.
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync#if defined(DEBUG_sandervl) || defined(DEBUG_frank) || defined(DEBUG_ramshankar) || defined(DOXYGEN_RUNNING)
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync/** @def VBOX_STRICT_VMM_STACK
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync * Enables VMM stack guard pages to catch stack over- and underruns. */
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync#if defined(VBOX_STRICT) || defined(DOXYGEN_RUNNING)
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync * Converts a VMM pointer into a VM pointer.
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync * @returns Pointer to the VM structure the VMM is part of.
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync * @param pVMM Pointer to VMM instance data.
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync#define VMM2VM(pVMM) ( (PVM)((char*)pVMM - pVMM->offVM) )
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync * Switcher function, HC to RC.
e470d654059e0c976fe3ce83874ac6e8fd2338a6vboxsync * @param pVM Pointer to the VM.
e470d654059e0c976fe3ce83874ac6e8fd2338a6vboxsync * @returns Return code indicating the action to take.
e470d654059e0c976fe3ce83874ac6e8fd2338a6vboxsync/** Pointer to switcher function. */
e470d654059e0c976fe3ce83874ac6e8fd2338a6vboxsync * Switcher function, RC to HC.
e470d654059e0c976fe3ce83874ac6e8fd2338a6vboxsync * @param rc VBox status code.
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync/** Pointer to switcher function. */
e470d654059e0c976fe3ce83874ac6e8fd2338a6vboxsync * The ring-0 logger instance wrapper.
e470d654059e0c976fe3ce83874ac6e8fd2338a6vboxsync * We need to be able to find the VM handle from the logger instance, so we wrap
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync * it in this structure.
54c3620994786a33db473956c4e6c3c7d94ab695vboxsynctypedef struct VMMR0LOGGER
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync /** Pointer to Pointer to the VM. */
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync /** Size of the allocated logger instance (Logger). */
e470d654059e0c976fe3ce83874ac6e8fd2338a6vboxsync /** Flag indicating whether we've create the logger Ring-0 instance yet. */
e470d654059e0c976fe3ce83874ac6e8fd2338a6vboxsync /** Flag indicating whether we've disabled flushing (world switch) or not. */
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync /** Flag indicating whether we've registered the instance already. */
e470d654059e0c976fe3ce83874ac6e8fd2338a6vboxsync /** The CPU ID. */
e470d654059e0c976fe3ce83874ac6e8fd2338a6vboxsync /** The ring-0 logger instance. This extends beyond the size. */
e470d654059e0c976fe3ce83874ac6e8fd2338a6vboxsync/** Pointer to a ring-0 logger instance wrapper. */
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync * Jump buffer for the setjmp/longjmp like constructs used to
8fa59d6e8a7241b88e10a611d883318d157317cfvboxsync * quickly 'call' back into Ring-3.
e470d654059e0c976fe3ce83874ac6e8fd2338a6vboxsynctypedef struct VMMR0JMPBUF
8fa59d6e8a7241b88e10a611d883318d157317cfvboxsync /** Traditional jmp_buf stuff
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync /** Flag that indicates that we've done a ring-3 call. */
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync /** The number of bytes we've saved. */
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync /** Pointer to the buffer used to save the stack.
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync * This is assumed to be 8KB. */
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync /** Esp we we match against esp on resume to make sure the stack wasn't relocated. */
54c3620994786a33db473956c4e6c3c7d94ab695vboxsync /** The esp we should resume execution with after the restore. */
e470d654059e0c976fe3ce83874ac6e8fd2338a6vboxsync /** ESP/RSP at the time of the jump to ring 3. */
} VMMR0JMPBUF;
typedef struct VMM
#ifdef VBOX_WITH_NMI
/** Size of the allocated logger instance (pRCLoggerRC/pRCLoggerR3). */
/** Size of the allocated release logger instance (pRCRelLoggerRC/pRCRelLoggerR3).
bool fStackGuardsStationed;
} VMM;
typedef struct VMMCPU
bool volatile fInRendezvous;
} VMMCPU;
typedef enum VMMGCOPERATION
int vmmInitFormatTypes(void);
void vmmTermFormatTypes(void);
#ifdef IN_RING3
#ifdef IN_RING0
# ifdef VBOX_WITH_TRIPLE_FAULT_HACK
int vmmR0TripleFaultHackInit(void);
void vmmR0TripleFaultHackTerm(void);
#ifdef IN_RC