vm.h revision 4b9dfb569f4f1db12f2edcab743d6b251c0a65c1
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * VM - The Virtual Machine, data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * available from http://www.virtualbox.org. This file is free software;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * you can redistribute it and/or modify it under the terms of the GNU
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * General Public License (GPL) as published by the Free Software
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * The contents of this file may alternatively be used under the terms
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * of the Common Development and Distribution License Version 1.0
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * VirtualBox OSE distribution, in which case the provisions of the
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * CDDL are applicable instead of those of the GPL.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * You may elect to license modified versions of this file under the
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * terms and conditions of either the GPL or the CDDL or both.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * additional information or have any questions.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @defgroup grp_vm The Virtual Machine
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Maximum number of virtual CPUs per VM. */
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync * The state of a virtual CPU.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * The VM running states are a sub-states of the VMSTATE_RUNNING state. While
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * VMCPUSTATE_NOT_RUNNING is a place holder for the other VM states.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The customary invalid zero. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Running guest code (VM running). */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Running guest code in the recompiler (VM running). */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Halted (VM running). */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** All the other bits we do while running a VM (VM running). */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** VM not running, we're servicing requests or whatever. */
ae5379e3e7573369566d4628ef6c597da693cc55vboxsync /** The end of valid virtual CPU states. */
ae5379e3e7573369566d4628ef6c597da693cc55vboxsync /** Ensure 32-bit type. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * Per virtual CPU data.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsynctypedef struct VMCPU
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Per CPU forced action.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * See the VMCPU_FF_* \#defines. Updated atomically. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The CPU state. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Ring-3 Host Context VM Pointer. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Ring-0 Host Context VM Pointer. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Raw-mode Context VM Pointer. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The CPU ID.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This is the index into the VM::aCpus array. */
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync /** The ring-3 thread handle of the emulation thread for this CPU.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @todo Use the VM_IS_EMT() macro to check if executing in EMT? */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The native ring-3 handle. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The native ring-0 handle. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Align the next bit on a 64-byte boundary. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uint32_t au32Alignment[HC_ARCH_BITS == 32 ? 7 : 2];
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync /** CPUM part. */
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync /** VMM part. */
9e293277b378073ce86910209a246b744b4caa2cvboxsync /** PGM part. */
9e293277b378073ce86910209a246b744b4caa2cvboxsync /** HWACCM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** EM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** TM part. */
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync/** Pointer to a VMCPU. */
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync/** The name of the Guest Context VMM Core module. */
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync/** The name of the Ring 0 Context VMM Core module. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** VM Forced Action Flags.
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync * Use the VM_FF_SET() and VM_FF_CLEAR() macros to change the force
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync * action mask of a VM.
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync/** This action forces the VM to service check and pending interrups on the APIC. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** This action forces the VM to service check and pending interrups on the PIC. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** This action forces the VM to schedule and run pending timer (TM). */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** PDM Queues are pending. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** PDM DMA transfers are pending. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** PDM critical section unlocking is pending, process promptly upon return to R3. */
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync/** This action forces the VM to call DBGF so DBGF can service debugger
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync * requests in the emulation thread.
39592d8ff3243f6116c4e99be391bcf30a4ad187vboxsync * This action flag stays asserted till DBGF clears it.*/
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** This action forces the VM to service pending requests from other
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * thread or requests which must be executed in another context. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Terminate the VM immediately. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Reset the VM. (postponed) */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** This action forces the VM to resync the page tables before going
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * back to execute guest code. (GLOBAL FLUSH) */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Same as VM_FF_PGM_SYNC_CR3 except that global pages can be skipped.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * (NON-GLOBAL FLUSH) */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** PGM needs to allocate handy pages. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Check the interupt and trap gates */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Check Guest's TSS ring 0 stack */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Check Guest's GDT table */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Check Guest's LDT table */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Inhibit interrupts pending. See EMGetInhibitInterruptsPC(). */
c77e7bff89c7639353778366984d51ff165ea0e3vboxsync/** CSAM needs to scan the page that's being executed */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** CSAM needs to do some homework. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Force return to Ring-3. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** REM needs to be informed about handler changes. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Suspend the VM - debug only. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Externally forced actions. Used to quit the idle/wait loop. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_EXTERNAL_SUSPENDED_MASK (VM_FF_TERMINATE | VM_FF_DBGF | VM_FF_REQUEST)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Externally forced actions. Used to quit the idle/wait loop. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#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)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** High priority pre-execution actions. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#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 \
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync | 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)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** High priority pre raw-mode execution mask. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#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 \
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** High priority post-execution actions. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_HIGH_PRIORITY_POST_MASK (VM_FF_PDM_CRITSECT | VM_FF_CSAM_PENDING_ACTION)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Normal priority post-execution actions. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_NORMAL_PRIORITY_POST_MASK (VM_FF_TERMINATE | VM_FF_DBGF | VM_FF_RESET | VM_FF_CSAM_SCAN_PAGE)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Normal priority actions. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_NORMAL_PRIORITY_MASK (VM_FF_REQUEST | VM_FF_PDM_QUEUES | VM_FF_PDM_DMA | VM_FF_REM_HANDLER_NOTIFY)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Flags to check before resuming guest execution. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** All the forced flags. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** All the forced flags. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_ALL_BUT_RAW_MASK (~(VM_FF_HIGH_PRIORITY_PRE_RAW_MASK | VM_FF_CSAM_PENDING_ACTION | VM_FF_PDM_CRITSECT))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VM_FF_SET
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Sets a force action flag.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pVM VM Handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fFlag The flag to set.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VM_FF_SET(pVM, fFlag) ASMAtomicOrU32(&(pVM)->fForcedActions, (fFlag))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync do { ASMAtomicOrU32(&(pVM)->fForcedActions, (fFlag)); \
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTLogPrintf("VM_FF_SET : %08x %s - %s(%d) %s\n", (pVM)->fForcedActions, #fFlag, __FILE__, __LINE__, __FUNCTION__); \
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync } while (0)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VMCPU_FF_SET
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Sets a force action flag for given VCPU.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pVM VM Handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param idCpu Virtual CPU ID.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fFlag The flag to set.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VMCPU_FF_SET(pVM, idCpu, fFlag) ASMAtomicOrU32(&(pVM)->aCpus[idCpu].fForcedActions, (fFlag))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VMCPU_FF_SET(pVM, idCpu, fFlag) VM_FF_SET(pVM, fFlag)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VM_FF_CLEAR
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Clears a force action flag.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pVM VM Handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fFlag The flag to clear.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VM_FF_CLEAR(pVM, fFlag) ASMAtomicAndU32(&(pVM)->fForcedActions, ~(fFlag))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync do { ASMAtomicAndU32(&(pVM)->fForcedActions, ~(fFlag)); \
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTLogPrintf("VM_FF_CLEAR: %08x %s - %s(%d) %s\n", (pVM)->fForcedActions, #fFlag, __FILE__, __LINE__, __FUNCTION__); \
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync } while (0)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VMCPU_FF_CLEAR
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Clears a force action flag for given VCPU.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pVM VM Handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param idCpu Virtual CPU ID.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fFlag The flag to clear.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VMCPU_FF_CLEAR(pVM, idCpu, fFlag) ASMAtomicAndU32(&(pVM)->aCpus[idCpu].fForcedActions, ~(fFlag))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VMCPU_FF_CLEAR(pVM, idCpu, fFlag) VM_FF_CLEAR(pVM, fFlag)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VM_FF_ISSET
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Checks if a force action flag is set.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pVM VM Handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fFlag The flag to check.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_ISSET(pVM, fFlag) (((pVM)->fForcedActions & (fFlag)) == (fFlag))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VMCPU_FF_ISSET
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Checks if a force action flag is set for given VCPU.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pVM VM Handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param idCpu Virtual CPU ID.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fFlag The flag to check.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VMCPU_FF_ISSET(pVM, idCpu, fFlag) (((pVM)->aCpus[idCpu].fForcedActions & (fFlag)) == (fFlag))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VMCPU_FF_ISSET(pVM, idCpu, fFlag) VM_FF_ISSET(pVM, fFlag)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VM_FF_ISPENDING
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Checks if one or more force action in the specified set is pending.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pVM VM Handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fFlags The flags to check for.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_ISPENDING(pVM, fFlags) ((pVM)->fForcedActions & (fFlags))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VMCPU_FF_ISPENDING
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Checks if one or more force action in the specified set is pending for given VCPU.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pVM VM Handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param idCpu Virtual CPU ID.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fFlags The flags to check for.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VMCPU_FF_ISPENDING(pVM, idCpu, fFlags) ((pVM)->aCpus[idCpu].fForcedActions & (fFlags))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VMCPU_FF_ISPENDING(pVM, idCpu, fFlags) VM_FF_ISPENDING(pVM, fFlags)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VM_IS_EMT
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Checks if the current thread is the emulation thread (EMT).
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @remark The ring-0 variation will need attention if we expand the ring-0
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * code to let threads other than EMT mess around with the VM.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @todo need to rework this macro for the case of multiple emulation threads for SMP */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VM_IS_EMT(pVM) ((pVM)->NativeThreadEMT == RTThreadNativeSelf())
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VM_ASSERT_EMT
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Asserts that the current thread IS the emulation thread (EMT).
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync ("Not emulation thread! Thread=%RTnthrd ThreadEMT=%RTnthrd\n", RTThreadNativeSelf(), pVM->NativeThreadEMT))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VM_ASSERT_EMT_RETURN
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Asserts that the current thread IS the emulation thread (EMT) and returns if it isn't.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VM_ASSERT_EMT_RETURN(pVM, rc) AssertReturn(VM_IS_EMT(pVM), (rc))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VM_ASSERT_EMT_RETURN(pVM, rc) AssertReturn(VM_IS_EMT(pVM), (rc))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync ("Not emulation thread! Thread=%RTnthrd ThreadEMT=%RTnthrd\n", RTThreadNativeSelf(), pVM->NativeThreadEMT), \
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Asserts that the current thread is NOT the emulation thread.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync AssertMsg(!VM_IS_EMT(pVM), ("Not other thread!!\n"))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VM_ASSERT_STATE_RETURN
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Asserts a certain VM state.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync ("state %s, expected %s\n", VMGetStateName(pVM->enmVMState), VMGetStateName(_enmState)))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VM_ASSERT_STATE_RETURN
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Asserts a certain VM state and returns if it doesn't match.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_ASSERT_STATE_RETURN(pVM, _enmState, rc) \
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync AssertMsgReturn((pVM)->enmVMState == (_enmState), \
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync ("state %s, expected %s\n", VMGetStateName(pVM->enmVMState), VMGetStateName(_enmState)), \
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** This is the VM structure.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * It contains (nearly?) all the VM data which have to be available in all
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * contexts. Even if it contains all the data the idea is to use APIs not
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * to modify all the members all around the place. Therefore we make use of
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * unions to hide everything which isn't local to the current source module.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This means we'll have to pay a little bit of attention when adding new
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * members to structures in the unions and make sure to keep the padding sizes
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * up to date.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Run tstVMStructSize after update!
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsynctypedef struct VM
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The state of the VM.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This field is read only to everyone except the VM and EM. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Forced action flags.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * See the VM_FF_* \#defines. Updated atomically.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Pointer to the array of page descriptors for the VM structure allocation. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Session handle. For use when calling SUPR0 APIs. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Pointer to the ring-3 VM structure. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Ring-3 Host Context VM Pointer. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Ring-0 Host Context VM Pointer. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Raw-mode Context VM Pointer.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @deprecated Use VM::pVMRC. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Raw-mode Context VM Pointer. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The GVM VM handle. Only the GVM should modify this field. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Number of virtual CPUs. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Size of the VM structure including the VMCPU array. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Offset to the VMCPU array starting from beginning of this structure. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Reserved; alignment. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** @name Public VMM Switcher APIs
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Assembly switch entry point for returning to host context.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This function will clean up the stack frame.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param eax The return code, register.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param Ctx The guest core context.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @remark Assume interrupts disabled.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTGCPTR32 pfnVMMGCGuestToHostAsmGuestCtx/*(int32_t eax, CPUMCTXCORE Ctx)*/;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Assembly switch entry point for returning to host context.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This is an alternative entry point which we'll be using when the we have the
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * hypervisor context and need to save that before going to the host.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This is typically useful when abandoning the hypervisor because of a trap
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * and want the trap state to be saved.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param eax The return code, register.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param ecx Pointer to the hypervisor core context, register.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @remark Assume interrupts disabled.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTGCPTR32 pfnVMMGCGuestToHostAsmHyperCtx/*(int32_t eax, PCPUMCTXCORE ecx)*/;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Assembly switch entry point for returning to host context.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This is an alternative to the two *Ctx APIs and implies that the context has already
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * been saved, or that it's just a brief return to HC and that the caller intends to resume
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * whatever it is doing upon 'return' from this call.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param eax The return code, register.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @remark Assume interrupts disabled.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** @name Various VM data owned by VM.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The thread handle of the emulation thread.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Use the VM_IS_EMT() macro to check if executing in EMT. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The native handle of ThreadEMT. Getting the native handle
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * is generally faster than getting the IPRT one (except on OS/2 :-). */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** @name Various items that are frequently accessed.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Raw ring-3 indicator. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Raw ring-0 indicator. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** PATM enabled flag.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This is placed here for performance reasons. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** CSAM enabled flag.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This is placed here for performance reasons. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Hardware VM support is available and enabled.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This is placed here for performance reasons. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** PARAV enabled flag. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /* padding to make gnuc put the StatQemuToGC where msc does. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Profiling the total time from Qemu to GC. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Profiling the total time from GC to Qemu. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Profiling the total time spent in GC. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Profiling the total time spent not in Qemu. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Profiling the VMMSwitcher code for going to GC. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Profiling the VMMSwitcher code for going to HC. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @todo Realign everything on 64 byte boundraries to better match the
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * cache-line size. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /* padding - the unions must be aligned on 32 bytes boundraries. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** CPUM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** VMM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** PGM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** HWACCM part. */
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync /** TRPM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** SELM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** MM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** CFGM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** PDM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** IOM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** PATM part. */
c77e7bff89c7639353778366984d51ff165ea0e3vboxsync /** CSAM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** PARAV part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** EM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** TM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** DBGF part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** SSM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** VM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** REM part. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/** @def VM_REM_SIZE
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * Must be multiple of 32 and coherent with REM_ENV_SIZE from REMInternal.h. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync# define VM_REM_SIZE (HC_ARCH_BITS == 32 ? 0x10800 : 0x10800)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync# define VM_REM_SIZE (HC_ARCH_BITS == 32 ? 0x10900 : 0x10900)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync#else /* !VBOX_WITH_NEW_RECOMILER */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync# define VM_REM_SIZE (HC_ARCH_BITS == 32 ? 0x6f00 : 0xbf00)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync# define VM_REM_SIZE (HC_ARCH_BITS == 32 ? 0x9f00 : 0xdf00)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync#endif /* !VBOX_WITH_NEW_RECOMILER */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /** Padding for aligning the cpu array on a 64 byte boundrary. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /** VMCPU array for the configured number of virtual CPUs. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/** Pointer to a VM. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/** The VM structure.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * This is imported from the VMMGCBuiltin module, i.e. it's a one
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * of those magic globals which we should avoid using.