cpumctx.h revision 8e8b76c53d4184bab1fc42f94c9fea709880c481
/** @file
* CPUM - CPU Monitor(/ Manager), Context Structures.
*/
/*
* Copyright (C) 2006-2012 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
/** @addgroup grp_cpum_ctx The CPUM Context Structures
* @ingroup grp_cpum
* @{
*/
/**
* Selector hidden registers.
*/
typedef struct CPUMSELREGHID
{
/** 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. */
/**
* 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
# define CPUM_UNION_NAME u
#elif defined(VBOX_WITHOUT_UNNAMED_UNIONS)
# define CPUM_UNION_NAME u
#else
# define CPUM_UNION_NAME
#endif
/**
* CPU context core.
*/
#ifndef VBOX_FOR_DTRACE_LIB
# pragma pack(1)
#endif
typedef struct CPUMCTXCORE
{
union
{
union
{
union
{
union
{
union
{
union
{
union
{
union
{
/* Note: lss esp, [] in the switcher needs some space, so we reserve it here instead of relying on the exact esp & ss layout as before. */
union
{
union
{
/** Hidden selector registers.
* @{ */
/** @} */
} CPUMCTXCORE;
# ifndef VBOX_FOR_DTRACE_LIB
# pragma pack()
# endif
/**
* CPU context.
*/
#ifndef VBOX_FOR_DTRACE_LIB
# pragma pack(1)
#endif
typedef struct CPUMCTX
{
/** FPU state. (16-byte alignment)
* @todo This doesn't have to be in X86FXSTATE on CPUs without fxsr - we need a type for the
* actual format or convert it (waste of time). */
/** CPUMCTXCORE Part.
* @{ */
union
{
union
{
union
{
union
{
union
{
union
{
union
{
union
{
/** @note lss esp, [] in the switcher needs some space, so we reserve it here
* instead of relying on the exact esp & ss layout as before (prevented
* us from using a union with rsp). */
union
{
union
{
/** Hidden selector registers.
* @{ */
/** @} */
/** @} */
/** 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.
* @{ */
/** @} */
/** Global Descriptor Table register. */
/** 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. */
/** System MSRs.
* @{ */
/** @} */
/** Hidden selector registers.
* @{ */
/** @} */
# if 0
/** Padding to align the size on a 64 byte boundary. */
# endif
} CPUMCTX;
# ifndef VBOX_FOR_DTRACE_LIB
# pragma pack()
# endif
#ifndef VBOX_FOR_DTRACE_LIB
/**
* Gets the CPUMCTXCORE part of a CPUMCTX.
*/
/**
* Selector hidden registers, for version 1.6 saved state.
*/
typedef struct CPUMSELREGHID_VER1_6
{
/** Base register. */
/** Limit (expanded). */
/** Flags.
* This is the high 32-bit word of the descriptor entry.
* Only the flags, dpl and type are used. */
/**
* CPU context, for version 1.6 saved state.
* @remarks PATM uses this, which is why it has to be here.
*/
# pragma pack(1)
typedef struct CPUMCTX_VER1_6
{
/** FPU state. (16-byte alignment)
* @todo This doesn't have to be in X86FXSTATE on CPUs without fxsr - we need a type for the
* actual format or convert it (waste of time). */
/** CPUMCTXCORE Part.
* @{ */
union
{
union
{
union
{
union
{
union
{
union
{
union
{
/** @note We rely on the exact layout, because we use lss esp, [] in the
* switcher. */
/* Note: no overlap with esp here. */
union
{
union
{
/** Hidden selector registers.
* @{ */
/** @} */
/** @} */
/** Control registers.
* @{ */
/** @} */
/** Debug registers.
* @{ */
/* DR8-15 are currently not supported */
/** @} */
/** Global Descriptor Table register. */
/** 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. */
/** System MSRs.
* @{ */
/** @} */
/** Hidden selector registers.
* @{ */
/** @} */
/** padding to get 32byte aligned size. */
# pragma pack()
#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