VirtualBox

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

Last change on this file since 87835 was 87817, checked in by vboxsync, 4 years ago

AMD IOMMU: bugref:9654 Moved IOTLB cache completely to ring-3, moved DTE and IRTE caches from hyperheap to shared structure.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 126.6 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 (remote). */
507 RT_GCC_EXTENSION uint64_t u1SuppressPfEvents : 1; /**< Bit 97 - SE: Suppress Page-fault events. */
508 RT_GCC_EXTENSION uint64_t u1SuppressAllPfEvents : 1; /**< Bit 98 - SA: Suppress 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_DTE_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_DTE_GET_INTR_TAB_LEN(a_pDte) (IOMMU_DTE_GET_INTR_TAB_ENTRIES(a_pDte) * sizeof(IRTE_T))
581/** Mask of interrupt control bits. */
582#define IOMMU_DTE_INTR_CTRL_MASK 0x3
583/** Gets the interrupt control bits from the DTE. */
584#define IOMMU_DTE_GET_INTR_CTRL(a_pDte) (((a_pDte)->au64[2] >> 60) & IOMMU_DTE_INTR_CTRL_MASK)
585/** Gets the ignore unmapped interrupt bit from DTE. */
586#define IOMMU_DTE_GET_IG(a_pDte) (((a_pDte)->au64[2] >> 5) & 0x1)
587
588/**
589 * I/O Page Translation Entry.
590 * In accordance with the AMD spec.
591 */
592typedef union
593{
594 struct
595 {
596 RT_GCC_EXTENSION uint64_t u1Present : 1; /**< Bit 0 - PR: Present. */
597 RT_GCC_EXTENSION uint64_t u4Ign0 : 4; /**< Bits 4:1 - Ignored. */
598 RT_GCC_EXTENSION uint64_t u1Accessed : 1; /**< Bit 5 - A: Accessed. */
599 RT_GCC_EXTENSION uint64_t u1Dirty : 1; /**< Bit 6 - D: Dirty. */
600 RT_GCC_EXTENSION uint64_t u2Ign0 : 2; /**< Bits 8:7 - Ignored. */
601 RT_GCC_EXTENSION uint64_t u3NextLevel : 3; /**< Bits 11:9 - Next Level: Next page translation level. */
602 RT_GCC_EXTENSION uint64_t u40PageAddr : 40; /**< Bits 51:12 - Page address. */
603 RT_GCC_EXTENSION uint64_t u7Rsvd0 : 7; /**< Bits 58:52 - Reserved. */
604 RT_GCC_EXTENSION uint64_t u1UntranslatedAccess : 1; /**< Bit 59 - U: Untranslated Access Only. */
605 RT_GCC_EXTENSION uint64_t u1ForceCoherent : 1; /**< Bit 60 - FC: Force Coherent. */
606 RT_GCC_EXTENSION uint64_t u1IoRead : 1; /**< Bit 61 - IR: I/O Read permission. */
607 RT_GCC_EXTENSION uint64_t u1IoWrite : 1; /**< Bit 62 - IW: I/O Wead permission. */
608 RT_GCC_EXTENSION uint64_t u1Ign0 : 1; /**< Bit 63 - Ignored. */
609 } n;
610 /** The 64-bit unsigned integer view. */
611 uint64_t u64;
612} IOPTE_T;
613AssertCompileSize(IOPTE_T, 8);
614
615/**
616 * I/O Page Directory Entry.
617 * In accordance with the AMD spec.
618 */
619typedef union
620{
621 struct
622 {
623 RT_GCC_EXTENSION uint64_t u1Present : 1; /**< Bit 0 - PR: Present. */
624 RT_GCC_EXTENSION uint64_t u4Ign0 : 4; /**< Bits 4:1 - Ignored. */
625 RT_GCC_EXTENSION uint64_t u1Accessed : 1; /**< Bit 5 - A: Accessed. */
626 RT_GCC_EXTENSION uint64_t u3Ign0 : 3; /**< Bits 8:6 - Ignored. */
627 RT_GCC_EXTENSION uint64_t u3NextLevel : 3; /**< Bits 11:9 - Next Level: Next page translation level. */
628 RT_GCC_EXTENSION uint64_t u40PageAddr : 40; /**< Bits 51:12 - Page address (Next Table Address). */
629 RT_GCC_EXTENSION uint64_t u9Rsvd0 : 9; /**< Bits 60:52 - Reserved. */
630 RT_GCC_EXTENSION uint64_t u1IoRead : 1; /**< Bit 61 - IR: I/O Read permission. */
631 RT_GCC_EXTENSION uint64_t u1IoWrite : 1; /**< Bit 62 - IW: I/O Wead permission. */
632 RT_GCC_EXTENSION uint64_t u1Ign0 : 1; /**< Bit 63 - Ignored. */
633 } n;
634 /** The 64-bit unsigned integer view. */
635 uint64_t u64;
636} IOPDE_T;
637AssertCompileSize(IOPDE_T, 8);
638
639/**
640 * I/O Page Table Entity.
641 * In accordance with the AMD spec.
642 *
643 * This a common subset of an DTE.au64[0], PTE and PDE.
644 * Named as an "entity" to avoid confusing it with PTE.
645 */
646typedef union
647{
648 struct
649 {
650 RT_GCC_EXTENSION uint64_t u1Present : 1; /**< Bit 0 - PR: Present. */
651 RT_GCC_EXTENSION uint64_t u8Ign0 : 8; /**< Bits 8:1 - Ignored. */
652 RT_GCC_EXTENSION uint64_t u3NextLevel : 3; /**< Bits 11:9 - Mode / Next Level: Next page translation level. */
653 RT_GCC_EXTENSION uint64_t u40Addr : 40; /**< Bits 51:12 - Page address. */
654 RT_GCC_EXTENSION uint64_t u9Ign0 : 9; /**< Bits 60:52 - Ignored. */
655 RT_GCC_EXTENSION uint64_t u1IoRead : 1; /**< Bit 61 - IR: I/O Read permission. */
656 RT_GCC_EXTENSION uint64_t u1IoWrite : 1; /**< Bit 62 - IW: I/O Wead permission. */
657 RT_GCC_EXTENSION uint64_t u1Ign0 : 1; /**< Bit 63 - Ignored. */
658 } n;
659 /** The 64-bit unsigned integer view. */
660 uint64_t u64;
661} IOPTENTITY_T;
662AssertCompileSize(IOPTENTITY_T, 8);
663AssertCompile(sizeof(IOPTENTITY_T) == sizeof(IOPTE_T));
664AssertCompile(sizeof(IOPTENTITY_T) == sizeof(IOPDE_T));
665/** Pointer to an IOPT_ENTITY_T struct. */
666typedef IOPTENTITY_T *PIOPTENTITY_T;
667/** Pointer to a const IOPT_ENTITY_T struct. */
668typedef IOPTENTITY_T const *PCIOPTENTITY_T;
669/** Mask of the address field. */
670#define IOMMU_PTENTITY_ADDR_MASK UINT64_C(0x000ffffffffff000)
671
672/**
673 * Interrupt Remapping Table Entry (IRTE) - Basic Format.
674 * In accordance with the AMD spec.
675 */
676typedef union
677{
678 struct
679 {
680 uint32_t u1RemapEnable : 1; /**< Bit 0 - RemapEn: Remap Enable. */
681 uint32_t u1SuppressIoPf : 1; /**< Bit 1 - SupIOPF: Suppress I/O Page Fault. */
682 uint32_t u3IntrType : 3; /**< Bits 4:2 - IntType: Interrupt Type. */
683 uint32_t u1ReqEoi : 1; /**< Bit 5 - RqEoi: Request EOI. */
684 uint32_t u1DestMode : 1; /**< Bit 6 - DM: Destination Mode. */
685 uint32_t u1GuestMode : 1; /**< Bit 7 - GuestMode. */
686 uint32_t u8Dest : 8; /**< Bits 15:8 - Destination. */
687 uint32_t u8Vector : 8; /**< Bits 23:16 - Vector. */
688 uint32_t u8Rsvd0 : 8; /**< Bits 31:24 - Reserved. */
689 } n;
690 /** The 32-bit unsigned integer view. */
691 uint32_t u32;
692} IRTE_T;
693AssertCompileSize(IRTE_T, 4);
694/** Pointer to an IRTE_T struct. */
695typedef IRTE_T *PIRTE_T;
696/** Pointer to a const IRTE_T struct. */
697typedef IRTE_T const *PCIRTE_T;
698
699/** The IRTE offset corresponds directly to bits 10:0 of the originating MSI
700 * interrupt message. See AMD IOMMU spec. 2.2.5 "Interrupt Remapping Tables". */
701#define IOMMU_MSI_DATA_IRTE_OFFSET_MASK UINT32_C(0x000007ff)
702/** Gets the IRTE offset from the originating MSI interrupt message. */
703#define IOMMU_GET_IRTE_OFF(a_u32MsiData) (((a_u32MsiData) & IOMMU_MSI_DATA_IRTE_OFFSET_MASK) * sizeof(IRTE_T))
704
705/**
706 * Interrupt Remapping Table Entry (IRTE) - Guest Virtual APIC Enabled.
707 * In accordance with the AMD spec.
708 */
709typedef union
710{
711 struct
712 {
713 uint32_t u1RemapEnable : 1; /**< Bit 0 - RemapEn: Remap Enable. */
714 uint32_t u1SuppressIoPf : 1; /**< Bit 1 - SupIOPF: Suppress I/O Page Fault. */
715 uint32_t u1GALogIntr : 1; /**< Bit 2 - GALogIntr: Guest APIC Log Interrupt. */
716 uint32_t u3Rsvd : 3; /**< Bits 5:3 - Reserved. */
717 uint32_t u1IsRunning : 1; /**< Bit 6 - IsRun: Hint whether the guest is running. */
718 uint32_t u1GuestMode : 1; /**< Bit 7 - GuestMode. */
719 uint32_t u8Dest : 8; /**< Bits 15:8 - Destination. */
720 uint32_t u8Rsvd0 : 8; /**< Bits 31:16 - Reserved. */
721 uint32_t u32GATag : 32; /**< Bits 63:31 - GATag: Tag used when writing to GA log. */
722 uint32_t u8Vector : 8; /**< Bits 71:64 - Vector: Interrupt vector. */
723 uint32_t u4Reserved : 4; /**< Bits 75:72 - Reserved or ignored depending on RemapEn. */
724 uint32_t u20GATableRootPtrLo : 20; /**< Bits 95:76 - Bits [31:12] of Guest vAPIC Table Root Pointer. */
725 uint32_t u20GATableRootPtrHi : 20; /**< Bits 115:76 - Bits [51:32] of Guest vAPIC Table Root Pointer. */
726 uint32_t u12Rsvd : 12; /**< Bits 127:116 - Reserved. */
727 } n;
728 /** The 64-bit unsigned integer view. */
729 uint64_t u64[2];
730} IRTE_GVA_T;
731AssertCompileSize(IRTE_GVA_T, 16);
732/** Pointer to an IRTE_GVA_T struct. */
733typedef IRTE_GVA_T *PIRTE_GVA_T;
734/** Pointer to a const IRTE_GVA_T struct. */
735typedef IRTE_GVA_T const *PCIRTE_GVA_T;
736
737/**
738 * Command: Generic Command Buffer Entry.
739 * In accordance with the AMD spec.
740 */
741typedef union
742{
743 struct
744 {
745 uint32_t u32Operand1Lo; /**< Bits 31:0 - Operand 1 (Lo). */
746 uint32_t u28Operand1Hi : 28; /**< Bits 59:32 - Operand 1 (Hi). */
747 uint32_t u4Opcode : 4; /**< Bits 63:60 - Op Code. */
748 uint64_t u64Operand2; /**< Bits 127:64 - Operand 2. */
749 } n;
750 /** The 64-bit unsigned integer view. */
751 uint64_t au64[2];
752} CMD_GENERIC_T;
753AssertCompileSize(CMD_GENERIC_T, 16);
754/** Pointer to a generic command buffer entry. */
755typedef CMD_GENERIC_T *PCMD_GENERIC_T;
756/** Pointer to a const generic command buffer entry. */
757typedef CMD_GENERIC_T const *PCCMD_GENERIC_T;
758
759/** Number of bits to shift the byte offset of a command in the command buffer to
760 * get its index. */
761#define IOMMU_CMD_GENERIC_SHIFT 4
762
763/**
764 * Command: COMPLETION_WAIT.
765 * In accordance with the AMD spec.
766 */
767typedef union
768{
769 struct
770 {
771 uint32_t u1Store : 1; /**< Bit 0 - S: Completion Store. */
772 uint32_t u1Interrupt : 1; /**< Bit 1 - I: Completion Interrupt. */
773 uint32_t u1Flush : 1; /**< Bit 2 - F: Flush Queue. */
774 uint32_t u29StoreAddrLo : 29; /**< Bits 31:3 - Store Address (Lo). */
775 uint32_t u20StoreAddrHi : 20; /**< Bits 51:32 - Store Address (Hi). */
776 uint32_t u8Rsvd0 : 8; /**< Bits 59:52 - Reserved. */
777 uint32_t u4OpCode : 4; /**< Bits 63:60 - OpCode (Command). */
778 uint64_t u64StoreData; /**< Bits 127:64 - Store Data. */
779 } n;
780 /** The 64-bit unsigned integer view. */
781 uint64_t au64[2];
782} CMD_COMWAIT_T;
783AssertCompileSize(CMD_COMWAIT_T, 16);
784/** Pointer to a completion wait command. */
785typedef CMD_COMWAIT_T *PCMD_COMWAIT_T;
786/** Pointer to a const completion wait command. */
787typedef CMD_COMWAIT_T const *PCCMD_COMWAIT_T;
788#define IOMMU_CMD_COM_WAIT_QWORD_0_VALID_MASK UINT64_C(0xf00fffffffffffff)
789
790/**
791 * Command: INVALIDATE_DEVTAB_ENTRY.
792 * In accordance with the AMD spec.
793 */
794typedef union
795{
796 struct
797 {
798 uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
799 uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved. */
800 uint32_t u28Rsvd0 : 28; /**< Bits 59:32 - Reserved. */
801 uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
802 uint64_t u64Rsvd0; /**< Bits 127:64 - Reserved. */
803 } n;
804 /** The 64-bit unsigned integer view. */
805 uint64_t au64[2];
806} CMD_INV_DTE_T;
807AssertCompileSize(CMD_INV_DTE_T, 16);
808/** Pointer to a invalidate DTE command. */
809typedef CMD_INV_DTE_T *PCMD_INV_DTE_T;
810/** Pointer to a const invalidate DTE command. */
811typedef CMD_INV_DTE_T const *PCCMD_INV_DTE_T;
812#define IOMMU_CMD_INV_DTE_QWORD_0_VALID_MASK UINT64_C(0xf00000000000ffff)
813#define IOMMU_CMD_INV_DTE_QWORD_1_VALID_MASK UINT64_C(0x0000000000000000)
814
815/**
816 * Command: INVALIDATE_IOMMU_PAGES.
817 * In accordance with the AMD spec.
818 */
819typedef union
820{
821 struct
822 {
823 uint32_t u20Pasid : 20; /**< Bits 19:0 - PASID: Process Address-Space ID. */
824 uint32_t u12Rsvd0 : 12; /**< Bits 31:20 - Reserved. */
825 uint32_t u16DomainId : 16; /**< Bits 47:32 - Domain ID. */
826 uint32_t u12Rsvd1 : 12; /**< Bits 59:48 - Reserved. */
827 uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
828 uint32_t u1Size : 1; /**< Bit 64 - S: Size. */
829 uint32_t u1PageDirEntries : 1; /**< Bit 65 - PDE: Page Directory Entries. */
830 uint32_t u1GuestOrNested : 1; /**< Bit 66 - GN: Guest (GPA) or Nested (GVA). */
831 uint32_t u9Rsvd0 : 9; /**< Bits 75:67 - Reserved. */
832 uint32_t u20AddrLo : 20; /**< Bits 95:76 - Address (Lo). */
833 uint32_t u32AddrHi; /**< Bits 127:96 - Address (Hi). */
834 } n;
835 /** The 64-bit unsigned integer view. */
836 uint64_t au64[2];
837} CMD_INV_IOMMU_PAGES_T;
838AssertCompileSize(CMD_INV_IOMMU_PAGES_T, 16);
839/** Pointer to a invalidate iommu pages command. */
840typedef CMD_INV_IOMMU_PAGES_T *PCMD_INV_IOMMU_PAGES_T;
841/** Pointer to a const invalidate iommu pages command. */
842typedef CMD_INV_IOMMU_PAGES_T const *PCCMD_INV_IOMMU_PAGES_T;
843#define IOMMU_CMD_INV_IOMMU_PAGES_QWORD_0_VALID_MASK UINT64_C(0xf000ffff000fffff)
844#define IOMMU_CMD_INV_IOMMU_PAGES_QWORD_1_VALID_MASK UINT64_C(0xfffffffffffff007)
845
846/**
847 * Command: INVALIDATE_IOTLB_PAGES.
848 * In accordance with the AMD spec.
849 */
850typedef union
851{
852 struct
853 {
854 uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
855 uint8_t u8PasidLo; /**< Bits 23:16 - PASID: Process Address-Space ID (Lo). */
856 uint8_t u8MaxPend; /**< Bits 31:24 - Maxpend: Maximum simultaneous in-flight transactions. */
857 uint32_t u16QueueId : 16; /**< Bits 47:32 - Queue ID. */
858 uint32_t u12PasidHi : 12; /**< Bits 59:48 - PASID: Process Address-Space ID (Hi). */
859 uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
860 uint32_t u1Size : 1; /**< Bit 64 - S: Size. */
861 uint32_t u1Rsvd0: 1; /**< Bit 65 - Reserved. */
862 uint32_t u1GuestOrNested : 1; /**< Bit 66 - GN: Guest (GPA) or Nested (GVA). */
863 uint32_t u1Rsvd1 : 1; /**< Bit 67 - Reserved. */
864 uint32_t u2Type : 2; /**< Bit 69:68 - Type. */
865 uint32_t u6Rsvd0 : 6; /**< Bits 75:70 - Reserved. */
866 uint32_t u20AddrLo : 20; /**< Bits 95:76 - Address (Lo). */
867 uint32_t u32AddrHi; /**< Bits 127:96 - Address (Hi). */
868 } n;
869 /** The 64-bit unsigned integer view. */
870 uint64_t au64[2];
871} CMD_INV_IOTLB_PAGES_T;
872AssertCompileSize(CMD_INV_IOTLB_PAGES_T, 16);
873
874/**
875 * Command: INVALIDATE_INTR_TABLE.
876 * In accordance with the AMD spec.
877 */
878typedef union
879{
880 struct
881 {
882 uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
883 uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved. */
884 uint32_t u32Rsvd0 : 28; /**< Bits 59:32 - Reserved. */
885 uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
886 uint64_t u64Rsvd0; /**< Bits 127:64 - Reserved. */
887 } u;
888 /** The 64-bit unsigned integer view. */
889 uint64_t au64[2];
890} CMD_INV_INTR_TABLE_T;
891AssertCompileSize(CMD_INV_INTR_TABLE_T, 16);
892/** Pointer to a invalidate interrupt table command. */
893typedef CMD_INV_INTR_TABLE_T *PCMD_INV_INTR_TABLE_T;
894/** Pointer to a const invalidate interrupt table command. */
895typedef CMD_INV_INTR_TABLE_T const *PCCMD_INV_INTR_TABLE_T;
896#define IOMMU_CMD_INV_INTR_TABLE_QWORD_0_VALID_MASK UINT64_C(0xf00000000000ffff)
897#define IOMMU_CMD_INV_INTR_TABLE_QWORD_1_VALID_MASK UINT64_C(0x0000000000000000)
898
899/**
900 * Command: PREFETCH_IOMMU_PAGES.
901 * In accordance with the AMD spec.
902 */
903typedef union
904{
905 struct
906 {
907 uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
908 uint8_t u8Rsvd0; /**< Bits 23:16 - Reserved. */
909 uint8_t u8PrefCount; /**< Bits 31:24 - PFCount: Number of translations to prefetch. */
910 uint32_t u20Pasid : 20; /**< Bits 51:32 - PASID: Process Address-Space ID. */
911 uint32_t u8Rsvd1 : 8; /**< Bits 59:52 - Reserved. */
912 uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
913 uint32_t u1Size : 1; /**< Bit 64 - S: Size of the prefetched pages. */
914 uint32_t u1Rsvd0 : 1; /**< Bit 65 - Reserved. */
915 uint32_t u1GuestOrNested : 1; /**< Bit 66 - GN: Guest (GPA) or Nested (GVA). */
916 uint32_t u1Rsvd1 : 1; /**< Bit 67 - Reserved. */
917 uint32_t u1Invalidate : 1; /**< Bit 68 - Inval: Invalidate prior to prefetch. */
918 uint32_t u7Rsvd0 : 7; /**< Bits 75:69 - Reserved */
919 uint32_t u20AddrLo : 7; /**< Bits 95:76 - Address (Lo). */
920 uint32_t u32AddrHi; /**< Bits 127:96 - Address (Hi). */
921 } u;
922 /** The 64-bit unsigned integer view. */
923 uint64_t au64[2];
924} CMD_PREF_IOMMU_PAGES_T;
925AssertCompileSize(CMD_PREF_IOMMU_PAGES_T, 16);
926/** Pointer to a invalidate iommu pages command. */
927typedef CMD_PREF_IOMMU_PAGES_T *PCMD_PREF_IOMMU_PAGES_T;
928/** Pointer to a const invalidate iommu pages command. */
929typedef CMD_PREF_IOMMU_PAGES_T const *PCCMD_PREF_IOMMU_PAGES_T;
930#define IOMMU_CMD_PREF_IOMMU_PAGES_QWORD_0_VALID_MASK UINT64_C(0x780fffffff00ffff)
931#define IOMMU_CMD_PREF_IOMMU_PAGES_QWORD_1_VALID_MASK UINT64_C(0xfffffffffffff015)
932
933
934/**
935 * Command: COMPLETE_PPR_REQ.
936 * In accordance with the AMD spec.
937 */
938typedef union
939{
940 struct
941 {
942 uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
943 uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved. */
944 uint32_t u20Pasid : 20; /**< Bits 51:32 - PASID: Process Address-Space ID. */
945 uint32_t u8Rsvd0 : 8; /**< Bits 59:52 - Reserved. */
946 uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
947 uint32_t u2Rsvd0 : 2; /**< Bits 65:64 - Reserved. */
948 uint32_t u1GuestOrNested : 1; /**< Bit 66 - GN: Guest (GPA) or Nested (GVA). */
949 uint32_t u29Rsvd0 : 29; /**< Bits 95:67 - Reserved. */
950 uint32_t u16CompletionTag : 16; /**< Bits 111:96 - Completion Tag. */
951 uint32_t u16Rsvd1 : 16; /**< Bits 127:112 - Reserved. */
952 } n;
953 /** The 64-bit unsigned integer view. */
954 uint64_t au64[2];
955} CMD_COMPLETE_PPR_REQ_T;
956AssertCompileSize(CMD_COMPLETE_PPR_REQ_T, 16);
957
958/**
959 * Command: INV_IOMMU_ALL.
960 * In accordance with the AMD spec.
961 */
962typedef union
963{
964 struct
965 {
966 uint32_t u32Rsvd0; /**< Bits 31:0 - Reserved. */
967 uint32_t u28Rsvd0 : 28; /**< Bits 59:32 - Reserved. */
968 uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
969 uint64_t u64Rsvd0; /**< Bits 127:64 - Reserved. */
970 } n;
971 /** The 64-bit unsigned integer view. */
972 uint64_t au64[2];
973} CMD_INV_IOMMU_ALL_T;
974AssertCompileSize(CMD_INV_IOMMU_ALL_T, 16);
975/** Pointer to a invalidate IOMMU all command. */
976typedef CMD_INV_IOMMU_ALL_T *PCMD_INV_IOMMU_ALL_T;
977/** Pointer to a const invalidate IOMMU all command. */
978typedef CMD_INV_IOMMU_ALL_T const *PCCMD_INV_IOMMU_ALL_T;
979#define IOMMU_CMD_INV_IOMMU_ALL_QWORD_0_VALID_MASK UINT64_C(0xf000000000000000)
980#define IOMMU_CMD_INV_IOMMU_ALL_QWORD_1_VALID_MASK UINT64_C(0x0000000000000000)
981
982/**
983 * Event Log Entry: Generic.
984 * In accordance with the AMD spec.
985 */
986typedef union
987{
988 struct
989 {
990 uint32_t u32Operand1Lo; /**< Bits 31:0 - Operand 1 (Lo). */
991 uint32_t u28Operand1Hi : 28; /**< Bits 59:32 - Operand 1 (Hi). */
992 uint32_t u4EvtCode : 4; /**< Bits 63:60 - Event code. */
993 uint32_t u32Operand2Lo; /**< Bits 95:64 - Operand 2 (Lo). */
994 uint32_t u32Operand2Hi; /**< Bits 127:96 - Operand 2 (Hi). */
995 } n;
996 /** The 32-bit unsigned integer view. */
997 uint32_t au32[4];
998} EVT_GENERIC_T;
999AssertCompileSize(EVT_GENERIC_T, 16);
1000/** Number of bits to shift the byte offset of an event entry in the event log
1001 * buffer to get its index. */
1002#define IOMMU_EVT_GENERIC_SHIFT 4
1003/** Pointer to a generic event log entry. */
1004typedef EVT_GENERIC_T *PEVT_GENERIC_T;
1005/** Pointer to a const generic event log entry. */
1006typedef const EVT_GENERIC_T *PCEVT_GENERIC_T;
1007
1008/**
1009 * Hardware event types.
1010 * In accordance with the AMD spec.
1011 */
1012typedef enum HWEVTTYPE
1013{
1014 HWEVTTYPE_RSVD = 0,
1015 HWEVTTYPE_MASTER_ABORT,
1016 HWEVTTYPE_TARGET_ABORT,
1017 HWEVTTYPE_DATA_ERROR
1018} HWEVTTYPE;
1019AssertCompileSize(HWEVTTYPE, 4);
1020
1021/**
1022 * Event Log Entry: ILLEGAL_DEV_TABLE_ENTRY.
1023 * In accordance with the AMD spec.
1024 */
1025typedef union
1026{
1027 struct
1028 {
1029 uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
1030 RT_GCC_EXTENSION uint16_t u4PasidHi : 4; /**< Bits 19:16 - PASID: Process Address-Space ID (Hi). */
1031 RT_GCC_EXTENSION uint16_t u12Rsvd0 : 12; /**< Bits 31:20 - Reserved. */
1032 uint16_t u16PasidLo; /**< Bits 47:32 - PASID: Process Address-Space ID (Lo). */
1033 RT_GCC_EXTENSION uint16_t u1GuestOrNested : 1; /**< Bit 48 - GN: Guest (GPA) or Nested (GVA). */
1034 RT_GCC_EXTENSION uint16_t u2Rsvd0 : 2; /**< Bits 50:49 - Reserved. */
1035 RT_GCC_EXTENSION uint16_t u1Interrupt : 1; /**< Bit 51 - I: Interrupt. */
1036 RT_GCC_EXTENSION uint16_t u1Rsvd0 : 1; /**< Bit 52 - Reserved. */
1037 RT_GCC_EXTENSION uint16_t u1ReadWrite : 1; /**< Bit 53 - RW: Read/Write. */
1038 RT_GCC_EXTENSION uint16_t u1Rsvd1 : 1; /**< Bit 54 - Reserved. */
1039 RT_GCC_EXTENSION uint16_t u1RsvdNotZero : 1; /**< Bit 55 - RZ: Reserved bit not Zero (0=invalid level encoding). */
1040 RT_GCC_EXTENSION uint16_t u1Translation : 1; /**< Bit 56 - TN: Translation. */
1041 RT_GCC_EXTENSION uint16_t u3Rsvd0 : 3; /**< Bits 59:57 - Reserved. */
1042 RT_GCC_EXTENSION uint16_t u4EvtCode : 4; /**< Bits 63:60 - Event code. */
1043 uint64_t u64Addr; /**< Bits 127:64 - Address: I/O Virtual Address (IOVA). */
1044 } n;
1045 /** The 32-bit unsigned integer view. */
1046 uint32_t au32[4];
1047 /** The 64-bit unsigned integer view. */
1048 uint64_t au64[2];
1049} EVT_ILLEGAL_DTE_T;
1050AssertCompileSize(EVT_ILLEGAL_DTE_T, 16);
1051/** Pointer to an illegal device table entry event. */
1052typedef EVT_ILLEGAL_DTE_T *PEVT_ILLEGAL_DTE_T;
1053/** Pointer to a const illegal device table entry event. */
1054typedef EVT_ILLEGAL_DTE_T const *PCEVT_ILLEGAL_DTE_T;
1055
1056/**
1057 * Event Log Entry: IO_PAGE_FAULT_EVENT.
1058 * In accordance with the AMD spec.
1059 */
1060typedef union
1061{
1062 struct
1063 {
1064 uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
1065 RT_GCC_EXTENSION uint16_t u4PasidHi : 4; /**< Bits 19:16 - PASID: Process Address-Space ID (Hi). */
1066 RT_GCC_EXTENSION uint16_t u16DomainOrPasidLo; /**< Bits 47:32 - D/P: Domain ID or Process Address-Space ID (Lo). */
1067 RT_GCC_EXTENSION uint16_t u1GuestOrNested : 1; /**< Bit 48 - GN: Guest (GPA) or Nested (GVA). */
1068 RT_GCC_EXTENSION uint16_t u1NoExecute : 1; /**< Bit 49 - NX: No Execute. */
1069 RT_GCC_EXTENSION uint16_t u1User : 1; /**< Bit 50 - US: User/Supervisor. */
1070 RT_GCC_EXTENSION uint16_t u1Interrupt : 1; /**< Bit 51 - I: Interrupt. */
1071 RT_GCC_EXTENSION uint16_t u1Present : 1; /**< Bit 52 - PR: Present. */
1072 RT_GCC_EXTENSION uint16_t u1ReadWrite : 1; /**< Bit 53 - RW: Read/Write. */
1073 RT_GCC_EXTENSION uint16_t u1PermDenied : 1; /**< Bit 54 - PE: Permission Indicator. */
1074 RT_GCC_EXTENSION uint16_t u1RsvdNotZero : 1; /**< Bit 55 - RZ: Reserved bit not Zero (0=invalid level encoding). */
1075 RT_GCC_EXTENSION uint16_t u1Translation : 1; /**< Bit 56 - TN: Translation. */
1076 RT_GCC_EXTENSION uint16_t u3Rsvd0 : 3; /**< Bit 59:57 - Reserved. */
1077 RT_GCC_EXTENSION uint16_t u4EvtCode : 4; /**< Bits 63:60 - Event code. */
1078 uint64_t u64Addr; /**< Bits 127:64 - Address: I/O Virtual Address (IOVA). */
1079 } n;
1080 /** The 32-bit unsigned integer view. */
1081 uint32_t au32[4];
1082 /** The 64-bit unsigned integer view. */
1083 uint64_t au64[2];
1084} EVT_IO_PAGE_FAULT_T;
1085AssertCompileSize(EVT_IO_PAGE_FAULT_T, 16);
1086/** Pointer to an I/O page fault event. */
1087typedef EVT_IO_PAGE_FAULT_T *PEVT_IO_PAGE_FAULT_T;
1088/** Pointer to a const I/O page fault event. */
1089typedef EVT_IO_PAGE_FAULT_T const *PCEVT_IO_PAGE_FAULT_T;
1090
1091
1092/**
1093 * Event Log Entry: DEV_TAB_HARDWARE_ERROR.
1094 * In accordance with the AMD spec.
1095 */
1096typedef union
1097{
1098 struct
1099 {
1100 uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
1101 uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved. */
1102 uint32_t u19Rsvd0 : 19; /**< Bits 50:32 - Reserved. */
1103 uint32_t u1Intr : 1; /**< Bit 51 - I: Interrupt (1=interrupt request, 0=memory request). */
1104 uint32_t u1Rsvd0 : 1; /**< Bit 52 - Reserved. */
1105 uint32_t u1ReadWrite : 1; /**< Bit 53 - RW: Read/Write transaction (only meaninful when I=0 and TR=0). */
1106 uint32_t u2Rsvd0 : 2; /**< Bits 55:54 - Reserved. */
1107 uint32_t u1Translation : 1; /**< Bit 56 - TR: Translation (1=translation, 0=transaction). */
1108 uint32_t u2Type : 2; /**< Bits 58:57 - Type: The type of hardware error. */
1109 uint32_t u1Rsvd1 : 1; /**< Bit 59 - Reserved. */
1110 uint32_t u4EvtCode : 4; /**< Bits 63:60 - Event code. */
1111 uint64_t u64Addr; /**< Bits 127:64 - Address. */
1112 } n;
1113 /** The 32-bit unsigned integer view. */
1114 uint32_t au32[4];
1115 /** The 64-bit unsigned integer view. */
1116 uint64_t au64[2];
1117} EVT_DEV_TAB_HW_ERROR_T;
1118AssertCompileSize(EVT_DEV_TAB_HW_ERROR_T, 16);
1119/** Pointer to a device table hardware error event. */
1120typedef EVT_DEV_TAB_HW_ERROR_T *PEVT_DEV_TAB_HW_ERROR_T;
1121/** Pointer to a const device table hardware error event. */
1122typedef EVT_DEV_TAB_HW_ERROR_T const *PCEVT_DEV_TAB_HW_ERROR_T;
1123
1124/**
1125 * Event Log Entry: EVT_PAGE_TAB_HARDWARE_ERROR.
1126 * In accordance with the AMD spec.
1127 */
1128typedef union
1129{
1130 struct
1131 {
1132 uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
1133 uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved. */
1134 uint32_t u16DomainOrPasidLo : 16; /**< Bits 47:32 - D/P: Domain ID or Process Address-Space ID (Lo). */
1135 uint32_t u1GuestOrNested : 1; /**< Bit 48 - GN: Guest (GPA) or Nested (GVA). */
1136 uint32_t u2Rsvd0 : 2; /**< Bits 50:49 - Reserved. */
1137 uint32_t u1Interrupt : 1; /**< Bit 51 - I: Interrupt. */
1138 uint32_t u1Rsvd0 : 1; /**< Bit 52 - Reserved. */
1139 uint32_t u1ReadWrite : 1; /**< Bit 53 - RW: Read/Write. */
1140 uint32_t u2Rsvd1 : 2; /**< Bit 55:54 - Reserved. */
1141 uint32_t u1Translation : 1; /**< Bit 56 - TR: Translation. */
1142 uint32_t u2Type : 2; /**< Bits 58:57 - Type: The type of hardware error. */
1143 uint32_t u1Rsvd1 : 1; /**< Bit 59 - Reserved. */
1144 uint32_t u4EvtCode : 4; /**< Bit 63:60 - Event code. */
1145 /** @todo r=ramshankar: Figure 55: PAGE_TAB_HARDWARE_ERROR says Addr[31:3] but
1146 * table 58 mentions Addr[31:4], we just use the full 64-bits. Looks like a
1147 * typo in the figure.See AMD AMD IOMMU spec (3.05-PUB, Jan 2020). */
1148 uint64_t u64Addr; /** Bits 127:64 - Address: SPA of the page table entry. */
1149 } n;
1150 /** The 32-bit unsigned integer view. */
1151 uint32_t au32[4];
1152 /** The 64-bit unsigned integer view. */
1153 uint64_t au64[2];
1154} EVT_PAGE_TAB_HW_ERR_T;
1155AssertCompileSize(EVT_PAGE_TAB_HW_ERR_T, 16);
1156/** Pointer to a page table hardware error event. */
1157typedef EVT_PAGE_TAB_HW_ERR_T *PEVT_PAGE_TAB_HW_ERR_T;
1158/** Pointer to a const page table hardware error event. */
1159typedef EVT_PAGE_TAB_HW_ERR_T const *PCEVT_PAGE_TAB_HW_ERR_T;
1160
1161/**
1162 * Event Log Entry: ILLEGAL_COMMAND_ERROR.
1163 * In accordance with the AMD spec.
1164 */
1165typedef union
1166{
1167 struct
1168 {
1169 uint32_t u32Rsvd0; /**< Bits 31:0 - Reserved. */
1170 uint32_t u28Rsvd0 : 28; /**< Bits 47:32 - Reserved. */
1171 uint32_t u4EvtCode : 4; /**< Bits 63:60 - Event code. */
1172 uint64_t u64Addr; /**< Bits 127:64 - Address: SPA of the invalid command. */
1173 } n;
1174 /** The 32-bit unsigned integer view. */
1175 uint32_t au32[4];
1176 /** The 64-bit unsigned integer view. */
1177 uint64_t au64[2];
1178} EVT_ILLEGAL_CMD_ERR_T;
1179AssertCompileSize(EVT_ILLEGAL_CMD_ERR_T, 16);
1180/** Pointer to an illegal command error event. */
1181typedef EVT_ILLEGAL_CMD_ERR_T *PEVT_ILLEGAL_CMD_ERR_T;
1182/** Pointer to a const illegal command error event. */
1183typedef EVT_ILLEGAL_CMD_ERR_T const *PCEVT_ILLEGAL_CMD_ERR_T;
1184
1185/**
1186 * Event Log Entry: COMMAND_HARDWARE_ERROR.
1187 * In accordance with the AMD spec.
1188 */
1189typedef union
1190{
1191 struct
1192 {
1193 uint32_t u32Rsvd0; /**< Bits 31:0 - Reserved. */
1194 uint32_t u25Rsvd1 : 25; /**< Bits 56:32 - Reserved. */
1195 uint32_t u2Type : 2; /**< Bits 58:57 - Type: The type of hardware error. */
1196 uint32_t u1Rsvd1 : 1; /**< Bit 59 - Reserved. */
1197 uint32_t u4EvtCode : 4; /**< Bits 63:60 - Event code. */
1198 uint64_t u64Addr; /**< Bits 128:64 - Address: SPA of the attempted access. */
1199 } n;
1200 /** The 32-bit unsigned integer view. */
1201 uint32_t au32[4];
1202 /** The 64-bit unsigned integer view. */
1203 uint64_t au64[2];
1204} EVT_CMD_HW_ERR_T;
1205AssertCompileSize(EVT_CMD_HW_ERR_T, 16);
1206/** Pointer to a command hardware error event. */
1207typedef EVT_CMD_HW_ERR_T *PEVT_CMD_HW_ERR_T;
1208/** Pointer to a const command hardware error event. */
1209typedef EVT_CMD_HW_ERR_T const *PCEVT_CMD_HW_ERR_T;
1210
1211/**
1212 * Event Log Entry: IOTLB_INV_TIMEOUT.
1213 * In accordance with the AMD spec.
1214 */
1215typedef union
1216{
1217 struct
1218 {
1219 uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
1220 uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved.*/
1221 uint32_t u28Rsvd0 : 28; /**< Bits 59:32 - Reserved. */
1222 uint32_t u4EvtCode : 4; /**< Bits 63:60 - Event code. */
1223 uint32_t u4Rsvd0 : 4; /**< Bits 67:64 - Reserved. */
1224 uint32_t u28AddrLo : 28; /**< Bits 95:68 - Address: SPA of the invalidation command that timedout (Lo). */
1225 uint32_t u32AddrHi; /**< Bits 127:96 - Address: SPA of the invalidation command that timedout (Hi). */
1226 } n;
1227 /** The 32-bit unsigned integer view. */
1228 uint32_t au32[4];
1229} EVT_IOTLB_INV_TIMEOUT_T;
1230AssertCompileSize(EVT_IOTLB_INV_TIMEOUT_T, 16);
1231
1232/**
1233 * Event Log Entry: INVALID_DEVICE_REQUEST.
1234 * In accordance with the AMD spec.
1235 */
1236typedef union
1237{
1238 struct
1239 {
1240 uint32_t u16DevId : 16; /***< Bits 15:0 - Device ID. */
1241 uint32_t u4PasidHi : 4; /***< Bits 19:16 - PASID: Process Address-Space ID (Hi). */
1242 uint32_t u12Rsvd0 : 12; /***< Bits 31:20 - Reserved. */
1243 uint32_t u16PasidLo : 16; /***< Bits 47:32 - PASID: Process Address-Space ID (Lo). */
1244 uint32_t u1GuestOrNested : 1; /***< Bit 48 - GN: Guest (GPA) or Nested (GVA). */
1245 uint32_t u1User : 1; /***< Bit 49 - US: User/Supervisor. */
1246 uint32_t u6Rsvd0 : 6; /***< Bits 55:50 - Reserved. */
1247 uint32_t u1Translation: 1; /***< Bit 56 - TR: Translation. */
1248 uint32_t u3Type: 3; /***< Bits 59:57 - Type: The type of hardware error. */
1249 uint32_t u4EvtCode : 4; /***< Bits 63:60 - Event code. */
1250 uint64_t u64Addr; /***< Bits 127:64 - Address: Translation or access address. */
1251 } n;
1252 /** The 32-bit unsigned integer view. */
1253 uint32_t au32[4];
1254} EVT_INVALID_DEV_REQ_T;
1255AssertCompileSize(EVT_INVALID_DEV_REQ_T, 16);
1256
1257/**
1258 * Event Log Entry: EVENT_COUNTER_ZERO.
1259 * In accordance with the AMD spec.
1260 */
1261typedef union
1262{
1263 struct
1264 {
1265 uint32_t u32Rsvd0; /**< Bits 31:0 - Reserved. */
1266 uint32_t u28Rsvd0 : 28; /**< Bits 59:32 - Reserved. */
1267 uint32_t u4EvtCode : 4; /**< Bits 63:60 - Event code. */
1268 uint32_t u20CounterNoteHi : 20; /**< Bits 83:64 - CounterNote: Counter value for the event counter register (Hi). */
1269 uint32_t u12Rsvd0 : 12; /**< Bits 95:84 - Reserved. */
1270 uint32_t u32CounterNoteLo; /**< Bits 127:96 - CounterNote: Counter value for the event cuonter register (Lo). */
1271 } n;
1272 /** The 32-bit unsigned integer view. */
1273 uint32_t au32[4];
1274} EVT_EVENT_COUNTER_ZERO_T;
1275AssertCompileSize(EVT_EVENT_COUNTER_ZERO_T, 16);
1276
1277/**
1278 * IOMMU Capability Header (PCI).
1279 * In accordance with the AMD spec.
1280 */
1281typedef union
1282{
1283 struct
1284 {
1285 uint32_t u8CapId : 8; /**< Bits 7:0 - CapId: Capability ID. */
1286 uint32_t u8CapPtr : 8; /**< Bits 15:8 - CapPtr: Pointer (PCI config offset) to the next capability. */
1287 uint32_t u3CapType : 3; /**< Bits 18:16 - CapType: Capability Type. */
1288 uint32_t u5CapRev : 5; /**< Bits 23:19 - CapRev: Capability revision. */
1289 uint32_t u1IoTlbSup : 1; /**< Bit 24 - IotlbSup: IOTLB Support. */
1290 uint32_t u1HtTunnel : 1; /**< Bit 25 - HtTunnel: HyperTransport Tunnel translation support. */
1291 uint32_t u1NpCache : 1; /**< Bit 26 - NpCache: Not Present table entries are cached. */
1292 uint32_t u1EfrSup : 1; /**< Bit 27 - EFRSup: Extended Feature Register Support. */
1293 uint32_t u1CapExt : 1; /**< Bit 28 - CapExt: Misc. Information Register 1 Support. */
1294 uint32_t u3Rsvd0 : 3; /**< Bits 31:29 - Reserved. */
1295 } n;
1296 /** The 32-bit unsigned integer view. */
1297 uint32_t u32;
1298} IOMMU_CAP_HDR_T;
1299AssertCompileSize(IOMMU_CAP_HDR_T, 4);
1300
1301/**
1302 * IOMMU Base Address (Lo and Hi) Register (PCI).
1303 * In accordance with the AMD spec.
1304 */
1305typedef union
1306{
1307 struct
1308 {
1309 uint32_t u1Enable : 1; /**< Bit 1 - Enable: RW1S - Enable IOMMU MMIO region. */
1310 uint32_t u12Rsvd0 : 12; /**< Bits 13:1 - Reserved. */
1311 uint32_t u18BaseAddrLo : 18; /**< Bits 31:14 - Base address (Lo) of the MMIO region. */
1312 uint32_t u32BaseAddrHi; /**< Bits 63:32 - Base address (Hi) of the MMIO region. */
1313 } n;
1314 /** The 32-bit unsigned integer view. */
1315 uint32_t au32[2];
1316 /** The 64-bit unsigned integer view. */
1317 uint64_t u64;
1318} IOMMU_BAR_T;
1319AssertCompileSize(IOMMU_BAR_T, 8);
1320#define IOMMU_BAR_VALID_MASK UINT64_C(0xffffffffffffc001)
1321
1322/**
1323 * IOMMU Range Register (PCI).
1324 * In accordance with the AMD spec.
1325 */
1326typedef union
1327{
1328 struct
1329 {
1330 uint32_t u5HtUnitId : 5; /**< Bits 4:0 - UnitID: IOMMU HyperTransport Unit ID (not used). */
1331 uint32_t u2Rsvd0 : 2; /**< Bits 6:5 - Reserved. */
1332 uint32_t u1RangeValid : 1; /**< Bit 7 - RngValid: Range Valid. */
1333 uint32_t u8Bus : 8; /**< Bits 15:8 - BusNumber: Bus number of the first and last device. */
1334 uint32_t u8FirstDevice : 8; /**< Bits 23:16 - FirstDevice: Device and function number of the first device. */
1335 uint32_t u8LastDevice: 8; /**< Bits 31:24 - LastDevice: Device and function number of the last device. */
1336 } n;
1337 /** The 32-bit unsigned integer view. */
1338 uint32_t u32;
1339} IOMMU_RANGE_T;
1340AssertCompileSize(IOMMU_RANGE_T, 4);
1341
1342/**
1343 * Device Table Base Address Register (MMIO).
1344 * In accordance with the AMD spec.
1345 */
1346typedef union
1347{
1348 struct
1349 {
1350 RT_GCC_EXTENSION uint64_t u9Size : 9; /**< Bits 8:0 - Size: Size of the device table. */
1351 RT_GCC_EXTENSION uint64_t u3Rsvd0 : 3; /**< Bits 11:9 - Reserved. */
1352 RT_GCC_EXTENSION uint64_t u40Base : 40; /**< Bits 51:12 - DevTabBase: Device table base address. */
1353 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 63:52 - Reserved. */
1354 } n;
1355 /** The 64-bit unsigned integer view. */
1356 uint64_t u64;
1357} DEV_TAB_BAR_T;
1358AssertCompileSize(DEV_TAB_BAR_T, 8);
1359#define IOMMU_DEV_TAB_BAR_VALID_MASK UINT64_C(0x000ffffffffff1ff)
1360#define IOMMU_DEV_TAB_SEG_BAR_VALID_MASK UINT64_C(0x000ffffffffff0ff)
1361
1362/**
1363 * Command Buffer Base Address Register (MMIO).
1364 * In accordance with the AMD spec.
1365 */
1366typedef union
1367{
1368 struct
1369 {
1370 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 11:0 - Reserved. */
1371 RT_GCC_EXTENSION uint64_t u40Base : 40; /**< Bits 51:12 - ComBase: Command buffer base address. */
1372 RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 55:52 - Reserved. */
1373 RT_GCC_EXTENSION uint64_t u4Len : 4; /**< Bits 59:56 - ComLen: Command buffer length. */
1374 RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; /**< Bits 63:60 - Reserved. */
1375 } n;
1376 /** The 64-bit unsigned integer view. */
1377 uint64_t u64;
1378} CMD_BUF_BAR_T;
1379AssertCompileSize(CMD_BUF_BAR_T, 8);
1380#define IOMMU_CMD_BUF_BAR_VALID_MASK UINT64_C(0x0f0ffffffffff000)
1381
1382/**
1383 * Event Log Base Address Register (MMIO).
1384 * In accordance with the AMD spec.
1385 */
1386typedef union
1387{
1388 struct
1389 {
1390 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 11:0 - Reserved. */
1391 RT_GCC_EXTENSION uint64_t u40Base : 40; /**< Bits 51:12 - EventBase: Event log base address. */
1392 RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 55:52 - Reserved. */
1393 RT_GCC_EXTENSION uint64_t u4Len : 4; /**< Bits 59:56 - EventLen: Event log length. */
1394 RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; /**< Bits 63:60 - Reserved. */
1395 } n;
1396 /** The 64-bit unsigned integer view. */
1397 uint64_t u64;
1398} EVT_LOG_BAR_T;
1399AssertCompileSize(EVT_LOG_BAR_T, 8);
1400#define IOMMU_EVT_LOG_BAR_VALID_MASK UINT64_C(0x0f0ffffffffff000)
1401
1402/**
1403 * IOMMU Control Register (MMIO).
1404 * In accordance with the AMD spec.
1405 */
1406typedef union
1407{
1408 struct
1409 {
1410 uint32_t u1IommuEn : 1; /**< Bit 0 - IommuEn: IOMMU Enable. */
1411 uint32_t u1HtTunEn : 1; /**< Bit 1 - HtTunEn: HyperTransport Tunnel Enable. */
1412 uint32_t u1EvtLogEn : 1; /**< Bit 2 - EventLogEn: Event Log Enable. */
1413 uint32_t u1EvtIntrEn : 1; /**< Bit 3 - EventIntEn: Event Log Interrupt Enable. */
1414 uint32_t u1CompWaitIntrEn : 1; /**< Bit 4 - ComWaitIntEn: Completion Wait Interrupt Enable. */
1415 uint32_t u3InvTimeOut : 3; /**< Bits 7:5 - InvTimeOut: Invalidation Timeout. */
1416 uint32_t u1PassPW : 1; /**< Bit 8 - PassPW: Pass Posted Write. */
1417 uint32_t u1ResPassPW : 1; /**< Bit 9 - ResPassPW: Response Pass Posted Write. */
1418 uint32_t u1Coherent : 1; /**< Bit 10 - Coherent: HT read request packet Coherent bit. */
1419 uint32_t u1Isoc : 1; /**< Bit 11 - Isoc: HT read request packet Isochronous bit. */
1420 uint32_t u1CmdBufEn : 1; /**< Bit 12 - CmdBufEn: Command Buffer Enable. */
1421 uint32_t u1PprLogEn : 1; /**< Bit 13 - PprLogEn: Peripheral Page Request (PPR) Log Enable. */
1422 uint32_t u1PprIntrEn : 1; /**< Bit 14 - PprIntrEn: Peripheral Page Request Interrupt Enable. */
1423 uint32_t u1PprEn : 1; /**< Bit 15 - PprEn: Peripheral Page Request processing Enable. */
1424 uint32_t u1GstTranslateEn : 1; /**< Bit 16 - GTEn: Guest Translate Enable. */
1425 uint32_t u1GstVirtApicEn : 1; /**< Bit 17 - GAEn: Guest Virtual-APIC Enable. */
1426 uint32_t u4Crw : 1; /**< Bits 21:18 - CRW: Intended for future use (not documented). */
1427 uint32_t u1SmiFilterEn : 1; /**< Bit 22 - SmiFEn: SMI Filter Enable. */
1428 uint32_t u1SelfWriteBackDis : 1; /**< Bit 23 - SlfWBDis: Self Write-Back Disable. */
1429 uint32_t u1SmiFilterLogEn : 1; /**< Bit 24 - SmiFLogEn: SMI Filter Log Enable. */
1430 uint32_t u3GstVirtApicModeEn : 3; /**< Bits 27:25 - GAMEn: Guest Virtual-APIC Mode Enable. */
1431 uint32_t u1GstLogEn : 1; /**< Bit 28 - GALogEn: Guest Virtual-APIC GA Log Enable. */
1432 uint32_t u1GstIntrEn : 1; /**< Bit 29 - GAIntEn: Guest Virtual-APIC Interrupt Enable. */
1433 uint32_t u2DualPprLogEn : 2; /**< Bits 31:30 - DualPprLogEn: Dual Peripheral Page Request Log Enable. */
1434 uint32_t u2DualEvtLogEn : 2; /**< Bits 33:32 - DualEventLogEn: Dual Event Log Enable. */
1435 uint32_t u3DevTabSegEn : 3; /**< Bits 36:34 - DevTblSegEn: Device Table Segment Enable. */
1436 uint32_t u2PrivAbortEn : 2; /**< Bits 38:37 - PrivAbrtEn: Privilege Abort Enable. */
1437 uint32_t u1PprAutoRespEn : 1; /**< Bit 39 - PprAutoRspEn: Peripheral Page Request Auto Response Enable. */
1438 uint32_t u1MarcEn : 1; /**< Bit 40 - MarcEn: Memory Address Routing and Control Enable. */
1439 uint32_t u1BlockStopMarkEn : 1; /**< Bit 41 - BlkStopMarkEn: Block StopMark messages Enable. */
1440 uint32_t u1PprAutoRespAlwaysOnEn : 1; /**< Bit 42 - PprAutoRspAon:: PPR Auto Response - Always On Enable. */
1441 uint32_t u1DomainIDPNE : 1; /**< Bit 43 - DomainIDPE: Reserved (not documented). */
1442 uint32_t u1Rsvd0 : 1; /**< Bit 44 - Reserved. */
1443 uint32_t u1EnhancedPpr : 1; /**< Bit 45 - EPHEn: Enhanced Peripheral Page Request Handling Enable. */
1444 uint32_t u2HstAccDirtyBitUpdate : 2; /**< Bits 47:46 - HADUpdate: Access and Dirty Bit updated in host page table. */
1445 uint32_t u1GstDirtyUpdateDis : 1; /**< Bit 48 - GDUpdateDis: Disable hardare update of Dirty bit in GPT. */
1446 uint32_t u1Rsvd1 : 1; /**< Bit 49 - Reserved. */
1447 uint32_t u1X2ApicEn : 1; /**< Bit 50 - XTEn: Enable X2APIC. */
1448 uint32_t u1X2ApicIntrGenEn : 1; /**< Bit 51 - IntCapXTEn: Enable IOMMU X2APIC Interrupt generation. */
1449 uint32_t u2Rsvd0 : 2; /**< Bits 53:52 - Reserved. */
1450 uint32_t u1GstAccessUpdateDis : 1; /**< Bit 54 - GAUpdateDis: Disable hardare update of Access bit in GPT. */
1451 uint32_t u8Rsvd0 : 8; /**< Bits 63:55 - Reserved. */
1452 } n;
1453 /** The 64-bit unsigned integer view. */
1454 uint64_t u64;
1455} IOMMU_CTRL_T;
1456AssertCompileSize(IOMMU_CTRL_T, 8);
1457#define IOMMU_CTRL_VALID_MASK UINT64_C(0x004defffffffffff)
1458#define IOMMU_CTRL_CMD_BUF_EN_MASK UINT64_C(0x0000000000001001)
1459
1460/**
1461 * IOMMU Exclusion Base Register (MMIO).
1462 * In accordance with the AMD spec.
1463 */
1464typedef union
1465{
1466 struct
1467 {
1468 RT_GCC_EXTENSION uint64_t u1ExclEnable : 1; /**< Bit 0 - ExEn: Exclusion Range Enable. */
1469 RT_GCC_EXTENSION uint64_t u1AllowAll : 1; /**< Bit 1 - Allow: Allow All Devices. */
1470 RT_GCC_EXTENSION uint64_t u10Rsvd0 : 10; /**< Bits 11:2 - Reserved. */
1471 RT_GCC_EXTENSION uint64_t u40ExclRangeBase : 40; /**< Bits 51:12 - Exclusion Range Base Address. */
1472 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 63:52 - Reserved. */
1473 } n;
1474 /** The 64-bit unsigned integer view. */
1475 uint64_t u64;
1476} IOMMU_EXCL_RANGE_BAR_T;
1477AssertCompileSize(IOMMU_EXCL_RANGE_BAR_T, 8);
1478#define IOMMU_EXCL_RANGE_BAR_VALID_MASK UINT64_C(0x000ffffffffff003)
1479
1480/**
1481 * IOMMU Exclusion Range Limit Register (MMIO).
1482 * In accordance with the AMD spec.
1483 */
1484typedef union
1485{
1486 struct
1487 {
1488 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 63:52 - Reserved. */
1489 RT_GCC_EXTENSION uint64_t u40ExclRangeLimit : 40; /**< Bits 51:12 - Exclusion Range Limit Address. */
1490 RT_GCC_EXTENSION uint64_t u12Rsvd1 : 12; /**< Bits 63:52 - Reserved (treated as 1s). */
1491 } n;
1492 /** The 64-bit unsigned integer view. */
1493 uint64_t u64;
1494} IOMMU_EXCL_RANGE_LIMIT_T;
1495AssertCompileSize(IOMMU_EXCL_RANGE_LIMIT_T, 8);
1496#define IOMMU_EXCL_RANGE_LIMIT_VALID_MASK UINT64_C(0x000fffffffffffff)
1497
1498/**
1499 * IOMMU Extended Feature Register (MMIO).
1500 * In accordance with the AMD spec.
1501 */
1502typedef union
1503{
1504 struct
1505 {
1506 uint32_t u1PrefetchSup : 1; /**< Bit 0 - PreFSup: Prefetch Support. */
1507 uint32_t u1PprSup : 1; /**< Bit 1 - PPRSup: Peripheral Page Request Support. */
1508 uint32_t u1X2ApicSup : 1; /**< Bit 2 - XTSup: x2Apic Support. */
1509 uint32_t u1NoExecuteSup : 1; /**< Bit 3 - NXSup: No-Execute and Privilege Level Support. */
1510 uint32_t u1GstTranslateSup : 1; /**< Bit 4 - GTSup: Guest Translations (for GVAs) Support. */
1511 uint32_t u1Rsvd0 : 1; /**< Bit 5 - Reserved. */
1512 uint32_t u1InvAllSup : 1; /**< Bit 6 - IASup: Invalidate-All Support. */
1513 uint32_t u1GstVirtApicSup : 1; /**< Bit 7 - GASup: Guest Virtual-APIC Support. */
1514 uint32_t u1HwErrorSup : 1; /**< Bit 8 - HESup: Hardware Error registers Support. */
1515 uint32_t u1PerfCounterSup : 1; /**< Bit 9 - PCSup: Performance Counter Support. */
1516 uint32_t u2HostAddrTranslateSize : 2; /**< Bits 11:10 - HATS: Host Address Translation Size. */
1517 uint32_t u2GstAddrTranslateSize : 2; /**< Bits 13:12 - GATS: Guest Address Translation Size. */
1518 uint32_t u2GstCr3RootTblLevel : 2; /**< Bits 15:14 - GLXSup: Guest CR3 Root Table Level (Max) Size Support. */
1519 uint32_t u2SmiFilterSup : 2; /**< Bits 17:16 - SmiFSup: SMI Filter Register Support. */
1520 uint32_t u3SmiFilterCount : 3; /**< Bits 20:18 - SmiFRC: SMI Filter Register Count. */
1521 uint32_t u3GstVirtApicModeSup : 3; /**< Bits 23:21 - GAMSup: Guest Virtual-APIC Modes Supported. */
1522 uint32_t u2DualPprLogSup : 2; /**< Bits 25:24 - DualPprLogSup: Dual Peripheral Page Request Log Support. */
1523 uint32_t u2Rsvd0 : 2; /**< Bits 27:26 - Reserved. */
1524 uint32_t u2DualEvtLogSup : 2; /**< Bits 29:28 - DualEventLogSup: Dual Event Log Support. */
1525 uint32_t u2Rsvd1 : 2; /**< Bits 31:30 - Reserved. */
1526 uint32_t u5MaxPasidSup : 5; /**< Bits 36:32 - PASMax: Maximum PASID Supported. */
1527 uint32_t u1UserSupervisorSup : 1; /**< Bit 37 - USSup: User/Supervisor Page Protection Support. */
1528 uint32_t u2DevTabSegSup : 2; /**< Bits 39:38 - DevTlbSegSup: Segmented Device Table Support. */
1529 uint32_t u1PprLogOverflowWarn : 1; /**< Bit 40 - PprOvrflwEarlySup: PPR Log Overflow Early Warning Support. */
1530 uint32_t u1PprAutoRespSup : 1; /**< Bit 41 - PprAutoRspSup: PPR Automatic Response Support. */
1531 uint32_t u2MarcSup : 2; /**< Bit 43:42 - MarcSup: Memory Access Routing and Control Support. */
1532 uint32_t u1BlockStopMarkSup : 1; /**< Bit 44 - BlkStopMarkSup: Block StopMark messages Support. */
1533 uint32_t u1PerfOptSup : 1; /**< Bit 45 - PerfOptSup: IOMMU Performance Optimization Support. */
1534 uint32_t u1MsiCapMmioSup : 1; /**< Bit 46 - MsiCapMmioSup: MSI Capability Register MMIO Access Support. */
1535 uint32_t u1Rsvd1 : 1; /**< Bit 47 - Reserved. */
1536 uint32_t u1GstIoSup : 1; /**< Bit 48 - GIoSup: Guest I/O Protection Support. */
1537 uint32_t u1HostAccessSup : 1; /**< Bit 49 - HASup: Host Access Support. */
1538 uint32_t u1EnhancedPprSup : 1; /**< Bit 50 - EPHSup: Enhanced Peripheral Page Request Handling Support. */
1539 uint32_t u1AttrForwardSup : 1; /**< Bit 51 - AttrFWSup: Attribute Forward Support. */
1540 uint32_t u1HostDirtySup : 1; /**< Bit 52 - HDSup: Host Dirty Support. */
1541 uint32_t u1Rsvd2 : 1; /**< Bit 53 - Reserved. */
1542 uint32_t u1InvIoTlbTypeSup : 1; /**< Bit 54 - InvIotlbTypeSup: Invalidate IOTLB Type Support. */
1543 uint32_t u6Rsvd0 : 6; /**< Bit 60:55 - Reserved. */
1544 uint32_t u1GstUpdateDisSup : 1; /**< Bit 61 - GAUpdateDisSup: Disable hardware update on GPT Support. */
1545 uint32_t u1ForcePhysDstSup : 1; /**< Bit 62 - ForcePhyDestSup: Force Phys. Dst. Mode for Remapped Intr. */
1546 uint32_t u1Rsvd3 : 1; /**< Bit 63 - Reserved. */
1547 } n;
1548 /** The 64-bit unsigned integer view. */
1549 uint64_t u64;
1550} IOMMU_EXT_FEAT_T;
1551AssertCompileSize(IOMMU_EXT_FEAT_T, 8);
1552
1553/**
1554 * Peripheral Page Request Log Base Address Register (MMIO).
1555 * In accordance with the AMD spec.
1556 */
1557typedef union
1558{
1559 struct
1560 {
1561 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bit 11:0 - Reserved. */
1562 RT_GCC_EXTENSION uint64_t u40Base : 40; /**< Bits 51:12 - PPRLogBase: Peripheral Page Request Log Base Address. */
1563 RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 55:52 - Reserved. */
1564 RT_GCC_EXTENSION uint64_t u4Len : 4; /**< Bits 59:56 - PPRLogLen: Peripheral Page Request Log Length. */
1565 RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; /**< Bits 63:60 - Reserved. */
1566 } n;
1567 /** The 64-bit unsigned integer view. */
1568 uint64_t u64;
1569} PPR_LOG_BAR_T;
1570AssertCompileSize(PPR_LOG_BAR_T, 8);
1571#define IOMMU_PPR_LOG_BAR_VALID_MASK UINT64_C(0x0f0ffffffffff000)
1572
1573/**
1574 * IOMMU Hardware Event Upper Register (MMIO).
1575 * In accordance with the AMD spec.
1576 */
1577typedef union
1578{
1579 struct
1580 {
1581 RT_GCC_EXTENSION uint64_t u60FirstOperand : 60; /**< Bits 59:0 - First event code dependent operand. */
1582 RT_GCC_EXTENSION uint64_t u4EvtCode : 4; /**< Bits 63:60 - Event Code. */
1583 } n;
1584 /** The 64-bit unsigned integer view. */
1585 uint64_t u64;
1586} IOMMU_HW_EVT_HI_T;
1587AssertCompileSize(IOMMU_HW_EVT_HI_T, 8);
1588
1589/**
1590 * IOMMU Hardware Event Lower Register (MMIO).
1591 * In accordance with the AMD spec.
1592 */
1593typedef uint64_t IOMMU_HW_EVT_LO_T;
1594
1595/**
1596 * IOMMU Hardware Event Status (MMIO).
1597 * In accordance with the AMD spec.
1598 */
1599typedef union
1600{
1601 struct
1602 {
1603 uint32_t u1Valid : 1; /**< Bit 0 - HEV: Hardware Event Valid. */
1604 uint32_t u1Overflow : 1; /**< Bit 1 - HEO: Hardware Event Overflow. */
1605 uint32_t u30Rsvd0 : 30; /**< Bits 31:2 - Reserved. */
1606 uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved. */
1607 } n;
1608 /** The 64-bit unsigned integer view. */
1609 uint64_t u64;
1610} IOMMU_HW_EVT_STATUS_T;
1611AssertCompileSize(IOMMU_HW_EVT_STATUS_T, 8);
1612#define IOMMU_HW_EVT_STATUS_VALID_MASK UINT64_C(0x0000000000000003)
1613
1614/**
1615 * Guest Virtual-APIC Log Base Address Register (MMIO).
1616 * In accordance with the AMD spec.
1617 */
1618typedef union
1619{
1620 struct
1621 {
1622 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bit 11:0 - Reserved. */
1623 RT_GCC_EXTENSION uint64_t u40Base : 40; /**< Bits 51:12 - GALogBase: Guest Virtual-APIC Log Base Address. */
1624 RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 55:52 - Reserved. */
1625 RT_GCC_EXTENSION uint64_t u4Len : 4; /**< Bits 59:56 - GALogLen: Guest Virtual-APIC Log Length. */
1626 RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; /**< Bits 63:60 - Reserved. */
1627 } n;
1628 /** The 64-bit unsigned integer view. */
1629 uint64_t u64;
1630} GALOG_BAR_T;
1631AssertCompileSize(GALOG_BAR_T, 8);
1632
1633/**
1634 * Guest Virtual-APIC Log Tail Address Register (MMIO).
1635 * In accordance with the AMD spec.
1636 */
1637typedef union
1638{
1639 struct
1640 {
1641 RT_GCC_EXTENSION uint64_t u3Rsvd0 : 3; /**< Bits 2:0 - Reserved. */
1642 RT_GCC_EXTENSION uint64_t u40GALogTailAddr : 48; /**< Bits 51:3 - GATAddr: Guest Virtual-APIC Tail Log Address. */
1643 RT_GCC_EXTENSION uint64_t u11Rsvd1 : 11; /**< Bits 63:52 - Reserved. */
1644 } n;
1645 /** The 64-bit unsigned integer view. */
1646 uint64_t u64;
1647} GALOG_TAIL_ADDR_T;
1648AssertCompileSize(GALOG_TAIL_ADDR_T, 8);
1649
1650/**
1651 * PPR Log B Base Address Register (MMIO).
1652 * In accordance with the AMD spec.
1653 * Currently identical to PPR_LOG_BAR_T.
1654 */
1655typedef PPR_LOG_BAR_T PPR_LOG_B_BAR_T;
1656
1657/**
1658 * Event Log B Base Address Register (MMIO).
1659 * In accordance with the AMD spec.
1660 * Currently identical to EVT_LOG_BAR_T.
1661 */
1662typedef EVT_LOG_BAR_T EVT_LOG_B_BAR_T;
1663
1664/**
1665 * Device-specific Feature Extension (DSFX) Register (MMIO).
1666 * In accordance with the AMD spec.
1667 */
1668typedef union
1669{
1670 struct
1671 {
1672 uint32_t u24DevSpecFeat : 24; /**< Bits 23:0 - DevSpecificFeatSupp: Implementation specific features. */
1673 uint32_t u4RevMinor : 4; /**< Bits 27:24 - RevMinor: Minor revision identifier. */
1674 uint32_t u4RevMajor : 4; /**< Bits 31:28 - RevMajor: Major revision identifier. */
1675 uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved.*/
1676 } n;
1677 /** The 64-bit unsigned integer view. */
1678 uint64_t u64;
1679} DEV_SPECIFIC_FEAT_T;
1680AssertCompileSize(DEV_SPECIFIC_FEAT_T, 8);
1681
1682/**
1683 * Device-specific Control Extension (DSCX) Register (MMIO).
1684 * In accordance with the AMD spec.
1685 */
1686typedef union
1687{
1688 struct
1689 {
1690 uint32_t u24DevSpecCtrl : 24; /**< Bits 23:0 - DevSpecificFeatCntrl: Implementation specific control. */
1691 uint32_t u4RevMinor : 4; /**< Bits 27:24 - RevMinor: Minor revision identifier. */
1692 uint32_t u4RevMajor : 4; /**< Bits 31:28 - RevMajor: Major revision identifier. */
1693 uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved.*/
1694 } n;
1695 /** The 64-bit unsigned integer view. */
1696 uint64_t u64;
1697} DEV_SPECIFIC_CTRL_T;
1698AssertCompileSize(DEV_SPECIFIC_CTRL_T, 8);
1699
1700/**
1701 * Device-specific Status Extension (DSSX) Register (MMIO).
1702 * In accordance with the AMD spec.
1703 */
1704typedef union
1705{
1706 struct
1707 {
1708 uint32_t u24DevSpecStatus : 24; /**< Bits 23:0 - DevSpecificFeatStatus: Implementation specific status. */
1709 uint32_t u4RevMinor : 4; /**< Bits 27:24 - RevMinor: Minor revision identifier. */
1710 uint32_t u4RevMajor : 4; /**< Bits 31:28 - RevMajor: Major revision identifier. */
1711 uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved.*/
1712 } n;
1713 /** The 64-bit unsigned integer view. */
1714 uint64_t u64;
1715} DEV_SPECIFIC_STATUS_T;
1716AssertCompileSize(DEV_SPECIFIC_STATUS_T, 8);
1717
1718/**
1719 * MSI Information Register 0 and 1 (PCI) / MSI Vector Register 0 and 1 (MMIO).
1720 * In accordance with the AMD spec.
1721 */
1722typedef union
1723{
1724 struct
1725 {
1726 uint32_t u5MsiNumEvtLog : 5; /**< Bits 4:0 - MsiNum: Event Log MSI message number. */
1727 uint32_t u3GstVirtAddrSize: 3; /**< Bits 7:5 - GVAsize: Guest Virtual Address Size. */
1728 uint32_t u7PhysAddrSize : 7; /**< Bits 14:8 - PAsize: Physical Address Size. */
1729 uint32_t u7VirtAddrSize : 7; /**< Bits 21:15 - VAsize: Virtual Address Size. */
1730 uint32_t u1HtAtsResv: 1; /**< Bit 22 - HtAtsResv: HyperTransport ATS Response Address range Reserved. */
1731 uint32_t u4Rsvd0 : 4; /**< Bits 26:23 - Reserved. */
1732 uint32_t u5MsiNumPpr : 5; /**< Bits 31:27 - MsiNumPPR: Peripheral Page Request MSI message number. */
1733 uint32_t u5MsiNumGa : 5; /**< Bits 36:32 - MsiNumGa: MSI message number for guest virtual-APIC log. */
1734 uint32_t u27Rsvd0: 27; /**< Bits 63:37 - Reserved. */
1735 } n;
1736 /** The 32-bit unsigned integer view. */
1737 uint32_t au32[2];
1738 /** The 64-bit unsigned integer view. */
1739 uint64_t u64;
1740} MSI_MISC_INFO_T;
1741AssertCompileSize(MSI_MISC_INFO_T, 8);
1742/** MSI Vector Register 0 and 1 (MMIO). */
1743typedef MSI_MISC_INFO_T MSI_VECTOR_T;
1744/** Mask of valid bits in MSI Vector Register 1 (or high dword of MSI Misc.
1745 * info). */
1746#define IOMMU_MSI_VECTOR_1_VALID_MASK UINT32_C(0x1f)
1747
1748/**
1749 * MSI Capability Header Register (PCI + MMIO).
1750 * In accordance with the AMD spec.
1751 */
1752typedef union
1753{
1754 struct
1755 {
1756 uint32_t u8MsiCapId : 8; /**< Bits 7:0 - MsiCapId: Capability ID. */
1757 uint32_t u8MsiCapPtr : 8; /**< Bits 15:8 - MsiCapPtr: Pointer (PCI config offset) to the next capability. */
1758 uint32_t u1MsiEnable : 1; /**< Bit 16 - MsiEn: Message Signal Interrupt Enable. */
1759 uint32_t u3MsiMultiMessCap : 3; /**< Bits 19:17 - MsiMultMessCap: MSI Multi-Message Capability. */
1760 uint32_t u3MsiMultiMessEn : 3; /**< Bits 22:20 - MsiMultMessEn: MSI Multi-Message Enable. */
1761 uint32_t u1Msi64BitEn : 1; /**< Bit 23 - Msi64BitEn: MSI 64-bit Enable. */
1762 uint32_t u8Rsvd0 : 8; /**< Bits 31:24 - Reserved. */
1763 } n;
1764 /** The 32-bit unsigned integer view. */
1765 uint32_t u32;
1766} MSI_CAP_HDR_T;
1767AssertCompileSize(MSI_CAP_HDR_T, 4);
1768#define IOMMU_MSI_CAP_HDR_MSI_EN_MASK RT_BIT(16)
1769
1770/**
1771 * MSI Mapping Capability Header Register (PCI + MMIO).
1772 * In accordance with the AMD spec.
1773 */
1774typedef union
1775{
1776 struct
1777 {
1778 uint32_t u8MsiMapCapId : 8; /**< Bits 7:0 - MsiMapCapId: MSI Map capability ID. */
1779 uint32_t u8Rsvd0 : 8; /**< Bits 15:8 - Reserved. */
1780 uint32_t u1MsiMapEn : 1; /**< Bit 16 - MsiMapEn: MSI Map enable. */
1781 uint32_t u1MsiMapFixed : 1; /**< Bit 17 - MsiMapFixd: MSI Map fixed. */
1782 uint32_t u9Rsvd0 : 9; /**< Bits 26:18 - Reserved. */
1783 uint32_t u5MapCapType : 5; /**< Bits 31:27 - MsiMapCapType: MSI Mapping capability type. */
1784 } n;
1785 /** The 32-bit unsigned integer view. */
1786 uint32_t u32;
1787} MSI_MAP_CAP_HDR_T;
1788AssertCompileSize(MSI_MAP_CAP_HDR_T, 4);
1789
1790/**
1791 * Performance Optimization Control Register (MMIO).
1792 * In accordance with the AMD spec.
1793 */
1794typedef union
1795{
1796 struct
1797 {
1798 uint32_t u13Rsvd0 : 13; /**< Bits 12:0 - Reserved. */
1799 uint32_t u1PerfOptEn : 1; /**< Bit 13 - PerfOptEn: Performance Optimization Enable. */
1800 uint32_t u17Rsvd0 : 18; /**< Bits 31:14 - Reserved. */
1801 } n;
1802 /** The 32-bit unsigned integer view. */
1803 uint32_t u32;
1804} IOMMU_PERF_OPT_CTRL_T;
1805AssertCompileSize(IOMMU_PERF_OPT_CTRL_T, 4);
1806
1807/**
1808 * XT (x2APIC) IOMMU General Interrupt Control Register (MMIO).
1809 * In accordance with the AMD spec.
1810 */
1811typedef union
1812{
1813 struct
1814 {
1815 uint32_t u2Rsvd0 : 2; /**< Bits 1:0 - Reserved.*/
1816 uint32_t u1X2ApicIntrDstMode : 1; /**< Bit 2 - Destination Mode for general interrupt.*/
1817 uint32_t u4Rsvd0 : 4; /**< Bits 7:3 - Reserved.*/
1818 uint32_t u24X2ApicIntrDstLo : 24; /**< Bits 31:8 - Destination for general interrupt (Lo).*/
1819 uint32_t u8X2ApicIntrVector : 8; /**< Bits 39:32 - Vector for general interrupt.*/
1820 uint32_t u1X2ApicIntrDeliveryMode : 1; /**< Bit 40 - Delivery Mode for general interrupt.*/
1821 uint32_t u15Rsvd0 : 15; /**< Bits 55:41 - Reserved.*/
1822 uint32_t u7X2ApicIntrDstHi : 7; /**< Bits 63:56 - Destination for general interrupt (Hi) .*/
1823 } n;
1824 /** The 64-bit unsigned integer view. */
1825 uint64_t u64;
1826} IOMMU_XT_GEN_INTR_CTRL_T;
1827AssertCompileSize(IOMMU_XT_GEN_INTR_CTRL_T, 8);
1828
1829/**
1830 * XT (x2APIC) IOMMU General Interrupt Control Register (MMIO).
1831 * In accordance with the AMD spec.
1832 */
1833typedef union
1834{
1835 struct
1836 {
1837 uint32_t u2Rsvd0 : 2; /**< Bits 1:0 - Reserved.*/
1838 uint32_t u1X2ApicIntrDstMode : 1; /**< Bit 2 - Destination Mode for the interrupt.*/
1839 uint32_t u4Rsvd0 : 4; /**< Bits 7:3 - Reserved.*/
1840 uint32_t u24X2ApicIntrDstLo : 24; /**< Bits 31:8 - Destination for the interrupt (Lo).*/
1841 uint32_t u8X2ApicIntrVector : 8; /**< Bits 39:32 - Vector for the interrupt.*/
1842 uint32_t u1X2ApicIntrDeliveryMode : 1; /**< Bit 40 - Delivery Mode for the interrupt.*/
1843 uint32_t u15Rsvd0 : 15; /**< Bits 55:41 - Reserved.*/
1844 uint32_t u7X2ApicIntrDstHi : 7; /**< Bits 63:56 - Destination for the interrupt (Hi) .*/
1845 } n;
1846 /** The 64-bit unsigned integer view. */
1847 uint64_t u64;
1848} IOMMU_XT_INTR_CTRL_T;
1849AssertCompileSize(IOMMU_XT_INTR_CTRL_T, 8);
1850
1851/**
1852 * XT (x2APIC) IOMMU PPR Interrupt Control Register (MMIO).
1853 * In accordance with the AMD spec.
1854 * Currently identical to IOMMU_XT_INTR_CTRL_T.
1855 */
1856typedef IOMMU_XT_INTR_CTRL_T IOMMU_XT_PPR_INTR_CTRL_T;
1857
1858/**
1859 * XT (x2APIC) IOMMU GA (Guest Address) Log Control Register (MMIO).
1860 * In accordance with the AMD spec.
1861 * Currently identical to IOMMU_XT_INTR_CTRL_T.
1862 */
1863typedef IOMMU_XT_INTR_CTRL_T IOMMU_XT_GALOG_INTR_CTRL_T;
1864
1865/**
1866 * Memory Access and Routing Control (MARC) Aperture Base Register (MMIO).
1867 * In accordance with the AMD spec.
1868 */
1869typedef union
1870{
1871 struct
1872 {
1873 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 11:0 - Reserved. */
1874 RT_GCC_EXTENSION uint64_t u40MarcBaseAddr : 40; /**< Bits 51:12 - MarcBaseAddr: MARC Aperture Base Address. */
1875 RT_GCC_EXTENSION uint64_t u12Rsvd1 : 12; /**< Bits 63:52 - Reserved. */
1876 } n;
1877 /** The 64-bit unsigned integer view. */
1878 uint64_t u64;
1879} MARC_APER_BAR_T;
1880AssertCompileSize(MARC_APER_BAR_T, 8);
1881
1882/**
1883 * Memory Access and Routing Control (MARC) Relocation Register (MMIO).
1884 * In accordance with the AMD spec.
1885 */
1886typedef union
1887{
1888 struct
1889 {
1890 RT_GCC_EXTENSION uint64_t u1RelocEn : 1; /**< Bit 0 - RelocEn: Relocation Enabled. */
1891 RT_GCC_EXTENSION uint64_t u1ReadOnly : 1; /**< Bit 1 - ReadOnly: Whether only read-only acceses allowed. */
1892 RT_GCC_EXTENSION uint64_t u10Rsvd0 : 10; /**< Bits 11:2 - Reserved. */
1893 RT_GCC_EXTENSION uint64_t u40MarcRelocAddr : 40; /**< Bits 51:12 - MarcRelocAddr: MARC Aperture Relocation Address. */
1894 RT_GCC_EXTENSION uint64_t u12Rsvd1 : 12; /**< Bits 63:52 - Reserved. */
1895 } n;
1896 /** The 64-bit unsigned integer view. */
1897 uint64_t u64;
1898} MARC_APER_RELOC_T;
1899AssertCompileSize(MARC_APER_RELOC_T, 8);
1900
1901/**
1902 * Memory Access and Routing Control (MARC) Length Register (MMIO).
1903 * In accordance with the AMD spec.
1904 */
1905typedef union
1906{
1907 struct
1908 {
1909 RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 11:0 - Reserved. */
1910 RT_GCC_EXTENSION uint64_t u40MarcLength : 40; /**< Bits 51:12 - MarcLength: MARC Aperture Length. */
1911 RT_GCC_EXTENSION uint64_t u12Rsvd1 : 12; /**< Bits 63:52 - Reserved. */
1912 } n;
1913 /** The 64-bit unsigned integer view. */
1914 uint64_t u64;
1915} MARC_APER_LEN_T;
1916
1917/**
1918 * Memory Access and Routing Control (MARC) Aperture Register.
1919 * This combines other registers to match the MMIO layout for convenient access.
1920 */
1921typedef struct
1922{
1923 MARC_APER_BAR_T Base;
1924 MARC_APER_RELOC_T Reloc;
1925 MARC_APER_LEN_T Length;
1926} MARC_APER_T;
1927AssertCompileSize(MARC_APER_T, 24);
1928
1929/**
1930 * IOMMU Reserved Register (MMIO).
1931 * In accordance with the AMD spec.
1932 * This register is reserved for hardware use (although RW?).
1933 */
1934typedef uint64_t IOMMU_RSVD_REG_T;
1935
1936/**
1937 * Command Buffer Head Pointer Register (MMIO).
1938 * In accordance with the AMD spec.
1939 */
1940typedef union
1941{
1942 struct
1943 {
1944 uint32_t off; /**< Bits 31:0 - Buffer pointer (offset; 16 byte aligned, 512 KB max). */
1945 uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved. */
1946 } n;
1947 /** The 32-bit unsigned integer view. */
1948 uint32_t au32[2];
1949 /** The 64-bit unsigned integer view. */
1950 uint64_t u64;
1951} CMD_BUF_HEAD_PTR_T;
1952AssertCompileSize(CMD_BUF_HEAD_PTR_T, 8);
1953#define IOMMU_CMD_BUF_HEAD_PTR_VALID_MASK UINT64_C(0x000000000007fff0)
1954
1955/**
1956 * Command Buffer Tail Pointer Register (MMIO).
1957 * In accordance with the AMD spec.
1958 * Currently identical to CMD_BUF_HEAD_PTR_T.
1959 */
1960typedef CMD_BUF_HEAD_PTR_T CMD_BUF_TAIL_PTR_T;
1961#define IOMMU_CMD_BUF_TAIL_PTR_VALID_MASK IOMMU_CMD_BUF_HEAD_PTR_VALID_MASK
1962
1963/**
1964 * Event Log Head Pointer Register (MMIO).
1965 * In accordance with the AMD spec.
1966 * Currently identical to CMD_BUF_HEAD_PTR_T.
1967 */
1968typedef CMD_BUF_HEAD_PTR_T EVT_LOG_HEAD_PTR_T;
1969#define IOMMU_EVT_LOG_HEAD_PTR_VALID_MASK IOMMU_CMD_BUF_HEAD_PTR_VALID_MASK
1970
1971/**
1972 * Event Log Tail Pointer Register (MMIO).
1973 * In accordance with the AMD spec.
1974 * Currently identical to CMD_BUF_HEAD_PTR_T.
1975 */
1976typedef CMD_BUF_HEAD_PTR_T EVT_LOG_TAIL_PTR_T;
1977#define IOMMU_EVT_LOG_TAIL_PTR_VALID_MASK IOMMU_CMD_BUF_HEAD_PTR_VALID_MASK
1978
1979
1980/**
1981 * IOMMU Status Register (MMIO).
1982 * In accordance with the AMD spec.
1983 */
1984typedef union
1985{
1986 struct
1987 {
1988 uint32_t u1EvtOverflow : 1; /**< Bit 0 - EventOverflow: Event log overflow. */
1989 uint32_t u1EvtLogIntr : 1; /**< Bit 1 - EventLogInt: Event log interrupt. */
1990 uint32_t u1CompWaitIntr : 1; /**< Bit 2 - ComWaitInt: Completion wait interrupt . */
1991 uint32_t u1EvtLogRunning : 1; /**< Bit 3 - EventLogRun: Event logging is running. */
1992 uint32_t u1CmdBufRunning : 1; /**< Bit 4 - CmdBufRun: Command buffer is running. */
1993 uint32_t u1PprOverflow : 1; /**< Bit 5 - PprOverflow: Peripheral Page Request Log (PPR) overflow. */
1994 uint32_t u1PprIntr : 1; /**< Bit 6 - PprInt: PPR interrupt. */
1995 uint32_t u1PprLogRunning : 1; /**< Bit 7 - PprLogRun: PPR logging is running. */
1996 uint32_t u1GstLogRunning : 1; /**< Bit 8 - GALogRun: Guest virtual-APIC logging is running. */
1997 uint32_t u1GstLogOverflow : 1; /**< Bit 9 - GALOverflow: Guest virtual-APIC log overflow. */
1998 uint32_t u1GstLogIntr : 1; /**< Bit 10 - GAInt: Guest virtual-APIC log interrupt. */
1999 uint32_t u1PprOverflowB : 1; /**< Bit 11 - PprOverflowB: PPR log B overflow. */
2000 uint32_t u1PprLogActive : 1; /**< Bit 12 - PprLogActive: PPR log A is active. */
2001 uint32_t u2Rsvd0 : 2; /**< Bits 14:13 - Reserved. */
2002 uint32_t u1EvtOverflowB : 1; /**< Bit 15 - EvtOverflowB: Event log B overflow. */
2003 uint32_t u1EvtLogActive : 1; /**< Bit 16 - EvtLogActive: Event log A active. */
2004 uint32_t u1PprOverflowEarlyB : 1; /**< Bit 17 - PprOverflowEarlyB: PPR log B overflow early warning. */
2005 uint32_t u1PprOverflowEarly : 1; /**< Bit 18 - PprOverflowEarly: PPR log overflow early warning. */
2006 uint32_t u13Rsvd0 : 13; /**< Bits 31:19 - Reserved. */
2007 uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved . */
2008 } n;
2009 /** The 32-bit unsigned integer view. */
2010 uint32_t au32[2];
2011 /** The 64-bit unsigned integer view. */
2012 uint64_t u64;
2013} IOMMU_STATUS_T;
2014AssertCompileSize(IOMMU_STATUS_T, 8);
2015#define IOMMU_STATUS_VALID_MASK UINT64_C(0x0000000000079fff)
2016#define IOMMU_STATUS_RW1C_MASK UINT64_C(0x0000000000068e67)
2017
2018/**
2019 * PPR Log Head Pointer Register (MMIO).
2020 * In accordance with the AMD spec.
2021 * Currently identical to CMD_BUF_HEAD_PTR_T.
2022 */
2023typedef CMD_BUF_HEAD_PTR_T PPR_LOG_HEAD_PTR_T;
2024
2025/**
2026 * PPR Log Tail Pointer Register (MMIO).
2027 * In accordance with the AMD spec.
2028 * Currently identical to CMD_BUF_HEAD_PTR_T.
2029 */
2030typedef CMD_BUF_HEAD_PTR_T PPR_LOG_TAIL_PTR_T;
2031
2032/**
2033 * Guest Virtual-APIC Log Head Pointer Register (MMIO).
2034 * In accordance with the AMD spec.
2035 */
2036typedef union
2037{
2038 struct
2039 {
2040 uint32_t u2Rsvd0 : 2; /**< Bits 2:0 - Reserved. */
2041 uint32_t u12GALogPtr : 12; /**< Bits 15:3 - Guest Virtual-APIC Log Head or Tail Pointer. */
2042 uint32_t u16Rsvd0 : 16; /**< Bits 31:16 - Reserved. */
2043 uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved. */
2044 } n;
2045 /** The 32-bit unsigned integer view. */
2046 uint32_t au32[2];
2047 /** The 64-bit unsigned integer view. */
2048 uint64_t u64;
2049} GALOG_HEAD_PTR_T;
2050AssertCompileSize(GALOG_HEAD_PTR_T, 8);
2051
2052/**
2053 * Guest Virtual-APIC Log Tail Pointer Register (MMIO).
2054 * In accordance with the AMD spec.
2055 * Currently identical to GALOG_HEAD_PTR_T.
2056 */
2057typedef GALOG_HEAD_PTR_T GALOG_TAIL_PTR_T;
2058
2059/**
2060 * PPR Log B Head Pointer Register (MMIO).
2061 * In accordance with the AMD spec.
2062 * Currently identical to CMD_BUF_HEAD_PTR_T.
2063 */
2064typedef CMD_BUF_HEAD_PTR_T PPR_LOG_B_HEAD_PTR_T;
2065
2066/**
2067 * PPR Log B Tail Pointer Register (MMIO).
2068 * In accordance with the AMD spec.
2069 * Currently identical to CMD_BUF_HEAD_PTR_T.
2070 */
2071typedef CMD_BUF_HEAD_PTR_T PPR_LOG_B_TAIL_PTR_T;
2072
2073/**
2074 * Event Log B Head Pointer Register (MMIO).
2075 * In accordance with the AMD spec.
2076 * Currently identical to CMD_BUF_HEAD_PTR_T.
2077 */
2078typedef CMD_BUF_HEAD_PTR_T EVT_LOG_B_HEAD_PTR_T;
2079
2080/**
2081 * Event Log B Tail Pointer Register (MMIO).
2082 * In accordance with the AMD spec.
2083 * Currently identical to CMD_BUF_HEAD_PTR_T.
2084 */
2085typedef CMD_BUF_HEAD_PTR_T EVT_LOG_B_TAIL_PTR_T;
2086
2087/**
2088 * PPR Log Auto Response Register (MMIO).
2089 * In accordance with the AMD spec.
2090 */
2091typedef union
2092{
2093 struct
2094 {
2095 uint32_t u4AutoRespCode : 4; /**< Bits 3:0 - PprAutoRespCode: PPR log Auto Response Code. */
2096 uint32_t u1AutoRespMaskGen : 1; /**< Bit 4 - PprAutoRespMaskGn: PPR log Auto Response Mask Gen. */
2097 uint32_t u27Rsvd0 : 27; /**< Bits 31:5 - Reserved. */
2098 uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved.*/
2099 } n;
2100 /** The 32-bit unsigned integer view. */
2101 uint32_t au32[2];
2102 /** The 64-bit unsigned integer view. */
2103 uint64_t u64;
2104} PPR_LOG_AUTO_RESP_T;
2105AssertCompileSize(PPR_LOG_AUTO_RESP_T, 8);
2106
2107/**
2108 * PPR Log Overflow Early Indicator Register (MMIO).
2109 * In accordance with the AMD spec.
2110 */
2111typedef union
2112{
2113 struct
2114 {
2115 uint32_t u15Threshold : 15; /**< Bits 14:0 - PprOvrflwEarlyThreshold: Overflow early indicator threshold. */
2116 uint32_t u15Rsvd0 : 15; /**< Bits 29:15 - Reserved. */
2117 uint32_t u1IntrEn : 1; /**< Bit 30 - PprOvrflwEarlyIntEn: Overflow early indicator interrupt enable. */
2118 uint32_t u1Enable : 1; /**< Bit 31 - PprOvrflwEarlyEn: Overflow early indicator enable. */
2119 uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved. */
2120 } n;
2121 /** The 32-bit unsigned integer view. */
2122 uint32_t au32[2];
2123 /** The 64-bit unsigned integer view. */
2124 uint64_t u64;
2125} PPR_LOG_OVERFLOW_EARLY_T;
2126AssertCompileSize(PPR_LOG_OVERFLOW_EARLY_T, 8);
2127
2128/**
2129 * PPR Log B Overflow Early Indicator Register (MMIO).
2130 * In accordance with the AMD spec.
2131 * Currently identical to PPR_LOG_OVERFLOW_EARLY_T.
2132 */
2133typedef PPR_LOG_OVERFLOW_EARLY_T PPR_LOG_B_OVERFLOW_EARLY_T;
2134
2135/**
2136 * ILLEGAL_DEV_TABLE_ENTRY Event Types.
2137 * In accordance with the AMD spec.
2138 */
2139typedef enum EVT_ILLEGAL_DTE_TYPE_T
2140{
2141 kIllegalDteType_RsvdNotZero = 0,
2142 kIllegalDteType_RsvdIntTabLen,
2143 kIllegalDteType_RsvdIoCtl,
2144 kIllegalDteType_RsvdIntCtl
2145} EVT_ILLEGAL_DTE_TYPE_T;
2146
2147/**
2148 * ILLEGAL_DEV_TABLE_ENTRY Event Types.
2149 * In accordance with the AMD spec.
2150 */
2151typedef enum EVT_IO_PAGE_FAULT_TYPE_T
2152{
2153 /* Memory transaction. */
2154 kIoPageFaultType_DteRsvdPagingMode = 0,
2155 kIoPageFaultType_PteInvalidPageSize,
2156 kIoPageFaultType_PteInvalidLvlEncoding,
2157 kIoPageFaultType_SkippedLevelIovaNotZero,
2158 kIoPageFaultType_PteRsvdNotZero,
2159 kIoPageFaultType_PteValidNotSet,
2160 kIoPageFaultType_DteTranslationDisabled,
2161 kIoPageFaultType_PasidInvalidRange,
2162 kIoPageFaultType_PermDenied,
2163 kIoPageFaultType_UserSupervisor,
2164 /* Interrupt remapping */
2165 kIoPageFaultType_IrteAddrInvalid,
2166 kIoPageFaultType_IrteRsvdNotZero,
2167 kIoPageFaultType_IrteRemapEn,
2168 kIoPageFaultType_IrteRsvdIntType,
2169 kIoPageFaultType_IntrReqAborted,
2170 kIoPageFaultType_IntrWithPasid,
2171 kIoPageFaultType_SmiFilterMismatch,
2172 /* Memory transaction or interrupt remapping. */
2173 kIoPageFaultType_DevId_Invalid
2174} EVT_IO_PAGE_FAULT_TYPE_T;
2175
2176/**
2177 * IOTLB_INV_TIMEOUT Event Types.
2178 * In accordance with the AMD spec.
2179 */
2180typedef enum EVT_IOTLB_INV_TIMEOUT_TYPE_T
2181{
2182 InvTimeoutType_NoResponse = 0
2183} EVT_IOTLB_INV_TIMEOUT_TYPE_T;
2184
2185/**
2186 * INVALID_DEVICE_REQUEST Event Types.
2187 * In accordance with the AMD spec.
2188 */
2189typedef enum EVT_INVALID_DEV_REQ_TYPE_T
2190{
2191 /* Access. */
2192 kInvalidDevReqType_ReadOrNonPostedWrite = 0,
2193 kInvalidDevReqType_PretranslatedTransaction,
2194 kInvalidDevReqType_PortIo,
2195 kInvalidDevReqType_SysMgt,
2196 kInvalidDevReqType_IntrRange,
2197 kInvalidDevReqType_RsvdIntrRange,
2198 kInvalidDevReqType_SysMgtAddr,
2199 /* Translation Request. */
2200 kInvalidDevReqType_TrAccessInvalid,
2201 kInvalidDevReqType_TrDisabled,
2202 kInvalidDevReqType_DevIdInvalid
2203} EVT_INVALID_DEV_REQ_TYPE_T;
2204
2205/**
2206 * INVALID_PPR_REQUEST Event Types.
2207 * In accordance with the AMD spec.
2208 */
2209typedef enum EVT_INVALID_PPR_REQ_TYPE_T
2210{
2211 kInvalidPprReqType_PriNotSupported,
2212 kInvalidPprReqType_GstTranslateDisabled
2213} EVT_INVALID_PPR_REQ_TYPE_T;
2214
2215
2216/** @name IVRS format revision field.
2217 * In accordance with the AMD spec.
2218 * @{ */
2219/** Fixed: Supports only pre-assigned device IDs and type 10h and 11h IVHD
2220 * blocks. */
2221#define ACPI_IVRS_FMT_REV_FIXED 0x1
2222/** Mixed: Supports pre-assigned and ACPI HID device naming and all IVHD blocks. */
2223#define ACPI_IVRS_FMT_REV_MIXED 0x2
2224/** @} */
2225
2226/** @name IVHD special device entry variety field.
2227 * In accordance with the AMD spec.
2228 * @{ */
2229/** I/O APIC. */
2230#define ACPI_IVHD_VARIETY_IOAPIC 0x1
2231/** HPET. */
2232#define ACPI_IVHD_VARIETY_HPET 0x2
2233/** @} */
2234
2235/** @name IVHD device entry type codes.
2236 * In accordance with the AMD spec.
2237 * @{ */
2238/** Reserved. */
2239#define ACPI_IVHD_DEVENTRY_TYPE_RSVD 0x0
2240/** All: DTE setting applies to all Device IDs. */
2241#define ACPI_IVHD_DEVENTRY_TYPE_ALL 0x1
2242/** Select: DTE setting applies to the device specified in DevId field. */
2243#define ACPI_IVHD_DEVENTRY_TYPE_SELECT 0x2
2244/** Start of range: DTE setting applies to all devices from start of range specified
2245 * by the DevId field. */
2246#define ACPI_IVHD_DEVENTRY_TYPE_START_RANGE 0x3
2247/** End of range: DTE setting from previous type 3 entry applies to all devices
2248 * incl. DevId specified by this entry. */
2249#define ACPI_IVHD_DEVENTRY_TYPE_END_RANGE 0x4
2250/** @} */
2251
2252/** @name IVHD DTE (Device Table Entry) Settings.
2253 * In accordance with the AMD spec.
2254 * @{ */
2255/** INITPass: Identifies a device able to assert INIT interrupts. */
2256#define ACPI_IVHD_DTE_INIT_PASS_SHIFT 0
2257#define ACPI_IVHD_DTE_INIT_PASS_MASK UINT8_C(0x01)
2258/** EIntPass: Identifies a device able to assert ExtInt interrupts. */
2259#define ACPI_IVHD_DTE_EXTINT_PASS_SHIFT 1
2260#define ACPI_IVHD_DTE_EXTINT_PASS_MASK UINT8_C(0x02)
2261/** NMIPass: Identifies a device able to assert NMI interrupts. */
2262#define ACPI_IVHD_DTE_NMI_PASS_SHIFT 2
2263#define ACPI_IVHD_DTE_NMI_PASS_MASK UINT8_C(0x04)
2264/** Bit 3 reserved. */
2265#define ACPI_IVHD_DTE_RSVD_3_SHIFT 3
2266#define ACPI_IVHD_DTE_RSVD_3_MASK UINT8_C(0x08)
2267/** SysMgt: Identifies a device able to assert system management messages. */
2268#define ACPI_IVHD_DTE_SYS_MGT_SHIFT 4
2269#define ACPI_IVHD_DTE_SYS_MGT_MASK UINT8_C(0x30)
2270/** Lint0Pass: Identifies a device able to assert LINT0 interrupts. */
2271#define ACPI_IVHD_DTE_LINT0_PASS_SHIFT 6
2272#define ACPI_IVHD_DTE_LINT0_PASS_MASK UINT8_C(0x40)
2273/** Lint0Pass: Identifies a device able to assert LINT1 interrupts. */
2274#define ACPI_IVHD_DTE_LINT1_PASS_SHIFT 7
2275#define ACPI_IVHD_DTE_LINT1_PASS_MASK UINT8_C(0x80)
2276RT_BF_ASSERT_COMPILE_CHECKS(ACPI_IVHD_DTE_, UINT8_C(0), UINT8_MAX,
2277 (INIT_PASS, EXTINT_PASS, NMI_PASS, RSVD_3, SYS_MGT, LINT0_PASS, LINT1_PASS));
2278/** @} */
2279
2280/**
2281 * AMD IOMMU: IVHD (I/O Virtualization Hardware Definition) Device Entry (4-byte).
2282 * In accordance with the AMD spec.
2283 */
2284#pragma pack(1)
2285typedef struct ACPIIVHDDEVENTRY4
2286{
2287 uint8_t u8DevEntryType; /**< Device entry type. */
2288 uint16_t u16DevId; /**< Device ID. */
2289 uint8_t u8DteSetting; /**< DTE (Device Table Entry) setting. */
2290} ACPIIVHDDEVENTRY4;
2291#pragma pack()
2292AssertCompileSize(ACPIIVHDDEVENTRY4, 4);
2293
2294/**
2295 * AMD IOMMU: IVHD (I/O Virtualization Hardware Definition) Device Entry (8-byte).
2296 * In accordance with the AMD spec.
2297 */
2298#pragma pack(1)
2299typedef struct ACPIIVHDDEVENTRY8
2300{
2301 uint8_t u8DevEntryType; /**< Device entry type. */
2302 union
2303 {
2304 /** Reserved: When u8DevEntryType is 0x40, 0x41, 0x44 or 0x45 (or 0x49-0x7F). */
2305 struct
2306 {
2307 uint8_t au8Rsvd0[7]; /**< Reserved (MBZ). */
2308 } rsvd;
2309 /** Alias Select: When u8DevEntryType is 0x42 or 0x43. */
2310 struct
2311 {
2312 uint16_t u16DevIdA; /**< Device ID A. */
2313 uint8_t u8DteSetting; /**< DTE (Device Table Entry) setting. */
2314 uint8_t u8Rsvd0; /**< Reserved (MBZ). */
2315 uint16_t u16DevIdB; /**< Device ID B. */
2316 uint8_t u8Rsvd1; /**< Reserved (MBZ). */
2317 } alias;
2318 /** Extended Select: When u8DevEntryType is 0x46 or 0x47. */
2319 struct
2320 {
2321 uint16_t u16DevId; /**< Device ID. */
2322 uint8_t u8DteSetting; /**< DTE (Device Table Entry) setting. */
2323 uint32_t u32ExtDteSetting; /**< Extended DTE setting. */
2324 } ext;
2325 /** Special Device: When u8DevEntryType is 0x48. */
2326 struct
2327 {
2328 uint16_t u16Rsvd0; /**< Reserved (MBZ). */
2329 uint8_t u8DteSetting; /**< DTE (Device Table Entry) setting. */
2330 uint8_t u8Handle; /**< Handle contains I/O APIC ID or HPET number. */
2331 uint16_t u16DevIdB; /**< Device ID B (I/O APIC or HPET). */
2332 uint8_t u8Variety; /**< Whether this is the HPET or I/O APIC. */
2333 } special;
2334 } u;
2335} ACPIIVHDDEVENTRY8;
2336#pragma pack()
2337AssertCompileSize(ACPIIVHDDEVENTRY8, 8);
2338
2339/** @name IVHD Type 10h Flags.
2340 * In accordance with the AMD spec.
2341 * @{ */
2342/** Peripheral page request support. */
2343#define ACPI_IVHD_10H_F_PPR_SUP RT_BIT(7)
2344/** Prefetch IOMMU pages command support. */
2345#define ACPI_IVHD_10H_F_PREF_SUP RT_BIT(6)
2346/** Coherent control. */
2347#define ACPI_IVHD_10H_F_COHERENT RT_BIT(5)
2348/** Remote IOTLB support. */
2349#define ACPI_IVHD_10H_F_IOTLB_SUP RT_BIT(4)
2350/** Isochronous control. */
2351#define ACPI_IVHD_10H_F_ISOC RT_BIT(3)
2352/** Response Pass Posted Write. */
2353#define ACPI_IVHD_10H_F_RES_PASS_PW RT_BIT(2)
2354/** Pass Posted Write. */
2355#define ACPI_IVHD_10H_F_PASS_PW RT_BIT(1)
2356/** HyperTransport Tunnel. */
2357#define ACPI_IVHD_10H_F_HT_TUNNEL RT_BIT(0)
2358/** @} */
2359
2360/** @name IVRS IVinfo field.
2361 * In accordance with the AMD spec.
2362 * @{ */
2363/** EFRSup: Extended Feature Support. */
2364#define ACPI_IVINFO_BF_EFR_SUP_SHIFT 0
2365#define ACPI_IVINFO_BF_EFR_SUP_MASK UINT32_C(0x00000001)
2366/** DMA Remap Sup: DMA remapping support (pre-boot DMA protection with
2367 * mandatory remapping of device accessed memory). */
2368#define ACPI_IVINFO_BF_DMA_REMAP_SUP_SHIFT 1
2369#define ACPI_IVINFO_BF_DMA_REMAP_SUP_MASK UINT32_C(0x00000002)
2370/** Bits 4:2 reserved. */
2371#define ACPI_IVINFO_BF_RSVD_2_4_SHIFT 2
2372#define ACPI_IVINFO_BF_RSVD_2_4_MASK UINT32_C(0x0000001c)
2373/** GVASize: Guest virtual-address size. */
2374#define ACPI_IVINFO_BF_GVA_SIZE_SHIFT 5
2375#define ACPI_IVINFO_BF_GVA_SIZE_MASK UINT32_C(0x000000e0)
2376/** PASize: System physical address size. */
2377#define ACPI_IVINFO_BF_PA_SIZE_SHIFT 8
2378#define ACPI_IVINFO_BF_PA_SIZE_MASK UINT32_C(0x00007f00)
2379/** VASize: Virtual address size. */
2380#define ACPI_IVINFO_BF_VA_SIZE_SHIFT 15
2381#define ACPI_IVINFO_BF_VA_SIZE_MASK UINT32_C(0x003f8000)
2382/** HTAtsResv: HyperTransport ATS-response address translation range reserved. */
2383#define ACPI_IVINFO_BF_HT_ATS_RESV_SHIFT 22
2384#define ACPI_IVINFO_BF_HT_ATS_RESV_MASK UINT32_C(0x00400000)
2385/** Bits 31:23 reserved. */
2386#define ACPI_IVINFO_BF_RSVD_23_31_SHIFT 23
2387#define ACPI_IVINFO_BF_RSVD_23_31_MASK UINT32_C(0xff800000)
2388RT_BF_ASSERT_COMPILE_CHECKS(ACPI_IVINFO_BF_, UINT32_C(0), UINT32_MAX,
2389 (EFR_SUP, DMA_REMAP_SUP, RSVD_2_4, GVA_SIZE, PA_SIZE, VA_SIZE, HT_ATS_RESV, RSVD_23_31));
2390/** @} */
2391
2392/** @name IVHD IOMMU info flags.
2393 * In accordance with the AMD spec.
2394 * @{ */
2395/** MSI message number for the event log. */
2396#define ACPI_IOMMU_INFO_BF_MSI_NUM_SHIFT 0
2397#define ACPI_IOMMU_INFO_BF_MSI_NUM_MASK UINT16_C(0x001f)
2398/** Bits 7:5 reserved. */
2399#define ACPI_IOMMU_INFO_BF_RSVD_5_7_SHIFT 5
2400#define ACPI_IOMMU_INFO_BF_RSVD_5_7_MASK UINT16_C(0x00e0)
2401/** IOMMU HyperTransport Unit ID number. */
2402#define ACPI_IOMMU_INFO_BF_UNIT_ID_SHIFT 8
2403#define ACPI_IOMMU_INFO_BF_UNIT_ID_MASK UINT16_C(0x1f00)
2404/** Bits 15:13 reserved. */
2405#define ACPI_IOMMU_INFO_BF_RSVD_13_15_SHIFT 13
2406#define ACPI_IOMMU_INFO_BF_RSVD_13_15_MASK UINT16_C(0xe000)
2407RT_BF_ASSERT_COMPILE_CHECKS(ACPI_IOMMU_INFO_BF_, UINT16_C(0), UINT16_MAX,
2408 (MSI_NUM, RSVD_5_7, UNIT_ID, RSVD_13_15));
2409/** @} */
2410
2411/** @name IVHD IOMMU feature reporting field.
2412 * In accordance with the AMD spec.
2413 * @{ */
2414/** x2APIC supported for peripherals. */
2415#define ACPI_IOMMU_FEAT_BF_XT_SUP_SHIFT 0
2416#define ACPI_IOMMU_FEAT_BF_XT_SUP_MASK UINT32_C(0x00000001)
2417/** NX supported for I/O. */
2418#define ACPI_IOMMU_FEAT_BF_NX_SUP_SHIFT 1
2419#define ACPI_IOMMU_FEAT_BF_NX_SUP_MASK UINT32_C(0x00000002)
2420/** GT (Guest Translation) supported. */
2421#define ACPI_IOMMU_FEAT_BF_GT_SUP_SHIFT 2
2422#define ACPI_IOMMU_FEAT_BF_GT_SUP_MASK UINT32_C(0x00000004)
2423/** GLX (Number of guest CR3 tables) supported. */
2424#define ACPI_IOMMU_FEAT_BF_GLX_SUP_SHIFT 3
2425#define ACPI_IOMMU_FEAT_BF_GLX_SUP_MASK UINT32_C(0x00000018)
2426/** IA (INVALIDATE_IOMMU_ALL) command supported. */
2427#define ACPI_IOMMU_FEAT_BF_IA_SUP_SHIFT 5
2428#define ACPI_IOMMU_FEAT_BF_IA_SUP_MASK UINT32_C(0x00000020)
2429/** GA (Guest virtual APIC) supported. */
2430#define ACPI_IOMMU_FEAT_BF_GA_SUP_SHIFT 6
2431#define ACPI_IOMMU_FEAT_BF_GA_SUP_MASK UINT32_C(0x00000040)
2432/** HE (Hardware error) registers supported. */
2433#define ACPI_IOMMU_FEAT_BF_HE_SUP_SHIFT 7
2434#define ACPI_IOMMU_FEAT_BF_HE_SUP_MASK UINT32_C(0x00000080)
2435/** PASMax (maximum PASID) supported. Ignored if PPRSup=0. */
2436#define ACPI_IOMMU_FEAT_BF_PAS_MAX_SHIFT 8
2437#define ACPI_IOMMU_FEAT_BF_PAS_MAX_MASK UINT32_C(0x00001f00)
2438/** PNCounters (Number of performance counters per counter bank) supported. */
2439#define ACPI_IOMMU_FEAT_BF_PN_COUNTERS_SHIFT 13
2440#define ACPI_IOMMU_FEAT_BF_PN_COUNTERS_MASK UINT32_C(0x0001e000)
2441/** PNBanks (Number of performance counter banks) supported. */
2442#define ACPI_IOMMU_FEAT_BF_PN_BANKS_SHIFT 17
2443#define ACPI_IOMMU_FEAT_BF_PN_BANKS_MASK UINT32_C(0x007e0000)
2444/** MSINumPPR (MSI number for peripheral page requests). */
2445#define ACPI_IOMMU_FEAT_BF_MSI_NUM_PPR_SHIFT 23
2446#define ACPI_IOMMU_FEAT_BF_MSI_NUM_PPR_MASK UINT32_C(0x0f800000)
2447/** GATS (Guest address translation size). MBZ when GTSup=0. */
2448#define ACPI_IOMMU_FEAT_BF_GATS_SHIFT 28
2449#define ACPI_IOMMU_FEAT_BF_GATS_MASK UINT32_C(0x30000000)
2450/** HATS (Host address translation size). */
2451#define ACPI_IOMMU_FEAT_BF_HATS_SHIFT 30
2452#define ACPI_IOMMU_FEAT_BF_HATS_MASK UINT32_C(0xc0000000)
2453RT_BF_ASSERT_COMPILE_CHECKS(ACPI_IOMMU_FEAT_BF_, UINT32_C(0), UINT32_MAX,
2454 (XT_SUP, NX_SUP, GT_SUP, GLX_SUP, IA_SUP, GA_SUP, HE_SUP, PAS_MAX, PN_COUNTERS, PN_BANKS,
2455 MSI_NUM_PPR, GATS, HATS));
2456/** @} */
2457
2458/** @name IOMMU Extended Feature Register (PCI/MMIO/ACPI).
2459 * In accordance with the AMD spec.
2460 * @{ */
2461/** PreFSup: Prefetch support (RO). */
2462#define IOMMU_EXT_FEAT_BF_PREF_SUP_SHIFT 0
2463#define IOMMU_EXT_FEAT_BF_PREF_SUP_MASK UINT64_C(0x0000000000000001)
2464/** PPRSup: Peripheral Page Request (PPR) support (RO). */
2465#define IOMMU_EXT_FEAT_BF_PPR_SUP_SHIFT 1
2466#define IOMMU_EXT_FEAT_BF_PPR_SUP_MASK UINT64_C(0x0000000000000002)
2467/** XTSup: x2APIC support (RO). */
2468#define IOMMU_EXT_FEAT_BF_X2APIC_SUP_SHIFT 2
2469#define IOMMU_EXT_FEAT_BF_X2APIC_SUP_MASK UINT64_C(0x0000000000000004)
2470/** NXSup: No Execute (PMR and PRIV) support (RO). */
2471#define IOMMU_EXT_FEAT_BF_NO_EXEC_SUP_SHIFT 3
2472#define IOMMU_EXT_FEAT_BF_NO_EXEC_SUP_MASK UINT64_C(0x0000000000000008)
2473/** GTSup: Guest Translation support (RO). */
2474#define IOMMU_EXT_FEAT_BF_GT_SUP_SHIFT 4
2475#define IOMMU_EXT_FEAT_BF_GT_SUP_MASK UINT64_C(0x0000000000000010)
2476/** Bit 5 reserved. */
2477#define IOMMU_EXT_FEAT_BF_RSVD_5_SHIFT 5
2478#define IOMMU_EXT_FEAT_BF_RSVD_5_MASK UINT64_C(0x0000000000000020)
2479/** IASup: INVALIDATE_IOMMU_ALL command support (RO). */
2480#define IOMMU_EXT_FEAT_BF_IA_SUP_SHIFT 6
2481#define IOMMU_EXT_FEAT_BF_IA_SUP_MASK UINT64_C(0x0000000000000040)
2482/** GASup: Guest virtual-APIC support (RO). */
2483#define IOMMU_EXT_FEAT_BF_GA_SUP_SHIFT 7
2484#define IOMMU_EXT_FEAT_BF_GA_SUP_MASK UINT64_C(0x0000000000000080)
2485/** HESup: Hardware error registers support (RO). */
2486#define IOMMU_EXT_FEAT_BF_HE_SUP_SHIFT 8
2487#define IOMMU_EXT_FEAT_BF_HE_SUP_MASK UINT64_C(0x0000000000000100)
2488/** PCSup: Performance counters support (RO). */
2489#define IOMMU_EXT_FEAT_BF_PC_SUP_SHIFT 9
2490#define IOMMU_EXT_FEAT_BF_PC_SUP_MASK UINT64_C(0x0000000000000200)
2491/** HATS: Host Address Translation Size (RO). */
2492#define IOMMU_EXT_FEAT_BF_HATS_SHIFT 10
2493#define IOMMU_EXT_FEAT_BF_HATS_MASK UINT64_C(0x0000000000000c00)
2494/** GATS: Guest Address Translation Size (RO). */
2495#define IOMMU_EXT_FEAT_BF_GATS_SHIFT 12
2496#define IOMMU_EXT_FEAT_BF_GATS_MASK UINT64_C(0x0000000000003000)
2497/** GLXSup: Guest CR3 root table level support (RO). */
2498#define IOMMU_EXT_FEAT_BF_GLX_SUP_SHIFT 14
2499#define IOMMU_EXT_FEAT_BF_GLX_SUP_MASK UINT64_C(0x000000000000c000)
2500/** SmiFSup: SMI filter register support (RO). */
2501#define IOMMU_EXT_FEAT_BF_SMI_FLT_SUP_SHIFT 16
2502#define IOMMU_EXT_FEAT_BF_SMI_FLT_SUP_MASK UINT64_C(0x0000000000030000)
2503/** SmiFRC: SMI filter register count (RO). */
2504#define IOMMU_EXT_FEAT_BF_SMI_FLT_REG_CNT_SHIFT 18
2505#define IOMMU_EXT_FEAT_BF_SMI_FLT_REG_CNT_MASK UINT64_C(0x00000000001c0000)
2506/** GAMSup: Guest virtual-APIC modes support (RO). */
2507#define IOMMU_EXT_FEAT_BF_GAM_SUP_SHIFT 21
2508#define IOMMU_EXT_FEAT_BF_GAM_SUP_MASK UINT64_C(0x0000000000e00000)
2509/** DualPprLogSup: Dual PPR Log support (RO). */
2510#define IOMMU_EXT_FEAT_BF_DUAL_PPR_LOG_SUP_SHIFT 24
2511#define IOMMU_EXT_FEAT_BF_DUAL_PPR_LOG_SUP_MASK UINT64_C(0x0000000003000000)
2512/** Bits 27:26 reserved. */
2513#define IOMMU_EXT_FEAT_BF_RSVD_26_27_SHIFT 26
2514#define IOMMU_EXT_FEAT_BF_RSVD_26_27_MASK UINT64_C(0x000000000c000000)
2515/** DualEventLogSup: Dual Event Log support (RO). */
2516#define IOMMU_EXT_FEAT_BF_DUAL_EVT_LOG_SUP_SHIFT 28
2517#define IOMMU_EXT_FEAT_BF_DUAL_EVT_LOG_SUP_MASK UINT64_C(0x0000000030000000)
2518/** Bits 31:30 reserved. */
2519#define IOMMU_EXT_FEAT_BF_RSVD_30_31_SHIFT 30
2520#define IOMMU_EXT_FEAT_BF_RSVD_30_31_MASK UINT64_C(0x00000000c0000000)
2521/** PASMax: Maximum PASID support (RO). */
2522#define IOMMU_EXT_FEAT_BF_PASID_MAX_SHIFT 32
2523#define IOMMU_EXT_FEAT_BF_PASID_MAX_MASK UINT64_C(0x0000001f00000000)
2524/** USSup: User/Supervisor support (RO). */
2525#define IOMMU_EXT_FEAT_BF_US_SUP_SHIFT 37
2526#define IOMMU_EXT_FEAT_BF_US_SUP_MASK UINT64_C(0x0000002000000000)
2527/** DevTblSegSup: Segmented Device Table support (RO). */
2528#define IOMMU_EXT_FEAT_BF_DEV_TBL_SEG_SUP_SHIFT 38
2529#define IOMMU_EXT_FEAT_BF_DEV_TBL_SEG_SUP_MASK UINT64_C(0x000000c000000000)
2530/** PprOverflwEarlySup: PPR Log Overflow Early warning support (RO). */
2531#define IOMMU_EXT_FEAT_BF_PPR_OVERFLOW_EARLY_SHIFT 40
2532#define IOMMU_EXT_FEAT_BF_PPR_OVERFLOW_EARLY_MASK UINT64_C(0x0000010000000000)
2533/** PprAutoRspSup: PPR Automatic Response support (RO). */
2534#define IOMMU_EXT_FEAT_BF_PPR_AUTO_RES_SUP_SHIFT 41
2535#define IOMMU_EXT_FEAT_BF_PPR_AUTO_RES_SUP_MASK UINT64_C(0x0000020000000000)
2536/** MarcSup: Memory Access and Routing (MARC) support (RO). */
2537#define IOMMU_EXT_FEAT_BF_MARC_SUP_SHIFT 42
2538#define IOMMU_EXT_FEAT_BF_MARC_SUP_MASK UINT64_C(0x00000c0000000000)
2539/** BlkStopMrkSup: Block StopMark message support (RO). */
2540#define IOMMU_EXT_FEAT_BF_BLKSTOP_MARK_SUP_SHIFT 44
2541#define IOMMU_EXT_FEAT_BF_BLKSTOP_MARK_SUP_MASK UINT64_C(0x0000100000000000)
2542/** PerfOptSup: IOMMU Performance Optimization support (RO). */
2543#define IOMMU_EXT_FEAT_BF_PERF_OPT_SUP_SHIFT 45
2544#define IOMMU_EXT_FEAT_BF_PERF_OPT_SUP_MASK UINT64_C(0x0000200000000000)
2545/** MsiCapMmioSup: MSI-Capability Register MMIO access support (RO). */
2546#define IOMMU_EXT_FEAT_BF_MSI_CAP_MMIO_SUP_SHIFT 46
2547#define IOMMU_EXT_FEAT_BF_MSI_CAP_MMIO_SUP_MASK UINT64_C(0x0000400000000000)
2548/** Bit 47 reserved. */
2549#define IOMMU_EXT_FEAT_BF_RSVD_47_SHIFT 47
2550#define IOMMU_EXT_FEAT_BF_RSVD_47_MASK UINT64_C(0x0000800000000000)
2551/** GIoSup: Guest I/O Protection support (RO). */
2552#define IOMMU_EXT_FEAT_BF_GST_IO_PROT_SUP_SHIFT 48
2553#define IOMMU_EXT_FEAT_BF_GST_IO_PROT_SUP_MASK UINT64_C(0x0001000000000000)
2554/** HASup: Host Access support (RO). */
2555#define IOMMU_EXT_FEAT_BF_HST_ACCESS_SUP_SHIFT 49
2556#define IOMMU_EXT_FEAT_BF_HST_ACCESS_SUP_MASK UINT64_C(0x0002000000000000)
2557/** EPHSup: Enhandled PPR Handling support (RO). */
2558#define IOMMU_EXT_FEAT_BF_ENHANCED_PPR_SUP_SHIFT 50
2559#define IOMMU_EXT_FEAT_BF_ENHANCED_PPR_SUP_MASK UINT64_C(0x0004000000000000)
2560/** AttrFWSup: Attribute Forward support (RO). */
2561#define IOMMU_EXT_FEAT_BF_ATTR_FW_SUP_SHIFT 51
2562#define IOMMU_EXT_FEAT_BF_ATTR_FW_SUP_MASK UINT64_C(0x0008000000000000)
2563/** HDSup: Host Dirty Support (RO). */
2564#define IOMMU_EXT_FEAT_BF_HST_DIRTY_SUP_SHIFT 52
2565#define IOMMU_EXT_FEAT_BF_HST_DIRTY_SUP_MASK UINT64_C(0x0010000000000000)
2566/** Bit 53 reserved. */
2567#define IOMMU_EXT_FEAT_BF_RSVD_53_SHIFT 53
2568#define IOMMU_EXT_FEAT_BF_RSVD_53_MASK UINT64_C(0x0020000000000000)
2569/** InvIotlbTypeSup: Invalidate IOTLB type support (RO). */
2570#define IOMMU_EXT_FEAT_BF_INV_IOTLB_TYPE_SUP_SHIFT 54
2571#define IOMMU_EXT_FEAT_BF_INV_IOTLB_TYPE_SUP_MASK UINT64_C(0x0040000000000000)
2572/** Bits 60:55 reserved. */
2573#define IOMMU_EXT_FEAT_BF_RSVD_55_60_SHIFT 55
2574#define IOMMU_EXT_FEAT_BF_RSVD_55_60_MASK UINT64_C(0x1f80000000000000)
2575/** GAUpdateDisSup: Support disabling hardware update on guest page table access
2576 * (RO). */
2577#define IOMMU_EXT_FEAT_BF_GA_UPDATE_DIS_SUP_SHIFT 61
2578#define IOMMU_EXT_FEAT_BF_GA_UPDATE_DIS_SUP_MASK UINT64_C(0x2000000000000000)
2579/** ForcePhysDestSup: Force Physical Destination Mode for Remapped Interrupt
2580 * support (RO). */
2581#define IOMMU_EXT_FEAT_BF_FORCE_PHYS_DST_SUP_SHIFT 62
2582#define IOMMU_EXT_FEAT_BF_FORCE_PHYS_DST_SUP_MASK UINT64_C(0x4000000000000000)
2583/** Bit 63 reserved. */
2584#define IOMMU_EXT_FEAT_BF_RSVD_63_SHIFT 63
2585#define IOMMU_EXT_FEAT_BF_RSVD_63_MASK UINT64_C(0x8000000000000000)
2586RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_EXT_FEAT_BF_, UINT64_C(0), UINT64_MAX,
2587 (PREF_SUP, PPR_SUP, X2APIC_SUP, NO_EXEC_SUP, GT_SUP, RSVD_5, IA_SUP, GA_SUP, HE_SUP, PC_SUP,
2588 HATS, GATS, GLX_SUP, SMI_FLT_SUP, SMI_FLT_REG_CNT, GAM_SUP, DUAL_PPR_LOG_SUP, RSVD_26_27,
2589 DUAL_EVT_LOG_SUP, RSVD_30_31, PASID_MAX, US_SUP, DEV_TBL_SEG_SUP, PPR_OVERFLOW_EARLY,
2590 PPR_AUTO_RES_SUP, MARC_SUP, BLKSTOP_MARK_SUP, PERF_OPT_SUP, MSI_CAP_MMIO_SUP, RSVD_47,
2591 GST_IO_PROT_SUP, HST_ACCESS_SUP, ENHANCED_PPR_SUP, ATTR_FW_SUP, HST_DIRTY_SUP, RSVD_53,
2592 INV_IOTLB_TYPE_SUP, RSVD_55_60, GA_UPDATE_DIS_SUP, FORCE_PHYS_DST_SUP, RSVD_63));
2593/** @} */
2594
2595/**
2596 * IVHD (I/O Virtualization Hardware Definition) Type 10h.
2597 * In accordance with the AMD spec.
2598 */
2599#pragma pack(1)
2600typedef struct ACPIIVHDTYPE10
2601{
2602 uint8_t u8Type; /**< Type: Must be 0x10. */
2603 uint8_t u8Flags; /**< Flags (see ACPI_IVHD_10H_F_XXX). */
2604 uint16_t u16Length; /**< Length of IVHD including IVHD device entries. */
2605 uint16_t u16DeviceId; /**< Device ID of the IOMMU. */
2606 uint16_t u16CapOffset; /**< Offset in Capability space for control fields of IOMMU. */
2607 uint64_t u64BaseAddress; /**< Base address of IOMMU control registers in MMIO space. */
2608 uint16_t u16PciSegmentGroup; /**< PCI segment group number. */
2609 uint16_t u16IommuInfo; /**< Interrupt number and Unit ID. */
2610 uint32_t u32Features; /**< IOMMU feature reporting. */
2611 /* IVHD device entry block follows. */
2612} ACPIIVHDTYPE10;
2613#pragma pack()
2614AssertCompileSize(ACPIIVHDTYPE10, 24);
2615AssertCompileMemberOffset(ACPIIVHDTYPE10, u8Type, 0);
2616AssertCompileMemberOffset(ACPIIVHDTYPE10, u8Flags, 1);
2617AssertCompileMemberOffset(ACPIIVHDTYPE10, u16Length, 2);
2618AssertCompileMemberOffset(ACPIIVHDTYPE10, u16DeviceId, 4);
2619AssertCompileMemberOffset(ACPIIVHDTYPE10, u16CapOffset, 6);
2620AssertCompileMemberOffset(ACPIIVHDTYPE10, u64BaseAddress, 8);
2621AssertCompileMemberOffset(ACPIIVHDTYPE10, u16PciSegmentGroup, 16);
2622AssertCompileMemberOffset(ACPIIVHDTYPE10, u16IommuInfo, 18);
2623AssertCompileMemberOffset(ACPIIVHDTYPE10, u32Features, 20);
2624
2625/** @name IVHD Type 11h Flags.
2626 * In accordance with the AMD spec.
2627 * @{ */
2628/** Coherent control. */
2629#define ACPI_IVHD_11H_F_COHERENT RT_BIT(5)
2630/** Remote IOTLB support. */
2631#define ACPI_IVHD_11H_F_IOTLB_SUP RT_BIT(4)
2632/** Isochronous control. */
2633#define ACPI_IVHD_11H_F_ISOC RT_BIT(3)
2634/** Response Pass Posted Write. */
2635#define ACPI_IVHD_11H_F_RES_PASS_PW RT_BIT(2)
2636/** Pass Posted Write. */
2637#define ACPI_IVHD_11H_F_PASS_PW RT_BIT(1)
2638/** HyperTransport Tunnel. */
2639#define ACPI_IVHD_11H_F_HT_TUNNEL RT_BIT(0)
2640/** @} */
2641
2642/** @name IVHD IOMMU Type 11 Attributes field.
2643 * In accordance with the AMD spec.
2644 * @{ */
2645/** Bits 12:0 reserved. */
2646#define ACPI_IOMMU_ATTR_BF_RSVD_0_12_SHIFT 0
2647#define ACPI_IOMMU_ATTR_BF_RSVD_0_12_MASK UINT32_C(0x00001fff)
2648/** PNCounters: Number of performance counters per counter bank. */
2649#define ACPI_IOMMU_ATTR_BF_PN_COUNTERS_SHIFT 13
2650#define ACPI_IOMMU_ATTR_BF_PN_COUNTERS_MASK UINT32_C(0x0001e000)
2651/** PNBanks: Number of performance counter banks. */
2652#define ACPI_IOMMU_ATTR_BF_PN_BANKS_SHIFT 17
2653#define ACPI_IOMMU_ATTR_BF_PN_BANKS_MASK UINT32_C(0x007e0000)
2654/** MSINumPPR: MSI number for peripheral page requests (PPR). */
2655#define ACPI_IOMMU_ATTR_BF_MSI_NUM_PPR_SHIFT 23
2656#define ACPI_IOMMU_ATTR_BF_MSI_NUM_PPR_MASK UINT32_C(0x0f800000)
2657/** Bits 31:28 reserved. */
2658#define ACPI_IOMMU_ATTR_BF_RSVD_28_31_SHIFT 28
2659#define ACPI_IOMMU_ATTR_BF_RSVD_28_31_MASK UINT32_C(0xf0000000)
2660RT_BF_ASSERT_COMPILE_CHECKS(ACPI_IOMMU_ATTR_BF_, UINT32_C(0), UINT32_MAX,
2661 (RSVD_0_12, PN_COUNTERS, PN_BANKS, MSI_NUM_PPR, RSVD_28_31));
2662/** @} */
2663
2664/**
2665 * AMD IOMMU: IVHD (I/O Virtualization Hardware Definition) Type 11h.
2666 * In accordance with the AMD spec.
2667 */
2668#pragma pack(1)
2669typedef struct ACPIIVHDTYPE11
2670{
2671 uint8_t u8Type; /**< Type: Must be 0x11. */
2672 uint8_t u8Flags; /**< Flags. */
2673 uint16_t u16Length; /**< Length: Size starting from Type fields incl. IVHD device entries. */
2674 uint16_t u16DeviceId; /**< Device ID of the IOMMU. */
2675 uint16_t u16CapOffset; /**< Offset in Capability space for control fields of IOMMU. */
2676 uint64_t u64BaseAddress; /**< Base address of IOMMU control registers in MMIO space. */
2677 uint16_t u16PciSegmentGroup; /**< PCI segment group number. */
2678 uint16_t u16IommuInfo; /**< Interrupt number and unit ID. */
2679 uint32_t u32IommuAttr; /**< IOMMU info. not reported in EFR. */
2680 uint64_t u64EfrRegister; /**< Extended Feature Register (must be identical to its MMIO shadow). */
2681 uint64_t u64Rsvd0; /**< Reserved for future. */
2682 /* IVHD device entry block follows. */
2683} ACPIIVHDTYPE11;
2684#pragma pack()
2685AssertCompileSize(ACPIIVHDTYPE11, 40);
2686AssertCompileMemberOffset(ACPIIVHDTYPE11, u8Type, 0);
2687AssertCompileMemberOffset(ACPIIVHDTYPE11, u8Flags, 1);
2688AssertCompileMemberOffset(ACPIIVHDTYPE11, u16Length, 2);
2689AssertCompileMemberOffset(ACPIIVHDTYPE11, u16DeviceId, 4);
2690AssertCompileMemberOffset(ACPIIVHDTYPE11, u16CapOffset, 6);
2691AssertCompileMemberOffset(ACPIIVHDTYPE11, u64BaseAddress, 8);
2692AssertCompileMemberOffset(ACPIIVHDTYPE11, u16PciSegmentGroup, 16);
2693AssertCompileMemberOffset(ACPIIVHDTYPE11, u16IommuInfo, 18);
2694AssertCompileMemberOffset(ACPIIVHDTYPE11, u32IommuAttr, 20);
2695AssertCompileMemberOffset(ACPIIVHDTYPE11, u64EfrRegister, 24);
2696AssertCompileMemberOffset(ACPIIVHDTYPE11, u64Rsvd0, 32);
2697
2698/**
2699 * AMD IOMMU: IVHD (I/O Virtualization Hardware Definition) Type 40h.
2700 * In accordance with the AMD spec.
2701 */
2702typedef struct ACPIIVHDTYPE11 ACPIIVHDTYPE40;
2703
2704#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