em.h revision 78dea6229e0025891612cc52f77bf0b2beb7c46d
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * EM - Execution Monitor.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * Copyright (C) 2006-2010 Oracle Corporation
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * available from http://www.virtualbox.org. This file is free software;
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * you can redistribute it and/or modify it under the terms of the GNU
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * General Public License (GPL) as published by the Free Software
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * The contents of this file may alternatively be used under the terms
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * of the Common Development and Distribution License Version 1.0
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * VirtualBox OSE distribution, in which case the provisions of the
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * CDDL are applicable instead of those of the GPL.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * You may elect to license modified versions of this file under the
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * terms and conditions of either the GPL or the CDDL or both.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync/** @defgroup grp_em The Execution Monitor / Manager API
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync/** Enable to allow V86 code to run in raw mode. */
6ffe15b8a1730e56a0a818da51c4e7a115da5763vboxsync * The Execution Manager State.
6ffe15b8a1730e56a0a818da51c4e7a115da5763vboxsync * @remarks This is used in the saved state!
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync /** Not yet started. */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync /** Raw-mode execution. */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync /** Hardware accelerated raw-mode execution. */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync /** Value reserved for future use (used to be PARAV). */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync /** Recompiled mode execution. */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync /** Execution is halted. (waiting for interrupt) */
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync /** Application processor execution is halted. (waiting for startup IPI (SIPI)) */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync /** Execution is suspended. */
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync /** The VM is terminating. */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync /** Guest debug event from raw-mode is being processed. */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync /** Guest debug event from hardware accelerated mode is being processed. */
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync /** Guest debug event from recompiled-mode is being processed. */
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync /** Hypervisor debug event being processed. */
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync /** The VM has encountered a fatal error. (And everyone is panicing....) */
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync /** Just a hack to ensure that we get a 32-bit integer. */
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync * EMInterpretInstructionCPUEx execution modes.
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsynctypedef enum
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync /** Only supervisor code (CPL=0). */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync /** User-level code only. */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync /** Supervisor and user-level code (use with great care!). */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync /** Just a hack to ensure that we get a 32-bit integer. */
165b506f4c024dabd5a4caaeda31c66712d154eavboxsyncVMMDECL(void) EMSetState(PVMCPU pVCpu, EMSTATE enmNewState);
e0dec59adb362e8486c0622785420ad10e720972vboxsync/** @name Callback handlers for instruction emulation functions.
e0dec59adb362e8486c0622785420ad10e720972vboxsync * These are placed here because IOM wants to use them as well.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsynctypedef DECLCALLBACK(uint32_t) FNEMULATEPARAM2UINT32(void *pvParam1, uint64_t val2);
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsynctypedef FNEMULATEPARAM2UINT32 *PFNEMULATEPARAM2UINT32;
165b506f4c024dabd5a4caaeda31c66712d154eavboxsynctypedef DECLCALLBACK(uint32_t) FNEMULATEPARAM2(void *pvParam1, size_t val2);
165b506f4c024dabd5a4caaeda31c66712d154eavboxsynctypedef DECLCALLBACK(uint32_t) FNEMULATEPARAM3(void *pvParam1, uint64_t val2, size_t val3);
165b506f4c024dabd5a4caaeda31c66712d154eavboxsynctypedef DECLCALLBACK(int) FNEMULATELOCKPARAM2(void *pvParam1, uint64_t val2, RTGCUINTREG32 *pf);
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsynctypedef DECLCALLBACK(int) FNEMULATELOCKPARAM3(void *pvParam1, uint64_t val2, size_t cb, RTGCUINTREG32 *pf);
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * Checks if raw ring-3 execute mode is enabled.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * @returns true if enabled.
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync * @returns false if disabled.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * @param pVM The VM to operate on.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync#define EMIsRawRing3Enabled(pVM) (!(pVM)->fRecompileUser)
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync * Checks if raw ring-0 execute mode is enabled.
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsync * @returns true if enabled.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * @returns false if disabled.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * @param pVM The VM to operate on.
e0dec59adb362e8486c0622785420ad10e720972vboxsync#define EMIsRawRing0Enabled(pVM) (!(pVM)->fRecompileSupervisor)
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * Checks if execution with hardware assisted virtualization is enabled.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * @returns true if enabled.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * @returns false if disabled.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync * @param pVM The VM to operate on.
165b506f4c024dabd5a4caaeda31c66712d154eavboxsync#define EMIsHwVirtExecutionEnabled(pVM) (!(pVM)->fRecompileSupervisor && !(pVM)->fRecompileSupervisor)
165b506f4c024dabd5a4caaeda31c66712d154eavboxsyncVMMDECL(void) EMSetInhibitInterruptsPC(PVMCPU pVCpu, RTGCUINTPTR PC);
165b506f4c024dabd5a4caaeda31c66712d154eavboxsyncVMMDECL(RTGCUINTPTR) EMGetInhibitInterruptsPC(PVMCPU pVCpu);
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsyncVMMDECL(int) EMInterpretDisasOne(PVM pVM, PVMCPU pVCpu, PCCPUMCTXCORE pCtxCore, PDISCPUSTATE pCpu, unsigned *pcbInstr);
2c19fa7a35e93931f995c196426585b16f8bf2c0vboxsyncVMMDECL(int) EMInterpretDisasOneEx(PVM pVM, PVMCPU pVCpu, RTGCUINTPTR GCPtrInstr, PCCPUMCTXCORE pCtxCore,
e0dec59adb362e8486c0622785420ad10e720972vboxsyncVMMDECL(VBOXSTRICTRC) EMInterpretInstruction(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, uint32_t *pcbSize);
165b506f4c024dabd5a4caaeda31c66712d154eavboxsyncVMMDECL(VBOXSTRICTRC) EMInterpretInstructionCPU(PVM pVM, PVMCPU pVCpu, PDISCPUSTATE pDISState, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, EMCODETYPE enmCodeType, uint32_t *pcbSize);
165b506f4c024dabd5a4caaeda31c66712d154eavboxsyncVMMDECL(int) EMInterpretCpuId(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame);
165b506f4c024dabd5a4caaeda31c66712d154eavboxsyncVMMDECL(int) EMInterpretRdtsc(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame);
165b506f4c024dabd5a4caaeda31c66712d154eavboxsyncVMMDECL(int) EMInterpretRdpmc(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame);
165b506f4c024dabd5a4caaeda31c66712d154eavboxsyncVMMDECL(int) EMInterpretRdtscp(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
165b506f4c024dabd5a4caaeda31c66712d154eavboxsyncVMMDECL(VBOXSTRICTRC) EMInterpretInvlpg(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, RTGCPTR pAddrGC);
165b506f4c024dabd5a4caaeda31c66712d154eavboxsyncVMMDECL(int) EMInterpretIret(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame);
165b506f4c024dabd5a4caaeda31c66712d154eavboxsyncVMMDECL(VBOXSTRICTRC) EMInterpretMWait(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame);
165b506f4c024dabd5a4caaeda31c66712d154eavboxsyncVMMDECL(int) EMInterpretMonitor(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame);
VMMDECL(int) EMInterpretDRxWrite(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, uint32_t DestRegDrx, uint32_t SrcRegGen);
VMMDECL(int) EMInterpretDRxRead(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, uint32_t DestRegGen, uint32_t SrcRegDrx);
VMMDECL(int) EMInterpretCRxWrite(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, uint32_t DestRegCrx, uint32_t SrcRegGen);
VMMDECL(int) EMInterpretCRxRead(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, uint32_t DestRegGen, uint32_t SrcRegCrx);
VMMDECL(VBOXSTRICTRC) EMInterpretPortIO(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, PDISCPUSTATE pCpu, uint32_t cbOp);
VMMDECL(int) EMEmulateLockXor(void *pvParam1, uint64_t u64Param2, size_t cbSize, RTGCUINTREG32 *pf);
VMMDECL(int) EMEmulateLockAnd(void *pvParam1, uint64_t u64Param2, size_t cbSize, RTGCUINTREG32 *pf);
VMMDECL(uint32_t) EMEmulateCmpXchg(void *pvParam1, uint64_t *pu32Param2, uint64_t u32Param3, size_t cbSize);
VMMDECL(uint32_t) EMEmulateLockCmpXchg(void *pvParam1, uint64_t *pu64Param2, uint64_t u64Param3, size_t cbSize);
VMMDECL(uint32_t) EMEmulateCmpXchg8b(void *pu32Param1, uint32_t *pEAX, uint32_t *pEDX, uint32_t uEBX, uint32_t uECX);
VMMDECL(uint32_t) EMEmulateLockCmpXchg8b(void *pu32Param1, uint32_t *pEAX, uint32_t *pEDX, uint32_t uEBX, uint32_t uECX);
#ifdef IN_RING3
typedef enum EMEXECPOLICY
EMEXECPOLICY_INVALID = 0,
} EMEXECPOLICY;
#ifdef IN_RC