VMMInternal.h revision fa68b6ad102b983736f554a673bb2ee4259ee699
/* $Id$ */
/** @file
* VMM - Internal header file.
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#ifndef ___VMMInternal_h
#define ___VMMInternal_h
#include <iprt/critsect.h>
# error "Not in VMM! This is an internal header!"
#endif
/** @defgroup grp_vmm_int Internals
* @ingroup grp_vmm
* @internal
* @{
*/
/** @def VBOX_WITH_RC_RELEASE_LOGGING
* Enables RC release logging. */
#define VBOX_WITH_RC_RELEASE_LOGGING
/** @def VBOX_WITH_R0_LOGGING
* Enables Ring-0 logging (non-release).
*
* Ring-0 logging isn't 100% safe yet (thread id reuse / process exit cleanup),
* so you have to sign up here by adding your defined(DEBUG_<userid>) to the
* #if, or by adding VBOX_WITH_R0_LOGGING to your LocalConfig.kmk.
*
* You might also wish to enable the AssertMsg1/2 overrides in VMMR0.cpp when
* enabling this.
*/
# define VBOX_WITH_R0_LOGGING
#endif
/**
* Converts a VMM pointer into a VM pointer.
* @returns Pointer to the VM structure the VMM is part of.
* @param pVMM Pointer to VMM instance data.
*/
/**
* Switcher function, HC to RC.
*
* @param pVM The VM handle.
* @returns Return code indicating the action to take.
*/
/** Pointer to switcher function. */
typedef FNVMMSWITCHERHC *PFNVMMSWITCHERHC;
/**
* Switcher function, RC to HC.
*
* @param rc VBox status code.
*/
/** Pointer to switcher function. */
typedef FNVMMSWITCHERRC *PFNVMMSWITCHERRC;
/**
* The ring-0 logger instance wrapper.
*
* We need to be able to find the VM handle from the logger instance, so we wrap
* it in this structure.
*/
typedef struct VMMR0LOGGER
{
/** Pointer to the VM handle. */
/** Size of the allocated logger instance (Logger). */
/** Flag indicating whether we've create the logger Ring-0 instance yet. */
bool fCreated;
/** Flag indicating whether we've disabled flushing (world switch) or not. */
bool fFlushingDisabled;
#if HC_ARCH_BITS == 32
#endif
/** The ring-0 logger instance. This extends beyond the size. */
} VMMR0LOGGER;
/** Pointer to a ring-0 logger instance wrapper. */
typedef VMMR0LOGGER *PVMMR0LOGGER;
/**
* quickly 'call' back into Ring-3.
*/
typedef struct VMMR0JMPBUF
{
/** Traditional jmp_buf stuff
* @{ */
#if HC_ARCH_BITS == 32
#endif
#if HC_ARCH_BITS == 64
# ifdef RT_OS_WINDOWS
# endif
#endif
/** @} */
/** Flag that indicates that we've done a ring-3 call. */
bool fInRing3Call;
/** The number of bytes we've saved. */
/** Pointer to the buffer used to save the stack.
* This is assumed to be 8KB. */
/** Esp we we match against esp on resume to make sure the stack wasn't relocated. */
/** The esp we should resume execution with after the restore. */
} VMMR0JMPBUF;
/** Pointer to a ring-0 jump buffer. */
typedef VMMR0JMPBUF *PVMMR0JMPBUF;
/**
* VMM Data (part of VM)
*/
typedef struct VMM
{
/** Offset to the VM structure.
* See VMM2VM(). */
/** @name World Switcher and Related
* @{
*/
/** Size of the core code. */
/** Physical address of core code. */
/** Pointer to core code ring-3 mapping - contiguous memory.
* At present this only means the context switcher code. */
/** Pointer to core code ring-0 mapping - contiguous memory.
* At present this only means the context switcher code. */
/** Pointer to core code guest context mapping. */
#ifdef VBOX_WITH_NMI
/** The guest context address of the APIC (host) mapping. */
#endif
/** The current switcher.
* This will be set before the VMM is fully initialized. */
/** Flag to disable the switcher permanently (VMX) (boolean) */
bool fSwitcherDisabled;
/** Array of offsets to the different switchers within the core code. */
/** Resume Guest Execution. See CPUMGCResumeGuest(). */
/** Resume Guest Execution in V86 mode. See CPUMGCResumeGuestV86(). */
/** Call Trampoline. See vmmGCCallTrampoline(). */
/** Guest to host switcher entry point. */
/** Host to guest switcher entry point. */
/** @} */
/** @name Logging
* @{
*/
/** Size of the allocated logger instance (pRCLoggerRC/pRCLoggerR3). */
/** Pointer to the RC logger instance - RC Ptr.
* This is NULL if logging is disabled. */
/** Pointer to the GC logger instance - R3 Ptr.
* This is NULL if logging is disabled. */
/** Pointer to the GC release logger instance - R3 Ptr. */
/** Pointer to the GC release logger instance - RC Ptr. */
/** Size of the allocated release logger instance (pRCRelLoggerRC/pRCRelLoggerR3).
* This may differ from cbRCLogger. */
/** @} */
/** The EMT yield timer. */
/** The period to the next timeout when suspended or stopped.
* This is 0 when running. */
/** The EMT yield timer interval (milliseconds). */
/** The timestamp of the previous yield. (nano) */
/** Critical section.
* Use for synchronizing all VCPUs
*/
/** Buffer for storing the standard assertion message for a ring-0 assertion.
* Used for saving the assertion message text for the release log and guru
* meditation dump. */
char szRing0AssertMsg1[512];
/** Buffer for storing the custom message for a ring-0 assertion. */
char szRing0AssertMsg2[256];
/** Number of VMMR0_DO_RUN_GC calls. */
* @{ */
/** @} */
} VMM;
/** Pointer to VMM. */
/**
* VMMCPU Data (part of VMCPU)
*/
typedef struct VMMCPU
{
/** Offset to the VMCPU structure.
* See VMM2VMCPU(). */
/** VMM stack, pointer to the top of the stack in R3.
* Stack is allocated from the hypervisor heap and is page aligned
* and always writable in RC. */
/** Pointer to the bottom of the stack - needed for doing relocations. */
/** Pointer to the bottom of the stack - needed for doing relocations. */
/** Pointer to the R0 logger instance - R3 Ptr.
* This is NULL if logging is disabled. */
/** Pointer to the R0 logger instance - R0 Ptr.
* This is NULL if logging is disabled. */
/** @name CallHost
* @{ */
/** The pending operation. */
/** The result of the last operation. */
#if HC_ARCH_BITS == 32
#endif
/** The argument to the operation. */
/** The Ring-0 jmp buffer. */
/** @} */
} VMMCPU;
/** Pointer to VMMCPU. */
/**
* The VMMGCEntry() codes.
*/
typedef enum VMMGCOPERATION
{
/** Do GC module init. */
VMMGC_DO_VMMGC_INIT = 1,
/** The first Trap testcase. */
VMMGC_DO_TESTCASE_TRAP_FIRST = 0x0dead000,
/** Trap 0 testcases, uArg selects the variation. */
/** Trap 1 testcases, uArg selects the variation. */
/** Trap 2 testcases, uArg selects the variation. */
/** Trap 3 testcases, uArg selects the variation. */
/** Trap 4 testcases, uArg selects the variation. */
/** Trap 5 testcases, uArg selects the variation. */
/** Trap 6 testcases, uArg selects the variation. */
/** Trap 7 testcases, uArg selects the variation. */
/** Trap 8 testcases, uArg selects the variation. */
/** Trap 9 testcases, uArg selects the variation. */
/** Trap 0a testcases, uArg selects the variation. */
/** Trap 0b testcases, uArg selects the variation. */
/** Trap 0c testcases, uArg selects the variation. */
/** Trap 0d testcases, uArg selects the variation. */
/** Trap 0e testcases, uArg selects the variation. */
/** The last trap testcase (exclusive). */
/** Testcase for checking interrupt forwarding. */
/** Switching testing and profiling stub. */
/** Testcase for checking interrupt masking.. */
/** Switching testing and profiling stub. */
/** The usual 32-bit hack. */
VMMGC_DO_32_BIT_HACK = 0x7fffffff
#ifdef IN_RING3
#endif /* IN_RING3 */
#ifdef IN_RING0
/**
* World switcher assembly routine.
* It will call VMMGCEntry().
*
* @returns return code from VMMGCEntry().
* @param pVM The VM in question.
* @param uArg See VMMGCEntry().
* @internal
*/
/**
* Callback function for vmmR0CallHostSetJmp.
*
* @returns VBox status code.
* @param pVM The VM handle.
*/
/** Pointer to FNVMMR0SETJMP(). */
typedef FNVMMR0SETJMP *PFNVMMR0SETJMP;
/**
* The setjmp variant used for calling Ring-3.
*
* This differs from the normal setjmp in that it will resume VMMR0CallHost if we're
* in the middle of a ring-3 call. Another differences is the function pointer and
* argument. This has to do with resuming code and the stack frame of the caller.
*
* @returns VINF_SUCCESS on success or whatever is passed to vmmR0CallHostLongJmp.
* @param pJmpBuf The jmp_buf to set.
* @param pfn The function to be called when not resuming..
* @param pVM The argument of that function.
*/
/**
* Callback function for vmmR0CallHostSetJmpEx.
*
* @returns VBox status code.
* @param pvUser The user argument.
*/
/** Pointer to FNVMMR0SETJMP(). */
typedef FNVMMR0SETJMPEX *PFNVMMR0SETJMPEX;
/**
* Same as vmmR0CallHostSetJmp except for the function signature.
*
* @returns VINF_SUCCESS on success or whatever is passed to vmmR0CallHostLongJmp.
* @param pJmpBuf The jmp_buf to set.
* @param pfn The function to be called when not resuming..
* @param pvUser The argument of that function.
*/
/**
* Worker for VMMR0CallHost.
* This will save the stack and registers.
*
* @returns rc.
* @param pJmpBuf Pointer to the jump buffer.
* @param rc The return code.
*/
/**
* Internal R0 logger worker: Logger wrapper.
*/
/**
* Internal R0 logger worker: Flush logger.
*
* @param pLogger The logger instance to flush.
* @remark This function must be exported!
*/
#endif /* IN_RING0 */
#ifdef IN_RC
/**
* Internal GC logger worker: Logger wrapper.
*/
/**
* Internal GC release logger worker: Logger wrapper.
*/
/**
* Internal GC logger worker: Flush logger.
*
* @returns VINF_SUCCESS.
* @param pLogger The logger instance to flush.
* @remark This function must be exported!
*/
/** @name Trap testcases and related labels.
* @{ */
DECLASM(void) vmmGCEnableWP(void);
DECLASM(void) vmmGCDisableWP(void);
DECLASM(int) vmmGCTestTrap3(void);
DECLASM(int) vmmGCTestTrap8(void);
DECLASM(int) vmmGCTestTrap0d(void);
DECLASM(int) vmmGCTestTrap0e(void);
/** @} */
#endif /* IN_RC */
/** @} */
#endif