vm.h revision 4b9dfb569f4f1db12f2edcab743d6b251c0a65c1
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @file
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * VM - The Virtual Machine, data.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/*
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync *
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 *
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 *
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 *
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 */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifndef ___VBox_vm_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define ___VBox_vm_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#include <VBox/cdefs.h>
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#include <VBox/types.h>
628ddfbd43ad5365d69fddda4007598242956577vboxsync#include <VBox/cpum.h>
628ddfbd43ad5365d69fddda4007598242956577vboxsync#include <VBox/stam.h>
628ddfbd43ad5365d69fddda4007598242956577vboxsync#include <VBox/vmapi.h>
628ddfbd43ad5365d69fddda4007598242956577vboxsync#include <VBox/sup.h>
628ddfbd43ad5365d69fddda4007598242956577vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @defgroup grp_vm The Virtual Machine
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @{
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Maximum number of virtual CPUs per VM. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VMCPU_MAX_CPU_COUNT 255
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/**
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync * The state of a virtual CPU.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
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 */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsynctypedef enum VMCPUSTATE
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync{
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The customary invalid zero. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync VMCPUSTATE_INVALID = 0,
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Running guest code (VM running). */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync VMCPUSTATE_RUN_EXEC,
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Running guest code in the recompiler (VM running). */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync VMCPUSTATE_RUN_EXEC_REM,
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Halted (VM running). */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync VMCPUSTATE_RUN_HALTED,
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** All the other bits we do while running a VM (VM running). */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync VMCPUSTATE_RUN_MISC,
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** VM not running, we're servicing requests or whatever. */
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync VMCPUSTATE_NOT_RUNNING,
ae5379e3e7573369566d4628ef6c597da693cc55vboxsync /** The end of valid virtual CPU states. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync VMCPUSTATE_END,
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync
ae5379e3e7573369566d4628ef6c597da693cc55vboxsync /** Ensure 32-bit type. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync VMCPUSTATE_32BIT_HACK = 0x7fffffff
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync} VMCPUSTATE;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/**
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * Per virtual CPU data.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsynctypedef struct VMCPU
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync{
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Per CPU forced action.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * See the VMCPU_FF_* \#defines. Updated atomically. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uint32_t volatile fForcedActions;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The CPU state. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync VMCPUSTATE volatile enmState;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Ring-3 Host Context VM Pointer. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync PVMR3 pVMR3;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Ring-0 Host Context VM Pointer. */
54d3b0107d9bf326fe6e0de92e012c791dbb1587vboxsync PVMR0 pVMR0;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Raw-mode Context VM Pointer. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync PVMRC pVMRC;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The CPU ID.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This is the index into the VM::aCpus array. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync VMCPUID idCpu;
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 RTTHREAD hThreadR3;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The native ring-3 handle. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTNATIVETHREAD hNativeThreadR3;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The native ring-0 handle. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTNATIVETHREAD hNativeThreadR0;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Align the next bit on a 64-byte boundary. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uint32_t au32Alignment[HC_ARCH_BITS == 32 ? 7 : 2];
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync /** CPUM part. */
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync union
77cce7691847be5aef145f31ba3f9d66fc2cf594vboxsync {
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync#ifdef ___CPUMInternal_h
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync struct CPUMCPU s;
54d3b0107d9bf326fe6e0de92e012c791dbb1587vboxsync#endif
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync char padding[4096]; /* multiple of 32 */
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync } cpum;
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync /** VMM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync union
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync {
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync#ifdef ___VMMInternal_h
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync struct VMMCPU s;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync char padding[32]; /* multiple of 32 */
9e293277b378073ce86910209a246b744b4caa2cvboxsync } vmm;
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync
9e293277b378073ce86910209a246b744b4caa2cvboxsync /** PGM part. */
9e293277b378073ce86910209a246b744b4caa2cvboxsync union
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync {
9e293277b378073ce86910209a246b744b4caa2cvboxsync#ifdef ___PGMInternal_h
9e293277b378073ce86910209a246b744b4caa2cvboxsync struct PGMCPU s;
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync#endif
bdd15592ca3578b623ff588055a561f58b7e5586vboxsync char padding[32]; /* multiple of 32 */
bdd15592ca3578b623ff588055a561f58b7e5586vboxsync } pgm;
bdd15592ca3578b623ff588055a561f58b7e5586vboxsync
9e293277b378073ce86910209a246b744b4caa2cvboxsync /** HWACCM part. */
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync union
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync {
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync#ifdef ___HWACCMInternal_h
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync struct HWACCMCPU s;
f350b7cf96f1e2f3b0cfd34cfe8726c754f43584vboxsync#endif
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync char padding[32]; /* multiple of 32 */
f350b7cf96f1e2f3b0cfd34cfe8726c754f43584vboxsync } hwaccm;
f350b7cf96f1e2f3b0cfd34cfe8726c754f43584vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** EM part. */
f350b7cf96f1e2f3b0cfd34cfe8726c754f43584vboxsync union
f350b7cf96f1e2f3b0cfd34cfe8726c754f43584vboxsync {
f350b7cf96f1e2f3b0cfd34cfe8726c754f43584vboxsync#ifdef ___EMInternal_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync struct EMCPU s;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync char padding[32]; /* multiple of 32 */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync } em;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** TM part. */
f350b7cf96f1e2f3b0cfd34cfe8726c754f43584vboxsync union
551d9b8ee3568ad3e11b65ce6ef2867c36375f37vboxsync {
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef ___TMInternal_h
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync struct TMCPU s;
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync char padding[32]; /* multiple of 32 */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync } tm;
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync} VMCPU;
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync/** Pointer to a VMCPU. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifndef ___VBox_types_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsynctypedef struct VMCPU *PVMCPU;
8e0c2ca3abd721979958f95b9af73b60665478c8vboxsync#endif
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync/** The name of the Guest Context VMM Core module. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VMMGC_MAIN_MODULE_NAME "VMMGC.gc"
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync/** The name of the Ring 0 Context VMM Core module. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VMMR0_MAIN_MODULE_NAME "VMMR0.r0"
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** VM Forced Action Flags.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync * Use the VM_FF_SET() and VM_FF_CLEAR() macros to change the force
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync * action mask of a VM.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @{
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync/** This action forces the VM to service check and pending interrups on the APIC. */
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync#define VM_FF_INTERRUPT_APIC RT_BIT_32(0)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** This action forces the VM to service check and pending interrups on the PIC. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_INTERRUPT_PIC RT_BIT_32(1)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** This action forces the VM to schedule and run pending timer (TM). */
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync#define VM_FF_TIMER RT_BIT_32(2)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** PDM Queues are pending. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_PDM_QUEUES RT_BIT_32(3)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** PDM DMA transfers are pending. */
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync#define VM_FF_PDM_DMA RT_BIT_32(4)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** PDM critical section unlocking is pending, process promptly upon return to R3. */
39592d8ff3243f6116c4e99be391bcf30a4ad187vboxsync#define VM_FF_PDM_CRITSECT RT_BIT_32(5)
39592d8ff3243f6116c4e99be391bcf30a4ad187vboxsync
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#define VM_FF_DBGF RT_BIT_32(8)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** This action forces the VM to service pending requests from other
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * thread or requests which must be executed in another context. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_REQUEST RT_BIT_32(9)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Terminate the VM immediately. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_TERMINATE RT_BIT_32(10)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Reset the VM. (postponed) */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_RESET RT_BIT_32(11)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** This action forces the VM to resync the page tables before going
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * back to execute guest code. (GLOBAL FLUSH) */
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync#define VM_FF_PGM_SYNC_CR3 RT_BIT_32(16)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Same as VM_FF_PGM_SYNC_CR3 except that global pages can be skipped.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * (NON-GLOBAL FLUSH) */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_PGM_SYNC_CR3_NON_GLOBAL RT_BIT_32(17)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** PGM needs to allocate handy pages. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_PGM_NEED_HANDY_PAGES RT_BIT_32(18)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Check the interupt and trap gates */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_TRPM_SYNC_IDT RT_BIT_32(19)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Check Guest's TSS ring 0 stack */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_SELM_SYNC_TSS RT_BIT_32(20)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Check Guest's GDT table */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_SELM_SYNC_GDT RT_BIT_32(21)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Check Guest's LDT table */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_SELM_SYNC_LDT RT_BIT_32(22)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Inhibit interrupts pending. See EMGetInhibitInterruptsPC(). */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_INHIBIT_INTERRUPTS RT_BIT_32(23)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
c77e7bff89c7639353778366984d51ff165ea0e3vboxsync/** CSAM needs to scan the page that's being executed */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_CSAM_SCAN_PAGE RT_BIT_32(24)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** CSAM needs to do some homework. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_CSAM_PENDING_ACTION RT_BIT_32(25)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Force return to Ring-3. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_TO_R3 RT_BIT_32(28)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** REM needs to be informed about handler changes. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_REM_HANDLER_NOTIFY RT_BIT_32(29)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** Suspend the VM - debug only. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_DEBUG_SUSPEND RT_BIT_32(31)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
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 | VM_FF_INHIBIT_INTERRUPTS)
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#define VM_FF_RESUME_GUEST_MASK (VM_FF_TO_R3)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** All the forced flags. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_ALL_MASK (~0U)
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
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @} */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VM_FF_SET
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Sets a force action flag.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pVM VM Handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fFlag The flag to set.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#if 1
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VM_FF_SET(pVM, fFlag) ASMAtomicOrU32(&(pVM)->fForcedActions, (fFlag))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#else
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VM_FF_SET(pVM, 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#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VMCPU_FF_SET
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Sets a force action flag for given VCPU.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pVM VM Handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param idCpu Virtual CPU ID.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fFlag The flag to set.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef VBOX_WITH_SMP_GUESTS
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VMCPU_FF_SET(pVM, idCpu, fFlag) ASMAtomicOrU32(&(pVM)->aCpus[idCpu].fForcedActions, (fFlag))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#else
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VMCPU_FF_SET(pVM, idCpu, fFlag) VM_FF_SET(pVM, fFlag)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VM_FF_CLEAR
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Clears a force action flag.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pVM VM Handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fFlag The flag to clear.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#if 1
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VM_FF_CLEAR(pVM, fFlag) ASMAtomicAndU32(&(pVM)->fForcedActions, ~(fFlag))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#else
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VM_FF_CLEAR(pVM, 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#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VMCPU_FF_CLEAR
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Clears a force action flag for given VCPU.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pVM VM Handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param idCpu Virtual CPU ID.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fFlag The flag to clear.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef VBOX_WITH_SMP_GUESTS
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VMCPU_FF_CLEAR(pVM, idCpu, fFlag) ASMAtomicAndU32(&(pVM)->aCpus[idCpu].fForcedActions, ~(fFlag))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#else
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VMCPU_FF_CLEAR(pVM, idCpu, fFlag) VM_FF_CLEAR(pVM, fFlag)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VM_FF_ISSET
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Checks if a force action flag is set.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pVM VM Handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fFlag The flag to check.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_ISSET(pVM, fFlag) (((pVM)->fForcedActions & (fFlag)) == (fFlag))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VMCPU_FF_ISSET
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Checks if a force action flag is set for given VCPU.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pVM VM Handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param idCpu Virtual CPU ID.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fFlag The flag to check.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef VBOX_WITH_SMP_GUESTS
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VMCPU_FF_ISSET(pVM, idCpu, fFlag) (((pVM)->aCpus[idCpu].fForcedActions & (fFlag)) == (fFlag))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#else
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VMCPU_FF_ISSET(pVM, idCpu, fFlag) VM_FF_ISSET(pVM, fFlag)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VM_FF_ISPENDING
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Checks if one or more force action in the specified set is pending.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pVM VM Handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fFlags The flags to check for.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_FF_ISPENDING(pVM, fFlags) ((pVM)->fForcedActions & (fFlags))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VMCPU_FF_ISPENDING
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Checks if one or more force action in the specified set is pending for given VCPU.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param pVM VM Handle.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param idCpu Virtual CPU ID.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param fFlags The flags to check for.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef VBOX_WITH_SMP_GUESTS
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VMCPU_FF_ISPENDING(pVM, idCpu, fFlags) ((pVM)->aCpus[idCpu].fForcedActions & (fFlags))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#else
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VMCPU_FF_ISPENDING(pVM, idCpu, fFlags) VM_FF_ISPENDING(pVM, fFlags)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VM_IS_EMT
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Checks if the current thread is the emulation thread (EMT).
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
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 */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef IN_GC
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VM_IS_EMT(pVM) true
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#elif defined(IN_RING0)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VM_IS_EMT(pVM) true
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#else
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#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VM_ASSERT_EMT
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Asserts that the current thread IS the emulation thread (EMT).
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef IN_GC
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VM_ASSERT_EMT(pVM) Assert(VM_IS_EMT(pVM))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#elif defined(IN_RING0)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VM_ASSERT_EMT(pVM) Assert(VM_IS_EMT(pVM))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#else
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VM_ASSERT_EMT(pVM) \
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync AssertMsg(VM_IS_EMT(pVM), \
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync ("Not emulation thread! Thread=%RTnthrd ThreadEMT=%RTnthrd\n", RTThreadNativeSelf(), pVM->NativeThreadEMT))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VM_ASSERT_EMT_RETURN
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Asserts that the current thread IS the emulation thread (EMT) and returns if it isn't.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef IN_GC
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VM_ASSERT_EMT_RETURN(pVM, rc) AssertReturn(VM_IS_EMT(pVM), (rc))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#elif defined(IN_RING0)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VM_ASSERT_EMT_RETURN(pVM, rc) AssertReturn(VM_IS_EMT(pVM), (rc))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#else
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync# define VM_ASSERT_EMT_RETURN(pVM, rc) \
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync AssertMsgReturn(VM_IS_EMT(pVM), \
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync ("Not emulation thread! Thread=%RTnthrd ThreadEMT=%RTnthrd\n", RTThreadNativeSelf(), pVM->NativeThreadEMT), \
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync (rc))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Asserts that the current thread is NOT the emulation thread.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_ASSERT_OTHER_THREAD(pVM) \
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync AssertMsg(!VM_IS_EMT(pVM), ("Not other thread!!\n"))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VM_ASSERT_STATE_RETURN
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Asserts a certain VM state.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#define VM_ASSERT_STATE(pVM, _enmState) \
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync AssertMsg((pVM)->enmVMState == (_enmState), \
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync ("state %s, expected %s\n", VMGetStateName(pVM->enmVMState), VMGetStateName(_enmState)))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** @def VM_ASSERT_STATE_RETURN
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Asserts a certain VM state and returns if it doesn't match.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
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 (rc))
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/** This is the VM structure.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
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 *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Run tstVMStructSize after update!
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsynctypedef struct VM
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync{
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The state of the VM.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This field is read only to everyone except the VM and EM. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync VMSTATE enmVMState;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Forced action flags.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * See the VM_FF_* \#defines. Updated atomically.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync volatile uint32_t fForcedActions;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Pointer to the array of page descriptors for the VM structure allocation. */
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync R3PTRTYPE(PSUPPAGE) paVMPagesR3;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Session handle. For use when calling SUPR0 APIs. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync PSUPDRVSESSION pSession;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Pointer to the ring-3 VM structure. */
bac59dd15f093cbb8dae97ebd8f94f94786d1439vboxsync PUVM pUVM;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Ring-3 Host Context VM Pointer. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync R3PTRTYPE(struct VM *) pVMR3;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Ring-0 Host Context VM Pointer. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync R0PTRTYPE(struct VM *) pVMR0;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Raw-mode Context VM Pointer.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @deprecated Use VM::pVMRC. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RCPTRTYPE(struct VM *) pVMGC;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Raw-mode Context VM Pointer. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RCPTRTYPE(struct VM *) pVMRC;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The GVM VM handle. Only the GVM should modify this field. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uint32_t hSelf;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Number of virtual CPUs. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uint32_t cCPUs;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Size of the VM structure including the VMCPU array. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uint32_t cbSelf;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Offset to the VMCPU array starting from beginning of this structure. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uint32_t offVMCPU;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Reserved; alignment. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uint32_t u32Reserved[5];
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** @name Public VMM Switcher APIs
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @{ */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Assembly switch entry point for returning to host context.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This function will clean up the stack frame.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param eax The return code, register.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param Ctx The guest core context.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @remark Assume interrupts disabled.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTGCPTR32 pfnVMMGCGuestToHostAsmGuestCtx/*(int32_t eax, CPUMCTXCORE Ctx)*/;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Assembly switch entry point for returning to host context.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
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 *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This is typically useful when abandoning the hypervisor because of a trap
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * and want the trap state to be saved.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param eax The return code, register.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param ecx Pointer to the hypervisor core context, register.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @remark Assume interrupts disabled.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTGCPTR32 pfnVMMGCGuestToHostAsmHyperCtx/*(int32_t eax, PCPUMCTXCORE ecx)*/;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /**
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Assembly switch entry point for returning to host context.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync *
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 *
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @param eax The return code, register.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @remark Assume interrupts disabled.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTGCPTR32 pfnVMMGCGuestToHostAsm/*(int32_t eax)*/;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** @} */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** @name Various VM data owned by VM.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @{ */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The thread handle of the emulation thread.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Use the VM_IS_EMT() macro to check if executing in EMT. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTTHREAD ThreadEMT;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** The native handle of ThreadEMT. Getting the native handle
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * is generally faster than getting the IPRT one (except on OS/2 :-). */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync RTNATIVETHREAD NativeThreadEMT;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** @} */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** @name Various items that are frequently accessed.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * @{ */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Raw ring-3 indicator. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync bool fRawR3Enabled;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Raw ring-0 indicator. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync bool fRawR0Enabled;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** PATM enabled flag.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This is placed here for performance reasons. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync bool fPATMEnabled;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** CSAM enabled flag.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This is placed here for performance reasons. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync bool fCSAMEnabled;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Hardware VM support is available and enabled.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This is placed here for performance reasons. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync bool fHWACCMEnabled;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** PARAV enabled flag. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync bool fPARAVEnabled;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** @} */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /* padding to make gnuc put the StatQemuToGC where msc does. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#if HC_ARCH_BITS == 32
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uint32_t padding0;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Profiling the total time from Qemu to GC. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync STAMPROFILEADV StatTotalQemuToGC;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Profiling the total time from GC to Qemu. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync STAMPROFILEADV StatTotalGCToQemu;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Profiling the total time spent in GC. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync STAMPROFILEADV StatTotalInGC;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Profiling the total time spent not in Qemu. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync STAMPROFILEADV StatTotalInQemu;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Profiling the VMMSwitcher code for going to GC. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync STAMPROFILEADV StatSwitcherToGC;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** Profiling the VMMSwitcher code for going to HC. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync STAMPROFILEADV StatSwitcherToHC;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync STAMPROFILEADV StatSwitcherSaveRegs;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync STAMPROFILEADV StatSwitcherSysEnter;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync STAMPROFILEADV StatSwitcherDebug;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync STAMPROFILEADV StatSwitcherCR0;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync STAMPROFILEADV StatSwitcherCR4;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync STAMPROFILEADV StatSwitcherJmpCR3;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync STAMPROFILEADV StatSwitcherRstrRegs;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync STAMPROFILEADV StatSwitcherLgdt;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync STAMPROFILEADV StatSwitcherLidt;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync STAMPROFILEADV StatSwitcherLldt;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync STAMPROFILEADV StatSwitcherTSS;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
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 uint32_t padding[HC_ARCH_BITS == 32 ? 4+8 : 6];
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** CPUM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync union
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync {
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef ___CPUMInternal_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync struct CPUM s;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync char padding[4416]; /* multiple of 32 */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync } cpum;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** VMM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync union
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync {
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef ___VMMInternal_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync struct VMM s;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync char padding[1536]; /* multiple of 32 */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync } vmm;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** PGM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync union
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync {
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef ___PGMInternal_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync struct PGM s;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync char padding[50*1024]; /* multiple of 32 */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync } pgm;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** HWACCM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync union
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync {
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef ___HWACCMInternal_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync struct HWACCM s;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync char padding[1536]; /* multiple of 32 */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync } hwaccm;
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync /** TRPM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync union
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync {
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef ___TRPMInternal_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync struct TRPM s;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync char padding[5344]; /* multiple of 32 */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync } trpm;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** SELM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync union
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync {
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef ___SELMInternal_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync struct SELM s;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync char padding[544]; /* multiple of 32 */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync } selm;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** MM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync union
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync {
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef ___MMInternal_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync struct MM s;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync char padding[192]; /* multiple of 32 */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync } mm;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** CFGM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync union
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync {
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef ___CFGMInternal_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync struct CFGM s;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync char padding[32]; /* multiple of 32 */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync } cfgm;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** PDM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync union
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync {
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef ___PDMInternal_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync struct PDM s;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync char padding[1824]; /* multiple of 32 */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync } pdm;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** IOM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync union
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync {
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef ___IOMInternal_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync struct IOM s;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync char padding[4544]; /* multiple of 32 */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync } iom;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** PATM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync union
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync {
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef ___PATMInternal_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync struct PATM s;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync char padding[768]; /* multiple of 32 */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync } patm;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
c77e7bff89c7639353778366984d51ff165ea0e3vboxsync /** CSAM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync union
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync {
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef ___CSAMInternal_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync struct CSAM s;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync char padding[3328]; /* multiple of 32 */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync } csam;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** PARAV part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync union
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync {
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef ___PARAVInternal_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync struct PARAV s;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync char padding[128];
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync } parav;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** EM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync union
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync {
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef ___EMInternal_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync struct EM s;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync char padding[1344]; /* multiple of 32 */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync } em;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** TM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync union
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync {
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef ___TMInternal_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync struct TM s;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync char padding[1536]; /* multiple of 32 */
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync } tm;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** DBGF part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync union
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync {
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef ___DBGFInternal_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync struct DBGF s;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync char padding[2368]; /* multiple of 32 */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync } dbgf;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** SSM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync union
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync {
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef ___SSMInternal_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync struct SSM s;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync char padding[32]; /* multiple of 32 */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync } ssm;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** VM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync union
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync {
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef ___VMInternal_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync struct VMINT s;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync char padding[768]; /* multiple of 32 */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync } vm;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /** REM part. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync union
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync {
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef ___REMInternal_h
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync struct REM s;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#ifdef VBOX_WITH_NEW_RECOMPILER
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/** @def VM_REM_SIZE
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * Must be multiple of 32 and coherent with REM_ENV_SIZE from REMInternal.h. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync#if GC_ARCH_BITS == 32
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync# define VM_REM_SIZE (HC_ARCH_BITS == 32 ? 0x10800 : 0x10800)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync#else
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync# define VM_REM_SIZE (HC_ARCH_BITS == 32 ? 0x10900 : 0x10900)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync#endif
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync#else /* !VBOX_WITH_NEW_RECOMILER */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync#if GC_ARCH_BITS == 32
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync# define VM_REM_SIZE (HC_ARCH_BITS == 32 ? 0x6f00 : 0xbf00)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync#else
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync# define VM_REM_SIZE (HC_ARCH_BITS == 32 ? 0x9f00 : 0xdf00)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync#endif
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync#endif /* !VBOX_WITH_NEW_RECOMILER */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync char padding[VM_REM_SIZE]; /* multiple of 32 */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync } rem;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /** Padding for aligning the cpu array on a 64 byte boundrary. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync uint32_t u32Reserved2[8];
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /** VMCPU array for the configured number of virtual CPUs. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync VMCPU aCpus[1];
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync} VM;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/** Pointer to a VM. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync#ifndef ___VBox_types_h
37e7010b28a4667800196960b59cd63b5434b7d7vboxsynctypedef struct VM *PVM;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync#endif
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync#ifdef IN_GC
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync__BEGIN_DECLS
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
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.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsyncextern DECLIMPORT(VM) g_VM;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync__END_DECLS
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync#endif
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/** @} */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync#endif
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync