23#define GP_EXCEPTION 13
24#define VC_EXCEPTION 29
26#define GHCB_VERSION_MIN 1
27#define GHCB_VERSION_MAX 2
29#define GHCB_STANDARD_USAGE 0
34#define SVM_EXIT_DR7_READ 0x27ULL
35#define SVM_EXIT_DR7_WRITE 0x37ULL
36#define SVM_EXIT_RDTSC 0x6EULL
37#define SVM_EXIT_RDPMC 0x6FULL
38#define SVM_EXIT_CPUID 0x72ULL
39#define SVM_EXIT_INVD 0x76ULL
40#define SVM_EXIT_IOIO_PROT 0x7BULL
41#define SVM_EXIT_MSR 0x7CULL
42#define SVM_EXIT_VMMCALL 0x81ULL
43#define SVM_EXIT_RDTSCP 0x87ULL
44#define SVM_EXIT_WBINVD 0x89ULL
45#define SVM_EXIT_MONITOR 0x8AULL
46#define SVM_EXIT_MWAIT 0x8BULL
47#define SVM_EXIT_NPF 0x400ULL
52#define SVM_EXIT_MMIO_READ 0x80000001ULL
53#define SVM_EXIT_MMIO_WRITE 0x80000002ULL
54#define SVM_EXIT_NMI_COMPLETE 0x80000003ULL
55#define SVM_EXIT_AP_RESET_HOLD 0x80000004ULL
56#define SVM_EXIT_AP_JUMP_TABLE 0x80000005ULL
57#define SVM_EXIT_SNP_PAGE_STATE_CHANGE 0x80000010ULL
58#define SVM_EXIT_SNP_AP_CREATION 0x80000013ULL
59#define SVM_EXIT_GET_APIC_IDS 0x80000017ULL
60#define SVM_EXIT_HYPERVISOR_FEATURES 0x8000FFFDULL
61#define SVM_EXIT_UNSUPPORTED 0x8000FFFFULL
66#define IOIO_TYPE_STR BIT2
68#define IOIO_TYPE_INS (IOIO_TYPE_IN | IOIO_TYPE_STR)
69#define IOIO_TYPE_OUT 0
70#define IOIO_TYPE_OUTS (IOIO_TYPE_OUT | IOIO_TYPE_STR)
74#define IOIO_ADDR_64 BIT9
75#define IOIO_ADDR_32 BIT8
76#define IOIO_ADDR_16 BIT7
78#define IOIO_DATA_32 BIT6
79#define IOIO_DATA_16 BIT5
80#define IOIO_DATA_8 BIT4
81#define IOIO_DATA_MASK (BIT6 | BIT5 | BIT4)
82#define IOIO_DATA_OFFSET 4
83#define IOIO_DATA_BYTES(x) (((x) & IOIO_DATA_MASK) >> IOIO_DATA_OFFSET)
86#define IOIO_SEG_DS (BIT11 | BIT10)
91#define SVM_VMGEXIT_SNP_AP_CREATE_ON_INIT 0
92#define SVM_VMGEXIT_SNP_AP_CREATE 1
93#define SVM_VMGEXIT_SNP_AP_DESTROY 2
95typedef PACKED
struct {
100 UINT8 Reserved4[264];
104 UINT8 Reserved5[112];
111 UINT8 ValidBitmap[16];
113 UINT8 Reserved7[1016];
116typedef PACKED
struct {
117 GHCB_SAVE_AREA SaveArea;
118 UINT8 SharedBuffer[2032];
120 UINT16 ProtocolVersion;
124#define GHCB_SAVE_AREA_QWORD_OFFSET(RegisterField) \
125 (OFFSET_OF (GHCB, SaveArea.RegisterField) / sizeof (UINT64))
128 GhcbCpl = GHCB_SAVE_AREA_QWORD_OFFSET (Cpl),
129 GhcbRax = GHCB_SAVE_AREA_QWORD_OFFSET (Rax),
130 GhcbRbx = GHCB_SAVE_AREA_QWORD_OFFSET (Rbx),
131 GhcbRcx = GHCB_SAVE_AREA_QWORD_OFFSET (Rcx),
132 GhcbRdx = GHCB_SAVE_AREA_QWORD_OFFSET (Rdx),
133 GhcbXCr0 = GHCB_SAVE_AREA_QWORD_OFFSET (XCr0),
134 GhcbSwExitCode = GHCB_SAVE_AREA_QWORD_OFFSET (SwExitCode),
135 GhcbSwExitInfo1 = GHCB_SAVE_AREA_QWORD_OFFSET (SwExitInfo1),
136 GhcbSwExitInfo2 = GHCB_SAVE_AREA_QWORD_OFFSET (SwExitInfo2),
137 GhcbSwScratch = GHCB_SAVE_AREA_QWORD_OFFSET (SwScratch),
153 UINT32 ErrorCodeValid : 1;
162#define GHCB_EVENT_INJECTION_TYPE_INT 0
163#define GHCB_EVENT_INJECTION_TYPE_NMI 2
164#define GHCB_EVENT_INJECTION_TYPE_EXCEPTION 3
165#define GHCB_EVENT_INJECTION_TYPE_SOFT_INT 4
170#define GHCB_HV_FEATURES_SNP BIT0
171#define GHCB_HV_FEATURES_SNP_AP_CREATE (GHCB_HV_FEATURES_SNP | BIT1)
172#define GHCB_HV_FEATURES_SNP_RESTRICTED_INJECTION (GHCB_HV_FEATURES_SNP_AP_CREATE | BIT2)
173#define GHCB_HV_FEATURES_SNP_RESTRICTED_INJECTION_TIMER (GHCB_HV_FEATURES_SNP_RESTRICTED_INJECTION | BIT3)
174#define GHCB_HV_FEATURES_APIC_ID_LIST BIT4
181#define SNP_PAGE_STATE_PRIVATE 1
182#define SNP_PAGE_STATE_SHARED 2
183#define SNP_PAGE_STATE_PSMASH 3
184#define SNP_PAGE_STATE_UNSMASH 4
187 UINT64 CurrentPage : 12;
188 UINT64 GuestFrameNumber : 40;
189 UINT64 Operation : 4;
205#define SNP_PAGE_STATE_MAX_ENTRY \
206 ((sizeof (((GHCB *)0)->SharedBuffer) - sizeof (SNP_PAGE_STATE_HEADER)) / sizeof (SNP_PAGE_STATE_ENTRY))
228#define SEV_ES_RESET_CODE_SEGMENT_TYPE 0xA
229#define SEV_ES_RESET_DATA_SEGMENT_TYPE 0x2
231#define SEV_ES_RESET_LDT_TYPE 0x2
232#define SEV_ES_RESET_TSS_TYPE 0x3
242 UINT16 Reserved1 : 1;
244 UINT16 Granularity : 1;
271 UINT8 Reserved3[112];
279 UINT8 Reserved5[232];
281 UINT8 Reserved6[320];