TianoCore EDK2 master
Ghcb.h File Reference
#include <Base.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>

Go to the source code of this file.

Data Structures

union  GHCB_EXIT_INFO
 
union  GHCB_EVENT_INJECTION
 
struct  SNP_PAGE_STATE_ENTRY
 
struct  SNP_PAGE_STATE_HEADER
 
struct  SNP_PAGE_STATE_CHANGE_INFO
 
union  SEV_ES_SEGMENT_REGISTER_ATTRIBUTES
 
struct  SEV_ES_SEGMENT_REGISTER
 
struct  SEV_ES_SAVE_AREA
 

Macros

#define UD_EXCEPTION   6
 
#define GP_EXCEPTION   13
 
#define VC_EXCEPTION   29
 
#define GHCB_VERSION_MIN   1
 
#define GHCB_VERSION_MAX   2
 
#define GHCB_STANDARD_USAGE   0
 
#define SVM_EXIT_DR7_READ   0x27ULL
 
#define SVM_EXIT_DR7_WRITE   0x37ULL
 
#define SVM_EXIT_RDTSC   0x6EULL
 
#define SVM_EXIT_RDPMC   0x6FULL
 
#define SVM_EXIT_CPUID   0x72ULL
 
#define SVM_EXIT_INVD   0x76ULL
 
#define SVM_EXIT_IOIO_PROT   0x7BULL
 
#define SVM_EXIT_MSR   0x7CULL
 
#define SVM_EXIT_VMMCALL   0x81ULL
 
#define SVM_EXIT_RDTSCP   0x87ULL
 
#define SVM_EXIT_WBINVD   0x89ULL
 
#define SVM_EXIT_MONITOR   0x8AULL
 
#define SVM_EXIT_MWAIT   0x8BULL
 
#define SVM_EXIT_NPF   0x400ULL
 
#define SVM_EXIT_MMIO_READ   0x80000001ULL
 
#define SVM_EXIT_MMIO_WRITE   0x80000002ULL
 
#define SVM_EXIT_NMI_COMPLETE   0x80000003ULL
 
#define SVM_EXIT_AP_RESET_HOLD   0x80000004ULL
 
#define SVM_EXIT_AP_JUMP_TABLE   0x80000005ULL
 
#define SVM_EXIT_SNP_PAGE_STATE_CHANGE   0x80000010ULL
 
#define SVM_EXIT_SNP_AP_CREATION   0x80000013ULL
 
#define SVM_EXIT_HYPERVISOR_FEATURES   0x8000FFFDULL
 
#define SVM_EXIT_UNSUPPORTED   0x8000FFFFULL
 
#define IOIO_TYPE_STR   BIT2
 
#define IOIO_TYPE_IN   1
 
#define IOIO_TYPE_INS   (IOIO_TYPE_IN | IOIO_TYPE_STR)
 
#define IOIO_TYPE_OUT   0
 
#define IOIO_TYPE_OUTS   (IOIO_TYPE_OUT | IOIO_TYPE_STR)
 
#define IOIO_REP   BIT3
 
#define IOIO_ADDR_64   BIT9
 
#define IOIO_ADDR_32   BIT8
 
#define IOIO_ADDR_16   BIT7
 
#define IOIO_DATA_32   BIT6
 
#define IOIO_DATA_16   BIT5
 
#define IOIO_DATA_8   BIT4
 
#define IOIO_DATA_MASK   (BIT6 | BIT5 | BIT4)
 
#define IOIO_DATA_OFFSET   4
 
#define IOIO_DATA_BYTES(x)   (((x) & IOIO_DATA_MASK) >> IOIO_DATA_OFFSET)
 
#define IOIO_SEG_ES   0
 
#define IOIO_SEG_DS   (BIT11 | BIT10)
 
#define SVM_VMGEXIT_SNP_AP_CREATE_ON_INIT   0
 
#define SVM_VMGEXIT_SNP_AP_CREATE   1
 
#define SVM_VMGEXIT_SNP_AP_DESTROY   2
 
#define GHCB_SAVE_AREA_QWORD_OFFSET(RegisterField)    (OFFSET_OF (GHCB, SaveArea.RegisterField) / sizeof (UINT64))
 
#define GHCB_EVENT_INJECTION_TYPE_INT   0
 
#define GHCB_EVENT_INJECTION_TYPE_NMI   2
 
#define GHCB_EVENT_INJECTION_TYPE_EXCEPTION   3
 
#define GHCB_EVENT_INJECTION_TYPE_SOFT_INT   4
 
#define GHCB_HV_FEATURES_SNP   BIT0
 
#define GHCB_HV_FEATURES_SNP_AP_CREATE   (GHCB_HV_FEATURES_SNP | BIT1)
 
#define GHCB_HV_FEATURES_SNP_RESTRICTED_INJECTION   (GHCB_HV_FEATURES_SNP_AP_CREATE | BIT2)
 
#define GHCB_HV_FEATURES_SNP_RESTRICTED_INJECTION_TIMER   (GHCB_HV_FEATURES_SNP_RESTRICTED_INJECTION | BIT3)
 
#define SNP_PAGE_STATE_PRIVATE   1
 
#define SNP_PAGE_STATE_SHARED   2
 
#define SNP_PAGE_STATE_PSMASH   3
 
#define SNP_PAGE_STATE_UNSMASH   4
 
#define SNP_PAGE_STATE_MAX_ENTRY   253
 
#define SEV_ES_RESET_CODE_SEGMENT_TYPE   0xA
 
#define SEV_ES_RESET_DATA_SEGMENT_TYPE   0x2
 
#define SEV_ES_RESET_LDT_TYPE   0x2
 
#define SEV_ES_RESET_TSS_TYPE   0x3
 

Typedefs

struct {
   UINT8   Reserved1 [203]
 
   UINT8   Cpl
 
   UINT8   Reserved8 [300]
 
   UINT64   Rax
 
   UINT8   Reserved4 [264]
 
   UINT64   Rcx
 
   UINT64   Rdx
 
   UINT64   Rbx
 
   UINT8   Reserved5 [112]
 
   UINT64   SwExitCode
 
   UINT64   SwExitInfo1
 
   UINT64   SwExitInfo2
 
   UINT64   SwScratch
 
   UINT8   Reserved6 [56]
 
   UINT64   XCr0
 
   UINT8   ValidBitmap [16]
 
   UINT64   X87StateGpa
 
   UINT8   Reserved7 [1016]
 
GHCB_SAVE_AREA
 
struct {
   GHCB_SAVE_AREA   SaveArea
 
   UINT8   SharedBuffer [2032]
 
   UINT8   Reserved1 [10]
 
   UINT16   ProtocolVersion
 
   UINT32   GhcbUsage
 
GHCB
 

Enumerations

enum  GHCB_REGISTER {
  GhcbCpl = GHCB_SAVE_AREA_QWORD_OFFSET (Cpl) , GhcbRax = GHCB_SAVE_AREA_QWORD_OFFSET (Rax) , GhcbRbx = GHCB_SAVE_AREA_QWORD_OFFSET (Rbx) , GhcbRcx = GHCB_SAVE_AREA_QWORD_OFFSET (Rcx) ,
  GhcbRdx = GHCB_SAVE_AREA_QWORD_OFFSET (Rdx) , GhcbXCr0 = GHCB_SAVE_AREA_QWORD_OFFSET (XCr0) , GhcbSwExitCode = GHCB_SAVE_AREA_QWORD_OFFSET (SwExitCode) , GhcbSwExitInfo1 = GHCB_SAVE_AREA_QWORD_OFFSET (SwExitInfo1) ,
  GhcbSwExitInfo2 = GHCB_SAVE_AREA_QWORD_OFFSET (SwExitInfo2) , GhcbSwScratch = GHCB_SAVE_AREA_QWORD_OFFSET (SwScratch)
}
 

Detailed Description

Guest-Hypervisor Communication Block (GHCB) Definition.

Provides data types allowing an SEV-ES guest to interact with the hypervisor using the GHCB protocol.

Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Specification Reference:
SEV-ES Guest-Hypervisor Communication Block Standardization

Definition in file Ghcb.h.

Macro Definition Documentation

◆ GHCB_EVENT_INJECTION_TYPE_EXCEPTION

#define GHCB_EVENT_INJECTION_TYPE_EXCEPTION   3

Definition at line 163 of file Ghcb.h.

◆ GHCB_EVENT_INJECTION_TYPE_INT

#define GHCB_EVENT_INJECTION_TYPE_INT   0

Definition at line 161 of file Ghcb.h.

◆ GHCB_EVENT_INJECTION_TYPE_NMI

#define GHCB_EVENT_INJECTION_TYPE_NMI   2

Definition at line 162 of file Ghcb.h.

◆ GHCB_EVENT_INJECTION_TYPE_SOFT_INT

#define GHCB_EVENT_INJECTION_TYPE_SOFT_INT   4

Definition at line 164 of file Ghcb.h.

◆ GHCB_HV_FEATURES_SNP

#define GHCB_HV_FEATURES_SNP   BIT0

Definition at line 169 of file Ghcb.h.

◆ GHCB_HV_FEATURES_SNP_AP_CREATE

#define GHCB_HV_FEATURES_SNP_AP_CREATE   (GHCB_HV_FEATURES_SNP | BIT1)

Definition at line 170 of file Ghcb.h.

◆ GHCB_HV_FEATURES_SNP_RESTRICTED_INJECTION

#define GHCB_HV_FEATURES_SNP_RESTRICTED_INJECTION   (GHCB_HV_FEATURES_SNP_AP_CREATE | BIT2)

Definition at line 171 of file Ghcb.h.

◆ GHCB_HV_FEATURES_SNP_RESTRICTED_INJECTION_TIMER

#define GHCB_HV_FEATURES_SNP_RESTRICTED_INJECTION_TIMER   (GHCB_HV_FEATURES_SNP_RESTRICTED_INJECTION | BIT3)

Definition at line 172 of file Ghcb.h.

◆ GHCB_SAVE_AREA_QWORD_OFFSET

#define GHCB_SAVE_AREA_QWORD_OFFSET (   RegisterField)     (OFFSET_OF (GHCB, SaveArea.RegisterField) / sizeof (UINT64))

Definition at line 123 of file Ghcb.h.

◆ GHCB_STANDARD_USAGE

#define GHCB_STANDARD_USAGE   0

Definition at line 29 of file Ghcb.h.

◆ GHCB_VERSION_MAX

#define GHCB_VERSION_MAX   2

Definition at line 27 of file Ghcb.h.

◆ GHCB_VERSION_MIN

#define GHCB_VERSION_MIN   1

Definition at line 26 of file Ghcb.h.

◆ GP_EXCEPTION

#define GP_EXCEPTION   13

Definition at line 23 of file Ghcb.h.

◆ IOIO_ADDR_16

#define IOIO_ADDR_16   BIT7

Definition at line 75 of file Ghcb.h.

◆ IOIO_ADDR_32

#define IOIO_ADDR_32   BIT8

Definition at line 74 of file Ghcb.h.

◆ IOIO_ADDR_64

#define IOIO_ADDR_64   BIT9

Definition at line 73 of file Ghcb.h.

◆ IOIO_DATA_16

#define IOIO_DATA_16   BIT5

Definition at line 78 of file Ghcb.h.

◆ IOIO_DATA_32

#define IOIO_DATA_32   BIT6

Definition at line 77 of file Ghcb.h.

◆ IOIO_DATA_8

#define IOIO_DATA_8   BIT4

Definition at line 79 of file Ghcb.h.

◆ IOIO_DATA_BYTES

#define IOIO_DATA_BYTES (   x)    (((x) & IOIO_DATA_MASK) >> IOIO_DATA_OFFSET)

Definition at line 82 of file Ghcb.h.

◆ IOIO_DATA_MASK

#define IOIO_DATA_MASK   (BIT6 | BIT5 | BIT4)

Definition at line 80 of file Ghcb.h.

◆ IOIO_DATA_OFFSET

#define IOIO_DATA_OFFSET   4

Definition at line 81 of file Ghcb.h.

◆ IOIO_REP

#define IOIO_REP   BIT3

Definition at line 71 of file Ghcb.h.

◆ IOIO_SEG_DS

#define IOIO_SEG_DS   (BIT11 | BIT10)

Definition at line 85 of file Ghcb.h.

◆ IOIO_SEG_ES

#define IOIO_SEG_ES   0

Definition at line 84 of file Ghcb.h.

◆ IOIO_TYPE_IN

#define IOIO_TYPE_IN   1

Definition at line 66 of file Ghcb.h.

◆ IOIO_TYPE_INS

#define IOIO_TYPE_INS   (IOIO_TYPE_IN | IOIO_TYPE_STR)

Definition at line 67 of file Ghcb.h.

◆ IOIO_TYPE_OUT

#define IOIO_TYPE_OUT   0

Definition at line 68 of file Ghcb.h.

◆ IOIO_TYPE_OUTS

#define IOIO_TYPE_OUTS   (IOIO_TYPE_OUT | IOIO_TYPE_STR)

Definition at line 69 of file Ghcb.h.

◆ IOIO_TYPE_STR

#define IOIO_TYPE_STR   BIT2

Definition at line 65 of file Ghcb.h.

◆ SEV_ES_RESET_CODE_SEGMENT_TYPE

#define SEV_ES_RESET_CODE_SEGMENT_TYPE   0xA

Definition at line 217 of file Ghcb.h.

◆ SEV_ES_RESET_DATA_SEGMENT_TYPE

#define SEV_ES_RESET_DATA_SEGMENT_TYPE   0x2

Definition at line 218 of file Ghcb.h.

◆ SEV_ES_RESET_LDT_TYPE

#define SEV_ES_RESET_LDT_TYPE   0x2

Definition at line 220 of file Ghcb.h.

◆ SEV_ES_RESET_TSS_TYPE

#define SEV_ES_RESET_TSS_TYPE   0x3

Definition at line 221 of file Ghcb.h.

◆ SNP_PAGE_STATE_MAX_ENTRY

#define SNP_PAGE_STATE_MAX_ENTRY   253

Definition at line 198 of file Ghcb.h.

◆ SNP_PAGE_STATE_PRIVATE

#define SNP_PAGE_STATE_PRIVATE   1

Definition at line 179 of file Ghcb.h.

◆ SNP_PAGE_STATE_PSMASH

#define SNP_PAGE_STATE_PSMASH   3

Definition at line 181 of file Ghcb.h.

◆ SNP_PAGE_STATE_SHARED

#define SNP_PAGE_STATE_SHARED   2

Definition at line 180 of file Ghcb.h.

◆ SNP_PAGE_STATE_UNSMASH

#define SNP_PAGE_STATE_UNSMASH   4

Definition at line 182 of file Ghcb.h.

◆ SVM_EXIT_AP_JUMP_TABLE

#define SVM_EXIT_AP_JUMP_TABLE   0x80000005ULL

Definition at line 56 of file Ghcb.h.

◆ SVM_EXIT_AP_RESET_HOLD

#define SVM_EXIT_AP_RESET_HOLD   0x80000004ULL

Definition at line 55 of file Ghcb.h.

◆ SVM_EXIT_CPUID

#define SVM_EXIT_CPUID   0x72ULL

Definition at line 38 of file Ghcb.h.

◆ SVM_EXIT_DR7_READ

#define SVM_EXIT_DR7_READ   0x27ULL

Definition at line 34 of file Ghcb.h.

◆ SVM_EXIT_DR7_WRITE

#define SVM_EXIT_DR7_WRITE   0x37ULL

Definition at line 35 of file Ghcb.h.

◆ SVM_EXIT_HYPERVISOR_FEATURES

#define SVM_EXIT_HYPERVISOR_FEATURES   0x8000FFFDULL

Definition at line 59 of file Ghcb.h.

◆ SVM_EXIT_INVD

#define SVM_EXIT_INVD   0x76ULL

Definition at line 39 of file Ghcb.h.

◆ SVM_EXIT_IOIO_PROT

#define SVM_EXIT_IOIO_PROT   0x7BULL

Definition at line 40 of file Ghcb.h.

◆ SVM_EXIT_MMIO_READ

#define SVM_EXIT_MMIO_READ   0x80000001ULL

Definition at line 52 of file Ghcb.h.

◆ SVM_EXIT_MMIO_WRITE

#define SVM_EXIT_MMIO_WRITE   0x80000002ULL

Definition at line 53 of file Ghcb.h.

◆ SVM_EXIT_MONITOR

#define SVM_EXIT_MONITOR   0x8AULL

Definition at line 45 of file Ghcb.h.

◆ SVM_EXIT_MSR

#define SVM_EXIT_MSR   0x7CULL

Definition at line 41 of file Ghcb.h.

◆ SVM_EXIT_MWAIT

#define SVM_EXIT_MWAIT   0x8BULL

Definition at line 46 of file Ghcb.h.

◆ SVM_EXIT_NMI_COMPLETE

#define SVM_EXIT_NMI_COMPLETE   0x80000003ULL

Definition at line 54 of file Ghcb.h.

◆ SVM_EXIT_NPF

#define SVM_EXIT_NPF   0x400ULL

Definition at line 47 of file Ghcb.h.

◆ SVM_EXIT_RDPMC

#define SVM_EXIT_RDPMC   0x6FULL

Definition at line 37 of file Ghcb.h.

◆ SVM_EXIT_RDTSC

#define SVM_EXIT_RDTSC   0x6EULL

Definition at line 36 of file Ghcb.h.

◆ SVM_EXIT_RDTSCP

#define SVM_EXIT_RDTSCP   0x87ULL

Definition at line 43 of file Ghcb.h.

◆ SVM_EXIT_SNP_AP_CREATION

#define SVM_EXIT_SNP_AP_CREATION   0x80000013ULL

Definition at line 58 of file Ghcb.h.

◆ SVM_EXIT_SNP_PAGE_STATE_CHANGE

#define SVM_EXIT_SNP_PAGE_STATE_CHANGE   0x80000010ULL

Definition at line 57 of file Ghcb.h.

◆ SVM_EXIT_UNSUPPORTED

#define SVM_EXIT_UNSUPPORTED   0x8000FFFFULL

Definition at line 60 of file Ghcb.h.

◆ SVM_EXIT_VMMCALL

#define SVM_EXIT_VMMCALL   0x81ULL

Definition at line 42 of file Ghcb.h.

◆ SVM_EXIT_WBINVD

#define SVM_EXIT_WBINVD   0x89ULL

Definition at line 44 of file Ghcb.h.

◆ SVM_VMGEXIT_SNP_AP_CREATE

#define SVM_VMGEXIT_SNP_AP_CREATE   1

Definition at line 91 of file Ghcb.h.

◆ SVM_VMGEXIT_SNP_AP_CREATE_ON_INIT

#define SVM_VMGEXIT_SNP_AP_CREATE_ON_INIT   0

Definition at line 90 of file Ghcb.h.

◆ SVM_VMGEXIT_SNP_AP_DESTROY

#define SVM_VMGEXIT_SNP_AP_DESTROY   2

Definition at line 92 of file Ghcb.h.

◆ UD_EXCEPTION

#define UD_EXCEPTION   6

Definition at line 22 of file Ghcb.h.

◆ VC_EXCEPTION

#define VC_EXCEPTION   29

Definition at line 24 of file Ghcb.h.

Enumeration Type Documentation

◆ GHCB_REGISTER

enum GHCB_REGISTER

Definition at line 126 of file Ghcb.h.

Variable Documentation

◆ Cpl

UINT8 Cpl

Definition at line 96 of file Ghcb.h.

◆ GhcbUsage

UINT32 GhcbUsage

Definition at line 120 of file Ghcb.h.

◆ ProtocolVersion

UINT16 ProtocolVersion

Definition at line 119 of file Ghcb.h.

◆ Rax

UINT64 Rax

Definition at line 98 of file Ghcb.h.

◆ Rbx

UINT64 Rbx

Definition at line 102 of file Ghcb.h.

◆ Rcx

UINT64 Rcx

Definition at line 100 of file Ghcb.h.

◆ Rdx

UINT64 Rdx

Definition at line 101 of file Ghcb.h.

◆ Reserved1

UINT8 Reserved1[10]

Definition at line 95 of file Ghcb.h.

◆ Reserved4

UINT8 Reserved4[264]

Definition at line 99 of file Ghcb.h.

◆ Reserved5

UINT8 Reserved5[112]

Definition at line 103 of file Ghcb.h.

◆ Reserved6

UINT8 Reserved6[56]

Definition at line 108 of file Ghcb.h.

◆ Reserved7

UINT8 Reserved7[1016]

Definition at line 112 of file Ghcb.h.

◆ Reserved8

UINT8 Reserved8[300]

Definition at line 97 of file Ghcb.h.

◆ SaveArea

GHCB_SAVE_AREA SaveArea

Definition at line 116 of file Ghcb.h.

◆ SharedBuffer

UINT8 SharedBuffer[2032]

Definition at line 117 of file Ghcb.h.

◆ SwExitCode

UINT64 SwExitCode

Definition at line 104 of file Ghcb.h.

◆ SwExitInfo1

UINT64 SwExitInfo1

Definition at line 105 of file Ghcb.h.

◆ SwExitInfo2

UINT64 SwExitInfo2

Definition at line 106 of file Ghcb.h.

◆ SwScratch

UINT64 SwScratch

Definition at line 107 of file Ghcb.h.

◆ ValidBitmap

UINT8 ValidBitmap[16]

Definition at line 110 of file Ghcb.h.

◆ X87StateGpa

UINT64 X87StateGpa

Definition at line 111 of file Ghcb.h.

◆ XCr0

UINT64 XCr0

Definition at line 109 of file Ghcb.h.