vm.h revision 8b0f6d2d53953de1ce264626b185fb4f2298295e
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan/** @file
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos * VM - The Virtual Machine, data.
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan */
5779b9adde0a838db067a3d76f3124eeb8e86d4cJason Vincent
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan/*
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos * Copyright (C) 2006-2007 Sun Microsystems, Inc.
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos *
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos * This file is part of VirtualBox Open Source Edition (OSE), as
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos * available from http://www.virtualbox.org. This file is free software;
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan * you can redistribute it and/or modify it under the terms of the GNU
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos * General Public License (GPL) as published by the Free Software
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos * Foundation, in version 2 as it comes in the "COPYING" file of the
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos *
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos * The contents of this file may alternatively be used under the terms
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos * of the Common Development and Distribution License Version 1.0
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos * VirtualBox OSE distribution, in which case the provisions of the
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos * CDDL are applicable instead of those of the GPL.
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos *
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos * You may elect to license modified versions of this file under the
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan * terms and conditions of either the GPL or the CDDL or both.
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan *
ab359738f77f6061fd76982ba391ae52e07b0203Paul Bryan * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
f56ff38befd2d32c4d47af7794303ee7c3a36f94Andi Egloff * Clara, CA 95054 USA or visit http://www.sun.com if you need
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan * additional information or have any questions.
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle */
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle#ifndef ___VBox_vm_h
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle#define ___VBox_vm_h
99d48ef2e4a3c05cde78b89088fad201080e88f0Laszlo Hordos
9c8c2c05a3d08f94d29b4a42b8a0506a4e97e4faLaszlo Hordos#include <VBox/cdefs.h>
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle#include <VBox/types.h>
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan#include <VBox/cpum.h>
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos#include <VBox/stam.h>
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle#include <VBox/vmapi.h>
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan#include <VBox/sup.h>
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle/** @defgroup grp_vm The Virtual Machine
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan * @{
9c8c2c05a3d08f94d29b4a42b8a0506a4e97e4faLaszlo Hordos */
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan/** Maximum number of virtual CPUs per VM. */
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle#define VMCPU_MAX_CPU_COUNT 255
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle/**
5779b9adde0a838db067a3d76f3124eeb8e86d4cJason Vincent * The state of a virtual CPU.
5779b9adde0a838db067a3d76f3124eeb8e86d4cJason Vincent *
5779b9adde0a838db067a3d76f3124eeb8e86d4cJason Vincent * The VM running states are a sub-states of the VMSTATE_RUNNING state. While
5779b9adde0a838db067a3d76f3124eeb8e86d4cJason Vincent * VMCPUSTATE_NOT_RUNNING is a place holder for the other VM states.
93f72edb164ef872eab6e4d482baa186a0dd6c62Andi Egloff */
10a9be648c010204b8ba63b283aa177749227e11Paul Bryantypedef enum VMCPUSTATE
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan{
90e23b56c7ebf9dffe7ad87f1031103d2b49c08ePaul Bryan /** The customary invalid zero. */
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan VMCPUSTATE_INVALID = 0,
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle /** Running guest code (VM running). */
93f72edb164ef872eab6e4d482baa186a0dd6c62Andi Egloff VMCPUSTATE_RUN_EXEC,
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle /** Running guest code in the recompiler (VM running). */
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan VMCPUSTATE_RUN_EXEC_REM,
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle /** Halted (VM running). */
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle VMCPUSTATE_RUN_HALTED,
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle /** All the other bits we do while running a VM (VM running). */
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle VMCPUSTATE_RUN_MISC,
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle /** VM not running, we're servicing requests or whatever. */
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle VMCPUSTATE_NOT_RUNNING,
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle /** The end of valid virtual CPU states. */
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall VMCPUSTATE_END,
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos /** Ensure 32-bit type. */
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos VMCPUSTATE_32BIT_HACK = 0x7fffffff
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos} VMCPUSTATE;
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan
93f72edb164ef872eab6e4d482baa186a0dd6c62Andi Egloff
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan/**
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan * Per virtual CPU data.
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle */
9697d1ddb3900b1f7f16af9e3be0d1bb34c1f965Paul Bryantypedef struct VMCPU
47196c962e3caf7cdf7ea5d00ccdefc9f208bdceLaszlo Hordos{
47196c962e3caf7cdf7ea5d00ccdefc9f208bdceLaszlo Hordos /** Per CPU forced action.
47196c962e3caf7cdf7ea5d00ccdefc9f208bdceLaszlo Hordos * See the VMCPU_FF_* \#defines. Updated atomically. */
376d1bf8f8ca562eecccbf0a0d34aa7c7352e152Laszlo Hordos uint32_t volatile fForcedActions;
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall /** The CPU state. */
90e23b56c7ebf9dffe7ad87f1031103d2b49c08ePaul Bryan VMCPUSTATE volatile enmState;
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan /** Ring-3 Host Context VM Pointer. */
90e23b56c7ebf9dffe7ad87f1031103d2b49c08ePaul Bryan PVMR3 pVMR3;
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos /** Ring-0 Host Context VM Pointer. */
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos PVMR0 pVMR0;
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall /** Raw-mode Context VM Pointer. */
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan PVMRC pVMRC;
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos /** The CPU ID.
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos * This is the index into the VM::aCpu array. */
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos VMCPUID idCpu;
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos /** The native thread handle. */
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan RTNATIVETHREAD hNativeThread;
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos /** Align the next bit on a 64-byte boundary. */
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos uint32_t au32Alignment[HC_ARCH_BITS == 32 ? 9 : 6];
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos /** CPUM part. */
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos union
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan {
93f72edb164ef872eab6e4d482baa186a0dd6c62Andi Egloff#ifdef ___CPUMInternal_h
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan struct CPUMCPU s;
93f72edb164ef872eab6e4d482baa186a0dd6c62Andi Egloff#endif
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos char padding[2048]; /* multiple of 32 */
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos } cpum;
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos /** VMM part. */
9c8c2c05a3d08f94d29b4a42b8a0506a4e97e4faLaszlo Hordos union
9c8c2c05a3d08f94d29b4a42b8a0506a4e97e4faLaszlo Hordos {
9c8c2c05a3d08f94d29b4a42b8a0506a4e97e4faLaszlo Hordos#ifdef ___VMMInternal_h
376d1bf8f8ca562eecccbf0a0d34aa7c7352e152Laszlo Hordos struct VMMCPU s;
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos#endif
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan char padding[32]; /* multiple of 32 */
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan } vmm;
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan /** PGM part. */
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan union
93f72edb164ef872eab6e4d482baa186a0dd6c62Andi Egloff {
376d1bf8f8ca562eecccbf0a0d34aa7c7352e152Laszlo Hordos#ifdef ___PGMInternal_h
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan struct PGMCPU s;
9c8c2c05a3d08f94d29b4a42b8a0506a4e97e4faLaszlo Hordos#endif
93f72edb164ef872eab6e4d482baa186a0dd6c62Andi Egloff char padding[32]; /* multiple of 32 */
93f72edb164ef872eab6e4d482baa186a0dd6c62Andi Egloff } pgm;
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle /** HWACCM part. */
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle union
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle {
2aa8de21e6cca211bdb436c58886b60f4d32d073Brendan Miller#ifdef ___HWACCMInternal_h
2aa8de21e6cca211bdb436c58886b60f4d32d073Brendan Miller struct HWACCMCPU s;
2aa8de21e6cca211bdb436c58886b60f4d32d073Brendan Miller#endif
2aa8de21e6cca211bdb436c58886b60f4d32d073Brendan Miller char padding[1024]; /* multiple of 32 */
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall } hwaccm;
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan
376d1bf8f8ca562eecccbf0a0d34aa7c7352e152Laszlo Hordos /** EM part. */
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos union
2aa8de21e6cca211bdb436c58886b60f4d32d073Brendan Miller {
2aa8de21e6cca211bdb436c58886b60f4d32d073Brendan Miller#ifdef ___EMInternal_h
2aa8de21e6cca211bdb436c58886b60f4d32d073Brendan Miller struct EMCPU s;
2aa8de21e6cca211bdb436c58886b60f4d32d073Brendan Miller#endif
93f72edb164ef872eab6e4d482baa186a0dd6c62Andi Egloff char padding[32]; /* multiple of 32 */
9c8c2c05a3d08f94d29b4a42b8a0506a4e97e4faLaszlo Hordos } em;
0901148a508a9c433851a650cd8eb52899d1222bLaszlo Hordos
0901148a508a9c433851a650cd8eb52899d1222bLaszlo Hordos /** TM part. */
2aa8de21e6cca211bdb436c58886b60f4d32d073Brendan Miller union
2aa8de21e6cca211bdb436c58886b60f4d32d073Brendan Miller {
2aa8de21e6cca211bdb436c58886b60f4d32d073Brendan Miller#ifdef ___TMInternal_h
2aa8de21e6cca211bdb436c58886b60f4d32d073Brendan Miller struct TMCPU s;
2aa8de21e6cca211bdb436c58886b60f4d32d073Brendan Miller#endif
2aa8de21e6cca211bdb436c58886b60f4d32d073Brendan Miller char padding[32]; /* multiple of 32 */
2aa8de21e6cca211bdb436c58886b60f4d32d073Brendan Miller } tm;
2aa8de21e6cca211bdb436c58886b60f4d32d073Brendan Miller} VMCPU;
2aa8de21e6cca211bdb436c58886b60f4d32d073Brendan Miller
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle/** Pointer to a VMCPU. */
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle#ifndef ___VBox_types_h
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienletypedef struct VMCPU *PVMCPU;
9c8c2c05a3d08f94d29b4a42b8a0506a4e97e4faLaszlo Hordos#endif
9c8c2c05a3d08f94d29b4a42b8a0506a4e97e4faLaszlo Hordos
376d1bf8f8ca562eecccbf0a0d34aa7c7352e152Laszlo Hordos/** The name of the Guest Context VMM Core module. */
9c8c2c05a3d08f94d29b4a42b8a0506a4e97e4faLaszlo Hordos#define VMMGC_MAIN_MODULE_NAME "VMMGC.gc"
9c8c2c05a3d08f94d29b4a42b8a0506a4e97e4faLaszlo Hordos/** The name of the Ring 0 Context VMM Core module. */
9c8c2c05a3d08f94d29b4a42b8a0506a4e97e4faLaszlo Hordos#define VMMR0_MAIN_MODULE_NAME "VMMR0.r0"
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan
376d1bf8f8ca562eecccbf0a0d34aa7c7352e152Laszlo Hordos/** VM Forced Action Flags.
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos *
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall * Use the VM_FF_SET() and VM_FF_CLEAR() macros to change the force
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos * action mask of a VM.
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos *
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan * @{
376d1bf8f8ca562eecccbf0a0d34aa7c7352e152Laszlo Hordos */
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos/** This action forces the VM to service check and pending interrups on the APIC. */
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos#define VM_FF_INTERRUPT_APIC RT_BIT_32(0)
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos/** This action forces the VM to service check and pending interrups on the PIC. */
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos#define VM_FF_INTERRUPT_PIC RT_BIT_32(1)
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan/** This action forces the VM to schedule and run pending timer (TM). */
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos#define VM_FF_TIMER RT_BIT_32(2)
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos/** PDM Queues are pending. */
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan#define VM_FF_PDM_QUEUES RT_BIT_32(3)
376d1bf8f8ca562eecccbf0a0d34aa7c7352e152Laszlo Hordos/** PDM DMA transfers are pending. */
47196c962e3caf7cdf7ea5d00ccdefc9f208bdceLaszlo Hordos#define VM_FF_PDM_DMA RT_BIT_32(4)
376d1bf8f8ca562eecccbf0a0d34aa7c7352e152Laszlo Hordos/** PDM critical section unlocking is pending, process promptly upon return to R3. */
47196c962e3caf7cdf7ea5d00ccdefc9f208bdceLaszlo Hordos#define VM_FF_PDM_CRITSECT RT_BIT_32(5)
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan/** This action forces the VM to call DBGF so DBGF can service debugger
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan * requests in the emulation thread.
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle * This action flag stays asserted till DBGF clears it.*/
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle#define VM_FF_DBGF RT_BIT_32(8)
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle/** This action forces the VM to service pending requests from other
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle * thread or requests which must be executed in another context. */
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle#define VM_FF_REQUEST RT_BIT_32(9)
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle/** Terminate the VM immediately. */
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle#define VM_FF_TERMINATE RT_BIT_32(10)
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle/** Reset the VM. (postponed) */
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle#define VM_FF_RESET RT_BIT_32(11)
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle
2aa8de21e6cca211bdb436c58886b60f4d32d073Brendan Miller/** This action forces the VM to resync the page tables before going
2aa8de21e6cca211bdb436c58886b60f4d32d073Brendan Miller * back to execute guest code. (GLOBAL FLUSH) */
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle#define VM_FF_PGM_SYNC_CR3 RT_BIT_32(16)
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle/** Same as VM_FF_PGM_SYNC_CR3 except that global pages can be skipped.
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle * (NON-GLOBAL FLUSH) */
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle#define VM_FF_PGM_SYNC_CR3_NON_GLOBAL RT_BIT_32(17)
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle/** PGM needs to allocate handy pages. */
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle#define VM_FF_PGM_NEED_HANDY_PAGES RT_BIT_32(18)
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle/** Check the interupt and trap gates */
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle#define VM_FF_TRPM_SYNC_IDT RT_BIT_32(19)
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle/** Check Guest's TSS ring 0 stack */
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle#define VM_FF_SELM_SYNC_TSS RT_BIT_32(20)
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle/** Check Guest's GDT table */
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle#define VM_FF_SELM_SYNC_GDT RT_BIT_32(21)
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle/** Check Guest's LDT table */
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle#define VM_FF_SELM_SYNC_LDT RT_BIT_32(22)
dd291c383b4490ed77e47d65b4c52595d915f802Chad Kienle/** Inhibit interrupts pending. See EMGetInhibitInterruptsPC(). */
93f72edb164ef872eab6e4d482baa186a0dd6c62Andi Egloff#define VM_FF_INHIBIT_INTERRUPTS RT_BIT_32(23)
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan/** CSAM needs to scan the page that's being executed */
376d1bf8f8ca562eecccbf0a0d34aa7c7352e152Laszlo Hordos#define VM_FF_CSAM_SCAN_PAGE RT_BIT_32(24)
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan/** CSAM needs to do some homework. */
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan#define VM_FF_CSAM_PENDING_ACTION RT_BIT_32(25)
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan
90e23b56c7ebf9dffe7ad87f1031103d2b49c08ePaul Bryan/** Force return to Ring-3. */
90e23b56c7ebf9dffe7ad87f1031103d2b49c08ePaul Bryan#define VM_FF_TO_R3 RT_BIT_32(28)
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan
9697d1ddb3900b1f7f16af9e3be0d1bb34c1f965Paul Bryan/** REM needs to be informed about handler changes. */
376d1bf8f8ca562eecccbf0a0d34aa7c7352e152Laszlo Hordos#define VM_FF_REM_HANDLER_NOTIFY RT_BIT_32(29)
9697d1ddb3900b1f7f16af9e3be0d1bb34c1f965Paul Bryan
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan/** Suspend the VM - debug only. */
90e23b56c7ebf9dffe7ad87f1031103d2b49c08ePaul Bryan#define VM_FF_DEBUG_SUSPEND RT_BIT_32(31)
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan/** Externally forced actions. Used to quit the idle/wait loop. */
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan#define VM_FF_EXTERNAL_SUSPENDED_MASK (VM_FF_TERMINATE | VM_FF_DBGF | VM_FF_REQUEST)
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan/** Externally forced actions. Used to quit the idle/wait loop. */
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan#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)
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan/** High priority pre-execution actions. */
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan#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 \
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan | 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)
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos/** High priority pre raw-mode execution mask. */
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos#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 \
88f2d7061bb42999901dcff81c37089b000d32e0Paul Bryan | VM_FF_INHIBIT_INTERRUPTS)
88f2d7061bb42999901dcff81c37089b000d32e0Paul Bryan/** High priority post-execution actions. */
ab359738f77f6061fd76982ba391ae52e07b0203Paul Bryan#define VM_FF_HIGH_PRIORITY_POST_MASK (VM_FF_PDM_CRITSECT | VM_FF_CSAM_PENDING_ACTION)
2ae41f94c30465830758177491494f918a7a79bcLaszlo Hordos/** Normal priority post-execution actions. */
0da1e22d2b01edcea9b1b42072454ef841f17bfaPaul Bryan#define VM_FF_NORMAL_PRIORITY_POST_MASK (VM_FF_TERMINATE | VM_FF_DBGF | VM_FF_RESET | VM_FF_CSAM_SCAN_PAGE)
0da1e22d2b01edcea9b1b42072454ef841f17bfaPaul Bryan/** Normal priority actions. */
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan#define VM_FF_NORMAL_PRIORITY_MASK (VM_FF_REQUEST | VM_FF_PDM_QUEUES | VM_FF_PDM_DMA | VM_FF_REM_HANDLER_NOTIFY)
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan/** Flags to check before resuming guest execution. */
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan#define VM_FF_RESUME_GUEST_MASK (VM_FF_TO_R3)
88f2d7061bb42999901dcff81c37089b000d32e0Paul Bryan/** All the forced flags. */
88f2d7061bb42999901dcff81c37089b000d32e0Paul Bryan#define VM_FF_ALL_MASK (~0U)
88f2d7061bb42999901dcff81c37089b000d32e0Paul Bryan/** All the forced flags. */
90e23b56c7ebf9dffe7ad87f1031103d2b49c08ePaul Bryan#define VM_FF_ALL_BUT_RAW_MASK (~(VM_FF_HIGH_PRIORITY_PRE_RAW_MASK | VM_FF_CSAM_PENDING_ACTION | VM_FF_PDM_CRITSECT))
90e23b56c7ebf9dffe7ad87f1031103d2b49c08ePaul Bryan
90e23b56c7ebf9dffe7ad87f1031103d2b49c08ePaul Bryan/** @} */
90e23b56c7ebf9dffe7ad87f1031103d2b49c08ePaul Bryan
0da1e22d2b01edcea9b1b42072454ef841f17bfaPaul Bryan/** @def VM_FF_SET
0da1e22d2b01edcea9b1b42072454ef841f17bfaPaul Bryan * Sets a force action flag.
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan *
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall * @param pVM VM Handle.
4b93fff6cbed4e2ae34e954b9b9bd4f318d34cd4Andi Egloff * @param fFlag The flag to set.
4b93fff6cbed4e2ae34e954b9b9bd4f318d34cd4Andi Egloff */
47196c962e3caf7cdf7ea5d00ccdefc9f208bdceLaszlo Hordos#if 1
4b93fff6cbed4e2ae34e954b9b9bd4f318d34cd4Andi Egloff# define VM_FF_SET(pVM, fFlag) ASMAtomicOrU32(&(pVM)->fForcedActions, (fFlag))
4b93fff6cbed4e2ae34e954b9b9bd4f318d34cd4Andi Egloff#else
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall# define VM_FF_SET(pVM, fFlag) \
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall do { ASMAtomicOrU32(&(pVM)->fForcedActions, (fFlag)); \
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall RTLogPrintf("VM_FF_SET : %08x %s - %s(%d) %s\n", (pVM)->fForcedActions, #fFlag, __FILE__, __LINE__, __FUNCTION__); \
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall } while (0)
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall#endif
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall/** @def VMCPU_FF_SET
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall * Sets a force action flag for given VCPU.
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall *
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall * @param pVM VM Handle.
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall * @param idCpu Virtual CPU ID.
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall * @param fFlag The flag to set.
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall */
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall#ifdef VBOX_WITH_SMP_GUESTS
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall# define VMCPU_FF_SET(pVM, idCpu, fFlag) ASMAtomicOrU32(&(pVM)->aCpu[idCpu].fForcedActions, (fFlag))
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall#else
47196c962e3caf7cdf7ea5d00ccdefc9f208bdceLaszlo Hordos# define VMCPU_FF_SET(pVM, idCpu, fFlag) VM_FF_SET(pVM, fFlag)
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall#endif
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall/** @def VM_FF_CLEAR
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall * Clears a force action flag.
93f72edb164ef872eab6e4d482baa186a0dd6c62Andi Egloff *
88f2d7061bb42999901dcff81c37089b000d32e0Paul Bryan * @param pVM VM Handle.
88f2d7061bb42999901dcff81c37089b000d32e0Paul Bryan * @param fFlag The flag to clear.
93f72edb164ef872eab6e4d482baa186a0dd6c62Andi Egloff */
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall#if 1
4b93fff6cbed4e2ae34e954b9b9bd4f318d34cd4Andi Egloff# define VM_FF_CLEAR(pVM, fFlag) ASMAtomicAndU32(&(pVM)->fForcedActions, ~(fFlag))
4b93fff6cbed4e2ae34e954b9b9bd4f318d34cd4Andi Egloff#else
47196c962e3caf7cdf7ea5d00ccdefc9f208bdceLaszlo Hordos# define VM_FF_CLEAR(pVM, fFlag) \
4b93fff6cbed4e2ae34e954b9b9bd4f318d34cd4Andi Egloff do { ASMAtomicAndU32(&(pVM)->fForcedActions, ~(fFlag)); \
7483266ec82ab642b8991a17132b83b6b5d72c3dTravis Hall RTLogPrintf("VM_FF_CLEAR: %08x %s - %s(%d) %s\n", (pVM)->fForcedActions, #fFlag, __FILE__, __LINE__, __FUNCTION__); \
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle } while (0)
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle#endif
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle/** @def VMCPU_FF_CLEAR
5c6780831f7f32502f025e2e795378ae5712dfffchad.kienle * Clears a force action flag for given VCPU.
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle *
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle * @param pVM VM Handle.
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle * @param idCpu Virtual CPU ID.
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle * @param fFlag The flag to clear.
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle */
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle#ifdef VBOX_WITH_SMP_GUESTS
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle# define VMCPU_FF_CLEAR(pVM, idCpu, fFlag) ASMAtomicAndU32(&(pVM)->aCpu[idCpu].fForcedActions, ~(fFlag))
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle#else
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle# define VMCPU_FF_CLEAR(pVM, idCpu, fFlag) VM_FF_CLEAR(pVM, fFlag)
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle#endif
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle/** @def VM_FF_ISSET
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle * Checks if a force action flag is set.
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle *
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle * @param pVM VM Handle.
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle * @param fFlag The flag to check.
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle */
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle#define VM_FF_ISSET(pVM, fFlag) (((pVM)->fForcedActions & (fFlag)) == (fFlag))
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle/** @def VMCPU_FF_ISSET
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle * Checks if a force action flag is set for given VCPU.
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle *
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle * @param pVM VM Handle.
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle * @param idCpu Virtual CPU ID.
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle * @param fFlag The flag to check.
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle */
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle#ifdef VBOX_WITH_SMP_GUESTS
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle# define VMCPU_FF_ISSET(pVM, idCpu, fFlag) (((pVM)->aCpu[idCpu].fForcedActions & (fFlag)) == (fFlag))
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle#else
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle# define VMCPU_FF_ISSET(pVM, idCpu, fFlag) VM_FF_ISSET(pVM, fFlag)
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle#endif
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle/** @def VM_FF_ISPENDING
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle * Checks if one or more force action in the specified set is pending.
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle *
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle * @param pVM VM Handle.
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle * @param fFlags The flags to check for.
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle */
03f0437b30a5f4e8c85a5da94eadfa1f8faca90dBrendan Miller#define VM_FF_ISPENDING(pVM, fFlags) ((pVM)->fForcedActions & (fFlags))
03f0437b30a5f4e8c85a5da94eadfa1f8faca90dBrendan Miller
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle/** @def VMCPU_FF_ISPENDING
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle * Checks if one or more force action in the specified set is pending for given VCPU.
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle *
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle * @param pVM VM Handle.
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle * @param idCpu Virtual CPU ID.
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle * @param fFlags The flags to check for.
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle */
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle#ifdef VBOX_WITH_SMP_GUESTS
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle# define VMCPU_FF_ISPENDING(pVM, idCpu, fFlags) ((pVM)->aCpu[idCpu].fForcedActions & (fFlags))
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle#else
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle# define VMCPU_FF_ISPENDING(pVM, idCpu, fFlags) VM_FF_ISPENDING(pVM, fFlags)
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle#endif
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle/** @def VM_IS_EMT
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle * Checks if the current thread is the emulation thread (EMT).
0d225a5b73f6420cb2afb27337f53e9772d8e610chad.kienle *
10a9be648c010204b8ba63b283aa177749227e11Paul Bryan * @remark The ring-0 variation will need attention if we expand the ring-0
* code to let threads other than EMT mess around with the VM.
*/
#ifdef IN_RC
# define VM_IS_EMT(pVM) true
#elif defined(IN_RING0)
# define VM_IS_EMT(pVM) true
#else
/** @todo need to rework this macro for the case of multiple emulation threads for SMP */
# define VM_IS_EMT(pVM) (VMR3GetVMCPUNativeThread(pVM) == RTThreadNativeSelf())
#endif
/** @def VM_ASSERT_EMT
* Asserts that the current thread IS the emulation thread (EMT).
*/
#ifdef IN_RC
# define VM_ASSERT_EMT(pVM) Assert(VM_IS_EMT(pVM))
#elif defined(IN_RING0)
# define VM_ASSERT_EMT(pVM) Assert(VM_IS_EMT(pVM))
#else
# define VM_ASSERT_EMT(pVM) \
AssertMsg(VM_IS_EMT(pVM), \
("Not emulation thread! Thread=%RTnthrd ThreadEMT=%RTnthrd\n", RTThreadNativeSelf(), VMR3GetVMCPUNativeThread(pVM)))
#endif
/** @def VM_ASSERT_EMT_RETURN
* Asserts that the current thread IS the emulation thread (EMT) and returns if it isn't.
*/
#ifdef IN_RC
# define VM_ASSERT_EMT_RETURN(pVM, rc) AssertReturn(VM_IS_EMT(pVM), (rc))
#elif defined(IN_RING0)
# define VM_ASSERT_EMT_RETURN(pVM, rc) AssertReturn(VM_IS_EMT(pVM), (rc))
#else
# define VM_ASSERT_EMT_RETURN(pVM, rc) \
AssertMsgReturn(VM_IS_EMT(pVM), \
("Not emulation thread! Thread=%RTnthrd ThreadEMT=%RTnthrd\n", RTThreadNativeSelf(), VMR3GetVMCPUNativeThread(pVM)), \
(rc))
#endif
/**
* Asserts that the current thread is NOT the emulation thread.
*/
#define VM_ASSERT_OTHER_THREAD(pVM) \
AssertMsg(!VM_IS_EMT(pVM), ("Not other thread!!\n"))
/** @def VM_ASSERT_STATE_RETURN
* Asserts a certain VM state.
*/
#define VM_ASSERT_STATE(pVM, _enmState) \
AssertMsg((pVM)->enmVMState == (_enmState), \
("state %s, expected %s\n", VMGetStateName(pVM->enmVMState), VMGetStateName(_enmState)))
/** @def VM_ASSERT_STATE_RETURN
* Asserts a certain VM state and returns if it doesn't match.
*/
#define VM_ASSERT_STATE_RETURN(pVM, _enmState, rc) \
AssertMsgReturn((pVM)->enmVMState == (_enmState), \
("state %s, expected %s\n", VMGetStateName(pVM->enmVMState), VMGetStateName(_enmState)), \
(rc))
/** This is the VM structure.
*
* It contains (nearly?) all the VM data which have to be available in all
* contexts. Even if it contains all the data the idea is to use APIs not
* to modify all the members all around the place. Therefore we make use of
* unions to hide everything which isn't local to the current source module.
* This means we'll have to pay a little bit of attention when adding new
* members to structures in the unions and make sure to keep the padding sizes
* up to date.
*
* Run tstVMStructSize after update!
*/
typedef struct VM
{
/** The state of the VM.
* This field is read only to everyone except the VM and EM. */
VMSTATE enmVMState;
/** Forced action flags.
* See the VM_FF_* \#defines. Updated atomically.
*/
volatile uint32_t fForcedActions;
/** Pointer to the array of page descriptors for the VM structure allocation. */
R3PTRTYPE(PSUPPAGE) paVMPagesR3;
/** Session handle. For use when calling SUPR0 APIs. */
PSUPDRVSESSION pSession;
/** Pointer to the ring-3 VM structure. */
PUVM pUVM;
/** Ring-3 Host Context VM Pointer. */
R3PTRTYPE(struct VM *) pVMR3;
/** Ring-0 Host Context VM Pointer. */
R0PTRTYPE(struct VM *) pVMR0;
/** Raw-mode Context VM Pointer. */
RCPTRTYPE(struct VM *) pVMRC;
/** The GVM VM handle. Only the GVM should modify this field. */
uint32_t hSelf;
/** Number of virtual CPUs. */
uint32_t cCPUs;
/** Size of the VM structure including the VMCPU array. */
uint32_t cbSelf;
/** Offset to the VMCPU array starting from beginning of this structure. */
uint32_t offVMCPU;
/** Reserved; alignment. */
uint32_t u32Reserved[6];
/** @name Public VMM Switcher APIs
* @{ */
/**
* Assembly switch entry point for returning to host context.
* This function will clean up the stack frame.
*
* @param eax The return code, register.
* @param Ctx The guest core context.
* @remark Assume interrupts disabled.
*/
RTRCPTR pfnVMMGCGuestToHostAsmGuestCtx/*(int32_t eax, CPUMCTXCORE Ctx)*/;
/**
* Assembly switch entry point for returning to host context.
*
* This is an alternative entry point which we'll be using when the we have the
* hypervisor context and need to save that before going to the host.
*
* This is typically useful when abandoning the hypervisor because of a trap
* and want the trap state to be saved.
*
* @param eax The return code, register.
* @param ecx Pointer to the hypervisor core context, register.
* @remark Assume interrupts disabled.
*/
RTRCPTR pfnVMMGCGuestToHostAsmHyperCtx/*(int32_t eax, PCPUMCTXCORE ecx)*/;
/**
* Assembly switch entry point for returning to host context.
*
* This is an alternative to the two *Ctx APIs and implies that the context has already
* been saved, or that it's just a brief return to HC and that the caller intends to resume
* whatever it is doing upon 'return' from this call.
*
* @param eax The return code, register.
* @remark Assume interrupts disabled.
*/
RTRCPTR pfnVMMGCGuestToHostAsm/*(int32_t eax)*/;
/** @} */
/** @name Various VM data owned by VM.
* @{ */
RTTHREAD uPadding1;
/** The native handle of ThreadEMT. Getting the native handle
* is generally faster than getting the IPRT one (except on OS/2 :-). */
RTNATIVETHREAD uPadding2;
/** @} */
/** @name Various items that are frequently accessed.
* @{ */
/** Raw ring-3 indicator. */
bool fRawR3Enabled;
/** Raw ring-0 indicator. */
bool fRawR0Enabled;
/** PATM enabled flag.
* This is placed here for performance reasons. */
bool fPATMEnabled;
/** CSAM enabled flag.
* This is placed here for performance reasons. */
bool fCSAMEnabled;
/** Hardware VM support is available and enabled.
* This is placed here for performance reasons. */
bool fHWACCMEnabled;
/** PARAV enabled flag. */
bool fPARAVEnabled;
/** @} */
/* padding to make gnuc put the StatQemuToGC where msc does. */
#if HC_ARCH_BITS == 32
uint32_t padding0;
#endif
/** Profiling the total time from Qemu to GC. */
STAMPROFILEADV StatTotalQemuToGC;
/** Profiling the total time from GC to Qemu. */
STAMPROFILEADV StatTotalGCToQemu;
/** Profiling the total time spent in GC. */
STAMPROFILEADV StatTotalInGC;
/** Profiling the total time spent not in Qemu. */
STAMPROFILEADV StatTotalInQemu;
/** Profiling the VMMSwitcher code for going to GC. */
STAMPROFILEADV StatSwitcherToGC;
/** Profiling the VMMSwitcher code for going to HC. */
STAMPROFILEADV StatSwitcherToHC;
STAMPROFILEADV StatSwitcherSaveRegs;
STAMPROFILEADV StatSwitcherSysEnter;
STAMPROFILEADV StatSwitcherDebug;
STAMPROFILEADV StatSwitcherCR0;
STAMPROFILEADV StatSwitcherCR4;
STAMPROFILEADV StatSwitcherJmpCR3;
STAMPROFILEADV StatSwitcherRstrRegs;
STAMPROFILEADV StatSwitcherLgdt;
STAMPROFILEADV StatSwitcherLidt;
STAMPROFILEADV StatSwitcherLldt;
STAMPROFILEADV StatSwitcherTSS;
/** @todo Realign everything on 64 byte boundaries to better match the
* cache-line size. */
/* padding - the unions must be aligned on 32 bytes boundraries. */
uint32_t padding[HC_ARCH_BITS == 32 ? 4+8 : 6];
/** CPUM part. */
union
{
#ifdef ___CPUMInternal_h
struct CPUM s;
#endif
char padding[4096]; /* multiple of 32 */
} cpum;
/** VMM part. */
union
{
#ifdef ___VMMInternal_h
struct VMM s;
#endif
char padding[1536]; /* multiple of 32 */
} vmm;
/** PGM part. */
union
{
#ifdef ___PGMInternal_h
struct PGM s;
#endif
char padding[50*1024]; /* multiple of 32 */
} pgm;
/** HWACCM part. */
union
{
#ifdef ___HWACCMInternal_h
struct HWACCM s;
#endif
char padding[512]; /* multiple of 32 */
} hwaccm;
/** TRPM part. */
union
{
#ifdef ___TRPMInternal_h
struct TRPM s;
#endif
char padding[5344]; /* multiple of 32 */
} trpm;
/** SELM part. */
union
{
#ifdef ___SELMInternal_h
struct SELM s;
#endif
char padding[544]; /* multiple of 32 */
} selm;
/** MM part. */
union
{
#ifdef ___MMInternal_h
struct MM s;
#endif
char padding[192]; /* multiple of 32 */
} mm;
/** CFGM part. */
union
{
#ifdef ___CFGMInternal_h
struct CFGM s;
#endif
char padding[32]; /* multiple of 32 */
} cfgm;
/** PDM part. */
union
{
#ifdef ___PDMInternal_h
struct PDM s;
#endif
char padding[1824]; /* multiple of 32 */
} pdm;
/** IOM part. */
union
{
#ifdef ___IOMInternal_h
struct IOM s;
#endif
char padding[4544]; /* multiple of 32 */
} iom;
/** PATM part. */
union
{
#ifdef ___PATMInternal_h
struct PATM s;
#endif
char padding[768]; /* multiple of 32 */
} patm;
/** CSAM part. */
union
{
#ifdef ___CSAMInternal_h
struct CSAM s;
#endif
char padding[3328]; /* multiple of 32 */
} csam;
/** PARAV part. */
union
{
#ifdef ___PARAVInternal_h
struct PARAV s;
#endif
char padding[128];
} parav;
/** EM part. */
union
{
#ifdef ___EMInternal_h
struct EM s;
#endif
char padding[1344]; /* multiple of 32 */
} em;
/** TM part. */
union
{
#ifdef ___TMInternal_h
struct TM s;
#endif
char padding[1536]; /* multiple of 32 */
} tm;
/** DBGF part. */
union
{
#ifdef ___DBGFInternal_h
struct DBGF s;
#endif
char padding[2368]; /* multiple of 32 */
} dbgf;
/** SSM part. */
union
{
#ifdef ___SSMInternal_h
struct SSM s;
#endif
char padding[32]; /* multiple of 32 */
} ssm;
/** VM part. */
union
{
#ifdef ___VMInternal_h
struct VMINT s;
#endif
char padding[768]; /* multiple of 32 */
} vm;
/** REM part. */
union
{
#ifdef ___REMInternal_h
struct REM s;
#endif
#ifdef VBOX_WITH_NEW_RECOMPILER
/** @def VM_REM_SIZE
* Must be multiple of 32 and coherent with REM_ENV_SIZE from REMInternal.h. */
#if GC_ARCH_BITS == 32
# define VM_REM_SIZE (HC_ARCH_BITS == 32 ? 0x10800 : 0x10800)
#else
# define VM_REM_SIZE (HC_ARCH_BITS == 32 ? 0x10900 : 0x10900)
#endif
#else /* !VBOX_WITH_NEW_RECOMILER */
#if GC_ARCH_BITS == 32
# define VM_REM_SIZE (HC_ARCH_BITS == 32 ? 0x6f00 : 0xbf00)
#else
# define VM_REM_SIZE (HC_ARCH_BITS == 32 ? 0x9f00 : 0xdf00)
#endif
#endif /* !VBOX_WITH_NEW_RECOMILER */
char padding[VM_REM_SIZE]; /* multiple of 32 */
} rem;
/** Padding for aligning the cpu array on a 64 byte boundrary. */
uint32_t u32Reserved2[8];
/** VMCPU array for the configured number of virtual CPUs.
* Must be aligned on a 64-byte boundrary. */
VMCPU aCpus[1];
} VM;
/** Pointer to a VM. */
#ifndef ___VBox_types_h
typedef struct VM *PVM;
#endif
#ifdef IN_RC
__BEGIN_DECLS
/** The VM structure.
* This is imported from the VMMGCBuiltin module, i.e. it's a one
* of those magic globals which we should avoid using.
*/
extern DECLIMPORT(VM) g_VM;
__END_DECLS
#endif
/** @} */
#endif