hm_svm.h revision 7ed6686fafec2e7ce2b987446f8feb845bab7e9b
/** @file
* HM - SVM (AMD-V) Structures and Definitions. (VMM)
*/
/*
* 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_svm_h
#define ___VBox_vmm_svm_h
/** @defgroup grp_svm SVM (AMD-V) Types and Definitions
* @ingroup grp_hm
* @{
*/
/** @name SVM features for cpuid 0x8000000a
* @{
*/
/** Bit 0 - NP - Nested Paging supported. */
#define AMD_CPUID_SVM_FEATURE_EDX_NESTED_PAGING RT_BIT(0)
/** Bit 1 - LbrVirt - Support for saving five debug MSRs. */
/** Bit 2 - SVML - SVM locking bit supported. */
/** Bit 3 - NRIPS - Saving the next instruction pointer is supported. */
/** Bit 4 - TscRateMsr - Support for MSR TSC ratio. */
/** Bit 5 - VmcbClean - Support VMCB clean bits. */
/** Bit 6 - FlushByAsid - Indicate TLB flushing for current ASID only, and that
* VMCB.TLB_Control is supported. */
/** Bit 7 - DecodeAssist - Indicate decode assist is supported. */
/** Bit 10 - PauseFilter - Indicates support for the PAUSE intercept filter. */
/** Bit 12 - PauseFilterThreshold - Indicates support for the PAUSE
* intercept filter cycle count threshold. */
/** Bit 13 - AVIC - Advanced Virtual Interrupt Controller. */
/** @} */
/** @name SVM Basic Exit Reasons.
* @{
*/
/** Invalid guest state in VMCB. */
#define SVM_EXIT_INVALID (-1)
/** Read from CR0-CR15. */
#define SVM_EXIT_READ_CR0 0x0
#define SVM_EXIT_READ_CR1 0x1
#define SVM_EXIT_READ_CR2 0x2
#define SVM_EXIT_READ_CR3 0x3
#define SVM_EXIT_READ_CR4 0x4
#define SVM_EXIT_READ_CR5 0x5
#define SVM_EXIT_READ_CR6 0x6
#define SVM_EXIT_READ_CR7 0x7
#define SVM_EXIT_READ_CR8 0x8
#define SVM_EXIT_READ_CR9 0x9
#define SVM_EXIT_READ_CR10 0xA
#define SVM_EXIT_READ_CR11 0xB
#define SVM_EXIT_READ_CR12 0xC
#define SVM_EXIT_READ_CR13 0xD
#define SVM_EXIT_READ_CR14 0xE
#define SVM_EXIT_READ_CR15 0xF
/** Writes to CR0-CR15. */
#define SVM_EXIT_WRITE_CR0 0x10
#define SVM_EXIT_WRITE_CR1 0x11
#define SVM_EXIT_WRITE_CR2 0x12
#define SVM_EXIT_WRITE_CR3 0x13
#define SVM_EXIT_WRITE_CR4 0x14
#define SVM_EXIT_WRITE_CR5 0x15
#define SVM_EXIT_WRITE_CR6 0x16
#define SVM_EXIT_WRITE_CR7 0x17
#define SVM_EXIT_WRITE_CR8 0x18
#define SVM_EXIT_WRITE_CR9 0x19
#define SVM_EXIT_WRITE_CR10 0x1A
#define SVM_EXIT_WRITE_CR11 0x1B
#define SVM_EXIT_WRITE_CR12 0x1C
#define SVM_EXIT_WRITE_CR13 0x1D
#define SVM_EXIT_WRITE_CR14 0x1E
#define SVM_EXIT_WRITE_CR15 0x1F
/** Read from DR0-DR15. */
#define SVM_EXIT_READ_DR0 0x20
#define SVM_EXIT_READ_DR1 0x21
#define SVM_EXIT_READ_DR2 0x22
#define SVM_EXIT_READ_DR3 0x23
#define SVM_EXIT_READ_DR4 0x24
#define SVM_EXIT_READ_DR5 0x25
#define SVM_EXIT_READ_DR6 0x26
#define SVM_EXIT_READ_DR7 0x27
#define SVM_EXIT_READ_DR8 0x28
#define SVM_EXIT_READ_DR9 0x29
#define SVM_EXIT_READ_DR10 0x2A
#define SVM_EXIT_READ_DR11 0x2B
#define SVM_EXIT_READ_DR12 0x2C
#define SVM_EXIT_READ_DR13 0x2D
#define SVM_EXIT_READ_DR14 0x2E
#define SVM_EXIT_READ_DR15 0x2F
/** Writes to DR0-DR15. */
#define SVM_EXIT_WRITE_DR0 0x30
#define SVM_EXIT_WRITE_DR1 0x31
#define SVM_EXIT_WRITE_DR2 0x32
#define SVM_EXIT_WRITE_DR3 0x33
#define SVM_EXIT_WRITE_DR4 0x34
#define SVM_EXIT_WRITE_DR5 0x35
#define SVM_EXIT_WRITE_DR6 0x36
#define SVM_EXIT_WRITE_DR7 0x37
#define SVM_EXIT_WRITE_DR8 0x38
#define SVM_EXIT_WRITE_DR9 0x39
#define SVM_EXIT_WRITE_DR10 0x3A
#define SVM_EXIT_WRITE_DR11 0x3B
#define SVM_EXIT_WRITE_DR12 0x3C
#define SVM_EXIT_WRITE_DR13 0x3D
#define SVM_EXIT_WRITE_DR14 0x3E
#define SVM_EXIT_WRITE_DR15 0x3F
/* Exception 0-31. */
#define SVM_EXIT_EXCEPTION_0 0x40
#define SVM_EXIT_EXCEPTION_1 0x41
#define SVM_EXIT_EXCEPTION_2 0x42
#define SVM_EXIT_EXCEPTION_3 0x43
#define SVM_EXIT_EXCEPTION_4 0x44
#define SVM_EXIT_EXCEPTION_5 0x45
#define SVM_EXIT_EXCEPTION_6 0x46
#define SVM_EXIT_EXCEPTION_7 0x47
#define SVM_EXIT_EXCEPTION_8 0x48
#define SVM_EXIT_EXCEPTION_9 0x49
#define SVM_EXIT_EXCEPTION_A 0x4A
#define SVM_EXIT_EXCEPTION_B 0x4B
#define SVM_EXIT_EXCEPTION_C 0x4C
#define SVM_EXIT_EXCEPTION_D 0x4D
#define SVM_EXIT_EXCEPTION_E 0x4E
#define SVM_EXIT_EXCEPTION_F 0x4F
#define SVM_EXIT_EXCEPTION_10 0x50
#define SVM_EXIT_EXCEPTION_11 0x51
#define SVM_EXIT_EXCEPTION_12 0x52
#define SVM_EXIT_EXCEPTION_13 0x53
#define SVM_EXIT_EXCEPTION_14 0x54
#define SVM_EXIT_EXCEPTION_15 0x55
#define SVM_EXIT_EXCEPTION_16 0x56
#define SVM_EXIT_EXCEPTION_17 0x57
#define SVM_EXIT_EXCEPTION_18 0x58
#define SVM_EXIT_EXCEPTION_19 0x59
#define SVM_EXIT_EXCEPTION_1A 0x5A
#define SVM_EXIT_EXCEPTION_1B 0x5B
#define SVM_EXIT_EXCEPTION_1C 0x5C
#define SVM_EXIT_EXCEPTION_1D 0x5D
#define SVM_EXIT_EXCEPTION_1E 0x5E
#define SVM_EXIT_EXCEPTION_1F 0x5F
/** Physical maskable interrupt. */
#define SVM_EXIT_INTR 0x60
/** Non-maskable interrupt. */
#define SVM_EXIT_NMI 0x61
/** System Management interrupt. */
#define SVM_EXIT_SMI 0x62
/** Physical INIT signal. */
#define SVM_EXIT_INIT 0x63
/** Virtual interrupt. */
#define SVM_EXIT_VINTR 0x64
/** Write to CR0 that changed any bits other than CR0.TS or CR0.MP. */
#define SVM_EXIT_CR0_SEL_WRITE 0x65
/** IDTR read. */
#define SVM_EXIT_IDTR_READ 0x66
/** GDTR read. */
#define SVM_EXIT_GDTR_READ 0x67
/** LDTR read. */
#define SVM_EXIT_LDTR_READ 0x68
/** TR read. */
#define SVM_EXIT_TR_READ 0x69
/** IDTR write. */
#define SVM_EXIT_IDTR_WRITE 0x6A
/** GDTR write. */
#define SVM_EXIT_GDTR_WRITE 0x6B
/** LDTR write. */
#define SVM_EXIT_LDTR_WRITE 0x6C
/** TR write. */
#define SVM_EXIT_TR_WRITE 0x6D
/** RDTSC instruction. */
#define SVM_EXIT_RDTSC 0x6E
/** RDPMC instruction. */
#define SVM_EXIT_RDPMC 0x6F
/** PUSHF instruction. */
#define SVM_EXIT_PUSHF 0x70
/** POPF instruction. */
#define SVM_EXIT_POPF 0x71
/** CPUID instruction. */
#define SVM_EXIT_CPUID 0x72
/** RSM instruction. */
#define SVM_EXIT_RSM 0x73
/** IRET instruction. */
#define SVM_EXIT_IRET 0x74
/** software interrupt (INTn instructions). */
#define SVM_EXIT_SWINT 0x75
/** INVD instruction. */
#define SVM_EXIT_INVD 0x76
/** PAUSE instruction. */
#define SVM_EXIT_PAUSE 0x77
/** HLT instruction. */
#define SVM_EXIT_HLT 0x78
/** INVLPG instructions. */
#define SVM_EXIT_INVLPG 0x79
/** INVLPGA instruction. */
#define SVM_EXIT_INVLPGA 0x7A
/** IN or OUT accessing protected port (the EXITINFO1 field provides more information). */
#define SVM_EXIT_IOIO 0x7B
/** RDMSR or WRMSR access to protected MSR. */
#define SVM_EXIT_MSR 0x7C
/** task switch. */
#define SVM_EXIT_TASK_SWITCH 0x7D
/** FP legacy handling enabled, and processor is frozen in an x87/mmx instruction waiting for an interrupt. */
#define SVM_EXIT_FERR_FREEZE 0x7E
/** Shutdown. */
#define SVM_EXIT_SHUTDOWN 0x7F
/** VMRUN instruction. */
#define SVM_EXIT_VMRUN 0x80
/** VMMCALL instruction. */
#define SVM_EXIT_VMMCALL 0x81
/** VMLOAD instruction. */
#define SVM_EXIT_VMLOAD 0x82
/** VMSAVE instruction. */
#define SVM_EXIT_VMSAVE 0x83
/** STGI instruction. */
#define SVM_EXIT_STGI 0x84
/** CLGI instruction. */
#define SVM_EXIT_CLGI 0x85
/** SKINIT instruction. */
#define SVM_EXIT_SKINIT 0x86
/** RDTSCP instruction. */
#define SVM_EXIT_RDTSCP 0x87
/** ICEBP instruction. */
#define SVM_EXIT_ICEBP 0x88
/** WBINVD instruction. */
#define SVM_EXIT_WBINVD 0x89
/** MONITOR instruction. */
#define SVM_EXIT_MONITOR 0x8A
/** MWAIT instruction. */
#define SVM_EXIT_MWAIT 0x8B
/** MWAIT instruction, when armed. */
#define SVM_EXIT_MWAIT_ARMED 0x8C
/** Nested paging: host-level page fault occurred (EXITINFO1 contains fault errorcode; EXITINFO2 contains the guest physical address causing the fault). */
#define SVM_EXIT_NPF 0x400
/** AVIC: Virtual IPI delivery not completed. */
#define SVM_EXIT_AVIC_INCOMPLETE_IPI 0x401
/** AVIC: Attempted access by guest to a vAPIC register not handled by AVIC
* hardware. */
#define SVM_EXIT_AVIC_NOACCEL 0x402
/** The maximum possible exit value. */
#define SVM_EXIT_MAX (SVM_EXIT_AVIC_NOACCEL)
/** @} */
/** @name SVMVMCB.u64ExitInfo2 for task switches
* @{
*/
/** Set to 1 if the task switch was caused by an IRET; else cleared to 0. */
/** Set to 1 if the task switch was caused by a far jump; else cleared to 0. */
/** Set to 1 if the task switch has an error code; else cleared to 0. */
/** The value of EFLAGS.RF that would be saved in the outgoing TSS if the task switch were not intercepted. */
/** @} */
/** @name SVMVMCB.u64ExitInfo1 for MSR accesses
* @{
*/
/** The access was a read MSR. */
#define SVM_EXIT1_MSR_READ 0x0
/** The access was a write MSR. */
#define SVM_EXIT1_MSR_WRITE 0x1
/** @} */
/** @name SVMVMCB.ctrl.u32InterceptCtrl1
* @{
*/
/** 0 Intercept INTR (physical maskable interrupt). */
#define SVM_CTRL1_INTERCEPT_INTR RT_BIT(0)
/** 1 Intercept NMI. */
/** 2 Intercept SMI. */
/** 3 Intercept INIT. */
/** 4 Intercept VINTR (virtual maskable interrupt). */
/** 5 Intercept CR0 writes that change bits other than CR0.TS or CR0.MP */
/** 6 Intercept reads of IDTR. */
/** 7 Intercept reads of GDTR. */
/** 8 Intercept reads of LDTR. */
/** 9 Intercept reads of TR. */
/** 10 Intercept writes of IDTR. */
/** 11 Intercept writes of GDTR. */
/** 12 Intercept writes of LDTR. */
/** 13 Intercept writes of TR. */
/** 14 Intercept RDTSC instruction. */
/** 15 Intercept RDPMC instruction. */
/** 16 Intercept PUSHF instruction. */
/** 17 Intercept POPF instruction. */
/** 18 Intercept CPUID instruction. */
/** 19 Intercept RSM instruction. */
/** 20 Intercept IRET instruction. */
/** 21 Intercept INTn instruction. */
/** 22 Intercept INVD instruction. */
/** 23 Intercept PAUSE instruction. */
/** 24 Intercept HLT instruction. */
/** 25 Intercept INVLPG instruction. */
/** 26 Intercept INVLPGA instruction. */
/** 28 MSR_PROT Intercept RDMSR or WRMSR accesses to selected MSRs. */
/** 29 Intercept task switches. */
/** 30 FERR_FREEZE: intercept processor "freezing" during legacy FERR handling. */
/** 31 Intercept shutdown events. */
/** @} */
/** @name SVMVMCB.ctrl.u32InterceptCtrl2
* @{
*/
/** 0 Intercept VMRUN instruction. */
#define SVM_CTRL2_INTERCEPT_VMRUN RT_BIT(0)
/** 1 Intercept VMMCALL instruction. */
/** 2 Intercept VMLOAD instruction. */
/** 3 Intercept VMSAVE instruction. */
/** 4 Intercept STGI instruction. */
/** 5 Intercept CLGI instruction. */
/** 6 Intercept SKINIT instruction. */
/** 7 Intercept RDTSCP instruction. */
/** 8 Intercept ICEBP instruction. */
/** 9 Intercept WBINVD instruction. */
/** 10 Intercept MONITOR instruction. */
/** 11 Intercept MWAIT instruction unconditionally. */
/** 12 Intercept MWAIT instruction when armed. */
/** 13 Intercept XSETBV instruction. */
/** @} */
/** @name SVMVMCB.ctrl.u64NestedPaging
* @{
*/
#define SVM_NESTED_PAGING_ENABLE RT_BIT(0)
/** @} */
/** @name SVMVMCB.ctrl.u64IntShadow
* @{
*/
#define SVM_INTERRUPT_SHADOW_ACTIVE RT_BIT(0)
/** @} */
/** @name SVMINTCTRL.u3Type
* @{
*/
/** External or virtual interrupt. */
#define SVM_EVENT_EXTERNAL_IRQ 0
/** Non-maskable interrupt. */
#define SVM_EVENT_NMI 2
/** Exception; fault or trap. */
#define SVM_EVENT_EXCEPTION 3
/** Software interrupt. */
#define SVM_EVENT_SOFTWARE_INT 4
/** @} */
/** @name SVMVMCB.ctrl.TLBCtrl.n.u8TLBFlush
* @{
*/
/** Flush nothing. */
#define SVM_TLB_FLUSH_NOTHING 0
/** Flush entire TLB (host+guest entries) */
#define SVM_TLB_FLUSH_ENTIRE 1
/** Flush this guest's TLB entries (by ASID) */
#define SVM_TLB_FLUSH_SINGLE_CONTEXT 3
/** Flush this guest's non-global TLB entries (by ASID) */
/** @} */
/**
* SVM Selector type; includes hidden parts.
*/
typedef struct
{
} SVMSEL;
/**
*/
typedef struct
{
} SVMGDTR;
/**
* SVM Event injection structure (EVENTINJ and EXITINTINFO).
*/
typedef union
{
struct
{
} n;
uint64_t u;
} SVMEVENT;
/** Pointer to the SVMEVENT union. */
/**
* SVM Interrupt control structure (Virtual Interrupt Control).
*/
typedef union
{
struct
{
} n;
uint64_t u;
} SVMINTCTRL;
/**
* SVM TLB control structure.
*/
typedef union
{
struct
{
} n;
uint64_t u;
} SVMTLBCTRL;
/**
* SVM IOIO exit structure (EXITINFO1 for IOIO intercepts).
*/
typedef union
{
struct
{
} n;
uint32_t u;
} SVMIOIOEXIT;
/** @name SVMIOIOEXIT.u1Type
* @{ */
/** IO write. */
#define SVM_IOIO_WRITE 0
/** IO read. */
#define SVM_IOIO_READ 1
/** @}*/
/**
* SVM nested paging structure.
*/
typedef union
{
struct
{
} n;
uint64_t u;
} SVMNPCTRL;
/**
* SVM AVIC.
*/
typedef union
{
struct
{
} n;
uint64_t u;
} SVMAVIC;
/**
* SVM AVIC PHYSICAL_TABLE pointer.
*/
typedef union
{
struct
{
} n;
uint64_t u;
} SVMAVICPHYS;
/**
* SVM VM Control Block. (VMCB)
*/
typedef struct SVMVMCB
{
/** Control Area. */
struct
{
/** Offset 0x00 - Intercept reads of CR0-15. */
/** Offset 0x02 - Intercept writes to CR0-15. */
/** Offset 0x04 - Intercept reads of DR0-15. */
/** Offset 0x06 - Intercept writes to DR0-15. */
/** Offset 0x08 - Intercept exception vectors 0-31. */
/** Offset 0x0C - Intercept control field 1. */
/** Offset 0x10 - Intercept control field 2. */
/** Offset 0x14-0x3F - Reserved. */
/** Offset 0x3c - PAUSE filter threshold. */
/** Offset 0x3e - PAUSE intercept filter count. */
/** Offset 0x40 - Physical address of IOPM. */
/** Offset 0x48 - Physical address of MSRPM. */
/** Offset 0x50 - TSC Offset. */
/** Offset 0x58 - TLB control field. */
/** Offset 0x60 - Interrupt control field. */
/** Offset 0x68 - Interrupt shadow. */
/** Offset 0x70 - Exit code. */
/** Offset 0x78 - Exit info 1. */
/** Offset 0x80 - Exit info 2. */
/** Offset 0x88 - Exit Interrupt info. */
/** Offset 0x90 - Nested Paging. */
/** Offset 0x98 - AVIC APIC BAR. */
/** Offset 0xA0-0xA7 - Reserved. */
/** Offset 0xA8 - Event injection. */
/** Offset 0xB0 - Host CR3 for nested paging. */
/** Offset 0xB8 - LBR Virtualization. */
/** Offset 0xC0 - VMCB Clean Bits. */
/** Offset 0xC8 - Next sequential instruction pointer. */
/** Offset 0xD0 - Number of bytes fetched. */
/** Offset 0xD1 - Fetched bytes. */
/** Offset 0xE0 - AVIC APIC_BACKING_PAGE pointer. */
/** Offset 0xE8-0xEF - Reserved. */
/** Offset 0xF0 - AVIC LOGICAL_TABLE pointer. */
/** Offset 0xF8 - AVIC PHYSICAL_TABLE pointer. */
} ctrl;
/** Offset 0x100-0x3FF - Reserved. */
/** State Save Area. Starts at offset 0x400. */
struct
{
/** Offset 0x400 - Guest ES register + hidden parts. */
/** Offset 0x410 - Guest CS register + hidden parts. */
/** Offset 0x420 - Guest SS register + hidden parts. */
/** Offset 0x430 - Guest DS register + hidden parts. */
/** Offset 0x440 - Guest FS register + hidden parts. */
/** Offset 0x450 - Guest GS register + hidden parts. */
/** Offset 0x460 - Guest GDTR register. */
/** Offset 0x470 - Guest LDTR register + hidden parts. */
/** Offset 0x480 - Guest IDTR register. */
/** Offset 0x490 - Guest TR register + hidden parts. */
/** Offset 0x4A0-0x4CA - Reserved. */
/** Offset 0x4CB - CPL. */
/** Offset 0x4CC-0x4CF - Reserved. */
/** Offset 0x4D0 - EFER. */
/** Offset 0x4D8-0x547 - Reserved. */
/** Offset 0x548 - CR4. */
/** Offset 0x550 - CR3. */
/** Offset 0x558 - CR0. */
/** Offset 0x560 - DR7. */
/** Offset 0x568 - DR6. */
/** Offset 0x570 - RFLAGS. */
/** Offset 0x578 - RIP. */
/** Offset 0x580-0x5D7 - Reserved. */
/** Offset 0x5D8 - RSP. */
/** Offset 0x5E0-0x5F7 - Reserved. */
/** Offset 0x5F8 - RAX. */
/** Offset 0x600 - STAR. */
/** Offset 0x608 - LSTAR. */
/** Offset 0x610 - CSTAR. */
/** Offset 0x618 - SFMASK. */
/** Offset 0x620 - KernelGSBase. */
/** Offset 0x628 - SYSENTER_CS. */
/** Offset 0x630 - SYSENTER_ESP. */
/** Offset 0x638 - SYSENTER_EIP. */
/** Offset 0x640 - CR2. */
/** Offset 0x648-0x667 - Reserved. */
/** Offset 0x668 - G_PAT. */
/** Offset 0x670 - DBGCTL. */
/** Offset 0x678 - BR_FROM. */
/** Offset 0x680 - BR_TO. */
/** Offset 0x688 - LASTEXCPFROM. */
/** Offset 0x690 - LASTEXCPTO. */
} guest;
/** Offset 0x698-0xFFF- Reserved. */
} SVMVMCB;
/** Pointer to the SVMVMCB structure. */
#ifdef IN_RING0
#endif /* IN_RING0 */
/** @} */
#endif