cpumctx.h revision ff308c5c63cf562048295f83638429a925415a10
/** @file
* CPUM - CPU Monitor(/ Manager), Context Structures.
*/
/*
* Copyright (C) 2006-2015 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.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
#ifndef ___VBox_vmm_cpumctx_h
#define ___VBox_vmm_cpumctx_h
#ifndef VBOX_FOR_DTRACE_LIB
#else
#endif
/** @addgroup grp_cpum_ctx The CPUM Context Structures
* @ingroup grp_cpum
* @{
*/
/**
* Selector hidden registers.
*/
typedef struct CPUMSELREG
{
/** The selector register. */
/** Padding, don't use. */
/** The selector which info resides in u64Base, u32Limit and Attr, provided
* that CPUMSELREG_FLAGS_VALID is set. */
/** Flags, see CPUMSELREG_FLAGS_XXX. */
/** Base register.
*
* Long mode remarks:
* - Unused in long mode for CS, DS, ES, SS
* - 32 bits for FS & GS; FS(GS)_BASE msr used for the base address
* - 64 bits for TR & LDTR
*/
/** Limit (expanded). */
/** Flags.
* This is the high 32-bit word of the descriptor entry.
* Only the flags, dpl and type are used. */
} CPUMSELREG;
/** @name CPUMSELREG_FLAGS_XXX - CPUMSELREG::fFlags values.
* @{ */
/** @} */
/** Checks if the hidden parts of the selector register are valid. */
#ifdef VBOX_WITH_RAW_MODE_NOT_R0
|| ( (a_pVCpu) /*!= NULL*/ \
&& CPUMIsGuestInRawMode(a_pVCpu) \
) \
) \
)
#else
#endif
/** Old type used for the hidden register part.
* @deprecated */
typedef CPUMSELREG CPUMSELREGHID;
/**
* The sysenter register set.
*/
typedef struct CPUMSYSENTER
{
/** Ring 0 cs.
* This value + 8 is the Ring 0 ss.
* This value + 16 is the Ring 3 cs.
* This value + 24 is the Ring 3 ss.
*/
/** Ring 0 eip. */
/** Ring 0 esp. */
} CPUMSYSENTER;
/**
* For compilers (like DTrace) that does not grok nameless unions, we have a
* little hack to make them palatable.
*/
#ifdef VBOX_FOR_DTRACE_LIB
#elif defined(VBOX_WITHOUT_UNNAMED_UNIONS)
#else
# define CPUM_UNION_NAME(a_Nm)
#endif
/**
* CPU context core.
*
* @todo Eliminate this structure!
* @deprecated We don't push any context cores any more in TRPM.
*/
#pragma pack(1)
typedef struct CPUMCTXCORE
{
/** @name General Register.
* @note These follow the encoding order (X86_GREG_XXX) and can be accessed as
* an array starting a rax.
* @{ */
union
{
} CPUM_UNION_NAME(rax);
union
{
} CPUM_UNION_NAME(rcx);
union
{
} CPUM_UNION_NAME(rdx);
union
{
} CPUM_UNION_NAME(rbx);
union
{
} CPUM_UNION_NAME(rsp);
union
{
} CPUM_UNION_NAME(rbp);
union
{
} CPUM_UNION_NAME(rsi);
union
{
} CPUM_UNION_NAME(rdi);
/** @} */
/** @name Segment registers.
* @note These follow the encoding order (X86_SREG_XXX) and can be accessed as
* an array starting a es.
* @{ */
/** @} */
/** The program counter. */
union
{
} CPUM_UNION_NAME(rip);
/** The flags register. */
union
{
} CPUMCTXCORE;
#pragma pack()
/**
* CPU context.
*/
typedef struct CPUMCTX
{
/** CPUMCTXCORE Part.
* @{ */
/** @name General Register.
* @note These follow the encoding order (X86_GREG_XXX) and can be accessed as
* an array starting at rax.
* @{ */
union
{
} CPUM_UNION_NAME(rax);
union
{
} CPUM_UNION_NAME(rcx);
union
{
} CPUM_UNION_NAME(rdx);
union
{
} CPUM_UNION_NAME(rbx);
union
{
} CPUM_UNION_NAME(rsp);
union
{
} CPUM_UNION_NAME(rbp);
union
{
} CPUM_UNION_NAME(rsi);
union
{
} CPUM_UNION_NAME(rdi);
/** @} */
/** @name Segment registers.
* @note These follow the encoding order (X86_SREG_XXX) and can be accessed as
* an array starting at es.
* @{ */
/** @} */
/** The program counter. */
union
{
} CPUM_UNION_NAME(rip);
/** The flags register. */
union
{
/** @} */ /*(CPUMCTXCORE)*/
/** @name Control registers.
* @{ */
/** @} */
/** Debug registers.
* @remarks DR4 and DR5 should not be used since they are aliases for
* DR6 and DR7 respectively on both AMD and Intel CPUs.
* @remarks DR8-15 are currently not supported by AMD or Intel, so
* neither do we.
*/
/** Padding before the structure so the 64-bit member is correctly aligned.
* @todo fix this structure! */
/** Global Descriptor Table register. */
/** Padding before the structure so the 64-bit member is correctly aligned.
* @todo fix this structure! */
/** Interrupt Descriptor Table register. */
/** The task register.
* Only the guest context uses all the members. */
/** The task register.
* Only the guest context uses all the members. */
/** The sysenter msr registers.
* This member is not used by the hypervisor context. */
/** @name System MSRs.
* @{ */
/** @} */
/** The XCR0 register. */
/** State component offsets into pXState, UINT16_MAX if not present. */
/** Size padding. */
} CPUMCTX;
#pragma pack()
#ifndef VBOX_FOR_DTRACE_LIB
/**
* Gets the CPUMCTXCORE part of a CPUMCTX.
*/
/**
* Gets the CPUMCTXCORE part of a CPUMCTX.
*/
/**
* Gets the first selector register of a CPUMCTX.
*
* Use this with X86_SREG_COUNT to loop thru the selector registers.
*/
#endif /* !VBOX_FOR_DTRACE_LIB */
/**
* Additional guest MSRs (i.e. not part of the CPU context structure).
*
* @remarks Never change the order here because of the saved stated! The size
* can in theory be changed, but keep older VBox versions in mind.
*/
typedef union CPUMCTXMSRS
{
struct
{
} msr;
} CPUMCTXMSRS;
/** Pointer to the guest MSR state. */
typedef CPUMCTXMSRS *PCPUMCTXMSRS;
/** Pointer to the const guest MSR state. */
typedef const CPUMCTXMSRS *PCCPUMCTXMSRS;
/**
* The register set returned by a CPUID operation.
*/
typedef struct CPUMCPUID
{
} CPUMCPUID;
/** Pointer to a CPUID leaf. */
typedef CPUMCPUID *PCPUMCPUID;
/** Pointer to a const CPUID leaf. */
typedef const CPUMCPUID *PCCPUMCPUID;
/** @} */
#endif