VMInternal.h revision aafa3e3a526c178adf4947048684ed4590a16981
f48205be61a214698b763ff550ab9e657525104ccasper/* $Id$ */
f48205be61a214698b763ff550ab9e657525104ccasper/** @file
f48205be61a214698b763ff550ab9e657525104ccasper * VM - Internal header file.
f48205be61a214698b763ff550ab9e657525104ccasper */
f48205be61a214698b763ff550ab9e657525104ccasper
f48205be61a214698b763ff550ab9e657525104ccasper/*
f48205be61a214698b763ff550ab9e657525104ccasper * Copyright (C) 2006-2011 Oracle Corporation
f48205be61a214698b763ff550ab9e657525104ccasper *
f48205be61a214698b763ff550ab9e657525104ccasper * This file is part of VirtualBox Open Source Edition (OSE), as
f48205be61a214698b763ff550ab9e657525104ccasper * available from http://www.virtualbox.org. This file is free software;
f48205be61a214698b763ff550ab9e657525104ccasper * you can redistribute it and/or modify it under the terms of the GNU
f48205be61a214698b763ff550ab9e657525104ccasper * General Public License (GPL) as published by the Free Software
f48205be61a214698b763ff550ab9e657525104ccasper * Foundation, in version 2 as it comes in the "COPYING" file of the
f48205be61a214698b763ff550ab9e657525104ccasper * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
f48205be61a214698b763ff550ab9e657525104ccasper * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
f48205be61a214698b763ff550ab9e657525104ccasper */
f48205be61a214698b763ff550ab9e657525104ccasper
f48205be61a214698b763ff550ab9e657525104ccasper#ifndef ___VMInternal_h
f48205be61a214698b763ff550ab9e657525104ccasper#define ___VMInternal_h
f48205be61a214698b763ff550ab9e657525104ccasper
f48205be61a214698b763ff550ab9e657525104ccasper#include <VBox/cdefs.h>
f48205be61a214698b763ff550ab9e657525104ccasper#include <VBox/vmm/vmapi.h>
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States#include <iprt/assert.h>
f48205be61a214698b763ff550ab9e657525104ccasper#include <iprt/critsect.h>
f48205be61a214698b763ff550ab9e657525104ccasper#include <setjmp.h>
f48205be61a214698b763ff550ab9e657525104ccasper
f48205be61a214698b763ff550ab9e657525104ccasper
f48205be61a214698b763ff550ab9e657525104ccasper
f48205be61a214698b763ff550ab9e657525104ccasper/** @defgroup grp_vm_int Internals
f48205be61a214698b763ff550ab9e657525104ccasper * @ingroup grp_vm
f48205be61a214698b763ff550ab9e657525104ccasper * @internal
f48205be61a214698b763ff550ab9e657525104ccasper * @{
f48205be61a214698b763ff550ab9e657525104ccasper */
f48205be61a214698b763ff550ab9e657525104ccasper
f48205be61a214698b763ff550ab9e657525104ccasper
f48205be61a214698b763ff550ab9e657525104ccasper/**
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * VM state change callback.
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw */
f48205be61a214698b763ff550ab9e657525104ccaspertypedef struct VMATSTATE
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw{
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /** Pointer to the next one. */
f48205be61a214698b763ff550ab9e657525104ccasper struct VMATSTATE *pNext;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /** Pointer to the callback. */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw PFNVMATSTATE pfnAtState;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /** The user argument. */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw void *pvUser;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw} VMATSTATE;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw/** Pointer to a VM state change callback. */
bda89588bd7667394a834e8a9a34612cce2ae9c3jptypedef VMATSTATE *PVMATSTATE;
f48205be61a214698b763ff550ab9e657525104ccasper
bda89588bd7667394a834e8a9a34612cce2ae9c3jp
f48205be61a214698b763ff550ab9e657525104ccasper/**
bda89588bd7667394a834e8a9a34612cce2ae9c3jp * VM error callback.
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw */
f48205be61a214698b763ff550ab9e657525104ccaspertypedef struct VMATERROR
bda89588bd7667394a834e8a9a34612cce2ae9c3jp{
bda89588bd7667394a834e8a9a34612cce2ae9c3jp /** Pointer to the next one. */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw struct VMATERROR *pNext;
bda89588bd7667394a834e8a9a34612cce2ae9c3jp /** Pointer to the callback. */
bda89588bd7667394a834e8a9a34612cce2ae9c3jp PFNVMATERROR pfnAtError;
bda89588bd7667394a834e8a9a34612cce2ae9c3jp /** The user argument. */
f48205be61a214698b763ff550ab9e657525104ccasper void *pvUser;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw} VMATERROR;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw/** Pointer to a VM error callback. */
f48205be61a214698b763ff550ab9e657525104ccaspertypedef VMATERROR *PVMATERROR;
bda89588bd7667394a834e8a9a34612cce2ae9c3jp
bda89588bd7667394a834e8a9a34612cce2ae9c3jp
f48205be61a214698b763ff550ab9e657525104ccasper/**
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * Chunk of memory allocated off the hypervisor heap in which
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * we copy the error details.
f48205be61a214698b763ff550ab9e657525104ccasper */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwtypedef struct VMERROR
bda89588bd7667394a834e8a9a34612cce2ae9c3jp{
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /** The size of the chunk. */
bda89588bd7667394a834e8a9a34612cce2ae9c3jp uint32_t cbAllocated;
f48205be61a214698b763ff550ab9e657525104ccasper /** The current offset into the chunk.
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * We start by putting the filename and function immediately
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * after the end of the buffer. */
f48205be61a214698b763ff550ab9e657525104ccasper uint32_t off;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /** Offset from the start of this structure to the file name. */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw uint32_t offFile;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /** The line number. */
f48205be61a214698b763ff550ab9e657525104ccasper uint32_t iLine;
f48205be61a214698b763ff550ab9e657525104ccasper /** Offset from the start of this structure to the function name. */
f48205be61a214698b763ff550ab9e657525104ccasper uint32_t offFunction;
f48205be61a214698b763ff550ab9e657525104ccasper /** Offset from the start of this structure to the formatted message text. */
f48205be61a214698b763ff550ab9e657525104ccasper uint32_t offMessage;
f48205be61a214698b763ff550ab9e657525104ccasper /** The VBox status code. */
f48205be61a214698b763ff550ab9e657525104ccasper int32_t rc;
bda89588bd7667394a834e8a9a34612cce2ae9c3jp} VMERROR, *PVMERROR;
f48205be61a214698b763ff550ab9e657525104ccasper
bda89588bd7667394a834e8a9a34612cce2ae9c3jp
f48205be61a214698b763ff550ab9e657525104ccasper/**
f48205be61a214698b763ff550ab9e657525104ccasper * VM runtime error callback.
f48205be61a214698b763ff550ab9e657525104ccasper */
f48205be61a214698b763ff550ab9e657525104ccaspertypedef struct VMATRUNTIMEERROR
f48205be61a214698b763ff550ab9e657525104ccasper{
f48205be61a214698b763ff550ab9e657525104ccasper /** Pointer to the next one. */
f48205be61a214698b763ff550ab9e657525104ccasper struct VMATRUNTIMEERROR *pNext;
bda89588bd7667394a834e8a9a34612cce2ae9c3jp /** Pointer to the callback. */
bda89588bd7667394a834e8a9a34612cce2ae9c3jp PFNVMATRUNTIMEERROR pfnAtRuntimeError;
f48205be61a214698b763ff550ab9e657525104ccasper /** The user argument. */
bda89588bd7667394a834e8a9a34612cce2ae9c3jp void *pvUser;
f48205be61a214698b763ff550ab9e657525104ccasper} VMATRUNTIMEERROR;
f48205be61a214698b763ff550ab9e657525104ccasper/** Pointer to a VM error callback. */
f48205be61a214698b763ff550ab9e657525104ccaspertypedef VMATRUNTIMEERROR *PVMATRUNTIMEERROR;
f48205be61a214698b763ff550ab9e657525104ccasper
f48205be61a214698b763ff550ab9e657525104ccasper
f48205be61a214698b763ff550ab9e657525104ccasper/**
f48205be61a214698b763ff550ab9e657525104ccasper * Chunk of memory allocated off the hypervisor heap in which
bda89588bd7667394a834e8a9a34612cce2ae9c3jp * we copy the runtime error details.
f48205be61a214698b763ff550ab9e657525104ccasper */
f48205be61a214698b763ff550ab9e657525104ccaspertypedef struct VMRUNTIMEERROR
f48205be61a214698b763ff550ab9e657525104ccasper{
f48205be61a214698b763ff550ab9e657525104ccasper /** The size of the chunk. */
bda89588bd7667394a834e8a9a34612cce2ae9c3jp uint32_t cbAllocated;
bda89588bd7667394a834e8a9a34612cce2ae9c3jp /** The current offset into the chunk.
f48205be61a214698b763ff550ab9e657525104ccasper * We start by putting the error ID immediately
f48205be61a214698b763ff550ab9e657525104ccasper * after the end of the buffer. */
f48205be61a214698b763ff550ab9e657525104ccasper uint32_t off;
f48205be61a214698b763ff550ab9e657525104ccasper /** Offset from the start of this structure to the error ID. */
f48205be61a214698b763ff550ab9e657525104ccasper uint32_t offErrorId;
f48205be61a214698b763ff550ab9e657525104ccasper /** Offset from the start of this structure to the formatted message text. */
f48205be61a214698b763ff550ab9e657525104ccasper uint32_t offMessage;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States /** Error flags. */
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States uint32_t fFlags;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States} VMRUNTIMEERROR, *PVMRUNTIMEERROR;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States/** The halt method. */
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United Statestypedef enum
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States{
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States /** The usual invalid value. */
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States VMHALTMETHOD_INVALID = 0,
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States /** Use the method used during bootstrapping. */
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States VMHALTMETHOD_BOOTSTRAP,
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States /** Use the default method. */
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States VMHALTMETHOD_DEFAULT,
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States /** The old spin/yield/block method. */
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States VMHALTMETHOD_OLD,
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States /** The first go at a block/spin method. */
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States VMHALTMETHOD_1,
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States /** The first go at a more global approach. */
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States VMHALTMETHOD_GLOBAL_1,
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States /** The end of valid methods. (not inclusive of course) */
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States VMHALTMETHOD_END,
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States /** The usual 32-bit max value. */
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States VMHALTMETHOD_32BIT_HACK = 0x7fffffff
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States} VMHALTMETHOD;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States/**
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States * VM Internal Data (part of the VM structure).
f48205be61a214698b763ff550ab9e657525104ccasper *
f48205be61a214698b763ff550ab9e657525104ccasper * @todo Move this and all related things to VMM. The VM component was, to some
f48205be61a214698b763ff550ab9e657525104ccasper * extent at least, a bad ad hoc design which should all have been put in
f48205be61a214698b763ff550ab9e657525104ccasper * VMM. @see pg_vm.
f48205be61a214698b763ff550ab9e657525104ccasper */
f48205be61a214698b763ff550ab9e657525104ccaspertypedef struct VMINT
f48205be61a214698b763ff550ab9e657525104ccasper{
f48205be61a214698b763ff550ab9e657525104ccasper /** VM Error Message. */
f48205be61a214698b763ff550ab9e657525104ccasper R3PTRTYPE(PVMERROR) pErrorR3;
f48205be61a214698b763ff550ab9e657525104ccasper /** VM Runtime Error Message. */
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States R3PTRTYPE(PVMRUNTIMEERROR) pRuntimeErrorR3;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States /** The VM was/is-being teleported and has not yet been fully resumed. */
f48205be61a214698b763ff550ab9e657525104ccasper bool fTeleportedAndNotFullyResumedYet;
f48205be61a214698b763ff550ab9e657525104ccasper /** The VM should power off instead of reset. */
f48205be61a214698b763ff550ab9e657525104ccasper bool fPowerOffInsteadOfReset;
f48205be61a214698b763ff550ab9e657525104ccasper} VMINT;
/** Pointer to the VM Internal Data (part of the VM structure). */
typedef VMINT *PVMINT;
#ifdef IN_RING3
/**
* VM internal data kept in the UVM.
*/
typedef struct VMINTUSERPERVM
{
/** Head of the standard request queue. Atomic. */
volatile PVMREQ pNormalReqs;
/** Head of the priority request queue. Atomic. */
volatile PVMREQ pPriorityReqs;
/** The last index used during alloc/free. */
volatile uint32_t iReqFree;
/** Number of free request packets. */
volatile uint32_t cReqFree;
/** Array of pointers to lists of free request packets. Atomic. */
volatile PVMREQ apReqFree[16 - (HC_ARCH_BITS == 32 ? 5 : 4)];
/** The reference count of the UVM handle. */
volatile uint32_t cUvmRefs;
# ifdef VBOX_WITH_STATISTICS
/** Number of VMR3ReqAlloc returning a new packet. */
STAMCOUNTER StatReqAllocNew;
/** Number of VMR3ReqAlloc causing races. */
STAMCOUNTER StatReqAllocRaces;
/** Number of VMR3ReqAlloc returning a recycled packet. */
STAMCOUNTER StatReqAllocRecycled;
/** Number of VMR3ReqFree calls. */
STAMCOUNTER StatReqFree;
/** Number of times the request was actually freed. */
STAMCOUNTER StatReqFreeOverflow;
/** Number of requests served. */
STAMCOUNTER StatReqProcessed;
/** Number of times there are more than one request and the others needed to be
* pushed back onto the list. */
STAMCOUNTER StatReqMoreThan1;
/** Number of times we've raced someone when pushing the other requests back
* onto the list. */
STAMCOUNTER StatReqPushBackRaces;
# endif
/** Pointer to the support library session.
* Mainly for creation and destruction. */
PSUPDRVSESSION pSession;
/** Force EMT to terminate. */
bool volatile fTerminateEMT;
/** Critical section for pAtState and enmPrevVMState. */
RTCRITSECT AtStateCritSect;
/** List of registered state change callbacks. */
PVMATSTATE pAtState;
/** List of registered state change callbacks. */
PVMATSTATE *ppAtStateNext;
/** The previous VM state.
* This is mainly used for the 'Resetting' state, but may come in handy later
* and when debugging. */
VMSTATE enmPrevVMState;
/** Reason for the most recent suspend operation. */
VMSUSPENDREASON enmSuspendReason;
/** Reason for the most recent operation. */
VMRESUMEREASON enmResumeReason;
/** Critical section for pAtError and pAtRuntimeError. */
RTCRITSECT AtErrorCritSect;
/** List of registered error callbacks. */
PVMATERROR pAtError;
/** List of registered error callbacks. */
PVMATERROR *ppAtErrorNext;
/** The error message count.
* This is incremented every time an error is raised. */
uint32_t volatile cErrors;
/** The runtime error message count.
* This is incremented every time a runtime error is raised. */
uint32_t volatile cRuntimeErrors;
/** List of registered error callbacks. */
PVMATRUNTIMEERROR pAtRuntimeError;
/** List of registered error callbacks. */
PVMATRUNTIMEERROR *ppAtRuntimeErrorNext;
/** @name Generic Halt data
* @{
*/
/** The current halt method.
* Can be selected by CFGM option 'VM/HaltMethod'. */
VMHALTMETHOD enmHaltMethod;
/** The index into g_aHaltMethods of the current halt method. */
uint32_t volatile iHaltMethod;
/** @} */
/** @todo Do NOT add new members here or reuse the current, we need to store the config for
* each halt method separately because we're racing on SMP guest rigs. */
union
{
/**
* Method 1 & 2 - Block whenever possible, and when lagging behind
* switch to spinning with regular blocking every 5-200ms (defaults)
* depending on the accumulated lag. The blocking interval is adjusted
* with the average oversleeping of the last 64 times.
*
* The difference between 1 and 2 is that we use native absolute
* time APIs for the blocking instead of the millisecond based IPRT
* interface.
*/
struct
{
/** The max interval without blocking (when spinning). */
uint32_t u32MinBlockIntervalCfg;
/** The minimum interval between blocking (when spinning). */
uint32_t u32MaxBlockIntervalCfg;
/** The value to divide the current lag by to get the raw blocking interval (when spinning). */
uint32_t u32LagBlockIntervalDivisorCfg;
/** When to start spinning (lag / nano secs). */
uint32_t u32StartSpinningCfg;
/** When to stop spinning (lag / nano secs). */
uint32_t u32StopSpinningCfg;
} Method12;
/**
* The GVMM manages halted and waiting EMTs.
*/
struct
{
/** The threshold between spinning and blocking. */
uint32_t cNsSpinBlockThresholdCfg;
} Global1;
} Halt;
/** Pointer to the DBGC instance data. */
void *pvDBGC;
/** TLS index for the VMINTUSERPERVMCPU pointer. */
RTTLS idxTLS;
/** The VM name. (Set after the config constructure has been called.) */
char *pszName;
/** The VM UUID. (Set after the config constructure has been called.) */
RTUUID Uuid;
} VMINTUSERPERVM;
# ifdef VBOX_WITH_STATISTICS
AssertCompileMemberAlignment(VMINTUSERPERVM, StatReqAllocNew, 8);
# endif
/** Pointer to the VM internal data kept in the UVM. */
typedef VMINTUSERPERVM *PVMINTUSERPERVM;
/**
* VMCPU internal data kept in the UVM.
*
* Almost a copy of VMINTUSERPERVM. Separate data properly later on.
*/
typedef struct VMINTUSERPERVMCPU
{
/** Head of the normal request queue. Atomic. */
volatile PVMREQ pNormalReqs;
/** Head of the priority request queue. Atomic. */
volatile PVMREQ pPriorityReqs;
/** The handle to the EMT thread. */
RTTHREAD ThreadEMT;
/** The native of the EMT thread. */
RTNATIVETHREAD NativeThreadEMT;
/** Wait event semaphore. */
RTSEMEVENT EventSemWait;
/** Wait/Idle indicator. */
bool volatile fWait;
/** Align the next bit. */
bool afAlignment[HC_ARCH_BITS == 32 ? 3 : 7];
/** @name Generic Halt data
* @{
*/
/** The average time (ns) between two halts in the last second. (updated once per second) */
uint32_t HaltInterval;
/** The average halt frequency for the last second. (updated once per second) */
uint32_t HaltFrequency;
/** The number of halts in the current period. */
uint32_t cHalts;
uint32_t padding; /**< alignment padding. */
/** When we started counting halts in cHalts (RTTimeNanoTS). */
uint64_t u64HaltsStartTS;
/** @} */
/** Union containing data and config for the different halt algorithms. */
union
{
/**
* Method 1 & 2 - Block whenever possible, and when lagging behind
* switch to spinning with regular blocking every 5-200ms (defaults)
* depending on the accumulated lag. The blocking interval is adjusted
* with the average oversleeping of the last 64 times.
*
* The difference between 1 and 2 is that we use native absolute
* time APIs for the blocking instead of the millisecond based IPRT
* interface.
*/
struct
{
/** How many times we've blocked while cBlockedNS and cBlockedTooLongNS has been accumulating. */
uint32_t cBlocks;
/** Align the next member. */
uint32_t u32Alignment;
/** Avg. time spend oversleeping when blocking. (Re-calculated every so often.) */
uint64_t cNSBlockedTooLongAvg;
/** Total time spend oversleeping when blocking. */
uint64_t cNSBlockedTooLong;
/** Total time spent blocking. */
uint64_t cNSBlocked;
/** The timestamp (RTTimeNanoTS) of the last block. */
uint64_t u64LastBlockTS;
/** When we started spinning relentlessly in order to catch up some of the oversleeping.
* This is 0 when we're not spinning. */
uint64_t u64StartSpinTS;
} Method12;
# if 0
/**
* Method 3 & 4 - Same as method 1 & 2 respectivly, except that we
* sprinkle it with yields.
*/
struct
{
/** How many times we've blocked while cBlockedNS and cBlockedTooLongNS has been accumulating. */
uint32_t cBlocks;
/** Avg. time spend oversleeping when blocking. (Re-calculated every so often.) */
uint64_t cBlockedTooLongNSAvg;
/** Total time spend oversleeping when blocking. */
uint64_t cBlockedTooLongNS;
/** Total time spent blocking. */
uint64_t cBlockedNS;
/** The timestamp (RTTimeNanoTS) of the last block. */
uint64_t u64LastBlockTS;
/** How many times we've yielded while cBlockedNS and cBlockedTooLongNS has been accumulating. */
uint32_t cYields;
/** Avg. time spend oversleeping when yielding. */
uint32_t cYieldTooLongNSAvg;
/** Total time spend oversleeping when yielding. */
uint64_t cYieldTooLongNS;
/** Total time spent yielding. */
uint64_t cYieldedNS;
/** The timestamp (RTTimeNanoTS) of the last block. */
uint64_t u64LastYieldTS;
/** When we started spinning relentlessly in order to catch up some of the oversleeping. */
uint64_t u64StartSpinTS;
} Method34;
# endif
} Halt;
/** Profiling the halted state; yielding vs blocking.
* @{ */
STAMPROFILE StatHaltYield;
STAMPROFILE StatHaltBlock;
STAMPROFILE StatHaltBlockOverslept;
STAMPROFILE StatHaltBlockInsomnia;
STAMPROFILE StatHaltBlockOnTime;
STAMPROFILE StatHaltTimers;
STAMPROFILE StatHaltPoll;
/** @} */
} VMINTUSERPERVMCPU;
AssertCompileMemberAlignment(VMINTUSERPERVMCPU, u64HaltsStartTS, 8);
AssertCompileMemberAlignment(VMINTUSERPERVMCPU, Halt.Method12.cNSBlockedTooLongAvg, 8);
AssertCompileMemberAlignment(VMINTUSERPERVMCPU, StatHaltYield, 8);
/** Pointer to the VM internal data kept in the UVM. */
typedef VMINTUSERPERVMCPU *PVMINTUSERPERVMCPU;
#endif /* IN_RING3 */
RT_C_DECLS_BEGIN
DECLCALLBACK(int) vmR3EmulationThread(RTTHREAD ThreadSelf, void *pvArg);
int vmR3SetHaltMethodU(PUVM pUVM, VMHALTMETHOD enmHaltMethod);
DECLCALLBACK(int) vmR3Destroy(PVM pVM);
DECLCALLBACK(void) vmR3SetErrorUV(PUVM pUVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list *args);
void vmSetErrorCopy(PVM pVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list args);
DECLCALLBACK(int) vmR3SetRuntimeError(PVM pVM, uint32_t fFlags, const char *pszErrorId, char *pszMessage);
DECLCALLBACK(int) vmR3SetRuntimeErrorV(PVM pVM, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list *pVa);
void vmSetRuntimeErrorCopy(PVM pVM, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va);
void vmR3SetGuruMeditation(PVM pVM);
void vmR3SetTerminated(PVM pVM);
RT_C_DECLS_END
/** @} */
#endif