VirtualBox

source: vbox/trunk/include/VBox/iommu-amd.h@ 86296

Last change on this file since 86296 was 86253, checked in by vboxsync, 4 years ago

AMD IOMMU: bugref:9654 Comment, nit.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 120.7 KB
Line 
1/** @file
2 * IOMMU - Input/Output Memory Management Unit (AMD).
3 */
4
5/*
6 * Copyright (C) 2020 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef VBOX_INCLUDED_iommu_amd_h
27#define VBOX_INCLUDED_iommu_amd_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <iprt/types.h>
33#include <iprt/assertcompile.h>
34
35/**
36 * @name PCI configuration register offsets.
37 * In accordance with the AMD spec.
38 * @{
39 */
40#define IOMMU_PCI_OFF_CAP_HDR 0x40
41#define IOMMU_PCI_OFF_BASE_ADDR_REG_LO 0x44
42#define IOMMU_PCI_OFF_BASE_ADDR_REG_HI 0x48
43#define IOMMU_PCI_OFF_RANGE_REG 0x4c
44#define IOMMU_PCI_OFF_MISCINFO_REG_0 0x50
45#define IOMMU_PCI_OFF_MISCINFO_REG_1 0x54
46#define IOMMU_PCI_OFF_MSI_CAP_HDR 0x64
47#define IOMMU_PCI_OFF_MSI_ADDR_LO 0x68
48#define IOMMU_PCI_OFF_MSI_ADDR_HI 0x6c
49#define IOMMU_PCI_OFF_MSI_DATA 0x70
50#define IOMMU_PCI_OFF_MSI_MAP_CAP_HDR 0x74
51/** @} */
52
53/**
54 * @name MMIO register offsets.
55 * In accordance with the AMD spec.
56 * @{
57 */
58#define IOMMU_MMIO_OFF_QWORD_TABLE_0_START IOMMU_MMIO_OFF_DEV_TAB_BAR
59#define IOMMU_MMIO_OFF_DEV_TAB_BAR 0x00
60#define IOMMU_MMIO_OFF_CMD_BUF_BAR 0x08
61#define IOMMU_MMIO_OFF_EVT_LOG_BAR 0x10
62#define IOMMU_MMIO_OFF_CTRL 0x18
63#define IOMMU_MMIO_OFF_EXCL_BAR 0x20
64#define IOMMU_MMIO_OFF_EXCL_RANGE_LIMIT 0x28
65#define IOMMU_MMIO_OFF_EXT_FEAT 0x30
66
67#define IOMMU_MMIO_OFF_PPR_LOG_BAR 0x38
68#define IOMMU_MMIO_OFF_HW_EVT_HI 0x40
69#define IOMMU_MMIO_OFF_HW_EVT_LO 0x48
70#define IOMMU_MMIO_OFF_HW_EVT_STATUS 0x50
71
72#define IOMMU_MMIO_OFF_SMI_FLT_FIRST 0x60
73#define IOMMU_MMIO_OFF_SMI_FLT_LAST 0xd8
74
75#define IOMMU_MMIO_OFF_GALOG_BAR 0xe0
76#define IOMMU_MMIO_OFF_GALOG_TAIL_ADDR 0xe8
77
78#define IOMMU_MMIO_OFF_PPR_LOG_B_BAR 0xf0
79#define IOMMU_MMIO_OFF_PPR_EVT_B_BAR 0xf8
80
81#define IOMMU_MMIO_OFF_DEV_TAB_SEG_FIRST 0x100
82#define IOMMU_MMIO_OFF_DEV_TAB_SEG_1 0x100
83#define IOMMU_MMIO_OFF_DEV_TAB_SEG_2 0x108
84#define IOMMU_MMIO_OFF_DEV_TAB_SEG_3 0x110
85#define IOMMU_MMIO_OFF_DEV_TAB_SEG_4 0x118
86#define IOMMU_MMIO_OFF_DEV_TAB_SEG_5 0x120
87#define IOMMU_MMIO_OFF_DEV_TAB_SEG_6 0x128
88#define IOMMU_MMIO_OFF_DEV_TAB_SEG_7 0x130
89#define IOMMU_MMIO_OFF_DEV_TAB_SEG_LAST 0x130
90
91#define IOMMU_MMIO_OFF_DEV_SPECIFIC_FEAT 0x138
92#define IOMMU_MMIO_OFF_DEV_SPECIFIC_CTRL 0x140
93#define IOMMU_MMIO_OFF_DEV_SPECIFIC_STATUS 0x148
94
95#define IOMMU_MMIO_OFF_MSI_VECTOR_0 0x150
96#define IOMMU_MMIO_OFF_MSI_VECTOR_1 0x154
97#define IOMMU_MMIO_OFF_MSI_CAP_HDR 0x158
98#define IOMMU_MMIO_OFF_MSI_ADDR_LO 0x15c
99#define IOMMU_MMIO_OFF_MSI_ADDR_HI 0x160
100#define IOMMU_MMIO_OFF_MSI_DATA 0x164
101#define IOMMU_MMIO_OFF_MSI_MAPPING_CAP_HDR 0x168
102
103#define IOMMU_MMIO_OFF_PERF_OPT_CTRL 0x16c
104
105#define IOMMU_MMIO_OFF_XT_GEN_INTR_CTRL 0x170
106#define IOMMU_MMIO_OFF_XT_PPR_INTR_CTRL 0x178
107#define IOMMU_MMIO_OFF_XT_GALOG_INT_CTRL 0x180
108#define IOMMU_MMIO_OFF_QWORD_TABLE_0_END (IOMMU_MMIO_OFF_XT_GALOG_INT_CTRL + 8)
109
110#define IOMMU_MMIO_OFF_QWORD_TABLE_1_START IOMMU_MMIO_OFF_MARC_APER_BAR_0
111#define IOMMU_MMIO_OFF_MARC_APER_BAR_0 0x200
112#define IOMMU_MMIO_OFF_MARC_APER_RELOC_0 0x208
113#define IOMMU_MMIO_OFF_MARC_APER_LEN_0 0x210
114#define IOMMU_MMIO_OFF_MARC_APER_BAR_1 0x218
115#define IOMMU_MMIO_OFF_MARC_APER_RELOC_1 0x220
116#define IOMMU_MMIO_OFF_MARC_APER_LEN_1 0x228
117#define IOMMU_MMIO_OFF_MARC_APER_BAR_2 0x230
118#define IOMMU_MMIO_OFF_MARC_APER_RELOC_2 0x238
119#define IOMMU_MMIO_OFF_MARC_APER_LEN_2 0x240
120#define IOMMU_MMIO_OFF_MARC_APER_BAR_3 0x248
121#define IOMMU_MMIO_OFF_MARC_APER_RELOC_3 0x250
122#define IOMMU_MMIO_OFF_MARC_APER_LEN_3 0x258
123#define IOMMU_MMIO_OFF_QWORD_TABLE_1_END (IOMMU_MMIO_OFF_MARC_APER_LEN_3 + 8)
124
125#define IOMMU_MMIO_OFF_QWORD_TABLE_2_START IOMMU_MMIO_OFF_RSVD_REG
126#define IOMMU_MMIO_OFF_RSVD_REG 0x1ff8
127
128#define IOMMU_MMIO_OFF_CMD_BUF_HEAD_PTR 0x2000
129#define IOMMU_MMIO_OFF_CMD_BUF_TAIL_PTR 0x2008
130#define IOMMU_MMIO_OFF_EVT_LOG_HEAD_PTR 0x2010
131#define IOMMU_MMIO_OFF_EVT_LOG_TAIL_PTR 0x2018
132
133#define IOMMU_MMIO_OFF_STATUS 0x2020
134
135#define IOMMU_MMIO_OFF_PPR_LOG_HEAD_PTR 0x2030
136#define IOMMU_MMIO_OFF_PPR_LOG_TAIL_PTR 0x2038
137
138#define IOMMU_MMIO_OFF_GALOG_HEAD_PTR 0x2040
139#define IOMMU_MMIO_OFF_GALOG_TAIL_PTR 0x2048
140
141#define IOMMU_MMIO_OFF_PPR_LOG_B_HEAD_PTR 0x2050
142#define IOMMU_MMIO_OFF_PPR_LOG_B_TAIL_PTR 0x2058
143
144#define IOMMU_MMIO_OFF_EVT_LOG_B_HEAD_PTR 0x2070
145#define IOMMU_MMIO_OFF_EVT_LOG_B_TAIL_PTR 0x2078
146
147#define IOMMU_MMIO_OFF_PPR_LOG_AUTO_RESP 0x2080
148#define IOMMU_MMIO_OFF_PPR_LOG_OVERFLOW_EARLY 0x2088
149#define IOMMU_MMIO_OFF_PPR_LOG_B_OVERFLOW_EARLY 0x2090
150#define IOMMU_MMIO_OFF_QWORD_TABLE_2_END (IOMMU_MMIO_OFF_PPR_LOG_B_OVERFLOW_EARLY + 8)
151/** @} */
152
153/**
154 * @name MMIO register-access table offsets.
155 * Each table [first..last] (both inclusive) represents the range of registers
156 * covered by a distinct register-access table. This is done due to arbitrary large
157 * gaps in the MMIO register offsets themselves.
158 * @{
159 */
160#define IOMMU_MMIO_OFF_TABLE_0_FIRST 0x00
161#define IOMMU_MMIO_OFF_TABLE_0_LAST 0x258
162
163#define IOMMU_MMIO_OFF_TABLE_1_FIRST 0x1ff8
164#define IOMMU_MMIO_OFF_TABLE_1_LAST 0x2090
165/** @} */
166
167/**
168 * @name Commands.
169 * In accordance with the AMD spec.
170 * @{
171 */
172#define IOMMU_CMD_COMPLETION_WAIT 0x01
173#define IOMMU_CMD_INV_DEV_TAB_ENTRY 0x02
174#define IOMMU_CMD_INV_IOMMU_PAGES 0x03
175#define IOMMU_CMD_INV_IOTLB_PAGES 0x04
176#define IOMMU_CMD_INV_INTR_TABLE 0x05
177#define IOMMU_CMD_PREFETCH_IOMMU_PAGES 0x06
178#define IOMMU_CMD_COMPLETE_PPR_REQ 0x07
179#define IOMMU_CMD_INV_IOMMU_ALL 0x08
180/** @} */
181
182/**
183 * @name Event codes.
184 * In accordance with the AMD spec.
185 * @{
186 */
187#define IOMMU_EVT_ILLEGAL_DEV_TAB_ENTRY 0x01
188#define IOMMU_EVT_IO_PAGE_FAULT 0x02
189#define IOMMU_EVT_DEV_TAB_HW_ERROR 0x03
190#define IOMMU_EVT_PAGE_TAB_HW_ERROR 0x04
191#define IOMMU_EVT_ILLEGAL_CMD_ERROR 0x05
192#define IOMMU_EVT_COMMAND_HW_ERROR 0x06
193#define IOMMU_EVT_IOTLB_INV_TIMEOUT 0x07
194#define IOMMU_EVT_INVALID_DEV_REQ 0x08
195#define IOMMU_EVT_INVALID_PPR_REQ 0x09
196#define IOMMU_EVT_EVENT_COUNTER_ZERO 0x10
197#define IOMMU_EVT_GUEST_EVENT_FAULT 0x11
198/** @} */
199
200/**
201 * @name IOMMU Capability Header.
202 * In accordance with the AMD spec.
203 * @{
204 */
205/** CapId: Capability ID. */
206#define IOMMU_BF_CAPHDR_CAP_ID_SHIFT 0
207#define IOMMU_BF_CAPHDR_CAP_ID_MASK UINT32_C(0x000000ff)
208/** CapPtr: Capability Pointer. */
209#define IOMMU_BF_CAPHDR_CAP_PTR_SHIFT 8
210#define IOMMU_BF_CAPHDR_CAP_PTR_MASK UINT32_C(0x0000ff00)
211/** CapType: Capability Type. */
212#define IOMMU_BF_CAPHDR_CAP_TYPE_SHIFT 16
213#define IOMMU_BF_CAPHDR_CAP_TYPE_MASK UINT32_C(0x00070000)
214/** CapRev: Capability Revision. */
215#define IOMMU_BF_CAPHDR_CAP_REV_SHIFT 19
216#define IOMMU_BF_CAPHDR_CAP_REV_MASK UINT32_C(0x00f80000)
217/** IoTlbSup: IO TLB Support. */
218#define IOMMU_BF_CAPHDR_IOTLB_SUP_SHIFT 24
219#define IOMMU_BF_CAPHDR_IOTLB_SUP_MASK UINT32_C(0x01000000)
220/** HtTunnel: HyperTransport Tunnel translation support. */
221#define IOMMU_BF_CAPHDR_HT_TUNNEL_SHIFT 25
222#define IOMMU_BF_CAPHDR_HT_TUNNEL_MASK UINT32_C(0x02000000)
223/** NpCache: Not Present table entries Cached. */
224#define IOMMU_BF_CAPHDR_NP_CACHE_SHIFT 26
225#define IOMMU_BF_CAPHDR_NP_CACHE_MASK UINT32_C(0x04000000)
226/** EFRSup: Extended Feature Register (EFR) Supported. */
227#define IOMMU_BF_CAPHDR_EFR_SUP_SHIFT 27
228#define IOMMU_BF_CAPHDR_EFR_SUP_MASK UINT32_C(0x08000000)
229/** CapExt: Miscellaneous Information Register Supported . */
230#define IOMMU_BF_CAPHDR_CAP_EXT_SHIFT 28
231#define IOMMU_BF_CAPHDR_CAP_EXT_MASK UINT32_C(0x10000000)
232/** Bits 31:29 reserved. */
233#define IOMMU_BF_CAPHDR_RSVD_29_31_SHIFT 29
234#define IOMMU_BF_CAPHDR_RSVD_29_31_MASK UINT32_C(0xe0000000)
235RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_BF_CAPHDR_, UINT32_C(0), UINT32_MAX,
236 (CAP_ID, CAP_PTR, CAP_TYPE, CAP_REV, IOTLB_SUP, HT_TUNNEL, NP_CACHE, EFR_SUP, CAP_EXT, RSVD_29_31));
237/** @} */
238
239/**
240 * @name IOMMU Base Address Low Register.
241 * In accordance with the AMD spec.
242 * @{
243 */
244/** Enable: Enables access to the address specified in the Base Address Register. */
245#define IOMMU_BF_BASEADDR_LO_ENABLE_SHIFT 0
246#define IOMMU_BF_BASEADDR_LO_ENABLE_MASK UINT32_C(0x00000001)
247/** Bits 13:1 reserved. */
248#define IOMMU_BF_BASEADDR_LO_RSVD_1_13_SHIFT 1
249#define IOMMU_BF_BASEADDR_LO_RSVD_1_13_MASK UINT32_C(0x00003ffe)
250/** Base Address[31:14]: Low Base address of IOMMU MMIO control registers. */
251#define IOMMU_BF_BASEADDR_LO_ADDR_SHIFT 14
252#define IOMMU_BF_BASEADDR_LO_ADDR_MASK UINT32_C(0xffffc000)
253RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_BF_BASEADDR_LO_, UINT32_C(0), UINT32_MAX,
254 (ENABLE, RSVD_1_13, ADDR));
255/** @} */
256
257/**
258 * @name IOMMU Range Register.
259 * In accordance with the AMD spec.
260 * @{
261 */
262/** UnitID: HyperTransport Unit ID. */
263#define IOMMU_BF_RANGE_UNIT_ID_SHIFT 0
264#define IOMMU_BF_RANGE_UNIT_ID_MASK UINT32_C(0x0000001f)
265/** Bits 6:5 reserved. */
266#define IOMMU_BF_RANGE_RSVD_5_6_SHIFT 5
267#define IOMMU_BF_RANGE_RSVD_5_6_MASK UINT32_C(0x00000060)
268/** RngValid: Range valid. */
269#define IOMMU_BF_RANGE_VALID_SHIFT 7
270#define IOMMU_BF_RANGE_VALID_MASK UINT32_C(0x00000080)
271/** BusNumber: Device range bus number. */
272#define IOMMU_BF_RANGE_BUS_NUMBER_SHIFT 8
273#define IOMMU_BF_RANGE_BUS_NUMBER_MASK UINT32_C(0x0000ff00)
274/** First Device. */
275#define IOMMU_BF_RANGE_FIRST_DEVICE_SHIFT 16
276#define IOMMU_BF_RANGE_FIRST_DEVICE_MASK UINT32_C(0x00ff0000)
277/** Last Device. */
278#define IOMMU_BF_RANGE_LAST_DEVICE_SHIFT 24
279#define IOMMU_BF_RANGE_LAST_DEVICE_MASK UINT32_C(0xff000000)
280RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_BF_RANGE_, UINT32_C(0), UINT32_MAX,
281 (UNIT_ID, RSVD_5_6, VALID, BUS_NUMBER, FIRST_DEVICE, LAST_DEVICE));
282/** @} */
283
284/**
285 * @name IOMMU Miscellaneous Information Register 0.
286 * In accordance with the AMD spec.
287 * @{
288 */
289/** MsiNum: MSI message number. */
290#define IOMMU_BF_MISCINFO_0_MSI_NUM_SHIFT 0
291#define IOMMU_BF_MISCINFO_0_MSI_NUM_MASK UINT32_C(0x0000001f)
292/** GvaSize: Guest Virtual Address Size. */
293#define IOMMU_BF_MISCINFO_0_GVA_SIZE_SHIFT 5
294#define IOMMU_BF_MISCINFO_0_GVA_SIZE_MASK UINT32_C(0x000000e0)
295/** PaSize: Physical Address Size. */
296#define IOMMU_BF_MISCINFO_0_PA_SIZE_SHIFT 8
297#define IOMMU_BF_MISCINFO_0_PA_SIZE_MASK UINT32_C(0x00007f00)
298/** VaSize: Virtual Address Size. */
299#define IOMMU_BF_MISCINFO_0_VA_SIZE_SHIFT 15
300#define IOMMU_BF_MISCINFO_0_VA_SIZE_MASK UINT32_C(0x003f8000)
301/** HtAtsResv: HyperTransport ATS Response Address range Reserved. */
302#define IOMMU_BF_MISCINFO_0_HT_ATS_RESV_SHIFT 22
303#define IOMMU_BF_MISCINFO_0_HT_ATS_RESV_MASK UINT32_C(0x00400000)
304/** Bits 26:23 reserved. */
305#define IOMMU_BF_MISCINFO_0_RSVD_23_26_SHIFT 23
306#define IOMMU_BF_MISCINFO_0_RSVD_23_26_MASK UINT32_C(0x07800000)
307/** MsiNumPPR: Peripheral Page Request MSI message number. */
308#define IOMMU_BF_MISCINFO_0_MSI_NUM_PPR_SHIFT 27
309#define IOMMU_BF_MISCINFO_0_MSI_NUM_PPR_MASK UINT32_C(0xf8000000)
310RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_BF_MISCINFO_0_, UINT32_C(0), UINT32_MAX,
311 (MSI_NUM, GVA_SIZE, PA_SIZE, VA_SIZE, HT_ATS_RESV, RSVD_23_26, MSI_NUM_PPR));
312/** @} */
313
314/**
315 * @name IOMMU Miscellaneous Information Register 1.
316 * In accordance with the AMD spec.
317 * @{
318 */
319/** MsiNumGA: MSI message number for guest virtual-APIC log. */
320#define IOMMU_BF_MISCINFO_1_MSI_NUM_GA_SHIFT 0
321#define IOMMU_BF_MISCINFO_1_MSI_NUM_GA_MASK UINT32_C(0x0000001f)
322/** Bits 31:5 reserved. */
323#define IOMMU_BF_MISCINFO_1_RSVD_5_31_SHIFT 5
324#define IOMMU_BF_MISCINFO_1_RSVD_5_31_MASK UINT32_C(0xffffffe0)
325RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_BF_MISCINFO_1_, UINT32_C(0), UINT32_MAX,
326 (MSI_NUM_GA, RSVD_5_31));
327/** @} */
328
329/**
330 * @name MSI Capability Header Register.
331 * In accordance with the AMD spec.
332 * @{
333 */
334/** MsiCapId: Capability ID. */
335#define IOMMU_BF_MSI_CAP_HDR_CAP_ID_SHIFT 0
336#define IOMMU_BF_MSI_CAP_HDR_CAP_ID_MASK UINT32_C(0x000000ff)
337/** MsiCapPtr: Pointer (PCI config offset) to the next capability. */
338#define IOMMU_BF_MSI_CAP_HDR_CAP_PTR_SHIFT 8
339#define IOMMU_BF_MSI_CAP_HDR_CAP_PTR_MASK UINT32_C(0x0000ff00)
340/** MsiEn: Message Signal Interrupt enable. */
341#define IOMMU_BF_MSI_CAP_HDR_EN_SHIFT 16
342#define IOMMU_BF_MSI_CAP_HDR_EN_MASK UINT32_C(0x00010000)
343/** MsiMultMessCap: MSI Multi-Message Capability. */
344#define IOMMU_BF_MSI_CAP_HDR_MULTMESS_CAP_SHIFT 17
345#define IOMMU_BF_MSI_CAP_HDR_MULTMESS_CAP_MASK UINT32_C(0x000e0000)
346/** MsiMultMessEn: MSI Mult-Message Enable. */
347#define IOMMU_BF_MSI_CAP_HDR_MULTMESS_EN_SHIFT 20
348#define IOMMU_BF_MSI_CAP_HDR_MULTMESS_EN_MASK UINT32_C(0x00700000)
349/** Msi64BitEn: MSI 64-bit Enabled. */
350#define IOMMU_BF_MSI_CAP_HDR_64BIT_EN_SHIFT 23
351#define IOMMU_BF_MSI_CAP_HDR_64BIT_EN_MASK UINT32_C(0x00800000)
352/** Bits 31:24 reserved. */
353#define IOMMU_BF_MSI_CAP_HDR_RSVD_24_31_SHIFT 24
354#define IOMMU_BF_MSI_CAP_HDR_RSVD_24_31_MASK UINT32_C(0xff000000)
355RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_BF_MSI_CAP_HDR_, UINT32_C(0), UINT32_MAX,
356 (CAP_ID, CAP_PTR, EN, MULTMESS_CAP, MULTMESS_EN, 64BIT_EN, RSVD_24_31));
357/** @} */
358
359/**
360 * @name MSI Mapping Capability Header Register.
361 * In accordance with the AMD spec.
362 * @{
363 */
364/** MsiMapCapId: Capability ID. */
365#define IOMMU_BF_MSI_MAP_CAPHDR_CAP_ID_SHIFT 0
366#define IOMMU_BF_MSI_MAP_CAPHDR_CAP_ID_MASK UINT32_C(0x000000ff)
367/** MsiMapCapPtr: Pointer (PCI config offset) to the next capability. */
368#define IOMMU_BF_MSI_MAP_CAPHDR_CAP_PTR_SHIFT 8
369#define IOMMU_BF_MSI_MAP_CAPHDR_CAP_PTR_MASK UINT32_C(0x0000ff00)
370/** MsiMapEn: MSI mapping capability enable. */
371#define IOMMU_BF_MSI_MAP_CAPHDR_EN_SHIFT 16
372#define IOMMU_BF_MSI_MAP_CAPHDR_EN_MASK UINT32_C(0x00010000)
373/** MsiMapFixd: MSI interrupt mapping range is not programmable. */
374#define IOMMU_BF_MSI_MAP_CAPHDR_FIXED_SHIFT 17
375#define IOMMU_BF_MSI_MAP_CAPHDR_FIXED_MASK UINT32_C(0x00020000)
376/** Bits 18:28 reserved. */
377#define IOMMU_BF_MSI_MAP_CAPHDR_RSVD_18_28_SHIFT 18
378#define IOMMU_BF_MSI_MAP_CAPHDR_RSVD_18_28_MASK UINT32_C(0x07fc0000)
379/** MsiMapCapType: MSI mapping capability. */
380#define IOMMU_BF_MSI_MAP_CAPHDR_CAP_TYPE_SHIFT 27
381#define IOMMU_BF_MSI_MAP_CAPHDR_CAP_TYPE_MASK UINT32_C(0xf8000000)
382RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_BF_MSI_MAP_CAPHDR_, UINT32_C(0), UINT32_MAX,
383 (CAP_ID, CAP_PTR, EN, FIXED, RSVD_18_28, CAP_TYPE));
384/** @} */
385
386/**
387 * @name IOMMU Status Register Bits.
388 * In accordance with the AMD spec.
389 * @{
390 */
391/** EventOverflow: Event log overflow. */
392#define IOMMU_STATUS_EVT_LOG_OVERFLOW RT_BIT_64(0)
393/** EventLogInt: Event log interrupt. */
394#define IOMMU_STATUS_EVT_LOG_INTR RT_BIT_64(1)
395/** ComWaitInt: Completion wait interrupt. */
396#define IOMMU_STATUS_COMPLETION_WAIT_INTR RT_BIT_64(2)
397/** EventLogRun: Event log is running. */
398#define IOMMU_STATUS_EVT_LOG_RUNNING RT_BIT_64(3)
399/** CmdBufRun: Command buffer is running. */
400#define IOMMU_STATUS_CMD_BUF_RUNNING RT_BIT_64(4)
401/** PprOverflow: Peripheral page request log overflow. */
402#define IOMMU_STATUS_PPR_LOG_OVERFLOW RT_BIT_64(5)
403/** PprInt: Peripheral page request log interrupt. */
404#define IOMMU_STATUS_PPR_LOG_INTR RT_BIT_64(6)
405/** PprLogRun: Peripheral page request log is running. */
406#define IOMMU_STATUS_PPR_LOG_RUN RT_BIT_64(7)
407/** GALogRun: Guest virtual-APIC log is running. */
408#define IOMMU_STATUS_GA_LOG_RUN RT_BIT_64(8)
409/** GALOverflow: Guest virtual-APIC log overflow. */
410#define IOMMU_STATUS_GA_LOG_OVERFLOW RT_BIT_64(9)
411/** GAInt: Guest virtual-APIC log interrupt. */
412#define IOMMU_STATUS_GA_LOG_INTR RT_BIT_64(10)
413/** PprOvrflwB: PPR Log B overflow. */
414#define IOMMU_STATUS_PPR_LOG_B_OVERFLOW RT_BIT_64(11)
415/** PprLogActive: PPR Log B is active. */
416#define IOMMU_STATUS_PPR_LOG_B_ACTIVE RT_BIT_64(12)
417/** EvtOvrflwB: Event log B overflow. */
418#define IOMMU_STATUS_EVT_LOG_B_OVERFLOW RT_BIT_64(15)
419/** EventLogActive: Event log B active. */
420#define IOMMU_STATUS_EVT_LOG_B_ACTIVE RT_BIT_64(16)
421/** PprOvrflwEarlyB: PPR log B overflow early warning. */
422#define IOMMU_STATUS_PPR_LOG_B_OVERFLOW_EARLY RT_BIT_64(17)
423/** PprOverflowEarly: PPR log overflow early warning. */
424#define IOMMU_STATUS_PPR_LOG_OVERFLOW_EARLY RT_BIT_64(18)
425/** @} */
426
427/** @name IOMMU_IO_PERM_XXX: IOMMU I/O access permissions bits.
428 * In accordance with the AMD spec.
429 *
430 * These values match the shifted values of the IR and IW field of the DTE and the
431 * PTE, PDE of the I/O page tables.
432 *
433 * @{ */
434#define IOMMU_IO_PERM_NONE (0)
435#define IOMMU_IO_PERM_READ RT_BIT_64(0)
436#define IOMMU_IO_PERM_WRITE RT_BIT_64(1)
437#define IOMMU_IO_PERM_READ_WRITE (IOMMU_IO_PERM_READ | IOMMU_IO_PERM_WRITE)
438#define IOMMU_IO_PERM_SHIFT 61
439#define IOMMU_IO_PERM_MASK 0x3
440/** @} */
441
442/** @name SYSMGT_TYPE_XXX: System Management Message Enable Types.
443 * In accordance with the AMD spec.
444 * @{ */
445#define SYSMGTTYPE_DMA_DENY (0)
446#define SYSMGTTYPE_MSG_ALL_ALLOW (1)
447#define SYSMGTTYPE_MSG_INT_ALLOW (2)
448#define SYSMGTTYPE_DMA_ALLOW (3)
449/** @} */
450
451/** @name IOMMU_INTR_CTRL_XX: DTE::IntCtl field values.
452 * These are control bits for handling fixed and arbitrated interrupts.
453 * In accordance with the AMD spec.
454 * @{ */
455#define IOMMU_INTR_CTRL_TARGET_ABORT (0)
456#define IOMMU_INTR_CTRL_FWD_UNMAPPED (1)
457#define IOMMU_INTR_CTRL_REMAP (2)
458#define IOMMU_INTR_CTRL_RSVD (3)
459/** @} */
460
461/** Gets the device table length (in bytes) given the device table pointer. */
462#define IOMMU_GET_DEV_TAB_LEN(a_pDevTab) (((a_pDevTab)->n.u9Size + 1) << X86_PAGE_4K_SHIFT)
463
464/**
465 * The Device ID.
466 * In accordance with VirtualBox's PCI configuration.
467 */
468typedef union
469{
470 struct
471 {
472 RT_GCC_EXTENSION uint16_t u3Function : 3; /**< Bits 2:0 - Function. */
473 RT_GCC_EXTENSION uint16_t u9Device : 9; /**< Bits 11:3 - Device. */
474 RT_GCC_EXTENSION uint16_t u4Bus : 4; /**< Bits 15:12 - Bus. */
475 } n;
476 /** The unsigned integer view. */
477 uint16_t u;
478} DEVICE_ID_T;
479AssertCompileSize(DEVICE_ID_T, 2);
480
481/**
482 * Device Table Entry (DTE).
483 * In accordance with the AMD spec.
484 */
485typedef union
486{
487 struct
488 {
489 RT_GCC_EXTENSION uint64_t u1Valid : 1; /**< Bit 0 - V: Valid. */
490 RT_GCC_EXTENSION uint64_t u1TranslationValid : 1; /**< Bit 1 - TV: Translation information Valid. */
491 RT_GCC_EXTENSION uint64_t u5Rsvd0 : 5; /**< Bits 6:2 - Reserved. */
492 RT_GCC_EXTENSION uint64_t u2Had : 2; /**< Bits 8:7 - HAD: Host Access Dirty. */
493 RT_GCC_EXTENSION uint64_t u3Mode : 3; /**< Bits 11:9 - Mode: Paging mode. */
494 RT_GCC_EXTENSION uint64_t u40PageTableRootPtrLo : 40; /**< Bits 51:12 - Page Table Root Pointer. */
495 RT_GCC_EXTENSION uint64_t u1Ppr : 1; /**< Bit 52 - PPR: Peripheral Page Request. */
496 RT_GCC_EXTENSION uint64_t u1GstPprRespPasid : 1; /**< Bit 53 - GRPR: Guest PPR Response with PASID. */
497 RT_GCC_EXTENSION uint64_t u1GstIoValid : 1; /**< Bit 54 - GIoV: Guest I/O Protection Valid. */
498 RT_GCC_EXTENSION uint64_t u1GstTranslateValid : 1; /**< Bit 55 - GV: Guest translation Valid. */
499 RT_GCC_EXTENSION uint64_t u2GstMode : 2; /**< Bits 57:56 - GLX: Guest Paging mode levels. */
500 RT_GCC_EXTENSION uint64_t u3GstCr3TableRootPtrLo : 3; /**< Bits 60:58 - GCR3 TRP: Guest CR3 Table Root Ptr (Lo). */
501 RT_GCC_EXTENSION uint64_t u1IoRead : 1; /**< Bit 61 - IR: I/O Read permission. */
502 RT_GCC_EXTENSION uint64_t u1IoWrite : 1; /**< Bit 62 - IW: I/O Write permission. */
503 RT_GCC_EXTENSION uint64_t u1Rsvd0 : 1; /**< Bit 63 - Reserved. */
504 RT_GCC_EXTENSION uint64_t u16DomainId : 16; /**< Bits 79:64 - Domain ID. */
505 RT_GCC_EXTENSION uint64_t u16GstCr3TableRootPtrMid : 16; /**< Bits 95:80 - GCR3 TRP: Guest CR3 Table Root Ptr (Mid). */
506 RT_GCC_EXTENSION uint64_t u1IoTlbEnable : 1; /**< Bit 96 - I: IOTLB Enable. */
507 RT_GCC_EXTENSION uint64_t u1SuppressPfEvents : 1; /**< Bit 97 - SE: Supress Page-fault events. */
508 RT_GCC_EXTENSION uint64_t u1SuppressAllPfEvents : 1; /**< Bit 98 - SA: Supress All Page-fault events. */
509 RT_GCC_EXTENSION uint64_t u2IoCtl : 2; /**< Bits 100:99 - IoCtl: Port I/O Control. */
510 RT_GCC_EXTENSION uint64_t u1Cache : 1; /**< Bit 101 - Cache: IOTLB Cache Hint. */
511 RT_GCC_EXTENSION uint64_t u1SnoopDisable : 1; /**< Bit 102 - SD: Snoop Disable. */
512 RT_GCC_EXTENSION uint64_t u1AllowExclusion : 1; /**< Bit 103 - EX: Allow Exclusion. */
513 RT_GCC_EXTENSION uint64_t u2SysMgt : 2; /**< Bits 105:104 - SysMgt: System Management message enable. */
514 RT_GCC_EXTENSION uint64_t u1Rsvd1 : 1; /**< Bit 106 - Reserved. */
515 RT_GCC_EXTENSION uint64_t u21GstCr3TableRootPtrHi : 21; /**< Bits 127:107 - GCR3 TRP: Guest CR3 Table Root Ptr (Hi). */
516 RT_GCC_EXTENSION uint64_t u1IntrMapValid : 1; /**< Bit 128 - IV: Interrupt map Valid. */
517 RT_GCC_EXTENSION uint64_t u4IntrTableLength : 4; /**< Bits 132:129 - IntTabLen: Interrupt Table Length. */
518 RT_GCC_EXTENSION uint64_t u1IgnoreUnmappedIntrs : 1; /**< Bits 133 - IG: Ignore unmapped interrupts. */
519 RT_GCC_EXTENSION uint64_t u46IntrTableRootPtr : 46; /**< Bits 179:134 - Interrupt Root Table Pointer. */
520 RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 183:180 - Reserved. */
521 RT_GCC_EXTENSION uint64_t u1InitPassthru : 1; /**< Bits 184 - INIT Pass-through. */
522 RT_GCC_EXTENSION uint64_t u1ExtIntPassthru : 1; /**< Bits 185 - External Interrupt Pass-through. */
523 RT_GCC_EXTENSION uint64_t u1NmiPassthru : 1; /**< Bits 186 - NMI Pass-through. */
524 RT_GCC_EXTENSION uint64_t u1Rsvd2 : 1; /**< Bits 187 - Reserved. */
525 RT_GCC_EXTENSION uint64_t u2IntrCtrl : 2; /**< Bits 189:188 - IntCtl: Interrupt Control. */
526 RT_GCC_EXTENSION uint64_t u1Lint0Passthru : 1; /**< Bit 190 - Lint0Pass: LINT0 Pass-through. */
527 RT_GCC_EXTENSION uint64_t u1Lint1Passthru : 1; /**< Bit 191 - Lint1Pass: LINT1 Pass-through. */
528 RT_GCC_EXTENSION uint64_t u32Rsvd0 : 32; /**< Bits 223:192 - Reserved. */
529 RT_GCC_EXTENSION uint64_t u22Rsvd0 : 22; /**< Bits 245:224 - Reserved. */
530 RT_GCC_EXTENSION uint64_t u1AttrOverride : 1; /**< Bit 246 - AttrV: Attribute Override. */
531 RT_GCC_EXTENSION uint64_t u1Mode0FC : 1; /**< Bit 247 - Mode0FC. */
532 RT_GCC_EXTENSION uint64_t u8SnoopAttr : 8; /**< Bits 255:248 - Snoop Attribute. */
533 } n;
534 /** The 32-bit unsigned integer view. */
535 uint32_t au32[8];
536 /** The 64-bit unsigned integer view. */
537 uint64_t au64[4];
538} DTE_T;
539AssertCompileSize(DTE_T, 32);
540/** Pointer to a device table entry. */
541typedef DTE_T *PDTE_T;
542/** Pointer to a const device table entry. */
543typedef DTE_T const *PCDTE_T;
544
545/** Mask of valid bits for EPHSUP (Enhanced Peripheral Page Request Handling
546 * Support) feature (bits 52:53). */
547#define IOMMU_DTE_QWORD_0_FEAT_EPHSUP_MASK UINT64_C(0x0030000000000000)
548
549/** Mask of valid bits for GTSup (Guest Translation Support) feature (bits 55:60,
550 * bits 80:95). */
551#define IOMMU_DTE_QWORD_0_FEAT_GTSUP_MASK UINT64_C(0x1f80000000000000)
552#define IOMMU_DTE_QWORD_1_FEAT_GTSUP_MASK UINT64_C(0x00000000ffff0000)
553
554/** Mask of valid bits for GIoSup (Guest I/O Protection Support) feature (bit 54). */
555#define IOMMU_DTE_QWORD_0_FEAT_GIOSUP_MASK UINT64_C(0x0040000000000000)
556
557/** Mask of valid DTE feature bits. */
558#define IOMMU_DTE_QWORD_0_FEAT_MASK ( IOMMU_DTE_QWORD_0_FEAT_EPHSUP_MASK \
559 | IOMMU_DTE_QWORD_0_FEAT_GTSUP_MASK \
560 | IOMMU_DTE_QWORD_0_FEAT_GIOSUP_MASK)
561#define IOMMU_DTE_QWORD_1_FEAT_MASK (IOMMU_DTE_QWORD_0_FEAT_GIOSUP_MASK)
562
563/** Mask of all valid DTE bits (including all feature bits). */
564#define IOMMU_DTE_QWORD_0_VALID_MASK UINT64_C(0x7fffffffffffff83)
565#define IOMMU_DTE_QWORD_1_VALID_MASK UINT64_C(0xfffffbffffffffff)
566#define IOMMU_DTE_QWORD_2_VALID_MASK UINT64_C(0xff0fffffffffffff)
567#define IOMMU_DTE_QWORD_3_VALID_MASK UINT64_C(0xffc0000000000000)
568
569/** Mask of the interrupt table root pointer. */
570#define IOMMU_DTE_IRTE_ROOT_PTR_MASK UINT64_C(0x000fffffffffffc0)
571/** Number of bits to shift to get the interrupt root table pointer at
572 qword 2 (qword 0 being the first one) - 128-byte aligned. */
573#define IOMMU_DTE_IRTE_ROOT_PTR_SHIFT 6
574
575/** Maximum encoded IRTE length (exclusive). */
576#define IOMMU_DTE_INTR_TAB_LEN_MAX 12
577/** Gets the interrupt table entries (in bytes) given the DTE pointer. */
578#define IOMMU_GET_INTR_TAB_ENTRIES(a_pDte) (UINT64_C(1) << (a_pDte)->n.u4IntrTableLength)
579/** Gets the interrupt table length (in bytes) given the DTE pointer. */
580#define IOMMU_GET_INTR_TAB_LEN(a_pDte) (IOMMU_GET_INTR_TAB_ENTRIES(a_pDte) * sizeof(IRTE_T))
581
582/**
583 * I/O Page Translation Entry.
584 * In accordance with the AMD spec.
585 */
586typedef union
587{
588 struct
589 {
590 RT_GCC_EXTENSION uint64_t u1Present : 1; /**< Bit 0 - PR: Present. */
591 RT_GCC_EXTENSION uint64_t u4Ign0 : 4; /**< Bits 4:1 - Ignored. */
592 RT_GCC_EXTENSION uint64_t u1Accessed : 1; /**< Bit 5 - A: Accessed. */
593 RT_GCC_EXTENSION uint64_t u1Dirty : 1; /**< Bit 6 - D: Dirty. */
594 RT_GCC_EXTENSION uint64_t u2Ign0 : 2; /**< Bits 8:7 - Ignored. */
595 RT_GCC_EXTENSION uint64_t u3NextLevel : 3; /**< Bits 11:9 - Next Level: Next page translation level. */
596 RT_GCC_EXTENSION uint64_t u40PageAddr : 40; /**< Bits 51:12 - Page address. */
597 RT_GCC_EXTENSION uint64_t u7Rsvd0 : 7; /**< Bits 58:52 - Reserved. */
598 RT_GCC_EXTENSION uint64_t u1UntranslatedAccess : 1; /**< Bit 59 - U: Untranslated Access Only. */
599 RT_GCC_EXTENSION uint64_t u1ForceCoherent : 1; /**< Bit 60 - FC: Force Coherent. */
600 RT_GCC_EXTENSION uint64_t u1IoRead : 1; /**< Bit 61 - IR: I/O Read permission. */
601 RT_GCC_EXTENSION uint64_t u1IoWrite : 1; /**< Bit 62 - IW: I/O Wead permission. */
602 RT_GCC_EXTENSION uint64_t u1Ign0 : 1; /**< Bit 63 - Ignored. */
603 } n;
604 /** The 64-bit unsigned integer view. */
605 uint64_t u64;
606} IOPTE_T;
607AssertCompileSize(IOPTE_T, 8);
608
609/**
610 * I/O Page Directory Entry.
611 * In accordance with the AMD spec.
612 */
613typedef union
614{
615 struct
616 {
617 RT_GCC_EXTENSION uint64_t u1Present : 1; /**< Bit 0 - PR: Present. */
618 RT_GCC_EXTENSION uint64_t u4Ign0 : 4; /**< Bits 4:1 - Ignored. */
619 RT_GCC_EXTENSION uint64_t u1Accessed : 1; /**< Bit 5 - A: Accessed. */
620 RT_GCC_EXTENSION uint64_t u3Ign0 : 3; /**< Bits 8:6 - Ignored. */
621 RT_GCC_EXTENSION uint64_t u3NextLevel : 3; /**< Bits 11:9 - Next Level: Next page translation level. */
622 RT_GCC_EXTENSION uint64_t u40PageAddr : 40; /**< Bits 51:12 - Page address (Next Table Address). */
623 RT_GCC_EXTENSION uint64_t u9Rsvd0 : 9; /**< Bits 60:52 - Reserved. */
624 RT_GCC_EXTENSION uint64_t u1IoRead : 1; /**< Bit 61 - IR: I/O Read permission. */
625 RT_GCC_EXTENSION uint64_t u1IoWrite : 1; /**< Bit 62 - IW: I/O Wead permission. */
626 RT_GCC_EXTENSION uint64_t u1Ign0 : 1; /**< Bit 63 - Ignored. */
627 } n;
628 /** The 64-bit unsigned integer view. */
629 uint64_t u64;
630} IOPDE_T;
631AssertCompileSize(IOPDE_T, 8);
632
633/**
634 * I/O Page Table Entity.
635 * In accordance with the AMD spec.
636 *
637 * This a common subset of an DTE.au64[0], PTE and PDE.
638 * Named as an "entity" to avoid confusing it with PTE.
639 */
640typedef union
641{
642 struct
643 {
644 RT_GCC_EXTENSION uint64_t u1Present : 1; /**< Bit 0 - PR: Present. */
645 RT_GCC_EXTENSION uint64_t u8Ign0 : 8; /**< Bits 8:1 - Ignored. */
646 RT_GCC_EXTENSION uint64_t u3NextLevel : 3; /**< Bits 11:9 - Mode / Next Level: Next page translation level. */
647 RT_GCC_EXTENSION uint64_t u40Addr : 40; /**< Bits 51:12 - Page address. */
648 RT_GCC_EXTENSION uint64_t u9Ign0 : 9; /**< Bits 60:52 - Ignored. */
649 RT_GCC_EXTENSION uint64_t u1IoRead : 1; /**< Bit 61 - IR: I/O Read permission. */
650 RT_GCC_EXTENSION uint64_t u1IoWrite : 1; /**< Bit 62 - IW: I/O Wead permission. */
651 RT_GCC_EXTENSION uint64_t u1Ign0 : 1; /**< Bit 63 - Ignored. */
652 } n;
653 /** The 64-bit unsigned integer view. */
654 uint64_t u64;
655} IOPTENTITY_T;
656AssertCompileSize(IOPTENTITY_T, 8);
657AssertCompile(sizeof(IOPTENTITY_T) == sizeof(IOPTE_T));
658AssertCompile(sizeof(IOPTENTITY_T) == sizeof(IOPDE_T));
659/** Pointer to an IOPT_ENTITY_T struct. */
660typedef IOPTENTITY_T *PIOPTENTITY_T;
661/** Pointer to a const IOPT_ENTITY_T struct. */
662typedef IOPTENTITY_T const *PCIOPTENTITY_T;
663/** Mask of the address field. */
664#define IOMMU_PTENTITY_ADDR_MASK UINT64_C(0x000ffffffffff000)
665
666/**
667 * Interrupt Remapping Table Entry (IRTE) - Basic Format.
668 * In accordance with the AMD spec.
669 */
670typedef union
671{
672 struct
673 {
674 uint32_t u1RemapEnable : 1; /**< Bit 0 - RemapEn: Remap Enable. */
675 uint32_t u1SuppressIoPf : 1; /**< Bit 1 - SupIOPF: Supress I/O Page Fault. */
676 uint32_t u3IntrType : 3; /**< Bits 4:2 - IntType: Interrupt Type. */
677 uint32_t u1ReqEoi : 1; /**< Bit 5 - RqEoi: Request EOI. */
678 uint32_t u1DestMode : 1; /**< Bit 6 - DM: Destination Mode. */
679 uint32_t u1GuestMode : 1; /**< Bit 7 - GuestMode. */
680 uint32_t u8Dest : 8; /**< Bits 15:8 - Destination. */
681 uint32_t u8Vector : 8; /**< Bits 23:16 - Vector. */
682 uint32_t u8Rsvd0 : 8; /**< Bits 31:24 - Reserved. */
683 } n;
684 /** The 32-bit unsigned integer view. */
685 uint32_t u32;
686} IRTE_T;
687AssertCompileSize(IRTE_T, 4);
688/** Pointer to an IRTE_T struct. */
689typedef IRTE_T *PIRTE_T;
690/** Pointer to a const IRTE_T struct. */
691typedef IRTE_T const *PCIRTE_T;
692
693/** The IRTE offset corresponds directly to bits 10:0 of the originating MSI
694 * interrupt message. See AMD IOMMU spec. 2.2.5 "Interrupt Remapping Tables". */
695#define IOMMU_MSI_DATA_IRTE_OFFSET_MASK UINT32_C(0x000007ff)
696
697/**
698 * Command: Generic Command Buffer Entry.
699 * In accordance with the AMD spec.
700 */
701typedef union
702{
703 struct
704 {
705 uint32_t u32Operand1Lo; /**< Bits 31:0 - Operand 1 (Lo). */
706 uint32_t u28Operand1Hi : 28; /**< Bits 59:32 - Operand 1 (Hi). */
707 uint32_t u4Opcode : 4; /**< Bits 63:60 - Op Code. */
708 uint64_t u64Operand2; /**< Bits 127:64 - Operand 2. */
709 } n;
710 /** The 64-bit unsigned integer view. */
711 uint64_t au64[2];
712} CMD_GENERIC_T;
713AssertCompileSize(CMD_GENERIC_T, 16);
714/** Pointer to a generic command buffer entry. */
715typedef CMD_GENERIC_T *PCMD_GENERIC_T;
716/** Pointer to a const generic command buffer entry. */
717typedef CMD_GENERIC_T const *PCCMD_GENERIC_T;
718
719/** Number of bits to shift the byte offset of a command in the command buffer to
720 * get its index. */
721#define IOMMU_CMD_GENERIC_SHIFT 4
722
723/**
724 * Command: COMPLETION_WAIT.
725 * In accordance with the AMD spec.
726 */
727typedef union
728{
729 struct
730 {
731 uint32_t u1Store : 1; /**< Bit 0 - S: Completion Store. */
732 uint32_t u1Interrupt : 1; /**< Bit 1 - I: Completion Interrupt. */
733 uint32_t u1Flush : 1; /**< Bit 2 - F: Flush Queue. */
734 uint32_t u29StoreAddrLo : 29; /**< Bits 31:3 - Store Address (Lo). */
735 uint32_t u20StoreAddrHi : 20; /**< Bits 51:32 - Store Address (Hi). */
736 uint32_t u8Rsvd0 : 8; /**< Bits 59:52 - Reserved. */
737 uint32_t u4OpCode : 4; /**< Bits 63:60 - OpCode (Command). */
738 uint64_t u64StoreData; /**< Bits 127:64 - Store Data. */
739 } n;
740 /** The 64-bit unsigned integer view. */
741 uint64_t au64[2];
742} CMD_COMWAIT_T;
743AssertCompileSize(CMD_COMWAIT_T, 16);
744/** Pointer to a completion wait command. */
745typedef CMD_COMWAIT_T *PCMD_COMWAIT_T;
746/** Pointer to a const completion wait command. */
747typedef CMD_COMWAIT_T const *PCCMD_COMWAIT_T;
748#define IOMMU_CMD_COM_WAIT_QWORD_0_VALID_MASK UINT64_C(0xf00fffffffffffff)
749
750/**
751 * Command: INVALIDATE_DEVTAB_ENTRY.
752 * In accordance with the AMD spec.
753 */
754typedef union
755{
756 struct
757 {
758 uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
759 uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved. */
760 uint32_t u28Rsvd0 : 28; /**< Bits 59:32 - Reserved. */
761 uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
762 uint64_t u64Rsvd0; /**< Bits 127:64 - Reserved. */
763 } n;
764 /** The 64-bit unsigned integer view. */
765 uint64_t au64[2];
766} CMD_INV_DTE_T;
767AssertCompileSize(CMD_INV_DTE_T, 16);
768
769/**
770 * Command: INVALIDATE_IOMMU_PAGES.
771 * In accordance with the AMD spec.
772 */
773typedef union
774{
775 struct
776 {
777 uint32_t u20Pasid : 20; /**< Bits 19:0 - PASID: Process Address-Space ID. */
778 uint32_t u12Rsvd0 : 12; /**< Bits 31:20 - Reserved. */
779 uint32_t u16DomainId : 16; /**< Bits 47:32 - Domain ID. */
780 uint32_t u12Rsvd1 : 12; /**< Bits 59:48 - Reserved. */
781 uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
782 uint32_t u1Size : 1; /**< Bit 64 - S: Size. */
783 uint32_t u1PageDirEntries : 1; /**< Bit 65 - PDE: Page Directory Entries. */
784 uint32_t u1GuestOrNested : 1; /**< Bit 66 - GN: Guest (GPA) or Nested (GVA). */
785 uint32_t u9Rsvd0 : 9; /**< Bits 75:67 - Reserved. */
786 uint32_t u20AddrLo : 20; /**< Bits 95:76 - Address (Lo). */
787 uint32_t u32AddrHi; /**< Bits 127:96 - Address (Hi). */
788 } n;
789 /** The 64-bit unsigned integer view. */
790 uint64_t au64[2];
791} CMD_INV_IOMMU_PAGES_T;
792AssertCompileSize(CMD_INV_IOMMU_PAGES_T, 16);
793
794/**
795 * Command: INVALIDATE_IOTLB_PAGES.
796 * In accordance with the AMD spec.
797 */
798typedef union
799{
800 struct
801 {
802 uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
803 uint8_t u8PasidLo; /**< Bits 23:16 - PASID: Process Address-Space ID (Lo). */
804 uint8_t u8MaxPend; /**< Bits 31:24 - Maxpend: Maximum simultaneous in-flight transactions. */
805 uint32_t u16QueueId : 16; /**< Bits 47:32 - Queue ID. */
806 uint32_t u12PasidHi : 12; /**< Bits 59:48 - PASID: Process Address-Space ID (Hi). */
807 uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
808 uint32_t u1Size : 1; /**< Bit 64 - S: Size. */
809 uint32_t u1Rsvd0: 1; /**< Bit 65 - Reserved. */
810 uint32_t u1GuestOrNested : 1; /**< Bit 66 - GN: Guest (GPA) or Nested (GVA). */
811 uint32_t u1Rsvd1 : 1; /**< Bit 67 - Reserved. */
812 uint32_t u2Type : 2; /**< Bit 69:68 - Type. */
813 uint32_t u6Rsvd0 : 6; /**< Bits 75:70 - Reserved. */
814 uint32_t u20AddrLo : 20; /**< Bits 95:76 - Address (Lo). */
815 uint32_t u32AddrHi; /**< Bits 127:96 - Address (Hi). */
816 } n;
817 /** The 64-bit unsigned integer view. */
818 uint64_t au64[2];
819} CMD_INV_IOTLB_PAGES_T;
820AssertCompileSize(CMD_INV_IOTLB_PAGES_T, 16);
821
822/**
823 * Command: INVALIDATE_INTR_TABLE.
824 * In accordance with the AMD spec.
825 */
826typedef union
827{
828 struct
829 {
830 uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
831 uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved. */
832 uint32_t u32Rsvd0 : 28; /**< Bits 59:32 - Reserved. */
833 uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
834 uint64_t u64Rsvd0; /**< Bits 127:64 - Reserved. */
835 } u;
836 /** The 64-bit unsigned integer view. */
837 uint64_t au64[2];
838} CMD_INV_INTR_TABLE_T;
839AssertCompileSize(CMD_INV_INTR_TABLE_T, 16);
840
841/**
842 * Command: COMPLETE_PPR_REQ.
843 * In accordance with the AMD spec.
844 */
845typedef union
846{
847 struct
848 {
849 uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
850 uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved. */
851 uint32_t u20Pasid : 20; /**< Bits 51:32 - PASID: Process Address-Space ID. */
852 uint32_t u8Rsvd0 : 8; /**< Bits 59:52 - Reserved. */
853 uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
854 uint32_t u2Rsvd0 : 2; /**< Bits 65:64 - Reserved. */
855 uint32_t u1GuestOrNested : 1; /**< Bit 66 - GN: Guest (GPA) or Nested (GVA). */
856 uint32_t u29Rsvd0 : 29; /**< Bits 95:67 - Reserved. */
857 uint32_t u16CompletionTag : 16; /**< Bits 111:96 - Completion Tag. */
858 uint32_t u16Rsvd1 : 16; /**< Bits 127:112 - Reserved. */
859 } n;
860 /** The 64-bit unsigned integer view. */
861 uint64_t au64[2];
862} CMD_COMPLETE_PPR_REQ_T;
863AssertCompileSize(CMD_COMPLETE_PPR_REQ_T, 16);
864
865/**
866 * Command: INV_IOMMU_ALL.
867 * In accordance with the AMD spec.
868 */
869typedef union
870{
871 struct
872 {
873 uint32_t u32Rsvd0; /**< Bits 31:0 - Reserved. */
874 uint32_t u28Rsvd0 : 28; /**< Bits 59:32 - Reserved. */
875 uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
876 uint64_t u64Rsvd0; /**< Bits 127:64 - Reserved. */
877 } n;
878 /** The 64-bit unsigned integer view. */
879 uint64_t au64[2];
880} CMD_IOMMU_ALL_T;
881AssertCompileSize(CMD_IOMMU_ALL_T, 16);
882
883/**
884 * Event Log Entry: Generic.
885 * In accordance with the AMD spec.
886 */
887typedef union
888{
889 struct
890 {
891 uint32_t u32Operand1Lo; /**< Bits 31:0 - Operand 1 (Lo). */
892 uint32_t u28Operand1Hi : 28; /**< Bits 59:32 - Operand 1 (Hi). */
893 uint32_t u4EvtCode : 4; /**< Bits 63:60 - Event code. */
894 uint32_t u32Operand2Lo; /**< Bits 95:64 - Operand 2 (Lo). */
895 uint32_t u32Operand2Hi; /**< Bits 127:96 - Operand 2 (Hi). */
896 } n;
897 /** The 32-bit unsigned integer view. */
898 uint32_t au32[4];
899} EVT_GENERIC_T;
900AssertCompileSize(EVT_GENERIC_T, 16);
901/** Number of bits to shift the byte offset of an event entry in the event log
902 * buffer to get its index. */
903#define IOMMU_EVT_GENERIC_SHIFT 4
904/** Pointer to a generic event log entry. */
905typedef EVT_GENERIC_T *PEVT_GENERIC_T;
906/** Pointer to a const generic event log entry. */
907typedef const EVT_GENERIC_T *PCEVT_GENERIC_T;
908
909/**
910 * Hardware event types.
911 * In accordance with the AMD spec.
912 */
913typedef enum HWEVTTYPE
914{
915 HWEVTTYPE_RSVD = 0,
916 HWEVTTYPE_MASTER_ABORT,
917 HWEVTTYPE_TARGET_ABORT,
918 HWEVTTYPE_DATA_ERROR
919} HWEVTTYPE;
920AssertCompileSize(HWEVTTYPE, 4);
921
922/**
923 * Event Log Entry: ILLEGAL_DEV_TABLE_ENTRY.
924 * In accordance with the AMD spec.
925 */
926typedef union
927{
928 struct
929 {
930 uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
931 RT_GCC_EXTENSION uint16_t u4PasidHi : 4; /**< Bits 19:16 - PASID: Process Address-Space ID (Hi). */
932 RT_GCC_EXTENSION uint16_t u12Rsvd0 : 12; /**< Bits 31:20 - Reserved. */
933 uint16_t u16PasidLo; /**< Bits 47:32 - PASID: Process Address-Space ID (Lo). */
934 RT_GCC_EXTENSION uint16_t u1GuestOrNested : 1; /**< Bit 48 - GN: Guest (GPA) or Nested (GVA). */
935 RT_GCC_EXTENSION uint16_t u2Rsvd0 : 2; /**< Bits 50:49 - Reserved. */
936 RT_GCC_EXTENSION uint16_t u1Interrupt : 1; /**< Bit 51 - I: Interrupt. */
937 RT_GCC_EXTENSION uint16_t u1Rsvd0 : 1; /**< Bit 52 - Reserved. */
938 RT_GCC_EXTENSION uint16_t u1ReadWrite : 1; /**< Bit 53 - RW: Read/Write. */
939 RT_GCC_EXTENSION uint16_t u1Rsvd1 : 1; /**< Bit 54 - Reserved. */
940 RT_GCC_EXTENSION uint16_t u1RsvdNotZero : 1; /**< Bit 55 - RZ: Reserved bit not Zero (0=invalid level encoding). */
941 RT_GCC_EXTENSION uint16_t u1Translation : 1; /**< Bit 56 - TN: Translation. */
942 RT_GCC_EXTENSION uint16_t u3Rsvd0 : 3; /**< Bits 59:57 - Reserved. */
943 RT_GCC_EXTENSION uint16_t u4EvtCode : 4; /**< Bits 63:60 - Event code. */
944 uint64_t u64Addr; /**< Bits 127:64 - Address: I/O Virtual Address (IOVA). */
945 } n;
946 /** The 32-bit unsigned integer view. */
947 uint32_t au32[4];
948 /** The 64-bit unsigned integer view. */
949 uint64_t au64[2];
950} EVT_ILLEGAL_DTE_T;
951AssertCompileSize(EVT_ILLEGAL_DTE_T, 16);
952/** Pointer to an illegal device table entry event. */
953typedef EVT_ILLEGAL_DTE_T *PEVT_ILLEGAL_DTE_T;
954/** Pointer to a const illegal device table entry event. */
955typedef EVT_ILLEGAL_DTE_T const *PCEVT_ILLEGAL_DTE_T;
956
957/**
958 * Event Log Entry: IO_PAGE_FAULT_EVENT.
959 * In accordance with the AMD spec.
960 */
961typedef union
962{
963 struct
964 {
965 uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
966 RT_GCC_EXTENSION uint16_t u4PasidHi : 4; /**< Bits 19:16 - PASID: Process Address-Space ID (Hi). */
967 RT_GCC_EXTENSION uint16_t u16DomainOrPasidLo; /**< Bits 47:32 - D/P: Domain ID or Process Address-Space ID (Lo). */
968 RT_GCC_EXTENSION uint16_t u1GuestOrNested : 1; /**< Bit 48 - GN: Guest (GPA) or Nested (GVA). */
969 RT_GCC_EXTENSION uint16_t u1NoExecute : 1; /**< Bit 49 - NX: No Execute. */
970 RT_GCC_EXTENSION uint16_t u1User : 1; /**< Bit 50 - US: User/Supervisor. */
971 RT_GCC_EXTENSION uint16_t u1Interrupt : 1; /**< Bit 51 - I: Interrupt. */
972 RT_GCC_EXTENSION uint16_t u1Present : 1; /**< Bit 52 - PR: Present. */
973 RT_GCC_EXTENSION uint16_t u1ReadWrite : 1; /**< Bit 53 - RW: Read/Write. */
974 RT_GCC_EXTENSION uint16_t u1PermDenied : 1; /**< Bit 54 - PE: Permission Indicator. */
975 RT_GCC_EXTENSION uint16_t u1RsvdNotZero : 1; /**< Bit 55 - RZ: Reserved bit not Zero (0=invalid level encoding). */
976 RT_GCC_EXTENSION uint16_t u1Translation : 1; /**< Bit 56 - TN: Translation. */
977 RT_GCC_EXTENSION uint16_t u3Rsvd0 : 3; /**< Bit 59:57 - Reserved. */
978 RT_GCC_EXTENSION uint16_t u4EvtCode : 4; /**< Bits 63:60 - Event code. */
979 uint64_t u64Addr; /**< Bits 127:64 - Address: I/O Virtual Address (IOVA). */
980 } n;
981 /** The 32-bit unsigned integer view. */
982 uint32_t au32[4];
983 /** The 64-bit unsigned integer view. */
984 uint64_t au64[2];
985} EVT_IO_PAGE_FAULT_T;
986AssertCompileSize(EVT_IO_PAGE_FAULT_T, 16);
987/** Pointer to an I/O page fault event. */
988typedef EVT_IO_PAGE_FAULT_T *PEVT_IO_PAGE_FAULT_T;
989/** Pointer to a const I/O page fault event. */
990typedef EVT_IO_PAGE_FAULT_T const *PCEVT_IO_PAGE_FAULT_T;
991
992
993/**
994 * Event Log Entry: DEV_TAB_HARDWARE_ERROR.
995 * In accordance with the AMD spec.
996 */
997typedef union
998{
999 struct
1000 {
1001 uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
1002 uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved. */
1003 uint32_t u19Rsvd0 : 19; /**< Bits 50:32 - Reserved. */
1004 uint32_t u1Intr : 1; /**< Bit 51 - I: Interrupt (1=interrupt request, 0=memory request). */
1005 uint32_t u1Rsvd0 : 1; /**< Bit 52 - Reserved. */
1006 uint32_t u1ReadWrite : 1; /**< Bit 53 - RW: Read/Write transaction (only meaninful when I=0 and TR=0). */
1007 uint32_t u2Rsvd0 : 2; /**< Bits 55:54 - Reserved. */
1008 uint32_t u1Translation : 1; /**< Bit 56 - TR: Translation (1=translation, 0=transaction). */
1009 uint32_t u2Type : 2; /**< Bits 58:57 - Type: The type of hardware error. */
1010 uint32_t u1Rsvd1 : 1; /**< Bit 59 - Reserved. */
1011 uint32_t u4EvtCode : 4; /**< Bits 63:60 - Event code. */
1012 uint64_t u64Addr; /**< Bits 127:64 - Address. */
1013 } n;
1014 /** The 32-bit unsigned integer view. */
1015 uint32_t au32[4];
1016 /** The 64-bit unsigned integer view. */
1017 uint64_t au64[2];
1018} EVT_DEV_TAB_HW_ERROR_T;
1019AssertCompileSize(EVT_DEV_TAB_HW_ERROR_T, 16);
1020/** Pointer to a device table hardware error event. */
1021typedef EVT_DEV_TAB_HW_ERROR_T *PEVT_DEV_TAB_HW_ERROR_T;
1022/** Pointer to a const device table hardware error event. */
1023typedef EVT_DEV_TAB_HW_ERROR_T const *PCEVT_DEV_TAB_HW_ERROR_T;
1024
1025/**
1026 * Event Log Entry: EVT_PAGE_TAB_HARDWARE_ERROR.
1027 * In accordance with the AMD spec.
1028 */
1029typedef union
1030{
1031 struct
1032 {
1033 uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
1034 uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved. */
1035 uint32_t u16DomainOrPasidLo : 16; /**< Bits 47:32 - D/P: Domain ID or Process Address-Space ID (Lo). */
1036 uint32_t u1GuestOrNested : 1; /**< Bit 48 - GN: Guest (GPA) or Nested (GVA). */
1037 uint32_t u2Rsvd0 : 2; /**< Bits 50:49 - Reserved. */
1038 uint32_t u1Interrupt : 1; /**< Bit 51 - I: Interrupt. */
1039 uint32_t u1Rsvd0 : 1; /**< Bit 52 - Reserved. */
1040 uint32_t u1ReadWrite : 1; /**< Bit 53 - RW: Read/Write. */
1041 uint32_t u2Rsvd1 : 2; /**< Bit 55:54 - Reserved. */
1042 uint32_t u1Translation : 1; /**< Bit 56 - TR: Translation. */
1043 uint32_t u2Type : 2; /**< Bits 58:57 - Type: The type of hardware error. */
1044 uint32_t u1Rsvd1 : 1; /**< Bit 59 - Reserved. */
1045 uint32_t u4EvtCode : 4; /**< Bit 63:60 - Event code. */
1046 /** @todo r=ramshankar: Figure 55: PAGE_TAB_HARDWARE_ERROR says Addr[31:3] but
1047 * table 58 mentions Addr[31:4], we just use the full 64-bits. Looks like a
1048 * typo in the figure.See AMD AMD IOMMU spec (3.05-PUB, Jan 2020). */
1049 uint64_t u64Addr; /** Bits 127:64 - Address: SPA of the page table entry. */
1050 } n;
1051 /** The 32-bit unsigned integer view. */
1052 uint32_t au32[4];
1053 /** The 64-bit unsigned integer view. */
1054 uint64_t au64[2];
1055} EVT_PAGE_TAB_HW_ERR_T;
1056AssertCompileSize(EVT_PAGE_TAB_HW_ERR_T, 16);
1057/** Pointer to a page table hardware error event. */
1058typedef EVT_PAGE_TAB_HW_ERR_T *PEVT_PAGE_TAB_HW_ERR_T;
1059/** Pointer to a const page table hardware error event. */
1060typedef EVT_PAGE_TAB_HW_ERR_T const *PCEVT_PAGE_TAB_HW_ERR_T;
1061
1062/**
1063 * Event Log Entry: ILLEGAL_COMMAND_ERROR.
1064 * In accordance with the AMD spec.
1065 */
1066typedef union
1067{
1068 struct
1069 {
1070 uint32_t u32Rsvd0; /**< Bits 31:0 - Reserved. */
1071 uint32_t u28Rsvd0 : 28; /**< Bits 47:32 - Reserved. */
1072 uint32_t u4EvtCode : 4; /**< Bits 63:60 - Event code. */
1073 uint64_t u64Addr; /**< Bits 127:64 - Address: SPA of the invalid command. */
1074 } n;
1075 /** The 32-bit unsigned integer view. */
1076 uint32_t au32[4];
1077 /** The 64-bit unsigned integer view. */
1078 uint64_t au64[2];
1079} EVT_ILLEGAL_CMD_ERR_T;
1080AssertCompileSize(EVT_ILLEGAL_CMD_ERR_T, 16);
1081/** Pointer to an illegal command error event. */
1082typedef EVT_ILLEGAL_CMD_ERR_T *PEVT_ILLEGAL_CMD_ERR_T;
1083/** Pointer to a const illegal command error event. */
1084typedef EVT_ILLEGAL_CMD_ERR_T const *PCEVT_ILLEGAL_CMD_ERR_T;
1085
1086/**
1087 * Event Log Entry: COMMAND_HARDWARE_ERROR.
1088 * In accordance with the AMD spec.
1089 */
1090typedef union
1091{
1092 struct
1093 {
1094 uint32_t u32Rsvd0; /**< Bits 31:0 - Reserved. */
1095 uint32_t u25Rsvd1 : 25; /**< Bits 56:32 - Reserved. */
1096 uint32_t u2Type : 2; /**< Bits 58:57 - Type: The type of hardware error. */
1097 uint32_t u1Rsvd1 : 1; /**< Bit 59 - Reserved. */
1098 uint32_t u4EvtCode : 4; /**< Bits 63:60 - Event code. */
1099 uint64_t u64Addr; /**< Bits 128:64 - Address: SPA of the attempted access. */
1100 } n;
1101 /** The 32-bit unsigned integer view. */
1102 uint32_t au32[4];
1103 /** The 64-bit unsigned integer view. */
1104 uint64_t au64[2];
1105} EVT_CMD_HW_ERR_T;
1106AssertCompileSize(EVT_CMD_HW_ERR_T, 16);
1107/** Pointer to a command hardware error event. */
1108typedef EVT_CMD_HW_ERR_T *PEVT_CMD_HW_ERR_T;
1109/** Pointer to a const command hardware error event. */
1110typedef EVT_CMD_HW_ERR_T const *PCEVT_CMD_HW_ERR_T;
1111
1112/**
1113 * Event Log Entry: IOTLB_INV_TIMEOUT.
1114 * In accordance with the AMD spec.
1115 */
1116typedef union
1117{
1118 struct
1119 {
1120 uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
1121 uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved.*/
1122 uint32_t u28Rsvd0 : 28; /**< Bits 59:32 - Reserved. */
1123 uint32_t u4EvtCode : 4; /**< Bits 63:60 - Event code. */
1124 uint32_t u4Rsvd0 : 4; /**< Bits 67:64 - Reserved. */
1125 uint32_t u28AddrLo : 28; /**< Bits 95:68 - Address: SPA of the invalidation command that timedout (Lo). */
1126 uint32_t u32AddrHi; /**< Bits 127:96 - Address: SPA of the invalidation command that timedout (Hi). */
1127 } n;
1128 /** The 32-bit unsigned integer view. */
1129 uint32_t au32[4];
1130} EVT_IOTLB_INV_TIMEOUT_T;
1131AssertCompileSize(EVT_IOTLB_INV_TIMEOUT_T, 16);
1132
1133/**
1134 * Event Log Entry: INVALID_DEVICE_REQUEST.
1135 * In accordance with the AMD spec.
1136 */
1137typedef union
1138{
1139 struct
1140 {
1141 uint32_t u16DevId : 16; /***< Bits 15:0 - Device ID. */
1142 uint32_t u4PasidHi : 4; /***< Bits 19:16 - PASID: Process Address-Space ID (Hi). */
1143 uint32_t u12Rsvd0 : 12; /***< Bits 31:20 - Reserved. */
1144 uint32_t u16PasidLo : 16; /***< Bits 47:32 - PASID: Process Address-Space ID (Lo). */
1145 uint32_t u1GuestOrNested : 1; /***< Bit 48 - GN: Guest (GPA) or Nested (GVA). */
1146 uint32_t u1User : 1; /***< Bit 49 - US: User/Supervisor. */
1147 uint32_t u6Rsvd0 : 6; /***< Bits 55:50 - Reserved. */
1148 uint32_t u1Translation: 1; /***< Bit 56 - TR: Translation. */
1149 uint32_t u3Type: 3; /***< Bits 59:57 - Type: The type of hardware error. */
1150 uint32_t u4EvtCode : 4; /***< Bits 63:60 - Event code. */
1151 uint64_t u64Addr; /***< Bits 127:64 - Address: Translation or access address. */
1152 } n;
1153 /** The 32-bit unsigned integer view. */
1154 uint32_t au32[4];
1155} EVT_INVALID_DEV_REQ_T;
1156AssertCompileSize(EVT_INVALID_DEV_REQ_T, 16);
1157
1158/**
1159 * Event Log Entry: EVENT_COUNTER_ZERO.
1160 * In accordance with the AMD spec.
1161 */
1162typedef union
1163{
1164 struct
1165 {
1166 uint32_t u32Rsvd0; /**< Bits 31:0 - Reserved. */
1167 uint32_t u28Rsvd0 : 28; /**< Bits 59:32 - Reserved. */
1168 uint32_t u4EvtCode : 4; /**< Bits 63:60 - Event code. */
1169 uint32_t u20CounterNoteHi : 20; /**< Bits 83:64 - CounterNote: Counter value for the event counter register (Hi). */
1170 uint32_t u12Rsvd0 : 12; /**< Bits 95:84 - Reserved. */
1171 uint32_t u32CounterNoteLo; /**< Bits 127:96 - CounterNote: Counter value for the event cuonter register (Lo). */
1172 } n;
1173 /** The 32-bit unsigned integer view. */
1174 uint32_t au32[4];
1175} EVT_EVENT_COUNTER_ZERO_T;
1176AssertCompileSize(EVT_EVENT_COUNTER_ZERO_T, 16);
1177
1178/**
1179 * IOMMU Capability Header (PCI).
1180 * In accordance with the AMD spec.
1181 */
1182typedef union
1183{
1184 struct
1185 {
1186 uint32_t u8CapId : 8; /**< Bits 7:0 - CapId: Capability ID. */
1187 uint32_t u8CapPtr : 8; /**< Bits 15:8 - CapPtr: Pointer (PCI config offset) to the next capability. */
1188 uint32_t u3CapType : 3; /**< Bits 18:16 - CapType: Capability Type. */
1189 uint32_t u5CapRev : 5; /**< Bits 23:19 - CapRev: Capability revision. */
1190 uint32_t u1IoTlbSup : 1; /**< Bit 24 - IotlbSup: IOTLB Support. */
1191 uint32_t u1HtTunnel : 1; /**< Bit 25 - HtTunnel: HyperTransport Tunnel translation support. */
1192 uint32_t u1NpCache : 1; /**< Bit 26 - NpCache: Not Present table entries are cached. */
1193 uint32_t u1EfrSup : 1; /**< Bit 27 - EFRSup: Extended Feature Register Support. */
1194 uint32_t u1CapExt : 1; /**< Bit 28 - CapExt: Misc. Information Register 1 Support. */
1195 uint32_t u3Rsvd0 : 3; /**< Bits 31:29 - Reserved. */
1196 } n;
1197 /** The 32-bit unsigned integer view. */
1198 uint32_t u32;
1199} IOMMU_CAP_HDR_T;
1200AssertCompileSize(IOMMU_CAP_HDR_T, 4);
1201
1202/**
1203 * IOMMU Base Address (Lo and Hi) Register (PCI).
1204 * In accordance with the AMD spec.
1205 */
1206typedef union
1207{
1208 struct
1209 {
1210 uint32_t u1Enable : 1; /**< Bit 1 - Enable: RW1S - Enable IOMMU MMIO region. */
1211 uint32_t u12Rsvd0 : 12; /**< Bits 13:1 - Reserved. */
1212 uint32_t u18BaseAddrLo : 18; /**< Bits 31:14 - Base address (Lo) of the MMIO region. */
1213 uint32_t u32BaseAddrHi; /**< Bits 63:32 - Base address (Hi) of the MMIO region. */
1214 } n;
1215 /** The 32-bit unsigned integer view. */
1216 uint32_t au32[2];
1217 /** The 64-bit unsigned integer view. */
1218 uint64_t u64;
1219} IOMMU_BAR_T;
1220AssertCompileSize(IOMMU_BAR_T, 8);
1221#define IOMMU_BAR_VALID_MASK UINT64_C(0xffffffffffffc001)
1222
1223/**
1224 * IOMMU Range Register (PCI).
1225 * In accordance with the AMD spec.
1226 */
1227typedef union
1228{
1229 struct
1230 {
1231 uint32_t u5HtUnitId : 5; /**< Bits 4:0 - UnitID: IOMMU HyperTransport Unit ID (not used). */
1232 uint32_t u2Rsvd0 : 2; /**< Bits 6:5 - Reserved. */
1233 uint32_t u1RangeValid : 1; /**< Bit 7 - RngValid: Range Valid. */
1234 uint32_t u8Bus : 8; /**< Bits 15:8 - BusNumber: Bus number of the first and last device. */
1235 uint32_t u8FirstDevice : 8; /**< Bits 23:16 - FirstDevice: Device and function number of the first device. */
1236 uint32_t u8LastDevice: 8; /**< Bits 31:24 - LastDevice: Device and function number of the last device. */
1237 } n;
1238 /** The 32-bit unsigned integer view. */
1239 uint32_t u32;
1240} IOMMU_RANGE_T;
1241AssertCompileSize(IOMMU_RANGE_T, 4);
1242
1243/**
1244 * Device Table Base Address Register (MMIO).
1245 * In accordance with the AMD spec.
1246 */
1247typedef union
1248{
1249 struct
1250 {
1251 RT_GCC_EXTENSION uint64_t u9Size : 9; /**< Bits 8:0 - Size: Size of the device table. */
1252 RT_GCC_EXTENSION uint64_t u3Rsvd0 : 3; /**< Bits 11:9 - Reserved. */
1253 RT_GCC_EXTENSION uint64_t u40Base : 40; /**< Bits 51:12 - DevTabBase: Device table base address. */
1254 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 63:52 - Reserved. */
1255 } n;
1256 /** The 64-bit unsigned integer view. */
1257 uint64_t u64;
1258} DEV_TAB_BAR_T;
1259AssertCompileSize(DEV_TAB_BAR_T, 8);
1260#define IOMMU_DEV_TAB_BAR_VALID_MASK UINT64_C(0x000ffffffffff1ff)
1261#define IOMMU_DEV_TAB_SEG_BAR_VALID_MASK UINT64_C(0x000ffffffffff0ff)
1262
1263/**
1264 * Command Buffer Base Address Register (MMIO).
1265 * In accordance with the AMD spec.
1266 */
1267typedef union
1268{
1269 struct
1270 {
1271 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 11:0 - Reserved. */
1272 RT_GCC_EXTENSION uint64_t u40Base : 40; /**< Bits 51:12 - ComBase: Command buffer base address. */
1273 RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 55:52 - Reserved. */
1274 RT_GCC_EXTENSION uint64_t u4Len : 4; /**< Bits 59:56 - ComLen: Command buffer length. */
1275 RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; /**< Bits 63:60 - Reserved. */
1276 } n;
1277 /** The 64-bit unsigned integer view. */
1278 uint64_t u64;
1279} CMD_BUF_BAR_T;
1280AssertCompileSize(CMD_BUF_BAR_T, 8);
1281#define IOMMU_CMD_BUF_BAR_VALID_MASK UINT64_C(0x0f0ffffffffff000)
1282
1283/**
1284 * Event Log Base Address Register (MMIO).
1285 * In accordance with the AMD spec.
1286 */
1287typedef union
1288{
1289 struct
1290 {
1291 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 11:0 - Reserved. */
1292 RT_GCC_EXTENSION uint64_t u40Base : 40; /**< Bits 51:12 - EventBase: Event log base address. */
1293 RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 55:52 - Reserved. */
1294 RT_GCC_EXTENSION uint64_t u4Len : 4; /**< Bits 59:56 - EventLen: Event log length. */
1295 RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; /**< Bits 63:60 - Reserved. */
1296 } n;
1297 /** The 64-bit unsigned integer view. */
1298 uint64_t u64;
1299} EVT_LOG_BAR_T;
1300AssertCompileSize(EVT_LOG_BAR_T, 8);
1301#define IOMMU_EVT_LOG_BAR_VALID_MASK UINT64_C(0x0f0ffffffffff000)
1302
1303/**
1304 * IOMMU Control Register (MMIO).
1305 * In accordance with the AMD spec.
1306 */
1307typedef union
1308{
1309 struct
1310 {
1311 uint32_t u1IommuEn : 1; /**< Bit 0 - IommuEn: IOMMU Enable. */
1312 uint32_t u1HtTunEn : 1; /**< Bit 1 - HtTunEn: HyperTransport Tunnel Enable. */
1313 uint32_t u1EvtLogEn : 1; /**< Bit 2 - EventLogEn: Event Log Enable. */
1314 uint32_t u1EvtIntrEn : 1; /**< Bit 3 - EventIntEn: Event Log Interrupt Enable. */
1315 uint32_t u1CompWaitIntrEn : 1; /**< Bit 4 - ComWaitIntEn: Completion Wait Interrupt Enable. */
1316 uint32_t u3InvTimeOut : 3; /**< Bits 7:5 - InvTimeOut: Invalidation Timeout. */
1317 uint32_t u1PassPW : 1; /**< Bit 8 - PassPW: Pass Posted Write. */
1318 uint32_t u1ResPassPW : 1; /**< Bit 9 - ResPassPW: Response Pass Posted Write. */
1319 uint32_t u1Coherent : 1; /**< Bit 10 - Coherent: HT read request packet Coherent bit. */
1320 uint32_t u1Isoc : 1; /**< Bit 11 - Isoc: HT read request packet Isochronous bit. */
1321 uint32_t u1CmdBufEn : 1; /**< Bit 12 - CmdBufEn: Command Buffer Enable. */
1322 uint32_t u1PprLogEn : 1; /**< Bit 13 - PprLogEn: Peripheral Page Request (PPR) Log Enable. */
1323 uint32_t u1PprIntrEn : 1; /**< Bit 14 - PprIntrEn: Peripheral Page Request Interrupt Enable. */
1324 uint32_t u1PprEn : 1; /**< Bit 15 - PprEn: Peripheral Page Request processing Enable. */
1325 uint32_t u1GstTranslateEn : 1; /**< Bit 16 - GTEn: Guest Translate Enable. */
1326 uint32_t u1GstVirtApicEn : 1; /**< Bit 17 - GAEn: Guest Virtual-APIC Enable. */
1327 uint32_t u4Crw : 1; /**< Bits 21:18 - CRW: Intended for future use (not documented). */
1328 uint32_t u1SmiFilterEn : 1; /**< Bit 22 - SmiFEn: SMI Filter Enable. */
1329 uint32_t u1SelfWriteBackDis : 1; /**< Bit 23 - SlfWBDis: Self Write-Back Disable. */
1330 uint32_t u1SmiFilterLogEn : 1; /**< Bit 24 - SmiFLogEn: SMI Filter Log Enable. */
1331 uint32_t u3GstVirtApicModeEn : 3; /**< Bits 27:25 - GAMEn: Guest Virtual-APIC Mode Enable. */
1332 uint32_t u1GstLogEn : 1; /**< Bit 28 - GALogEn: Guest Virtual-APIC GA Log Enable. */
1333 uint32_t u1GstIntrEn : 1; /**< Bit 29 - GAIntEn: Guest Virtual-APIC Interrupt Enable. */
1334 uint32_t u2DualPprLogEn : 2; /**< Bits 31:30 - DualPprLogEn: Dual Peripheral Page Request Log Enable. */
1335 uint32_t u2DualEvtLogEn : 2; /**< Bits 33:32 - DualEventLogEn: Dual Event Log Enable. */
1336 uint32_t u3DevTabSegEn : 3; /**< Bits 36:34 - DevTblSegEn: Device Table Segment Enable. */
1337 uint32_t u2PrivAbortEn : 2; /**< Bits 38:37 - PrivAbrtEn: Privilege Abort Enable. */
1338 uint32_t u1PprAutoRespEn : 1; /**< Bit 39 - PprAutoRspEn: Peripheral Page Request Auto Response Enable. */
1339 uint32_t u1MarcEn : 1; /**< Bit 40 - MarcEn: Memory Address Routing and Control Enable. */
1340 uint32_t u1BlockStopMarkEn : 1; /**< Bit 41 - BlkStopMarkEn: Block StopMark messages Enable. */
1341 uint32_t u1PprAutoRespAlwaysOnEn : 1; /**< Bit 42 - PprAutoRspAon:: PPR Auto Response - Always On Enable. */
1342 uint32_t u1DomainIDPNE : 1; /**< Bit 43 - DomainIDPE: Reserved (not documented). */
1343 uint32_t u1Rsvd0 : 1; /**< Bit 44 - Reserved. */
1344 uint32_t u1EnhancedPpr : 1; /**< Bit 45 - EPHEn: Enhanced Peripheral Page Request Handling Enable. */
1345 uint32_t u2HstAccDirtyBitUpdate : 2; /**< Bits 47:46 - HADUpdate: Access and Dirty Bit updated in host page table. */
1346 uint32_t u1GstDirtyUpdateDis : 1; /**< Bit 48 - GDUpdateDis: Disable hardare update of Dirty bit in GPT. */
1347 uint32_t u1Rsvd1 : 1; /**< Bit 49 - Reserved. */
1348 uint32_t u1X2ApicEn : 1; /**< Bit 50 - XTEn: Enable X2APIC. */
1349 uint32_t u1X2ApicIntrGenEn : 1; /**< Bit 51 - IntCapXTEn: Enable IOMMU X2APIC Interrupt generation. */
1350 uint32_t u2Rsvd0 : 2; /**< Bits 53:52 - Reserved. */
1351 uint32_t u1GstAccessUpdateDis : 1; /**< Bit 54 - GAUpdateDis: Disable hardare update of Access bit in GPT. */
1352 uint32_t u8Rsvd0 : 8; /**< Bits 63:55 - Reserved. */
1353 } n;
1354 /** The 64-bit unsigned integer view. */
1355 uint64_t u64;
1356} IOMMU_CTRL_T;
1357AssertCompileSize(IOMMU_CTRL_T, 8);
1358#define IOMMU_CTRL_VALID_MASK UINT64_C(0x004defffffffffff)
1359#define IOMMU_CTRL_CMD_BUF_EN_MASK UINT64_C(0x0000000000001001)
1360
1361/**
1362 * IOMMU Exclusion Base Register (MMIO).
1363 * In accordance with the AMD spec.
1364 */
1365typedef union
1366{
1367 struct
1368 {
1369 RT_GCC_EXTENSION uint64_t u1ExclEnable : 1; /**< Bit 0 - ExEn: Exclusion Range Enable. */
1370 RT_GCC_EXTENSION uint64_t u1AllowAll : 1; /**< Bit 1 - Allow: Allow All Devices. */
1371 RT_GCC_EXTENSION uint64_t u10Rsvd0 : 10; /**< Bits 11:2 - Reserved. */
1372 RT_GCC_EXTENSION uint64_t u40ExclRangeBase : 40; /**< Bits 51:12 - Exclusion Range Base Address. */
1373 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 63:52 - Reserved. */
1374 } n;
1375 /** The 64-bit unsigned integer view. */
1376 uint64_t u64;
1377} IOMMU_EXCL_RANGE_BAR_T;
1378AssertCompileSize(IOMMU_EXCL_RANGE_BAR_T, 8);
1379#define IOMMU_EXCL_RANGE_BAR_VALID_MASK UINT64_C(0x000ffffffffff003)
1380
1381/**
1382 * IOMMU Exclusion Range Limit Register (MMIO).
1383 * In accordance with the AMD spec.
1384 */
1385typedef union
1386{
1387 struct
1388 {
1389 RT_GCC_EXTENSION uint64_t u52ExclLimit : 52; /**< Bits 51:0 - Exclusion Range Limit (last 12 bits are treated as 1s). */
1390 RT_GCC_EXTENSION uint64_t u12Rsvd1 : 12; /**< Bits 63:52 - Reserved. */
1391 } n;
1392 /** The 64-bit unsigned integer view. */
1393 uint64_t u64;
1394} IOMMU_EXCL_RANGE_LIMIT_T;
1395AssertCompileSize(IOMMU_EXCL_RANGE_LIMIT_T, 8);
1396#define IOMMU_EXCL_RANGE_LIMIT_VALID_MASK UINT64_C(0x000fffffffffffff)
1397
1398/**
1399 * IOMMU Extended Feature Register (MMIO).
1400 * In accordance with the AMD spec.
1401 */
1402typedef union
1403{
1404 struct
1405 {
1406 uint32_t u1PrefetchSup : 1; /**< Bit 0 - PreFSup: Prefetch Support. */
1407 uint32_t u1PprSup : 1; /**< Bit 1 - PPRSup: Peripheral Page Request Support. */
1408 uint32_t u1X2ApicSup : 1; /**< Bit 2 - XTSup: x2Apic Support. */
1409 uint32_t u1NoExecuteSup : 1; /**< Bit 3 - NXSup: No-Execute and Privilege Level Support. */
1410 uint32_t u1GstTranslateSup : 1; /**< Bit 4 - GTSup: Guest Translations (for GVAs) Support. */
1411 uint32_t u1Rsvd0 : 1; /**< Bit 5 - Reserved. */
1412 uint32_t u1InvAllSup : 1; /**< Bit 6 - IASup: Invalidate-All Support. */
1413 uint32_t u1GstVirtApicSup : 1; /**< Bit 7 - GASup: Guest Virtual-APIC Support. */
1414 uint32_t u1HwErrorSup : 1; /**< Bit 8 - HESup: Hardware Error registers Support. */
1415 uint32_t u1PerfCounterSup : 1; /**< Bit 9 - PCSup: Performance Counter Support. */
1416 uint32_t u2HostAddrTranslateSize : 2; /**< Bits 11:10 - HATS: Host Address Translation Size. */
1417 uint32_t u2GstAddrTranslateSize : 2; /**< Bits 13:12 - GATS: Guest Address Translation Size. */
1418 uint32_t u2GstCr3RootTblLevel : 2; /**< Bits 15:14 - GLXSup: Guest CR3 Root Table Level (Max) Size Support. */
1419 uint32_t u2SmiFilterSup : 2; /**< Bits 17:16 - SmiFSup: SMI Filter Register Support. */
1420 uint32_t u3SmiFilterCount : 3; /**< Bits 20:18 - SmiFRC: SMI Filter Register Count. */
1421 uint32_t u3GstVirtApicModeSup : 3; /**< Bits 23:21 - GAMSup: Guest Virtual-APIC Modes Supported. */
1422 uint32_t u2DualPprLogSup : 2; /**< Bits 25:24 - DualPprLogSup: Dual Peripheral Page Request Log Support. */
1423 uint32_t u2Rsvd0 : 2; /**< Bits 27:26 - Reserved. */
1424 uint32_t u2DualEvtLogSup : 2; /**< Bits 29:28 - DualEventLogSup: Dual Event Log Support. */
1425 uint32_t u2Rsvd1 : 2; /**< Bits 31:30 - Reserved. */
1426 uint32_t u5MaxPasidSup : 5; /**< Bits 36:32 - PASMax: Maximum PASID Supported. */
1427 uint32_t u1UserSupervisorSup : 1; /**< Bit 37 - USSup: User/Supervisor Page Protection Support. */
1428 uint32_t u2DevTabSegSup : 2; /**< Bits 39:38 - DevTlbSegSup: Segmented Device Table Support. */
1429 uint32_t u1PprLogOverflowWarn : 1; /**< Bit 40 - PprOvrflwEarlySup: PPR Log Overflow Early Warning Support. */
1430 uint32_t u1PprAutoRespSup : 1; /**< Bit 41 - PprAutoRspSup: PPR Automatic Response Support. */
1431 uint32_t u2MarcSup : 2; /**< Bit 43:42 - MarcSup: Memory Access Routing and Control Support. */
1432 uint32_t u1BlockStopMarkSup : 1; /**< Bit 44 - BlkStopMarkSup: Block StopMark messages Support. */
1433 uint32_t u1PerfOptSup : 1; /**< Bit 45 - PerfOptSup: IOMMU Performance Optimization Support. */
1434 uint32_t u1MsiCapMmioSup : 1; /**< Bit 46 - MsiCapMmioSup: MSI Capability Register MMIO Access Support. */
1435 uint32_t u1Rsvd1 : 1; /**< Bit 47 - Reserved. */
1436 uint32_t u1GstIoSup : 1; /**< Bit 48 - GIoSup: Guest I/O Protection Support. */
1437 uint32_t u1HostAccessSup : 1; /**< Bit 49 - HASup: Host Access Support. */
1438 uint32_t u1EnhancedPprSup : 1; /**< Bit 50 - EPHSup: Enhanced Peripheral Page Request Handling Support. */
1439 uint32_t u1AttrForwardSup : 1; /**< Bit 51 - AttrFWSup: Attribute Forward Support. */
1440 uint32_t u1HostDirtySup : 1; /**< Bit 52 - HDSup: Host Dirty Support. */
1441 uint32_t u1Rsvd2 : 1; /**< Bit 53 - Reserved. */
1442 uint32_t u1InvIoTlbTypeSup : 1; /**< Bit 54 - InvIotlbTypeSup: Invalidate IOTLB Type Support. */
1443 uint32_t u6Rsvd0 : 6; /**< Bit 60:55 - Reserved. */
1444 uint32_t u1GstUpdateDisSup : 1; /**< Bit 61 - GAUpdateDisSup: Disable hardware update on GPT Support. */
1445 uint32_t u1ForcePhysDstSup : 1; /**< Bit 62 - ForcePhyDestSup: Force Phys. Dst. Mode for Remapped Intr. */
1446 uint32_t u1Rsvd3 : 1; /**< Bit 63 - Reserved. */
1447 } n;
1448 /** The 64-bit unsigned integer view. */
1449 uint64_t u64;
1450} IOMMU_EXT_FEAT_T;
1451AssertCompileSize(IOMMU_EXT_FEAT_T, 8);
1452
1453/**
1454 * Peripheral Page Request Log Base Address Register (MMIO).
1455 * In accordance with the AMD spec.
1456 */
1457typedef union
1458{
1459 struct
1460 {
1461 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bit 11:0 - Reserved. */
1462 RT_GCC_EXTENSION uint64_t u40Base : 40; /**< Bits 51:12 - PPRLogBase: Peripheral Page Request Log Base Address. */
1463 RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 55:52 - Reserved. */
1464 RT_GCC_EXTENSION uint64_t u4Len : 4; /**< Bits 59:56 - PPRLogLen: Peripheral Page Request Log Length. */
1465 RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; /**< Bits 63:60 - Reserved. */
1466 } n;
1467 /** The 64-bit unsigned integer view. */
1468 uint64_t u64;
1469} PPR_LOG_BAR_T;
1470AssertCompileSize(PPR_LOG_BAR_T, 8);
1471#define IOMMU_PPR_LOG_BAR_VALID_MASK UINT64_C(0x0f0ffffffffff000)
1472
1473/**
1474 * IOMMU Hardware Event Upper Register (MMIO).
1475 * In accordance with the AMD spec.
1476 */
1477typedef union
1478{
1479 struct
1480 {
1481 RT_GCC_EXTENSION uint64_t u60FirstOperand : 60; /**< Bits 59:0 - First event code dependent operand. */
1482 RT_GCC_EXTENSION uint64_t u4EvtCode : 4; /**< Bits 63:60 - Event Code. */
1483 } n;
1484 /** The 64-bit unsigned integer view. */
1485 uint64_t u64;
1486} IOMMU_HW_EVT_HI_T;
1487AssertCompileSize(IOMMU_HW_EVT_HI_T, 8);
1488
1489/**
1490 * IOMMU Hardware Event Lower Register (MMIO).
1491 * In accordance with the AMD spec.
1492 */
1493typedef uint64_t IOMMU_HW_EVT_LO_T;
1494
1495/**
1496 * IOMMU Hardware Event Status (MMIO).
1497 * In accordance with the AMD spec.
1498 */
1499typedef union
1500{
1501 struct
1502 {
1503 uint32_t u1Valid : 1; /**< Bit 0 - HEV: Hardware Event Valid. */
1504 uint32_t u1Overflow : 1; /**< Bit 1 - HEO: Hardware Event Overflow. */
1505 uint32_t u30Rsvd0 : 30; /**< Bits 31:2 - Reserved. */
1506 uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved. */
1507 } n;
1508 /** The 64-bit unsigned integer view. */
1509 uint64_t u64;
1510} IOMMU_HW_EVT_STATUS_T;
1511AssertCompileSize(IOMMU_HW_EVT_STATUS_T, 8);
1512#define IOMMU_HW_EVT_STATUS_VALID_MASK UINT64_C(0x0000000000000003)
1513
1514/**
1515 * Guest Virtual-APIC Log Base Address Register (MMIO).
1516 * In accordance with the AMD spec.
1517 */
1518typedef union
1519{
1520 struct
1521 {
1522 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bit 11:0 - Reserved. */
1523 RT_GCC_EXTENSION uint64_t u40Base : 40; /**< Bits 51:12 - GALogBase: Guest Virtual-APIC Log Base Address. */
1524 RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 55:52 - Reserved. */
1525 RT_GCC_EXTENSION uint64_t u4Len : 4; /**< Bits 59:56 - GALogLen: Guest Virtual-APIC Log Length. */
1526 RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; /**< Bits 63:60 - Reserved. */
1527 } n;
1528 /** The 64-bit unsigned integer view. */
1529 uint64_t u64;
1530} GALOG_BAR_T;
1531AssertCompileSize(GALOG_BAR_T, 8);
1532
1533/**
1534 * Guest Virtual-APIC Log Tail Address Register (MMIO).
1535 * In accordance with the AMD spec.
1536 */
1537typedef union
1538{
1539 struct
1540 {
1541 RT_GCC_EXTENSION uint64_t u3Rsvd0 : 3; /**< Bits 2:0 - Reserved. */
1542 RT_GCC_EXTENSION uint64_t u40GALogTailAddr : 48; /**< Bits 51:3 - GATAddr: Guest Virtual-APIC Tail Log Address. */
1543 RT_GCC_EXTENSION uint64_t u11Rsvd1 : 11; /**< Bits 63:52 - Reserved. */
1544 } n;
1545 /** The 64-bit unsigned integer view. */
1546 uint64_t u64;
1547} GALOG_TAIL_ADDR_T;
1548AssertCompileSize(GALOG_TAIL_ADDR_T, 8);
1549
1550/**
1551 * PPR Log B Base Address Register (MMIO).
1552 * In accordance with the AMD spec.
1553 * Currently identical to PPR_LOG_BAR_T.
1554 */
1555typedef PPR_LOG_BAR_T PPR_LOG_B_BAR_T;
1556
1557/**
1558 * Event Log B Base Address Register (MMIO).
1559 * In accordance with the AMD spec.
1560 * Currently identical to EVT_LOG_BAR_T.
1561 */
1562typedef EVT_LOG_BAR_T EVT_LOG_B_BAR_T;
1563
1564/**
1565 * Device-specific Feature Extension (DSFX) Register (MMIO).
1566 * In accordance with the AMD spec.
1567 */
1568typedef union
1569{
1570 struct
1571 {
1572 uint32_t u24DevSpecFeat : 24; /**< Bits 23:0 - DevSpecificFeatSupp: Implementation specific features. */
1573 uint32_t u4RevMinor : 4; /**< Bits 27:24 - RevMinor: Minor revision identifier. */
1574 uint32_t u4RevMajor : 4; /**< Bits 31:28 - RevMajor: Major revision identifier. */
1575 uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved.*/
1576 } n;
1577 /** The 64-bit unsigned integer view. */
1578 uint64_t u64;
1579} DEV_SPECIFIC_FEAT_T;
1580AssertCompileSize(DEV_SPECIFIC_FEAT_T, 8);
1581
1582/**
1583 * Device-specific Control Extension (DSCX) Register (MMIO).
1584 * In accordance with the AMD spec.
1585 */
1586typedef union
1587{
1588 struct
1589 {
1590 uint32_t u24DevSpecCtrl : 24; /**< Bits 23:0 - DevSpecificFeatCntrl: Implementation specific control. */
1591 uint32_t u4RevMinor : 4; /**< Bits 27:24 - RevMinor: Minor revision identifier. */
1592 uint32_t u4RevMajor : 4; /**< Bits 31:28 - RevMajor: Major revision identifier. */
1593 uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved.*/
1594 } n;
1595 /** The 64-bit unsigned integer view. */
1596 uint64_t u64;
1597} DEV_SPECIFIC_CTRL_T;
1598AssertCompileSize(DEV_SPECIFIC_CTRL_T, 8);
1599
1600/**
1601 * Device-specific Status Extension (DSSX) Register (MMIO).
1602 * In accordance with the AMD spec.
1603 */
1604typedef union
1605{
1606 struct
1607 {
1608 uint32_t u24DevSpecStatus : 24; /**< Bits 23:0 - DevSpecificFeatStatus: Implementation specific status. */
1609 uint32_t u4RevMinor : 4; /**< Bits 27:24 - RevMinor: Minor revision identifier. */
1610 uint32_t u4RevMajor : 4; /**< Bits 31:28 - RevMajor: Major revision identifier. */
1611 uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved.*/
1612 } n;
1613 /** The 64-bit unsigned integer view. */
1614 uint64_t u64;
1615} DEV_SPECIFIC_STATUS_T;
1616AssertCompileSize(DEV_SPECIFIC_STATUS_T, 8);
1617
1618/**
1619 * MSI Information Register 0 and 1 (PCI) / MSI Vector Register 0 and 1 (MMIO).
1620 * In accordance with the AMD spec.
1621 */
1622typedef union
1623{
1624 struct
1625 {
1626 uint32_t u5MsiNumEvtLog : 5; /**< Bits 4:0 - MsiNum: Event Log MSI message number. */
1627 uint32_t u3GstVirtAddrSize: 3; /**< Bits 7:5 - GVAsize: Guest Virtual Address Size. */
1628 uint32_t u7PhysAddrSize : 7; /**< Bits 14:8 - PAsize: Physical Address Size. */
1629 uint32_t u7VirtAddrSize : 7; /**< Bits 21:15 - VAsize: Virtual Address Size. */
1630 uint32_t u1HtAtsResv: 1; /**< Bit 22 - HtAtsResv: HyperTransport ATS Response Address range Reserved. */
1631 uint32_t u4Rsvd0 : 4; /**< Bits 26:23 - Reserved. */
1632 uint32_t u5MsiNumPpr : 5; /**< Bits 31:27 - MsiNumPPR: Peripheral Page Request MSI message number. */
1633 uint32_t u5MsiNumGa : 5; /**< Bits 36:32 - MsiNumGa: MSI message number for guest virtual-APIC log. */
1634 uint32_t u27Rsvd0: 27; /**< Bits 63:37 - Reserved. */
1635 } n;
1636 /** The 32-bit unsigned integer view. */
1637 uint32_t au32[2];
1638 /** The 64-bit unsigned integer view. */
1639 uint64_t u64;
1640} MSI_MISC_INFO_T;
1641AssertCompileSize(MSI_MISC_INFO_T, 8);
1642/** MSI Vector Register 0 and 1 (MMIO). */
1643typedef MSI_MISC_INFO_T MSI_VECTOR_T;
1644/** Mask of valid bits in MSI Vector Register 1 (or high dword of MSI Misc.
1645 * info). */
1646#define IOMMU_MSI_VECTOR_1_VALID_MASK UINT32_C(0x1f)
1647
1648/**
1649 * MSI Capability Header Register (PCI + MMIO).
1650 * In accordance with the AMD spec.
1651 */
1652typedef union
1653{
1654 struct
1655 {
1656 uint32_t u8MsiCapId : 8; /**< Bits 7:0 - MsiCapId: Capability ID. */
1657 uint32_t u8MsiCapPtr : 8; /**< Bits 15:8 - MsiCapPtr: Pointer (PCI config offset) to the next capability. */
1658 uint32_t u1MsiEnable : 1; /**< Bit 16 - MsiEn: Message Signal Interrupt Enable. */
1659 uint32_t u3MsiMultiMessCap : 3; /**< Bits 19:17 - MsiMultMessCap: MSI Multi-Message Capability. */
1660 uint32_t u3MsiMultiMessEn : 3; /**< Bits 22:20 - MsiMultMessEn: MSI Multi-Message Enable. */
1661 uint32_t u1Msi64BitEn : 1; /**< Bit 23 - Msi64BitEn: MSI 64-bit Enable. */
1662 uint32_t u8Rsvd0 : 8; /**< Bits 31:24 - Reserved. */
1663 } n;
1664 /** The 32-bit unsigned integer view. */
1665 uint32_t u32;
1666} MSI_CAP_HDR_T;
1667AssertCompileSize(MSI_CAP_HDR_T, 4);
1668#define IOMMU_MSI_CAP_HDR_MSI_EN_MASK RT_BIT(16)
1669
1670/**
1671 * MSI Mapping Capability Header Register (PCI + MMIO).
1672 * In accordance with the AMD spec.
1673 */
1674typedef union
1675{
1676 struct
1677 {
1678 uint32_t u8MsiMapCapId : 8; /**< Bits 7:0 - MsiMapCapId: MSI Map capability ID. */
1679 uint32_t u8Rsvd0 : 8; /**< Bits 15:8 - Reserved. */
1680 uint32_t u1MsiMapEn : 1; /**< Bit 16 - MsiMapEn: MSI Map enable. */
1681 uint32_t u1MsiMapFixed : 1; /**< Bit 17 - MsiMapFixd: MSI Map fixed. */
1682 uint32_t u9Rsvd0 : 9; /**< Bits 26:18 - Reserved. */
1683 uint32_t u5MapCapType : 5; /**< Bits 31:27 - MsiMapCapType: MSI Mapping capability type. */
1684 } n;
1685 /** The 32-bit unsigned integer view. */
1686 uint32_t u32;
1687} MSI_MAP_CAP_HDR_T;
1688AssertCompileSize(MSI_MAP_CAP_HDR_T, 4);
1689
1690/**
1691 * Performance Optimization Control Register (MMIO).
1692 * In accordance with the AMD spec.
1693 */
1694typedef union
1695{
1696 struct
1697 {
1698 uint32_t u13Rsvd0 : 13; /**< Bits 12:0 - Reserved. */
1699 uint32_t u1PerfOptEn : 1; /**< Bit 13 - PerfOptEn: Performance Optimization Enable. */
1700 uint32_t u17Rsvd0 : 18; /**< Bits 31:14 - Reserved. */
1701 } n;
1702 /** The 32-bit unsigned integer view. */
1703 uint32_t u32;
1704} IOMMU_PERF_OPT_CTRL_T;
1705AssertCompileSize(IOMMU_PERF_OPT_CTRL_T, 4);
1706
1707/**
1708 * XT (x2APIC) IOMMU General Interrupt Control Register (MMIO).
1709 * In accordance with the AMD spec.
1710 */
1711typedef union
1712{
1713 struct
1714 {
1715 uint32_t u2Rsvd0 : 2; /**< Bits 1:0 - Reserved.*/
1716 uint32_t u1X2ApicIntrDstMode : 1; /**< Bit 2 - Destination Mode for general interrupt.*/
1717 uint32_t u4Rsvd0 : 4; /**< Bits 7:3 - Reserved.*/
1718 uint32_t u24X2ApicIntrDstLo : 24; /**< Bits 31:8 - Destination for general interrupt (Lo).*/
1719 uint32_t u8X2ApicIntrVector : 8; /**< Bits 39:32 - Vector for general interrupt.*/
1720 uint32_t u1X2ApicIntrDeliveryMode : 1; /**< Bit 40 - Delivery Mode for general interrupt.*/
1721 uint32_t u15Rsvd0 : 15; /**< Bits 55:41 - Reserved.*/
1722 uint32_t u7X2ApicIntrDstHi : 7; /**< Bits 63:56 - Destination for general interrupt (Hi) .*/
1723 } n;
1724 /** The 64-bit unsigned integer view. */
1725 uint64_t u64;
1726} IOMMU_XT_GEN_INTR_CTRL_T;
1727AssertCompileSize(IOMMU_XT_GEN_INTR_CTRL_T, 8);
1728
1729/**
1730 * XT (x2APIC) IOMMU General Interrupt Control Register (MMIO).
1731 * In accordance with the AMD spec.
1732 */
1733typedef union
1734{
1735 struct
1736 {
1737 uint32_t u2Rsvd0 : 2; /**< Bits 1:0 - Reserved.*/
1738 uint32_t u1X2ApicIntrDstMode : 1; /**< Bit 2 - Destination Mode for the interrupt.*/
1739 uint32_t u4Rsvd0 : 4; /**< Bits 7:3 - Reserved.*/
1740 uint32_t u24X2ApicIntrDstLo : 24; /**< Bits 31:8 - Destination for the interrupt (Lo).*/
1741 uint32_t u8X2ApicIntrVector : 8; /**< Bits 39:32 - Vector for the interrupt.*/
1742 uint32_t u1X2ApicIntrDeliveryMode : 1; /**< Bit 40 - Delivery Mode for the interrupt.*/
1743 uint32_t u15Rsvd0 : 15; /**< Bits 55:41 - Reserved.*/
1744 uint32_t u7X2ApicIntrDstHi : 7; /**< Bits 63:56 - Destination for the interrupt (Hi) .*/
1745 } n;
1746 /** The 64-bit unsigned integer view. */
1747 uint64_t u64;
1748} IOMMU_XT_INTR_CTRL_T;
1749AssertCompileSize(IOMMU_XT_INTR_CTRL_T, 8);
1750
1751/**
1752 * XT (x2APIC) IOMMU PPR Interrupt Control Register (MMIO).
1753 * In accordance with the AMD spec.
1754 * Currently identical to IOMMU_XT_INTR_CTRL_T.
1755 */
1756typedef IOMMU_XT_INTR_CTRL_T IOMMU_XT_PPR_INTR_CTRL_T;
1757
1758/**
1759 * XT (x2APIC) IOMMU GA (Guest Address) Log Control Register (MMIO).
1760 * In accordance with the AMD spec.
1761 * Currently identical to IOMMU_XT_INTR_CTRL_T.
1762 */
1763typedef IOMMU_XT_INTR_CTRL_T IOMMU_XT_GALOG_INTR_CTRL_T;
1764
1765/**
1766 * Memory Access and Routing Control (MARC) Aperture Base Register (MMIO).
1767 * In accordance with the AMD spec.
1768 */
1769typedef union
1770{
1771 struct
1772 {
1773 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 11:0 - Reserved. */
1774 RT_GCC_EXTENSION uint64_t u40MarcBaseAddr : 40; /**< Bits 51:12 - MarcBaseAddr: MARC Aperture Base Address. */
1775 RT_GCC_EXTENSION uint64_t u12Rsvd1 : 12; /**< Bits 63:52 - Reserved. */
1776 } n;
1777 /** The 64-bit unsigned integer view. */
1778 uint64_t u64;
1779} MARC_APER_BAR_T;
1780AssertCompileSize(MARC_APER_BAR_T, 8);
1781
1782/**
1783 * Memory Access and Routing Control (MARC) Relocation Register (MMIO).
1784 * In accordance with the AMD spec.
1785 */
1786typedef union
1787{
1788 struct
1789 {
1790 RT_GCC_EXTENSION uint64_t u1RelocEn : 1; /**< Bit 0 - RelocEn: Relocation Enabled. */
1791 RT_GCC_EXTENSION uint64_t u1ReadOnly : 1; /**< Bit 1 - ReadOnly: Whether only read-only acceses allowed. */
1792 RT_GCC_EXTENSION uint64_t u10Rsvd0 : 10; /**< Bits 11:2 - Reserved. */
1793 RT_GCC_EXTENSION uint64_t u40MarcRelocAddr : 40; /**< Bits 51:12 - MarcRelocAddr: MARC Aperture Relocation Address. */
1794 RT_GCC_EXTENSION uint64_t u12Rsvd1 : 12; /**< Bits 63:52 - Reserved. */
1795 } n;
1796 /** The 64-bit unsigned integer view. */
1797 uint64_t u64;
1798} MARC_APER_RELOC_T;
1799AssertCompileSize(MARC_APER_RELOC_T, 8);
1800
1801/**
1802 * Memory Access and Routing Control (MARC) Length Register (MMIO).
1803 * In accordance with the AMD spec.
1804 */
1805typedef union
1806{
1807 struct
1808 {
1809 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 11:0 - Reserved. */
1810 RT_GCC_EXTENSION uint64_t u40MarcLength : 40; /**< Bits 51:12 - MarcLength: MARC Aperture Length. */
1811 RT_GCC_EXTENSION uint64_t u12Rsvd1 : 12; /**< Bits 63:52 - Reserved. */
1812 } n;
1813 /** The 64-bit unsigned integer view. */
1814 uint64_t u64;
1815} MARC_APER_LEN_T;
1816
1817/**
1818 * Memory Access and Routing Control (MARC) Aperture Register.
1819 * This combines other registers to match the MMIO layout for convenient access.
1820 */
1821typedef struct
1822{
1823 MARC_APER_BAR_T Base;
1824 MARC_APER_RELOC_T Reloc;
1825 MARC_APER_LEN_T Length;
1826} MARC_APER_T;
1827AssertCompileSize(MARC_APER_T, 24);
1828
1829/**
1830 * IOMMU Reserved Register (MMIO).
1831 * In accordance with the AMD spec.
1832 * This register is reserved for hardware use (although RW?).
1833 */
1834typedef uint64_t IOMMU_RSVD_REG_T;
1835
1836/**
1837 * Command Buffer Head Pointer Register (MMIO).
1838 * In accordance with the AMD spec.
1839 */
1840typedef union
1841{
1842 struct
1843 {
1844 uint32_t off; /**< Bits 31:0 - Buffer pointer (offset; 16 byte aligned, 512 KB max). */
1845 uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved. */
1846 } n;
1847 /** The 32-bit unsigned integer view. */
1848 uint32_t au32[2];
1849 /** The 64-bit unsigned integer view. */
1850 uint64_t u64;
1851} CMD_BUF_HEAD_PTR_T;
1852AssertCompileSize(CMD_BUF_HEAD_PTR_T, 8);
1853#define IOMMU_CMD_BUF_HEAD_PTR_VALID_MASK UINT64_C(0x000000000007fff0)
1854
1855/**
1856 * Command Buffer Tail Pointer Register (MMIO).
1857 * In accordance with the AMD spec.
1858 * Currently identical to CMD_BUF_HEAD_PTR_T.
1859 */
1860typedef CMD_BUF_HEAD_PTR_T CMD_BUF_TAIL_PTR_T;
1861#define IOMMU_CMD_BUF_TAIL_PTR_VALID_MASK IOMMU_CMD_BUF_HEAD_PTR_VALID_MASK
1862
1863/**
1864 * Event Log Head Pointer Register (MMIO).
1865 * In accordance with the AMD spec.
1866 * Currently identical to CMD_BUF_HEAD_PTR_T.
1867 */
1868typedef CMD_BUF_HEAD_PTR_T EVT_LOG_HEAD_PTR_T;
1869#define IOMMU_EVT_LOG_HEAD_PTR_VALID_MASK IOMMU_CMD_BUF_HEAD_PTR_VALID_MASK
1870
1871/**
1872 * Event Log Tail Pointer Register (MMIO).
1873 * In accordance with the AMD spec.
1874 * Currently identical to CMD_BUF_HEAD_PTR_T.
1875 */
1876typedef CMD_BUF_HEAD_PTR_T EVT_LOG_TAIL_PTR_T;
1877#define IOMMU_EVT_LOG_TAIL_PTR_VALID_MASK IOMMU_CMD_BUF_HEAD_PTR_VALID_MASK
1878
1879
1880/**
1881 * IOMMU Status Register (MMIO).
1882 * In accordance with the AMD spec.
1883 */
1884typedef union
1885{
1886 struct
1887 {
1888 uint32_t u1EvtOverflow : 1; /**< Bit 0 - EventOverflow: Event log overflow. */
1889 uint32_t u1EvtLogIntr : 1; /**< Bit 1 - EventLogInt: Event log interrupt. */
1890 uint32_t u1CompWaitIntr : 1; /**< Bit 2 - ComWaitInt: Completion wait interrupt . */
1891 uint32_t u1EvtLogRunning : 1; /**< Bit 3 - EventLogRun: Event logging is running. */
1892 uint32_t u1CmdBufRunning : 1; /**< Bit 4 - CmdBufRun: Command buffer is running. */
1893 uint32_t u1PprOverflow : 1; /**< Bit 5 - PprOverflow: Peripheral Page Request Log (PPR) overflow. */
1894 uint32_t u1PprIntr : 1; /**< Bit 6 - PprInt: PPR interrupt. */
1895 uint32_t u1PprLogRunning : 1; /**< Bit 7 - PprLogRun: PPR logging is running. */
1896 uint32_t u1GstLogRunning : 1; /**< Bit 8 - GALogRun: Guest virtual-APIC logging is running. */
1897 uint32_t u1GstLogOverflow : 1; /**< Bit 9 - GALOverflow: Guest virtual-APIC log overflow. */
1898 uint32_t u1GstLogIntr : 1; /**< Bit 10 - GAInt: Guest virtual-APIC log interrupt. */
1899 uint32_t u1PprOverflowB : 1; /**< Bit 11 - PprOverflowB: PPR log B overflow. */
1900 uint32_t u1PprLogActive : 1; /**< Bit 12 - PprLogActive: PPR log A is active. */
1901 uint32_t u2Rsvd0 : 2; /**< Bits 14:13 - Reserved. */
1902 uint32_t u1EvtOverflowB : 1; /**< Bit 15 - EvtOverflowB: Event log B overflow. */
1903 uint32_t u1EvtLogActive : 1; /**< Bit 16 - EvtLogActive: Event log A active. */
1904 uint32_t u1PprOverflowEarlyB : 1; /**< Bit 17 - PprOverflowEarlyB: PPR log B overflow early warning. */
1905 uint32_t u1PprOverflowEarly : 1; /**< Bit 18 - PprOverflowEarly: PPR log overflow early warning. */
1906 uint32_t u13Rsvd0 : 13; /**< Bits 31:19 - Reserved. */
1907 uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved . */
1908 } n;
1909 /** The 32-bit unsigned integer view. */
1910 uint32_t au32[2];
1911 /** The 64-bit unsigned integer view. */
1912 uint64_t u64;
1913} IOMMU_STATUS_T;
1914AssertCompileSize(IOMMU_STATUS_T, 8);
1915#define IOMMU_STATUS_VALID_MASK UINT64_C(0x0000000000079fff)
1916#define IOMMU_STATUS_RW1C_MASK UINT64_C(0x0000000000068e67)
1917
1918/**
1919 * PPR Log Head Pointer Register (MMIO).
1920 * In accordance with the AMD spec.
1921 * Currently identical to CMD_BUF_HEAD_PTR_T.
1922 */
1923typedef CMD_BUF_HEAD_PTR_T PPR_LOG_HEAD_PTR_T;
1924
1925/**
1926 * PPR Log Tail Pointer Register (MMIO).
1927 * In accordance with the AMD spec.
1928 * Currently identical to CMD_BUF_HEAD_PTR_T.
1929 */
1930typedef CMD_BUF_HEAD_PTR_T PPR_LOG_TAIL_PTR_T;
1931
1932/**
1933 * Guest Virtual-APIC Log Head Pointer Register (MMIO).
1934 * In accordance with the AMD spec.
1935 */
1936typedef union
1937{
1938 struct
1939 {
1940 uint32_t u2Rsvd0 : 2; /**< Bits 2:0 - Reserved. */
1941 uint32_t u12GALogPtr : 12; /**< Bits 15:3 - Guest Virtual-APIC Log Head or Tail Pointer. */
1942 uint32_t u16Rsvd0 : 16; /**< Bits 31:16 - Reserved. */
1943 uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved. */
1944 } n;
1945 /** The 32-bit unsigned integer view. */
1946 uint32_t au32[2];
1947 /** The 64-bit unsigned integer view. */
1948 uint64_t u64;
1949} GALOG_HEAD_PTR_T;
1950AssertCompileSize(GALOG_HEAD_PTR_T, 8);
1951
1952/**
1953 * Guest Virtual-APIC Log Tail Pointer Register (MMIO).
1954 * In accordance with the AMD spec.
1955 * Currently identical to GALOG_HEAD_PTR_T.
1956 */
1957typedef GALOG_HEAD_PTR_T GALOG_TAIL_PTR_T;
1958
1959/**
1960 * PPR Log B Head Pointer Register (MMIO).
1961 * In accordance with the AMD spec.
1962 * Currently identical to CMD_BUF_HEAD_PTR_T.
1963 */
1964typedef CMD_BUF_HEAD_PTR_T PPR_LOG_B_HEAD_PTR_T;
1965
1966/**
1967 * PPR Log B Tail Pointer Register (MMIO).
1968 * In accordance with the AMD spec.
1969 * Currently identical to CMD_BUF_HEAD_PTR_T.
1970 */
1971typedef CMD_BUF_HEAD_PTR_T PPR_LOG_B_TAIL_PTR_T;
1972
1973/**
1974 * Event Log B Head Pointer Register (MMIO).
1975 * In accordance with the AMD spec.
1976 * Currently identical to CMD_BUF_HEAD_PTR_T.
1977 */
1978typedef CMD_BUF_HEAD_PTR_T EVT_LOG_B_HEAD_PTR_T;
1979
1980/**
1981 * Event Log B Tail Pointer Register (MMIO).
1982 * In accordance with the AMD spec.
1983 * Currently identical to CMD_BUF_HEAD_PTR_T.
1984 */
1985typedef CMD_BUF_HEAD_PTR_T EVT_LOG_B_TAIL_PTR_T;
1986
1987/**
1988 * PPR Log Auto Response Register (MMIO).
1989 * In accordance with the AMD spec.
1990 */
1991typedef union
1992{
1993 struct
1994 {
1995 uint32_t u4AutoRespCode : 4; /**< Bits 3:0 - PprAutoRespCode: PPR log Auto Response Code. */
1996 uint32_t u1AutoRespMaskGen : 1; /**< Bit 4 - PprAutoRespMaskGn: PPR log Auto Response Mask Gen. */
1997 uint32_t u27Rsvd0 : 27; /**< Bits 31:5 - Reserved. */
1998 uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved.*/
1999 } n;
2000 /** The 32-bit unsigned integer view. */
2001 uint32_t au32[2];
2002 /** The 64-bit unsigned integer view. */
2003 uint64_t u64;
2004} PPR_LOG_AUTO_RESP_T;
2005AssertCompileSize(PPR_LOG_AUTO_RESP_T, 8);
2006
2007/**
2008 * PPR Log Overflow Early Indicator Register (MMIO).
2009 * In accordance with the AMD spec.
2010 */
2011typedef union
2012{
2013 struct
2014 {
2015 uint32_t u15Threshold : 15; /**< Bits 14:0 - PprOvrflwEarlyThreshold: Overflow early indicator threshold. */
2016 uint32_t u15Rsvd0 : 15; /**< Bits 29:15 - Reserved. */
2017 uint32_t u1IntrEn : 1; /**< Bit 30 - PprOvrflwEarlyIntEn: Overflow early indicator interrupt enable. */
2018 uint32_t u1Enable : 1; /**< Bit 31 - PprOvrflwEarlyEn: Overflow early indicator enable. */
2019 uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved. */
2020 } n;
2021 /** The 32-bit unsigned integer view. */
2022 uint32_t au32[2];
2023 /** The 64-bit unsigned integer view. */
2024 uint64_t u64;
2025} PPR_LOG_OVERFLOW_EARLY_T;
2026AssertCompileSize(PPR_LOG_OVERFLOW_EARLY_T, 8);
2027
2028/**
2029 * PPR Log B Overflow Early Indicator Register (MMIO).
2030 * In accordance with the AMD spec.
2031 * Currently identical to PPR_LOG_OVERFLOW_EARLY_T.
2032 */
2033typedef PPR_LOG_OVERFLOW_EARLY_T PPR_LOG_B_OVERFLOW_EARLY_T;
2034
2035/**
2036 * ILLEGAL_DEV_TABLE_ENTRY Event Types.
2037 * In accordance with the AMD spec.
2038 */
2039typedef enum EVT_ILLEGAL_DTE_TYPE_T
2040{
2041 kIllegalDteType_RsvdNotZero = 0,
2042 kIllegalDteType_RsvdIntTabLen,
2043 kIllegalDteType_RsvdIoCtl,
2044 kIllegalDteType_RsvdIntCtl
2045} EVT_ILLEGAL_DTE_TYPE_T;
2046
2047/**
2048 * ILLEGAL_DEV_TABLE_ENTRY Event Types.
2049 * In accordance with the AMD spec.
2050 */
2051typedef enum EVT_IO_PAGE_FAULT_TYPE_T
2052{
2053 /* Memory transaction. */
2054 kIoPageFaultType_DteRsvdPagingMode = 0,
2055 kIoPageFaultType_PteInvalidPageSize,
2056 kIoPageFaultType_PteInvalidLvlEncoding,
2057 kIoPageFaultType_SkippedLevelIovaNotZero,
2058 kIoPageFaultType_PteRsvdNotZero,
2059 kIoPageFaultType_PteValidNotSet,
2060 kIoPageFaultType_DteTranslationDisabled,
2061 kIoPageFaultType_PasidInvalidRange,
2062 kIoPageFaultType_PermDenied,
2063 kIoPageFaultType_UserSupervisor,
2064 /* Interrupt remapping */
2065 kIoPageFaultType_IrteAddrInvalid,
2066 kIoPageFaultType_IrteRsvdNotZero,
2067 kIoPageFaultType_IrteRemapEn,
2068 kIoPageFaultType_IrteRsvdIntType,
2069 kIoPageFaultType_IntrReqAborted,
2070 kIoPageFaultType_IntrWithPasid,
2071 kIoPageFaultType_SmiFilterMismatch,
2072 /* Memory transaction or interrupt remapping. */
2073 kIoPageFaultType_DevId_Invalid
2074} EVT_IO_PAGE_FAULT_TYPE_T;
2075
2076/**
2077 * IOTLB_INV_TIMEOUT Event Types.
2078 * In accordance with the AMD spec.
2079 */
2080typedef enum EVT_IOTLB_INV_TIMEOUT_TYPE_T
2081{
2082 InvTimeoutType_NoResponse = 0
2083} EVT_IOTLB_INV_TIMEOUT_TYPE_T;
2084
2085/**
2086 * INVALID_DEVICE_REQUEST Event Types.
2087 * In accordance with the AMD spec.
2088 */
2089typedef enum EVT_INVALID_DEV_REQ_TYPE_T
2090{
2091 /* Access. */
2092 kInvalidDevReqType_ReadOrNonPostedWrite = 0,
2093 kInvalidDevReqType_PretranslatedTransaction,
2094 kInvalidDevReqType_PortIo,
2095 kInvalidDevReqType_SysMgt,
2096 kInvalidDevReqType_IntrRange,
2097 kInvalidDevReqType_RsvdIntrRange,
2098 kInvalidDevReqType_SysMgtAddr,
2099 /* Translation Request. */
2100 kInvalidDevReqType_TrAccessInvalid,
2101 kInvalidDevReqType_TrDisabled,
2102 kInvalidDevReqType_DevIdInvalid
2103} EVT_INVALID_DEV_REQ_TYPE_T;
2104
2105/**
2106 * INVALID_PPR_REQUEST Event Types.
2107 * In accordance with the AMD spec.
2108 */
2109typedef enum EVT_INVALID_PPR_REQ_TYPE_T
2110{
2111 kInvalidPprReqType_PriNotSupported,
2112 kInvalidPprReqType_GstTranslateDisabled
2113} EVT_INVALID_PPR_REQ_TYPE_T;
2114
2115
2116/** @name IVRS format revision field.
2117 * In accordance with the AMD spec.
2118 * @{ */
2119/** Fixed: Supports only pre-assigned device IDs and type 10h and 11h IVHD
2120 * blocks. */
2121#define ACPI_IVRS_FMT_REV_FIXED 0x1
2122/** Mixed: Supports pre-assigned and ACPI HID device naming and all IVHD blocks. */
2123#define ACPI_IVRS_FMT_REV_MIXED 0x2
2124/** @} */
2125
2126/** @name IVHD special device entry variety field.
2127 * In accordance with the AMD spec.
2128 * @{ */
2129/** I/O APIC. */
2130#define ACPI_IVHD_VARIETY_IOAPIC 0x1
2131/** HPET. */
2132#define ACPI_IVHD_VARIETY_HPET 0x2
2133/** @} */
2134
2135/** @name IVHD device entry type codes.
2136 * In accordance with the AMD spec.
2137 * @{ */
2138/** Reserved. */
2139#define ACPI_IVHD_DEVENTRY_TYPE_RSVD 0x0
2140/** All: DTE setting applies to all Device IDs. */
2141#define ACPI_IVHD_DEVENTRY_TYPE_ALL 0x1
2142/** Select: DTE setting applies to the device specified in DevId field. */
2143#define ACPI_IVHD_DEVENTRY_TYPE_SELECT 0x2
2144/** Start of range: DTE setting applies to all devices from start of range specified
2145 * by the DevId field. */
2146#define ACPI_IVHD_DEVENTRY_TYPE_START_RANGE 0x3
2147/** End of range: DTE setting from previous type 3 entry applies to all devices
2148 * incl. DevId specified by this entry. */
2149#define ACPI_IVHD_DEVENTRY_TYPE_END_RANGE 0x4
2150/** @} */
2151
2152/** @name IVHD DTE (Device Table Entry) Settings.
2153 * In accordance with the AMD spec.
2154 * @{ */
2155/** INITPass: Identifies a device able to assert INIT interrupts. */
2156#define ACPI_IVHD_DTE_INIT_PASS_SHIFT 0
2157#define ACPI_IVHD_DTE_INIT_PASS_MASK UINT8_C(0x01)
2158/** EIntPass: Identifies a device able to assert ExtInt interrupts. */
2159#define ACPI_IVHD_DTE_EXTINT_PASS_SHIFT 1
2160#define ACPI_IVHD_DTE_EXTINT_PASS_MASK UINT8_C(0x02)
2161/** NMIPass: Identifies a device able to assert NMI interrupts. */
2162#define ACPI_IVHD_DTE_NMI_PASS_SHIFT 2
2163#define ACPI_IVHD_DTE_NMI_PASS_MASK UINT8_C(0x04)
2164/** Bit 3 reserved. */
2165#define ACPI_IVHD_DTE_RSVD_3_SHIFT 3
2166#define ACPI_IVHD_DTE_RSVD_3_MASK UINT8_C(0x08)
2167/** SysMgt: Identifies a device able to assert system management messages. */
2168#define ACPI_IVHD_DTE_SYS_MGT_SHIFT 4
2169#define ACPI_IVHD_DTE_SYS_MGT_MASK UINT8_C(0x30)
2170/** Lint0Pass: Identifies a device able to assert LINT0 interrupts. */
2171#define ACPI_IVHD_DTE_LINT0_PASS_SHIFT 6
2172#define ACPI_IVHD_DTE_LINT0_PASS_MASK UINT8_C(0x40)
2173/** Lint0Pass: Identifies a device able to assert LINT1 interrupts. */
2174#define ACPI_IVHD_DTE_LINT1_PASS_SHIFT 7
2175#define ACPI_IVHD_DTE_LINT1_PASS_MASK UINT8_C(0x80)
2176RT_BF_ASSERT_COMPILE_CHECKS(ACPI_IVHD_DTE_, UINT8_C(0), UINT8_MAX,
2177 (INIT_PASS, EXTINT_PASS, NMI_PASS, RSVD_3, SYS_MGT, LINT0_PASS, LINT1_PASS));
2178/** @} */
2179
2180/**
2181 * AMD IOMMU: IVHD (I/O Virtualization Hardware Definition) Device Entry (4-byte).
2182 * In accordance with the AMD spec.
2183 */
2184#pragma pack(1)
2185typedef struct ACPIIVHDDEVENTRY4
2186{
2187 uint8_t u8DevEntryType; /**< Device entry type. */
2188 uint16_t u16DevId; /**< Device ID. */
2189 uint8_t u8DteSetting; /**< DTE (Device Table Entry) setting. */
2190} ACPIIVHDDEVENTRY4;
2191#pragma pack()
2192AssertCompileSize(ACPIIVHDDEVENTRY4, 4);
2193
2194/**
2195 * AMD IOMMU: IVHD (I/O Virtualization Hardware Definition) Device Entry (8-byte).
2196 * In accordance with the AMD spec.
2197 */
2198#pragma pack(1)
2199typedef struct ACPIIVHDDEVENTRY8
2200{
2201 uint8_t u8DevEntryType; /**< Device entry type. */
2202 union
2203 {
2204 /** Reserved: When u8DevEntryType is 0x40, 0x41, 0x44 or 0x45 (or 0x49-0x7F). */
2205 struct
2206 {
2207 uint8_t au8Rsvd0[7]; /**< Reserved (MBZ). */
2208 } rsvd;
2209 /** Alias Select: When u8DevEntryType is 0x42 or 0x43. */
2210 struct
2211 {
2212 uint16_t u16DevIdA; /**< Device ID A. */
2213 uint8_t u8DteSetting; /**< DTE (Device Table Entry) setting. */
2214 uint8_t u8Rsvd0; /**< Reserved (MBZ). */
2215 uint16_t u16DevIdB; /**< Device ID B. */
2216 uint8_t u8Rsvd1; /**< Reserved (MBZ). */
2217 } alias;
2218 /** Extended Select: When u8DevEntryType is 0x46 or 0x47. */
2219 struct
2220 {
2221 uint16_t u16DevId; /**< Device ID. */
2222 uint8_t u8DteSetting; /**< DTE (Device Table Entry) setting. */
2223 uint32_t u32ExtDteSetting; /**< Extended DTE setting. */
2224 } ext;
2225 /** Special Device: When u8DevEntryType is 0x48. */
2226 struct
2227 {
2228 uint16_t u16Rsvd0; /**< Reserved (MBZ). */
2229 uint8_t u8DteSetting; /**< DTE (Device Table Entry) setting. */
2230 uint8_t u8Handle; /**< Handle contains I/O APIC ID or HPET number. */
2231 uint16_t u16DevIdB; /**< Device ID B (I/O APIC or HPET). */
2232 uint8_t u8Variety; /**< Whether this is the HPET or I/O APIC. */
2233 } special;
2234 } u;
2235} ACPIIVHDDEVENTRY8;
2236#pragma pack()
2237AssertCompileSize(ACPIIVHDDEVENTRY8, 8);
2238
2239/** @name IVHD Type 10h Flags.
2240 * In accordance with the AMD spec.
2241 * @{ */
2242/** Peripheral page request support. */
2243#define ACPI_IVHD_10H_F_PPR_SUP RT_BIT(7)
2244/** Prefetch IOMMU pages command support. */
2245#define ACPI_IVHD_10H_F_PREF_SUP RT_BIT(6)
2246/** Coherent control. */
2247#define ACPI_IVHD_10H_F_COHERENT RT_BIT(5)
2248/** Remote IOTLB support. */
2249#define ACPI_IVHD_10H_F_IOTLB_SUP RT_BIT(4)
2250/** Isochronous control. */
2251#define ACPI_IVHD_10H_F_ISOC RT_BIT(3)
2252/** Response Pass Posted Write. */
2253#define ACPI_IVHD_10H_F_RES_PASS_PW RT_BIT(2)
2254/** Pass Posted Write. */
2255#define ACPI_IVHD_10H_F_PASS_PW RT_BIT(1)
2256/** HyperTransport Tunnel. */
2257#define ACPI_IVHD_10H_F_HT_TUNNEL RT_BIT(0)
2258/** @} */
2259
2260/** @name IVRS IVinfo field.
2261 * In accordance with the AMD spec.
2262 * @{ */
2263/** EFRSup: Extended Feature Support. */
2264#define ACPI_IVINFO_BF_EFR_SUP_SHIFT 0
2265#define ACPI_IVINFO_BF_EFR_SUP_MASK UINT32_C(0x00000001)
2266/** DMA Remap Sup: DMA remapping support (pre-boot DMA protection with
2267 * mandatory remapping of device accessed memory). */
2268#define ACPI_IVINFO_BF_DMA_REMAP_SUP_SHIFT 1
2269#define ACPI_IVINFO_BF_DMA_REMAP_SUP_MASK UINT32_C(0x00000002)
2270/** Bits 4:2 reserved. */
2271#define ACPI_IVINFO_BF_RSVD_2_4_SHIFT 2
2272#define ACPI_IVINFO_BF_RSVD_2_4_MASK UINT32_C(0x0000001c)
2273/** GVASize: Guest virtual-address size. */
2274#define ACPI_IVINFO_BF_GVA_SIZE_SHIFT 5
2275#define ACPI_IVINFO_BF_GVA_SIZE_MASK UINT32_C(0x000000e0)
2276/** PASize: System physical address size. */
2277#define ACPI_IVINFO_BF_PA_SIZE_SHIFT 8
2278#define ACPI_IVINFO_BF_PA_SIZE_MASK UINT32_C(0x00007f00)
2279/** VASize: Virtual address size. */
2280#define ACPI_IVINFO_BF_VA_SIZE_SHIFT 15
2281#define ACPI_IVINFO_BF_VA_SIZE_MASK UINT32_C(0x003f8000)
2282/** HTAtsResv: HyperTransport ATS-response address translation range reserved. */
2283#define ACPI_IVINFO_BF_HT_ATS_RESV_SHIFT 22
2284#define ACPI_IVINFO_BF_HT_ATS_RESV_MASK UINT32_C(0x00400000)
2285/** Bits 31:23 reserved. */
2286#define ACPI_IVINFO_BF_RSVD_23_31_SHIFT 23
2287#define ACPI_IVINFO_BF_RSVD_23_31_MASK UINT32_C(0xff800000)
2288RT_BF_ASSERT_COMPILE_CHECKS(ACPI_IVINFO_BF_, UINT32_C(0), UINT32_MAX,
2289 (EFR_SUP, DMA_REMAP_SUP, RSVD_2_4, GVA_SIZE, PA_SIZE, VA_SIZE, HT_ATS_RESV, RSVD_23_31));
2290/** @} */
2291
2292/** @name IVHD IOMMU info flags.
2293 * In accordance with the AMD spec.
2294 * @{ */
2295/** MSI message number for the event log. */
2296#define ACPI_IOMMU_INFO_BF_MSI_NUM_SHIFT 0
2297#define ACPI_IOMMU_INFO_BF_MSI_NUM_MASK UINT16_C(0x001f)
2298/** Bits 7:5 reserved. */
2299#define ACPI_IOMMU_INFO_BF_RSVD_5_7_SHIFT 5
2300#define ACPI_IOMMU_INFO_BF_RSVD_5_7_MASK UINT16_C(0x00e0)
2301/** IOMMU HyperTransport Unit ID number. */
2302#define ACPI_IOMMU_INFO_BF_UNIT_ID_SHIFT 8
2303#define ACPI_IOMMU_INFO_BF_UNIT_ID_MASK UINT16_C(0x1f00)
2304/** Bits 15:13 reserved. */
2305#define ACPI_IOMMU_INFO_BF_RSVD_13_15_SHIFT 13
2306#define ACPI_IOMMU_INFO_BF_RSVD_13_15_MASK UINT16_C(0xe000)
2307RT_BF_ASSERT_COMPILE_CHECKS(ACPI_IOMMU_INFO_BF_, UINT16_C(0), UINT16_MAX,
2308 (MSI_NUM, RSVD_5_7, UNIT_ID, RSVD_13_15));
2309/** @} */
2310
2311/** @name IVHD IOMMU feature reporting field.
2312 * In accordance with the AMD spec.
2313 * @{ */
2314/** x2APIC supported for peripherals. */
2315#define ACPI_IOMMU_FEAT_BF_XT_SUP_SHIFT 0
2316#define ACPI_IOMMU_FEAT_BF_XT_SUP_MASK UINT32_C(0x00000001)
2317/** NX supported for I/O. */
2318#define ACPI_IOMMU_FEAT_BF_NX_SUP_SHIFT 1
2319#define ACPI_IOMMU_FEAT_BF_NX_SUP_MASK UINT32_C(0x00000002)
2320/** GT (Guest Translation) supported. */
2321#define ACPI_IOMMU_FEAT_BF_GT_SUP_SHIFT 2
2322#define ACPI_IOMMU_FEAT_BF_GT_SUP_MASK UINT32_C(0x00000004)
2323/** GLX (Number of guest CR3 tables) supported. */
2324#define ACPI_IOMMU_FEAT_BF_GLX_SUP_SHIFT 3
2325#define ACPI_IOMMU_FEAT_BF_GLX_SUP_MASK UINT32_C(0x00000018)
2326/** IA (INVALIDATE_IOMMU_ALL) command supported. */
2327#define ACPI_IOMMU_FEAT_BF_IA_SUP_SHIFT 5
2328#define ACPI_IOMMU_FEAT_BF_IA_SUP_MASK UINT32_C(0x00000020)
2329/** GA (Guest virtual APIC) supported. */
2330#define ACPI_IOMMU_FEAT_BF_GA_SUP_SHIFT 6
2331#define ACPI_IOMMU_FEAT_BF_GA_SUP_MASK UINT32_C(0x00000040)
2332/** HE (Hardware error) registers supported. */
2333#define ACPI_IOMMU_FEAT_BF_HE_SUP_SHIFT 7
2334#define ACPI_IOMMU_FEAT_BF_HE_SUP_MASK UINT32_C(0x00000080)
2335/** PASMax (maximum PASID) supported. Ignored if PPRSup=0. */
2336#define ACPI_IOMMU_FEAT_BF_PAS_MAX_SHIFT 8
2337#define ACPI_IOMMU_FEAT_BF_PAS_MAX_MASK UINT32_C(0x00001f00)
2338/** PNCounters (Number of performance counters per counter bank) supported. */
2339#define ACPI_IOMMU_FEAT_BF_PN_COUNTERS_SHIFT 13
2340#define ACPI_IOMMU_FEAT_BF_PN_COUNTERS_MASK UINT32_C(0x0001e000)
2341/** PNBanks (Number of performance counter banks) supported. */
2342#define ACPI_IOMMU_FEAT_BF_PN_BANKS_SHIFT 17
2343#define ACPI_IOMMU_FEAT_BF_PN_BANKS_MASK UINT32_C(0x007e0000)
2344/** MSINumPPR (MSI number for peripheral page requests). */
2345#define ACPI_IOMMU_FEAT_BF_MSI_NUM_PPR_SHIFT 23
2346#define ACPI_IOMMU_FEAT_BF_MSI_NUM_PPR_MASK UINT32_C(0x0f800000)
2347/** GATS (Guest address translation size). MBZ when GTSup=0. */
2348#define ACPI_IOMMU_FEAT_BF_GATS_SHIFT 28
2349#define ACPI_IOMMU_FEAT_BF_GATS_MASK UINT32_C(0x30000000)
2350/** HATS (Host address translation size). */
2351#define ACPI_IOMMU_FEAT_BF_HATS_SHIFT 30
2352#define ACPI_IOMMU_FEAT_BF_HATS_MASK UINT32_C(0xc0000000)
2353RT_BF_ASSERT_COMPILE_CHECKS(ACPI_IOMMU_FEAT_BF_, UINT32_C(0), UINT32_MAX,
2354 (XT_SUP, NX_SUP, GT_SUP, GLX_SUP, IA_SUP, GA_SUP, HE_SUP, PAS_MAX, PN_COUNTERS, PN_BANKS,
2355 MSI_NUM_PPR, GATS, HATS));
2356/** @} */
2357
2358/** @name IOMMU Extended Feature Register (PCI/MMIO/ACPI).
2359 * In accordance with the AMD spec.
2360 * @{ */
2361/** PreFSup: Prefetch support (RO). */
2362#define IOMMU_EXT_FEAT_BF_PREF_SUP_SHIFT 0
2363#define IOMMU_EXT_FEAT_BF_PREF_SUP_MASK UINT64_C(0x0000000000000001)
2364/** PPRSup: Peripheral Page Request (PPR) support (RO). */
2365#define IOMMU_EXT_FEAT_BF_PPR_SUP_SHIFT 1
2366#define IOMMU_EXT_FEAT_BF_PPR_SUP_MASK UINT64_C(0x0000000000000002)
2367/** XTSup: x2APIC support (RO). */
2368#define IOMMU_EXT_FEAT_BF_X2APIC_SUP_SHIFT 2
2369#define IOMMU_EXT_FEAT_BF_X2APIC_SUP_MASK UINT64_C(0x0000000000000004)
2370/** NXSup: No Execute (PMR and PRIV) support (RO). */
2371#define IOMMU_EXT_FEAT_BF_NO_EXEC_SUP_SHIFT 3
2372#define IOMMU_EXT_FEAT_BF_NO_EXEC_SUP_MASK UINT64_C(0x0000000000000008)
2373/** GTSup: Guest Translation support (RO). */
2374#define IOMMU_EXT_FEAT_BF_GT_SUP_SHIFT 4
2375#define IOMMU_EXT_FEAT_BF_GT_SUP_MASK UINT64_C(0x0000000000000010)
2376/** Bit 5 reserved. */
2377#define IOMMU_EXT_FEAT_BF_RSVD_5_SHIFT 5
2378#define IOMMU_EXT_FEAT_BF_RSVD_5_MASK UINT64_C(0x0000000000000020)
2379/** IASup: INVALIDATE_IOMMU_ALL command support (RO). */
2380#define IOMMU_EXT_FEAT_BF_IA_SUP_SHIFT 6
2381#define IOMMU_EXT_FEAT_BF_IA_SUP_MASK UINT64_C(0x0000000000000040)
2382/** GASup: Guest virtual-APIC support (RO). */
2383#define IOMMU_EXT_FEAT_BF_GA_SUP_SHIFT 7
2384#define IOMMU_EXT_FEAT_BF_GA_SUP_MASK UINT64_C(0x0000000000000080)
2385/** HESup: Hardware error registers support (RO). */
2386#define IOMMU_EXT_FEAT_BF_HE_SUP_SHIFT 8
2387#define IOMMU_EXT_FEAT_BF_HE_SUP_MASK UINT64_C(0x0000000000000100)
2388/** PCSup: Performance counters support (RO). */
2389#define IOMMU_EXT_FEAT_BF_PC_SUP_SHIFT 9
2390#define IOMMU_EXT_FEAT_BF_PC_SUP_MASK UINT64_C(0x0000000000000200)
2391/** HATS: Host Address Translation Size (RO). */
2392#define IOMMU_EXT_FEAT_BF_HATS_SHIFT 10
2393#define IOMMU_EXT_FEAT_BF_HATS_MASK UINT64_C(0x0000000000000c00)
2394/** GATS: Guest Address Translation Size (RO). */
2395#define IOMMU_EXT_FEAT_BF_GATS_SHIFT 12
2396#define IOMMU_EXT_FEAT_BF_GATS_MASK UINT64_C(0x0000000000003000)
2397/** GLXSup: Guest CR3 root table level support (RO). */
2398#define IOMMU_EXT_FEAT_BF_GLX_SUP_SHIFT 14
2399#define IOMMU_EXT_FEAT_BF_GLX_SUP_MASK UINT64_C(0x000000000000c000)
2400/** SmiFSup: SMI filter register support (RO). */
2401#define IOMMU_EXT_FEAT_BF_SMI_FLT_SUP_SHIFT 16
2402#define IOMMU_EXT_FEAT_BF_SMI_FLT_SUP_MASK UINT64_C(0x0000000000030000)
2403/** SmiFRC: SMI filter register count (RO). */
2404#define IOMMU_EXT_FEAT_BF_SMI_FLT_REG_CNT_SHIFT 18
2405#define IOMMU_EXT_FEAT_BF_SMI_FLT_REG_CNT_MASK UINT64_C(0x00000000001c0000)
2406/** GAMSup: Guest virtual-APIC modes support (RO). */
2407#define IOMMU_EXT_FEAT_BF_GAM_SUP_SHIFT 21
2408#define IOMMU_EXT_FEAT_BF_GAM_SUP_MASK UINT64_C(0x0000000000e00000)
2409/** DualPprLogSup: Dual PPR Log support (RO). */
2410#define IOMMU_EXT_FEAT_BF_DUAL_PPR_LOG_SUP_SHIFT 24
2411#define IOMMU_EXT_FEAT_BF_DUAL_PPR_LOG_SUP_MASK UINT64_C(0x0000000003000000)
2412/** Bits 27:26 reserved. */
2413#define IOMMU_EXT_FEAT_BF_RSVD_26_27_SHIFT 26
2414#define IOMMU_EXT_FEAT_BF_RSVD_26_27_MASK UINT64_C(0x000000000c000000)
2415/** DualEventLogSup: Dual Event Log support (RO). */
2416#define IOMMU_EXT_FEAT_BF_DUAL_EVT_LOG_SUP_SHIFT 28
2417#define IOMMU_EXT_FEAT_BF_DUAL_EVT_LOG_SUP_MASK UINT64_C(0x0000000030000000)
2418/** Bits 31:30 reserved. */
2419#define IOMMU_EXT_FEAT_BF_RSVD_30_31_SHIFT 30
2420#define IOMMU_EXT_FEAT_BF_RSVD_30_31_MASK UINT64_C(0x00000000c0000000)
2421/** PASMax: Maximum PASID support (RO). */
2422#define IOMMU_EXT_FEAT_BF_PASID_MAX_SHIFT 32
2423#define IOMMU_EXT_FEAT_BF_PASID_MAX_MASK UINT64_C(0x0000001f00000000)
2424/** USSup: User/Supervisor support (RO). */
2425#define IOMMU_EXT_FEAT_BF_US_SUP_SHIFT 37
2426#define IOMMU_EXT_FEAT_BF_US_SUP_MASK UINT64_C(0x0000002000000000)
2427/** DevTblSegSup: Segmented Device Table support (RO). */
2428#define IOMMU_EXT_FEAT_BF_DEV_TBL_SEG_SUP_SHIFT 38
2429#define IOMMU_EXT_FEAT_BF_DEV_TBL_SEG_SUP_MASK UINT64_C(0x000000c000000000)
2430/** PprOverflwEarlySup: PPR Log Overflow Early warning support (RO). */
2431#define IOMMU_EXT_FEAT_BF_PPR_OVERFLOW_EARLY_SHIFT 40
2432#define IOMMU_EXT_FEAT_BF_PPR_OVERFLOW_EARLY_MASK UINT64_C(0x0000010000000000)
2433/** PprAutoRspSup: PPR Automatic Response support (RO). */
2434#define IOMMU_EXT_FEAT_BF_PPR_AUTO_RES_SUP_SHIFT 41
2435#define IOMMU_EXT_FEAT_BF_PPR_AUTO_RES_SUP_MASK UINT64_C(0x0000020000000000)
2436/** MarcSup: Memory Access and Routing (MARC) support (RO). */
2437#define IOMMU_EXT_FEAT_BF_MARC_SUP_SHIFT 42
2438#define IOMMU_EXT_FEAT_BF_MARC_SUP_MASK UINT64_C(0x00000c0000000000)
2439/** BlkStopMrkSup: Block StopMark message support (RO). */
2440#define IOMMU_EXT_FEAT_BF_BLKSTOP_MARK_SUP_SHIFT 44
2441#define IOMMU_EXT_FEAT_BF_BLKSTOP_MARK_SUP_MASK UINT64_C(0x0000100000000000)
2442/** PerfOptSup: IOMMU Performance Optimization support (RO). */
2443#define IOMMU_EXT_FEAT_BF_PERF_OPT_SUP_SHIFT 45
2444#define IOMMU_EXT_FEAT_BF_PERF_OPT_SUP_MASK UINT64_C(0x0000200000000000)
2445/** MsiCapMmioSup: MSI-Capability Register MMIO access support (RO). */
2446#define IOMMU_EXT_FEAT_BF_MSI_CAP_MMIO_SUP_SHIFT 46
2447#define IOMMU_EXT_FEAT_BF_MSI_CAP_MMIO_SUP_MASK UINT64_C(0x0000400000000000)
2448/** Bit 47 reserved. */
2449#define IOMMU_EXT_FEAT_BF_RSVD_47_SHIFT 47
2450#define IOMMU_EXT_FEAT_BF_RSVD_47_MASK UINT64_C(0x0000800000000000)
2451/** GIoSup: Guest I/O Protection support (RO). */
2452#define IOMMU_EXT_FEAT_BF_GST_IO_PROT_SUP_SHIFT 48
2453#define IOMMU_EXT_FEAT_BF_GST_IO_PROT_SUP_MASK UINT64_C(0x0001000000000000)
2454/** HASup: Host Access support (RO). */
2455#define IOMMU_EXT_FEAT_BF_HST_ACCESS_SUP_SHIFT 49
2456#define IOMMU_EXT_FEAT_BF_HST_ACCESS_SUP_MASK UINT64_C(0x0002000000000000)
2457/** EPHSup: Enhandled PPR Handling support (RO). */
2458#define IOMMU_EXT_FEAT_BF_ENHANCED_PPR_SUP_SHIFT 50
2459#define IOMMU_EXT_FEAT_BF_ENHANCED_PPR_SUP_MASK UINT64_C(0x0004000000000000)
2460/** AttrFWSup: Attribute Forward support (RO). */
2461#define IOMMU_EXT_FEAT_BF_ATTR_FW_SUP_SHIFT 51
2462#define IOMMU_EXT_FEAT_BF_ATTR_FW_SUP_MASK UINT64_C(0x0008000000000000)
2463/** HDSup: Host Dirty Support (RO). */
2464#define IOMMU_EXT_FEAT_BF_HST_DIRTY_SUP_SHIFT 52
2465#define IOMMU_EXT_FEAT_BF_HST_DIRTY_SUP_MASK UINT64_C(0x0010000000000000)
2466/** Bit 53 reserved. */
2467#define IOMMU_EXT_FEAT_BF_RSVD_53_SHIFT 53
2468#define IOMMU_EXT_FEAT_BF_RSVD_53_MASK UINT64_C(0x0020000000000000)
2469/** InvIotlbTypeSup: Invalidate IOTLB type support (RO). */
2470#define IOMMU_EXT_FEAT_BF_INV_IOTLB_TYPE_SUP_SHIFT 54
2471#define IOMMU_EXT_FEAT_BF_INV_IOTLB_TYPE_SUP_MASK UINT64_C(0x0040000000000000)
2472/** Bits 60:55 reserved. */
2473#define IOMMU_EXT_FEAT_BF_RSVD_55_60_SHIFT 55
2474#define IOMMU_EXT_FEAT_BF_RSVD_55_60_MASK UINT64_C(0x1f80000000000000)
2475/** GAUpdateDisSup: Support disabling hardware update on guest page table access
2476 * (RO). */
2477#define IOMMU_EXT_FEAT_BF_GA_UPDATE_DIS_SUP_SHIFT 61
2478#define IOMMU_EXT_FEAT_BF_GA_UPDATE_DIS_SUP_MASK UINT64_C(0x2000000000000000)
2479/** ForcePhysDestSup: Force Physical Destination Mode for Remapped Interrupt
2480 * support (RO). */
2481#define IOMMU_EXT_FEAT_BF_FORCE_PHYS_DST_SUP_SHIFT 62
2482#define IOMMU_EXT_FEAT_BF_FORCE_PHYS_DST_SUP_MASK UINT64_C(0x4000000000000000)
2483/** Bit 63 reserved. */
2484#define IOMMU_EXT_FEAT_BF_RSVD_63_SHIFT 63
2485#define IOMMU_EXT_FEAT_BF_RSVD_63_MASK UINT64_C(0x8000000000000000)
2486RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_EXT_FEAT_BF_, UINT64_C(0), UINT64_MAX,
2487 (PREF_SUP, PPR_SUP, X2APIC_SUP, NO_EXEC_SUP, GT_SUP, RSVD_5, IA_SUP, GA_SUP, HE_SUP, PC_SUP,
2488 HATS, GATS, GLX_SUP, SMI_FLT_SUP, SMI_FLT_REG_CNT, GAM_SUP, DUAL_PPR_LOG_SUP, RSVD_26_27,
2489 DUAL_EVT_LOG_SUP, RSVD_30_31, PASID_MAX, US_SUP, DEV_TBL_SEG_SUP, PPR_OVERFLOW_EARLY,
2490 PPR_AUTO_RES_SUP, MARC_SUP, BLKSTOP_MARK_SUP, PERF_OPT_SUP, MSI_CAP_MMIO_SUP, RSVD_47,
2491 GST_IO_PROT_SUP, HST_ACCESS_SUP, ENHANCED_PPR_SUP, ATTR_FW_SUP, HST_DIRTY_SUP, RSVD_53,
2492 INV_IOTLB_TYPE_SUP, RSVD_55_60, GA_UPDATE_DIS_SUP, FORCE_PHYS_DST_SUP, RSVD_63));
2493/** @} */
2494
2495/**
2496 * IVHD (I/O Virtualization Hardware Definition) Type 10h.
2497 * In accordance with the AMD spec.
2498 */
2499#pragma pack(1)
2500typedef struct ACPIIVHDTYPE10
2501{
2502 uint8_t u8Type; /**< Type: Must be 0x10. */
2503 uint8_t u8Flags; /**< Flags (see ACPI_IVHD_10H_F_XXX). */
2504 uint16_t u16Length; /**< Length of IVHD including IVHD device entries. */
2505 uint16_t u16DeviceId; /**< Device ID of the IOMMU. */
2506 uint16_t u16CapOffset; /**< Offset in Capability space for control fields of IOMMU. */
2507 uint64_t u64BaseAddress; /**< Base address of IOMMU control registers in MMIO space. */
2508 uint16_t u16PciSegmentGroup; /**< PCI segment group number. */
2509 uint16_t u16IommuInfo; /**< Interrupt number and Unit ID. */
2510 uint32_t u32Features; /**< IOMMU feature reporting. */
2511 /* IVHD device entry block follows. */
2512} ACPIIVHDTYPE10;
2513#pragma pack()
2514AssertCompileSize(ACPIIVHDTYPE10, 24);
2515AssertCompileMemberOffset(ACPIIVHDTYPE10, u8Type, 0);
2516AssertCompileMemberOffset(ACPIIVHDTYPE10, u8Flags, 1);
2517AssertCompileMemberOffset(ACPIIVHDTYPE10, u16Length, 2);
2518AssertCompileMemberOffset(ACPIIVHDTYPE10, u16DeviceId, 4);
2519AssertCompileMemberOffset(ACPIIVHDTYPE10, u16CapOffset, 6);
2520AssertCompileMemberOffset(ACPIIVHDTYPE10, u64BaseAddress, 8);
2521AssertCompileMemberOffset(ACPIIVHDTYPE10, u16PciSegmentGroup, 16);
2522AssertCompileMemberOffset(ACPIIVHDTYPE10, u16IommuInfo, 18);
2523AssertCompileMemberOffset(ACPIIVHDTYPE10, u32Features, 20);
2524
2525/** @name IVHD Type 11h Flags.
2526 * In accordance with the AMD spec.
2527 * @{ */
2528/** Coherent control. */
2529#define ACPI_IVHD_11H_F_COHERENT RT_BIT(5)
2530/** Remote IOTLB support. */
2531#define ACPI_IVHD_11H_F_IOTLB_SUP RT_BIT(4)
2532/** Isochronous control. */
2533#define ACPI_IVHD_11H_F_ISOC RT_BIT(3)
2534/** Response Pass Posted Write. */
2535#define ACPI_IVHD_11H_F_RES_PASS_PW RT_BIT(2)
2536/** Pass Posted Write. */
2537#define ACPI_IVHD_11H_F_PASS_PW RT_BIT(1)
2538/** HyperTransport Tunnel. */
2539#define ACPI_IVHD_11H_F_HT_TUNNEL RT_BIT(0)
2540/** @} */
2541
2542/** @name IVHD IOMMU Type 11 Attributes field.
2543 * In accordance with the AMD spec.
2544 * @{ */
2545/** Bits 12:0 reserved. */
2546#define ACPI_IOMMU_ATTR_BF_RSVD_0_12_SHIFT 0
2547#define ACPI_IOMMU_ATTR_BF_RSVD_0_12_MASK UINT32_C(0x00001fff)
2548/** PNCounters: Number of performance counters per counter bank. */
2549#define ACPI_IOMMU_ATTR_BF_PN_COUNTERS_SHIFT 13
2550#define ACPI_IOMMU_ATTR_BF_PN_COUNTERS_MASK UINT32_C(0x0001e000)
2551/** PNBanks: Number of performance counter banks. */
2552#define ACPI_IOMMU_ATTR_BF_PN_BANKS_SHIFT 17
2553#define ACPI_IOMMU_ATTR_BF_PN_BANKS_MASK UINT32_C(0x007e0000)
2554/** MSINumPPR: MSI number for peripheral page requests (PPR). */
2555#define ACPI_IOMMU_ATTR_BF_MSI_NUM_PPR_SHIFT 23
2556#define ACPI_IOMMU_ATTR_BF_MSI_NUM_PPR_MASK UINT32_C(0x0f800000)
2557/** Bits 31:28 reserved. */
2558#define ACPI_IOMMU_ATTR_BF_RSVD_28_31_SHIFT 28
2559#define ACPI_IOMMU_ATTR_BF_RSVD_28_31_MASK UINT32_C(0xf0000000)
2560RT_BF_ASSERT_COMPILE_CHECKS(ACPI_IOMMU_ATTR_BF_, UINT32_C(0), UINT32_MAX,
2561 (RSVD_0_12, PN_COUNTERS, PN_BANKS, MSI_NUM_PPR, RSVD_28_31));
2562/** @} */
2563
2564/**
2565 * AMD IOMMU: IVHD (I/O Virtualization Hardware Definition) Type 11h.
2566 * In accordance with the AMD spec.
2567 */
2568#pragma pack(1)
2569typedef struct ACPIIVHDTYPE11
2570{
2571 uint8_t u8Type; /**< Type: Must be 0x11. */
2572 uint8_t u8Flags; /**< Flags. */
2573 uint16_t u16Length; /**< Length: Size starting from Type fields incl. IVHD device entries. */
2574 uint16_t u16DeviceId; /**< Device ID of the IOMMU. */
2575 uint16_t u16CapOffset; /**< Offset in Capability space for control fields of IOMMU. */
2576 uint64_t u64BaseAddress; /**< Base address of IOMMU control registers in MMIO space. */
2577 uint16_t u16PciSegmentGroup; /**< PCI segment group number. */
2578 uint16_t u16IommuInfo; /**< Interrupt number and unit ID. */
2579 uint32_t u32IommuAttr; /**< IOMMU info. not reported in EFR. */
2580 uint64_t u64EfrRegister; /**< Extended Feature Register (must be identical to its MMIO shadow). */
2581 uint64_t u64Rsvd0; /**< Reserved for future. */
2582 /* IVHD device entry block follows. */
2583} ACPIIVHDTYPE11;
2584#pragma pack()
2585AssertCompileSize(ACPIIVHDTYPE11, 40);
2586AssertCompileMemberOffset(ACPIIVHDTYPE11, u8Type, 0);
2587AssertCompileMemberOffset(ACPIIVHDTYPE11, u8Flags, 1);
2588AssertCompileMemberOffset(ACPIIVHDTYPE11, u16Length, 2);
2589AssertCompileMemberOffset(ACPIIVHDTYPE11, u16DeviceId, 4);
2590AssertCompileMemberOffset(ACPIIVHDTYPE11, u16CapOffset, 6);
2591AssertCompileMemberOffset(ACPIIVHDTYPE11, u64BaseAddress, 8);
2592AssertCompileMemberOffset(ACPIIVHDTYPE11, u16PciSegmentGroup, 16);
2593AssertCompileMemberOffset(ACPIIVHDTYPE11, u16IommuInfo, 18);
2594AssertCompileMemberOffset(ACPIIVHDTYPE11, u32IommuAttr, 20);
2595AssertCompileMemberOffset(ACPIIVHDTYPE11, u64EfrRegister, 24);
2596AssertCompileMemberOffset(ACPIIVHDTYPE11, u64Rsvd0, 32);
2597
2598/**
2599 * AMD IOMMU: IVHD (I/O Virtualization Hardware Definition) Type 40h.
2600 * In accordance with the AMD spec.
2601 */
2602typedef struct ACPIIVHDTYPE11 ACPIIVHDTYPE40;
2603
2604#endif /* !VBOX_INCLUDED_iommu_amd_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette