vm.h revision d292438512fae43184049e5354a9d74788a135ed
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * VM - The Virtual Machine, data.
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * Copyright (C) 2006-2007 innotek GmbH
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * This file is part of VirtualBox Open Source Edition (OSE), as
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * available from http://www.virtualbox.org. This file is free software;
96ad5d81ee4a2cc66a4ae19893efc8aa6d06fae7jailletc * you can redistribute it and/or modify it under the terms of the GNU
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * General Public License as published by the Free Software Foundation,
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * distribution. VirtualBox OSE is distributed in the hope that it will
2e545ce2450a9953665f701bb05350f0d3f26275nd * be useful, but WITHOUT ANY WARRANTY of any kind.
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** @defgroup grp_vm The Virtual Machine
d474d8ef01ec5c2a09341cd148851ed383c3287crbowen/** The name of the Guest Context VMM Core module. */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** The name of the Ring 0 Context VMM Core module. */
4b575a6b6704b516f22d65a3ad35696d7b9ba372rpluem/** VM Forced Action Flags.
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * Use the VM_FF_SET() and VM_FF_CLEAR() macros to change the force
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * action mask of a VM.
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** This action forces the VM to service check and pending interrups on the APIC. */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** This action forces the VM to service check and pending interrups on the PIC. */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** This action forces the VM to schedule and run pending timer (TM). */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** PDM Queues are pending. */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** PDM DMA transfers are pending. */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** PDM critical section unlocking is pending, process promptly upon return to R3. */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** This action forces the VM to call DBGF so DBGF can service debugger
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * requests in the emulation thread.
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * This action flag stays asserted till DBGF clears it.*/
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** This action forces the VM to service pending requests from other
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * thread or requests which must be executed in another context. */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** Terminate the VM immediately. */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** Reset the VM. (postponed) */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** This action forces the VM to resync the page tables before going
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * back to execute guest code. (GLOBAL FLUSH) */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** Same as VM_FF_PGM_SYNC_CR3 except that global pages can be skipped.
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * (NON-GLOBAL FLUSH) */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** PGM needs to allocate handy pages. */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** Check the interupt and trap gates */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** Check Guest's TSS ring 0 stack */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** Check Guest's GDT table */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** Check Guest's LDT table */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** Inhibit interrupts pending. See EMGetInhibitInterruptsPC(). */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** CSAM needs to scan the page that's being executed */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** CSAM needs to do some homework. */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** Force return to Ring-3. */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** Suspend the VM - debug only. */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** Externally forced actions. Used to quit the idle/wait loop. */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess#define VM_FF_EXTERNAL_SUSPENDED_MASK (VM_FF_TERMINATE | VM_FF_DBGF | VM_FF_REQUEST)
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** Externally forced actions. Used to quit the idle/wait loop. */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess#define VM_FF_EXTERNAL_HALTED_MASK (VM_FF_TERMINATE | VM_FF_DBGF | VM_FF_TIMER | VM_FF_INTERRUPT_APIC | VM_FF_INTERRUPT_PIC | VM_FF_REQUEST | VM_FF_PDM_QUEUES | VM_FF_PDM_DMA)
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** High priority pre-execution actions. */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess#define VM_FF_HIGH_PRIORITY_PRE_MASK (VM_FF_TERMINATE | VM_FF_DBGF | VM_FF_INTERRUPT_APIC | VM_FF_INTERRUPT_PIC | VM_FF_TIMER | VM_FF_DEBUG_SUSPEND \
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess | VM_FF_PGM_SYNC_CR3 | VM_FF_PGM_SYNC_CR3_NON_GLOBAL | VM_FF_SELM_SYNC_TSS | VM_FF_TRPM_SYNC_IDT | VM_FF_SELM_SYNC_GDT | VM_FF_SELM_SYNC_LDT | VM_FF_PGM_NEED_HANDY_PAGES)
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** High priority pre raw-mode execution mask. */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess#define VM_FF_HIGH_PRIORITY_PRE_RAW_MASK (VM_FF_PGM_SYNC_CR3 | VM_FF_PGM_SYNC_CR3_NON_GLOBAL | VM_FF_SELM_SYNC_TSS | VM_FF_TRPM_SYNC_IDT | VM_FF_SELM_SYNC_GDT | VM_FF_SELM_SYNC_LDT | VM_FF_PGM_NEED_HANDY_PAGES \
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** High priority post-execution actions. */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess#define VM_FF_HIGH_PRIORITY_POST_MASK (VM_FF_PDM_CRITSECT | VM_FF_CSAM_PENDING_ACTION)
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** Normal priority post-execution actions. */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess#define VM_FF_NORMAL_PRIORITY_POST_MASK (VM_FF_TERMINATE | VM_FF_DBGF | VM_FF_RESET | VM_FF_CSAM_SCAN_PAGE)
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** Normal priority actions. */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess#define VM_FF_NORMAL_PRIORITY_MASK (VM_FF_REQUEST | VM_FF_PDM_QUEUES | VM_FF_PDM_DMA)
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** Flags to check before resuming guest execution. */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** All the forced flags. */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** All the forced flags. */
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess#define VM_FF_ALL_BUT_RAW_MASK (~(VM_FF_HIGH_PRIORITY_PRE_RAW_MASK | VM_FF_CSAM_PENDING_ACTION | VM_FF_PDM_CRITSECT))
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess/** @def VM_FF_SET
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * Sets a force action flag.
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * @param pVM VM Handle.
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess * @param fFlag The flag to set.
1c8f2418892d98febb00a06b9a4f45f8bcfd80a3nd# define VM_FF_SET(pVM, fFlag) ASMAtomicOrU32(&(pVM)->fForcedActions, (fFlag))
d474d8ef01ec5c2a09341cd148851ed383c3287crbowen do { ASMAtomicOrU32(&(pVM)->fForcedActions, (fFlag)); \
d474d8ef01ec5c2a09341cd148851ed383c3287crbowen RTLogPrintf("VM_FF_SET : %08x %s - %s(%d) %s\n", (pVM)->fForcedActions, #fFlag, __FILE__, __LINE__, __FUNCTION__); \
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh/** @def VM_FF_CLEAR
0d0ba3a410038e179b695446bb149cce6264e0abnd * Clears a force action flag.
727872d18412fc021f03969b8641810d8896820bhumbedooh * @param pVM VM Handle.
0d0ba3a410038e179b695446bb149cce6264e0abnd * @param fFlag The flag to clear.
ac082aefa89416cbdc9a1836eaf3bed9698201c8humbedooh# define VM_FF_CLEAR(pVM, fFlag) ASMAtomicAndU32(&(pVM)->fForcedActions, ~(fFlag))
0d0ba3a410038e179b695446bb149cce6264e0abnd do { ASMAtomicAndU32(&(pVM)->fForcedActions, ~(fFlag)); \
727872d18412fc021f03969b8641810d8896820bhumbedooh RTLogPrintf("VM_FF_CLEAR: %08x %s - %s(%d) %s\n", (pVM)->fForcedActions, #fFlag, __FILE__, __LINE__, __FUNCTION__); \
0d0ba3a410038e179b695446bb149cce6264e0abnd } while (0)
205f749042ed530040a4f0080dbcb47ceae8a374rjung/** @def VM_FF_ISSET
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen * Checks if a force action flag is set.
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd * @param pVM VM Handle.
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd * @param fFlag The flag to check.
e655a84bbb62bb1c66993fda5e74b04feda14dc6kess#define VM_FF_ISSET(pVM, fFlag) (((pVM)->fForcedActions & (fFlag)) == (fFlag))
#ifdef IN_GC
#ifdef IN_GC
("Not emulation thread! Thread=%RTnthrd ThreadEMT=%RTnthrd\n", RTThreadNativeSelf(), pVM->NativeThreadEMT))
typedef struct VM
bool fRawR3Enabled;
bool fRawR0Enabled;
bool fPATMEnabled;
bool fCSAMEnabled;
bool fHWACCMEnabled;
#ifdef ___CPUMInternal_h
struct CPUM s;
} cpum;
#ifdef ___VMMInternal_h
struct VMM s;
} vmm;
#ifdef ___PGMInternal_h
struct PGM s;
} pgm;
#ifdef ___HWACCMInternal_h
struct HWACCM s;
} hwaccm;
#ifdef ___TRPMInternal_h
struct TRPM s;
} trpm;
#ifdef ___SELMInternal_h
struct SELM s;
} selm;
#ifdef ___MMInternal_h
struct MM s;
} mm;
#ifdef ___CFGMInternal_h
struct CFGM s;
} cfgm;
#ifdef ___PDMInternal_h
struct PDM s;
} pdm;
#ifdef ___IOMInternal_h
struct IOM s;
} iom;
#ifdef ___PATMInternal_h
struct PATM s;
} patm;
#ifdef ___CSAMInternal_h
struct CSAM s;
} csam;
#ifdef ___EMInternal_h
struct EM s;
} em;
#ifdef ___TMInternal_h
struct TM s;
} tm;
#ifdef ___DBGFInternal_h
struct DBGF s;
} dbgf;
#ifdef ___STAMInternal_h
struct STAM s;
} stam;
#ifdef ___SSMInternal_h
struct SSM s;
} ssm;
#ifdef ___VMInternal_h
struct VMINT s;
} vm;
#ifdef ___REMInternal_h
struct REM s;
} rem;
} VM;
#ifndef ___VBox_types_h
#ifdef IN_GC