CPUMInternal.h revision abb570b1d0fa7304983df800658356c8adbff89f
/* $Id$ */
/** @file
* CPUM - Internal header file.
*/
/*
* Copyright (C) 2006-2007 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef ___CPUMInternal_h
#define ___CPUMInternal_h
/** @defgroup grp_cpum_int Internals
* @ingroup grp_cpum
* @internal
* @{
*/
/** Flags and types for CPUM fault handlers
* @{ */
/** Type: Load DS */
#define CPUM_HANDLER_DS 1
/** Type: Load ES */
#define CPUM_HANDLER_ES 2
/** Type: Load FS */
#define CPUM_HANDLER_FS 3
/** Type: Load GS */
#define CPUM_HANDLER_GS 4
/** Type: IRET */
#define CPUM_HANDLER_IRET 5
/** Type mask. */
#define CPUM_HANDLER_TYPEMASK 0xff
/** If set EBP points to the CPUMCTXCORE that's being used. */
/** @} */
/** Use flags (CPUM::fUseFlags).
* (Don't forget to sync this with CPUMInternal.mac!)
* @{ */
/** Used the FPU, SSE or such stuff. */
#define CPUM_USED_FPU RT_BIT(0)
/** Used the FPU, SSE or such stuff since last we were in REM.
* REM syncing is clearing this, lazy FPU is setting it. */
/** Host OS is using SYSENTER and we must NULL the CS. */
/** Host OS is using SYSENTER and we must NULL the CS. */
/** Debug registers are used by host and must be disabled. */
/** Enabled use of debug registers in guest context. */
/** The XMM state was manually restored. (AMD only) */
/** Sync the FPU state on entry (32->64 switcher only). */
/** Sync the debug state on entry (32->64 switcher only). */
/** Enabled use of hypervisor debug registers in guest context. */
/** @} */
/* Sanity check. */
# error "VBOX_WITH_HYBRID_32BIT_KERNEL is only for 32 bit builds."
#endif
/**
* The saved host CPU state.
*
* @remark The special VBOX_WITH_HYBRID_32BIT_KERNEL checks here are for the 10.4.x series
* of Mac OS X where the OS is essentially 32-bit but the cpu mode can be 64-bit.
*/
typedef struct CPUMHOSTCTX
{
/** FPU state. (16-byte alignment)
* @remark On x86, the format isn't necessarily X86FXSTATE (not important). */
/** General purpose register, selectors, flags and more
* @{ */
/** General purpose register ++
* { */
//uint64_t rax; - scratch
//uint64_t rcx; - scratch
//uint64_t rdx; - scratch
//uint64_t r8; - scratch
//uint64_t r9; - scratch
//uint64_t rip; - scratch
#endif
#if HC_ARCH_BITS == 32
//uint32_t eax; - scratch
//uint32_t ecx; - scratch
//uint32_t edx; - scratch
//uint32_t eip; - scratch
/* lss pair! */
#endif
/** @} */
/** Selector registers
* @{ */
/** @} */
/** Control registers.
* @{ */
//uint32_t cr2; - scratch
/** @} */
/** Debug registers.
* @{ */
/** @} */
/** Global Descriptor Table register. */
/** Interrupt Descriptor Table register. */
/** The task register. */
/** The task register. */
/** The sysenter msr registers.
* This member is not used by the hypervisor context. */
/** MSRs
* @{ */
/** @} */
/* padding to get 64byte aligned size */
/** Control registers.
* @{ */
//uint64_t cr2; - scratch
/** @} */
/** Debug registers.
* @{ */
/** @} */
/** Global Descriptor Table register. */
/** Interrupt Descriptor Table register. */
/** The task register. */
/** The task register. */
/** MSRs
* @{ */
/** @} */
/* padding to get 32byte aligned size */
# ifdef VBOX_WITH_HYBRID_32BIT_KERNEL
# else
# endif
#else
#endif
} CPUMHOSTCTX;
/** Pointer to the saved host CPU state. */
typedef CPUMHOSTCTX *PCPUMHOSTCTX;
/**
* CPUM Data (part of VM)
*/
typedef struct CPUM
{
/** Offset from CPUM to CPUMCPU for the first CPU. */
/** Use flags.
* These flags indicates which CPU features the host uses.
*/
/** Host CPU Features - ECX */
struct
{
/** edx part */
/** ecx part */
} CPUFeatures;
/** Host extended CPU features. */
struct
{
/** edx part */
/** ecx part */
/** Host CPU manufacturer. */
/** Guest CPU manufacturer. */
/** CR4 mask */
struct
{
} CR4;
/** Synthetic CPU type? */
bool fSyntheticCpu;
/** The (more) portable CPUID level. */
/** Indicates that a state restore is pending.
* This is used to verify load order dependencies (PGM). */
bool fPendingRestore;
/** The standard set of CpuId leaves. */
/** The extended set of CpuId leaves. */
/** The centaur set of CpuId leaves. */
/** The hypervisor specific set of CpuId leaves. */
/** The default set of CpuId leaves. */
#if HC_ARCH_BITS == 32
#endif
#endif
/**
* Guest context on raw mode entry. 64-byte aligned!
* This a debug feature, see CPUMR3SaveEntryCtx.
*/
} CPUM;
/** Pointer to the CPUM instance data residing in the shared VM structure. */
/**
* CPUM Data (part of VMCPU)
*/
typedef struct CPUMCPU
{
/**
* Hypervisor context.
* Aligned on a 64-byte boundary.
*/
/**
* Saved host context. Only valid while inside GC.
* Aligned on a 64-byte boundary.
*/
#ifdef VBOX_WITH_CRASHDUMP_MAGIC
#endif
/**
* Guest context.
* Aligned on a 64-byte boundary.
*/
/**
* Guest context - misc MSRs
* Aligned on a 64-byte boundary.
*/
/** Pointer to the current hypervisor core context - R3Ptr. */
/** Pointer to the current hypervisor core context - R0Ptr. */
/** Pointer to the current hypervisor core context - RCPtr. */
/** Use flags.
* These flags indicates both what is to be used and what has been used.
*/
/** Changed flags.
* These flags indicates to REM (and others) which important guest
* registers which has been changed since last time the flags were cleared.
* See the CPUM_CHANGED_* defines for what we keep track of.
*/
/** Offset from CPUM to CPUMCPU. */
/** Temporary storage for the return code of the function called in the
* 32-64 switcher. */
/** Have we entered raw-mode? */
bool fRawEntered;
/** Have we entered the recompiler? */
bool fRemEntered;
/** Align the structure on a 64-byte boundary. */
/** Pointer to the CPUMCPU instance data residing in the shared VMCPU structure. */
#ifdef IN_RING3
#endif
#ifdef IN_RING0
#endif
/** @} */
#endif