1 | /* $Id: DevIommuAmd.cpp 83519 2020-04-03 07:39:23Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IOMMU - Input/Output Memory Management Unit - AMD implementation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2020 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 |
|
---|
19 | /*********************************************************************************************************************************
|
---|
20 | * Header Files *
|
---|
21 | *********************************************************************************************************************************/
|
---|
22 | #define LOG_GROUP LOG_GROUP_DEV_IOMMU
|
---|
23 | #include <VBox/vmm/pdmdev.h>
|
---|
24 | #include <VBox/AssertGuest.h>
|
---|
25 |
|
---|
26 | #include "VBoxDD.h"
|
---|
27 |
|
---|
28 |
|
---|
29 | /*********************************************************************************************************************************
|
---|
30 | * Defined Constants And Macros *
|
---|
31 | *********************************************************************************************************************************/
|
---|
32 | /** @name PCI configuration register offsets.
|
---|
33 | @{ */
|
---|
34 | #define IOMMU_PCI_OFF_CAP_HDR 0x00
|
---|
35 | #define IOMMU_PCI_OFF_BASE_ADDR_REG_LO 0x04
|
---|
36 | #define IOMMU_PCI_OFF_BASE_ADDR_REG_HI 0x08
|
---|
37 | #define IOMMU_PCI_OFF_RANGE_REG 0x0c
|
---|
38 | #define IOMMU_PCI_OFF_MISCINFO_REG_0 0x10
|
---|
39 | #define IOMMU_PCI_OFF_MISCINFO_REG_1 0x14
|
---|
40 | /** @} */
|
---|
41 |
|
---|
42 | /** @name MMIO register offsets.
|
---|
43 | * @{ */
|
---|
44 | #define IOMMU_MMIO_OFF_DEV_TAB_BAR 0x00
|
---|
45 | #define IOMMU_MMIO_OFF_CMD_BUF_BAR 0x08
|
---|
46 | #define IOMMU_MMIO_OFF_EVT_LOG_BAR 0x10
|
---|
47 | #define IOMMU_MMIO_OFF_CTRL 0x18
|
---|
48 | #define IOMMU_MMIO_OFF_EXCL_BAR 0x20
|
---|
49 | #define IOMMU_MMIO_OFF_EXCL_RANGE_LIMIT 0x28
|
---|
50 | #define IOMMU_MMIO_OFF_EXT_FEAT 0x30
|
---|
51 |
|
---|
52 | #define IOMMU_MMIO_OFF_PPR_LOG_BAR 0x38
|
---|
53 | #define IOMMU_MMIO_OFF_HW_EVT_HI 0x40
|
---|
54 | #define IOMMU_MMIO_OFF_HW_EVT_LO 0x48
|
---|
55 | #define IOMMU_MMIO_OFF_HW_EVT_STATUS 0x50
|
---|
56 |
|
---|
57 | #define IOMMU_MMIO_OFF_SMI_FLT_FIRST 0x60
|
---|
58 | #define IOMMU_MMIO_OFF_SMI_FLT_LAST 0xd8
|
---|
59 |
|
---|
60 | #define IOMMU_MMIO_OFF_GALOG_BAR 0xe0
|
---|
61 | #define IOMMU_MMIO_OFF_GALOG_TAIL_ADDR 0xe8
|
---|
62 |
|
---|
63 | #define IOMMU_MMIO_OFF_PPR_LOG_B_BAR 0xf0
|
---|
64 | #define IOMMU_MMIO_OFF_PPR_EVT_B_BAR 0xf8
|
---|
65 |
|
---|
66 | #define IOMMU_MMIO_OFF_DEV_TAB_SEG_FIRST 0x100
|
---|
67 | #define IOMMU_MMIO_OFF_DEV_TAB_SEG_LAST 0x130
|
---|
68 |
|
---|
69 | #define IOMMU_MMIO_OFF_DEV_SPECIFIC_FEAT 0x138
|
---|
70 | #define IOMMU_MMIO_OFF_DEV_SPECIFIC_CTRL 0x140
|
---|
71 | #define IOMMU_MMIO_OFF_DEV_SPECIFIC_STATUS 0x148
|
---|
72 |
|
---|
73 | #define IOMMU_MMIO_OFF_MSI_VECTOR_0 0x150
|
---|
74 | #define IOMMU_MMIO_OFF_MSI_VECTOR_1 0x154
|
---|
75 | #define IOMMU_MMIO_OFF_MSI_CAP_HDR 0x158
|
---|
76 | #define IOMMU_MMIO_OFF_MSI_ADDR_LO 0x15c
|
---|
77 | #define IOMMU_MMIO_OFF_MSI_ADDR_HI 0x160
|
---|
78 | #define IOMMU_MMIO_OFF_MSI_DATA 0x164
|
---|
79 | #define IOMMU_MMIO_OFF_MSI_MAPPING_CAP_HDR 0x168
|
---|
80 |
|
---|
81 | #define IOMMU_MMIO_OFF_PERF_OPT_CTRL 0x16c
|
---|
82 |
|
---|
83 | #define IOMMU_MMIO_OFF_XT_GEN_INTR_CTRL 0x170
|
---|
84 | #define IOMMU_MMIO_OFF_XT_PPR_INTR_CTRL 0x178
|
---|
85 | #define IOMMU_MMIO_OFF_XT_GALOG_INT_CTRL 0x180
|
---|
86 |
|
---|
87 | #define IOMMU_MMIO_OFF_MARC_APER_BAR_0 0x200
|
---|
88 | #define IOMMU_MMIO_OFF_MARC_APER_RELOC_0 0x208
|
---|
89 | #define IOMMU_MMIO_OFF_MARC_APER_LEN_0 0x210
|
---|
90 | #define IOMMU_MMIO_OFF_MARC_APER_BAR_1 0x218
|
---|
91 | #define IOMMU_MMIO_OFF_MARC_APER_RELOC_1 0x220
|
---|
92 | #define IOMMU_MMIO_OFF_MARC_APER_LEN_1 0x228
|
---|
93 | #define IOMMU_MMIO_OFF_MARC_APER_BAR_2 0x230
|
---|
94 | #define IOMMU_MMIO_OFF_MARC_APER_RELOC_2 0x238
|
---|
95 | #define IOMMU_MMIO_OFF_MARC_APER_LEN_2 0x240
|
---|
96 | #define IOMMU_MMIO_OFF_MARC_APER_BAR_3 0x248
|
---|
97 | #define IOMMU_MMIO_OFF_MARC_APER_RELOC_3 0x250
|
---|
98 | #define IOMMU_MMIO_OFF_MARC_APER_LEN_3 0x258
|
---|
99 |
|
---|
100 | #define IOMMU_MMIO_OFF_RSVD_REG 0x1ff8
|
---|
101 |
|
---|
102 | #define IOMMU_MMIO_CMD_BUF_HEAD_PTR 0x2000
|
---|
103 | #define IOMMU_MMIO_CMD_BUF_TAIL_PTR 0x2008
|
---|
104 | #define IOMMU_MMIO_EVT_LOG_HEAD_PTR 0x2010
|
---|
105 | #define IOMMU_MMIO_EVT_LOG_TAIL_PTR 0x2018
|
---|
106 |
|
---|
107 | #define IOMMU_MMIO_OFF_STATUS 0x2020
|
---|
108 |
|
---|
109 | #define IOMMU_MMIO_OFF_PPR_LOG_HEAD_PTR 0x2030
|
---|
110 | #define IOMMU_MMIO_OFF_PPR_LOG_TAIL_PTR 0x2038
|
---|
111 |
|
---|
112 | #define IOMMU_MMIO_OFF_GALOG_HEAD_PTR 0x2040
|
---|
113 | #define IOMMU_MMIO_OFF_GALOG_TAIL_PTR 0x2048
|
---|
114 |
|
---|
115 | #define IOMMU_MMIO_OFF_PPR_LOG_B_HEAD_PTR 0x2050
|
---|
116 | #define IOMMU_MMIO_OFF_PPR_LOG_B_TAIL_PTR 0x2058
|
---|
117 |
|
---|
118 | #define IOMMU_MMIO_OFF_EVT_LOG_B_HEAD_PTR 0x2070
|
---|
119 | #define IOMMU_MMIO_OFF_EVT_LOG_B_TAIL_PTR 0x2078
|
---|
120 |
|
---|
121 | #define IOMMU_MMIO_OFF_PPR_LOG_AUTO_RESP 0x2080
|
---|
122 | #define IOMMU_MMIO_OFF_PPR_LOG_OVERFLOW_EARLY 0x2088
|
---|
123 | #define IOMMU_MMIO_OFF_PPR_LOG_B_OVERFLOW_EARLY 0x2090
|
---|
124 | /** @} */
|
---|
125 |
|
---|
126 | /**
|
---|
127 | * @name Commands.
|
---|
128 | * In accordance with the AMD spec.
|
---|
129 | * @{
|
---|
130 | */
|
---|
131 | #define IOMMU_CMD_COMPLETION_WAIT 0x01
|
---|
132 | #define IOMMU_CMD_INV_DEV_TAB_ENTRY 0x02
|
---|
133 | #define IOMMU_CMD_INV_IOMMU_PAGES 0x03
|
---|
134 | #define IOMMU_CMD_INV_IOTLB_PAGES 0x04
|
---|
135 | #define IOMMU_CMD_INV_INTR_TABLE 0x05
|
---|
136 | #define IOMMU_CMD_PREFETCH_IOMMU_PAGES 0x06
|
---|
137 | #define IOMMU_CMD_COMPLETE_PPR_REQ 0x07
|
---|
138 | #define IOMMU_CMD_INV_IOMMU_ALL 0x08
|
---|
139 | /** @} */
|
---|
140 |
|
---|
141 | /**
|
---|
142 | * @name Event codes.
|
---|
143 | * In accordance with the AMD spec.
|
---|
144 | * @{
|
---|
145 | */
|
---|
146 | #define IOMMU_EVT_ILLEGAL_DEV_TAB_ENTRY 0x01
|
---|
147 | #define IOMMU_EVT_IO_PAGE_FAULT 0x02
|
---|
148 | #define IOMMU_EVT_DEV_TAB_HARDWARE_ERROR 0x03
|
---|
149 | #define IOMMU_EVT_PAGE_TAB_HARDWARE_ERROR 0x04
|
---|
150 | #define IOMMU_EVT_ILLEGAL_COMMAND_ERROR 0x05
|
---|
151 | #define IOMMU_EVT_COMMAND_HARDWARE_ERROR 0x06
|
---|
152 | #define IOMMU_EVT_IOTLB_INV_TIMEOUT 0x07
|
---|
153 | #define IOMMU_EVT_INVALID_DEVICE_REQUEST 0x08
|
---|
154 | #define IOMMU_EVT_INVALID_PPR_REQUEST 0x09
|
---|
155 | #define IOMMU_EVT_EVENT_COUNTER_ZERO 0x10
|
---|
156 | #define IOMMU_EVT_GUEST_EVENT_FAULT 0x11
|
---|
157 | /** @} */
|
---|
158 |
|
---|
159 | /**
|
---|
160 | * @name IOMMU Capability Header.
|
---|
161 | * In accordance with the AMD spec.
|
---|
162 | * @{
|
---|
163 | */
|
---|
164 | /** CapId: Capability ID. */
|
---|
165 | #define IOMMU_BF_CAPHDR_CAP_ID_SHIFT 0
|
---|
166 | #define IOMMU_BF_CAPHDR_CAP_ID_MASK UINT32_C(0x000000ff)
|
---|
167 | /** CapPtr: Capability Pointer. */
|
---|
168 | #define IOMMU_BF_CAPHDR_CAP_PTR_SHIFT 8
|
---|
169 | #define IOMMU_BF_CAPHDR_CAP_PTR_MASK UINT32_C(0x0000ff00)
|
---|
170 | /** CapType: Capability Type. */
|
---|
171 | #define IOMMU_BF_CAPHDR_CAP_TYPE_SHIFT 16
|
---|
172 | #define IOMMU_BF_CAPHDR_CAP_TYPE_MASK UINT32_C(0x00070000)
|
---|
173 | /** CapRev: Capability Revision. */
|
---|
174 | #define IOMMU_BF_CAPHDR_CAP_REV_SHIFT 19
|
---|
175 | #define IOMMU_BF_CAPHDR_CAP_REV_MASK UINT32_C(0x00f80000)
|
---|
176 | /** IoTlbSup: IO TLB Support. */
|
---|
177 | #define IOMMU_BF_CAPHDR_IOTLB_SUP_SHIFT 24
|
---|
178 | #define IOMMU_BF_CAPHDR_IOTLB_SUP_MASK UINT32_C(0x01000000)
|
---|
179 | /** HtTunnel: HyperTransport Tunnel translation support. */
|
---|
180 | #define IOMMU_BF_CAPHDR_HT_TUNNEL_SHIFT 25
|
---|
181 | #define IOMMU_BF_CAPHDR_HT_TUNNEL_MASK UINT32_C(0x02000000)
|
---|
182 | /** NpCache: Not Present table entries Cached. */
|
---|
183 | #define IOMMU_BF_CAPHDR_NP_CACHE_SHIFT 26
|
---|
184 | #define IOMMU_BF_CAPHDR_NP_CACHE_MASK UINT32_C(0x04000000)
|
---|
185 | /** EFRSup: Extended Feature Register (EFR) Supported. */
|
---|
186 | #define IOMMU_BF_CAPHDR_EFR_SUP_SHIFT 27
|
---|
187 | #define IOMMU_BF_CAPHDR_EFR_SUP_MASK UINT32_C(0x08000000)
|
---|
188 | /** CapExt: Miscellaneous Information Register Supported . */
|
---|
189 | #define IOMMU_BF_CAPHDR_CAP_EXT_SHIFT 28
|
---|
190 | #define IOMMU_BF_CAPHDR_CAP_EXT_MASK UINT32_C(0x10000000)
|
---|
191 | /** Bits 31:29 reserved. */
|
---|
192 | #define IOMMU_BF_CAPHDR_RSVD_29_31_SHIFT 29
|
---|
193 | #define IOMMU_BF_CAPHDR_RSVD_29_31_MASK UINT32_C(0xe0000000)
|
---|
194 | RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_BF_CAPHDR_, UINT32_C(0), UINT32_MAX,
|
---|
195 | (CAP_ID, CAP_PTR, CAP_TYPE, CAP_REV, IOTLB_SUP, HT_TUNNEL, NP_CACHE, EFR_SUP, CAP_EXT, RSVD_29_31));
|
---|
196 | /** @} */
|
---|
197 |
|
---|
198 | /**
|
---|
199 | * @name IOMMU Base Address Low Register.
|
---|
200 | * In accordance with the AMD spec.
|
---|
201 | * @{
|
---|
202 | */
|
---|
203 | /** Enable: Enables access to the address specified in the Base Address Register. */
|
---|
204 | #define IOMMU_BF_BASEADDR_LO_ENABLE_SHIFT 0
|
---|
205 | #define IOMMU_BF_BASEADDR_LO_ENABLE_MASK UINT32_C(0x00000001)
|
---|
206 | /** Bits 13:1 reserved. */
|
---|
207 | #define IOMMU_BF_BASEADDR_LO_RSVD_1_13_SHIFT 1
|
---|
208 | #define IOMMU_BF_BASEADDR_LO_RSVD_1_13_MASK UINT32_C(0x00003ffe)
|
---|
209 | /** Base Address[31:14]: Low Base address of IOMMU MMIO control registers. */
|
---|
210 | #define IOMMU_BF_BASEADDR_LO_ADDR_SHIFT 14
|
---|
211 | #define IOMMU_BF_BASEADDR_LO_ADDR_MASK UINT32_C(0xffffc000)
|
---|
212 | RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_BF_BASEADDR_LO_, UINT32_C(0), UINT32_MAX,
|
---|
213 | (ENABLE, RSVD_1_13, ADDR));
|
---|
214 | /** @} */
|
---|
215 |
|
---|
216 | /**
|
---|
217 | * @name IOMMU Range Register.
|
---|
218 | * In accordance with the AMD spec.
|
---|
219 | * @{
|
---|
220 | */
|
---|
221 | /** UnitID: HyperTransport Unit ID. */
|
---|
222 | #define IOMMU_BF_RANGE_UNIT_ID_SHIFT 0
|
---|
223 | #define IOMMU_BF_RANGE_UNIT_ID_MASK UINT32_C(0x0000001f)
|
---|
224 | /** Bits 6:5 reserved. */
|
---|
225 | #define IOMMU_BF_RANGE_RSVD_5_6_SHIFT 5
|
---|
226 | #define IOMMU_BF_RANGE_RSVD_5_6_MASK UINT32_C(0x00000060)
|
---|
227 | /** RngValid: Range valid. */
|
---|
228 | #define IOMMU_BF_RANGE_VALID_SHIFT 7
|
---|
229 | #define IOMMU_BF_RANGE_VALID_MASK UINT32_C(0x00000080)
|
---|
230 | /** BusNumber: Device range bus number. */
|
---|
231 | #define IOMMU_BF_RANGE_BUS_NUMBER_SHIFT 8
|
---|
232 | #define IOMMU_BF_RANGE_BUS_NUMBER_MASK UINT32_C(0x0000ff00)
|
---|
233 | /** First Device. */
|
---|
234 | #define IOMMU_BF_RANGE_FIRST_DEVICE_SHIFT 16
|
---|
235 | #define IOMMU_BF_RANGE_FIRST_DEVICE_MASK UINT32_C(0x00ff0000)
|
---|
236 | /** Last Device. */
|
---|
237 | #define IOMMU_BF_RANGE_LAST_DEVICE_SHIFT 24
|
---|
238 | #define IOMMU_BF_RANGE_LAST_DEVICE_MASK UINT32_C(0xff000000)
|
---|
239 | RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_BF_RANGE_, UINT32_C(0), UINT32_MAX,
|
---|
240 | (UNIT_ID, RSVD_5_6, VALID, BUS_NUMBER, FIRST_DEVICE, LAST_DEVICE));
|
---|
241 | /** @} */
|
---|
242 |
|
---|
243 | /**
|
---|
244 | * @name IOMMU Miscellaneous Information Register 0.
|
---|
245 | * In accordance with the AMD spec.
|
---|
246 | * @{
|
---|
247 | */
|
---|
248 | /** MsiNum: MSI message number. */
|
---|
249 | #define IOMMU_BF_MISCINFO_0_MSI_NUM_SHIFT 0
|
---|
250 | #define IOMMU_BF_MISCINFO_0_MSI_NUM_MASK UINT32_C(0x0000001f)
|
---|
251 | /** GvaSize: Guest Virtual Address Size. */
|
---|
252 | #define IOMMU_BF_MISCINFO_0_GVA_SIZE_SHIFT 5
|
---|
253 | #define IOMMU_BF_MISCINFO_0_GVA_SIZE_MASK UINT32_C(0x000000e0)
|
---|
254 | /** PaSize: Physical Address Size. */
|
---|
255 | #define IOMMU_BF_MISCINFO_0_PA_SIZE_SHIFT 8
|
---|
256 | #define IOMMU_BF_MISCINFO_0_PA_SIZE_MASK UINT32_C(0x00007f00)
|
---|
257 | /** VaSize: Virtual Address Size. */
|
---|
258 | #define IOMMU_BF_MISCINFO_0_VA_SIZE_SHIFT 15
|
---|
259 | #define IOMMU_BF_MISCINFO_0_VA_SIZE_MASK UINT32_C(0x003f8000)
|
---|
260 | /** HtAtsResv: HyperTransport ATS Response Address range Reserved. */
|
---|
261 | #define IOMMU_BF_MISCINFO_0_HT_ATS_RESV_SHIFT 22
|
---|
262 | #define IOMMU_BF_MISCINFO_0_HT_ATS_RESV_MASK UINT32_C(0x00400000)
|
---|
263 | /** Bits 26:23 reserved. */
|
---|
264 | #define IOMMU_BF_MISCINFO_0_RSVD_23_26_SHIFT 23
|
---|
265 | #define IOMMU_BF_MISCINFO_0_RSVD_23_26_MASK UINT32_C(0x07800000)
|
---|
266 | /** MsiNumPPR: Peripheral Page Request MSI message number. */
|
---|
267 | #define IOMMU_BF_MISCINFO_0_MSI_NUM_PPR_SHIFT 27
|
---|
268 | #define IOMMU_BF_MISCINFO_0_MSI_NUM_PPR_MASK UINT32_C(0xf8000000)
|
---|
269 | RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_BF_MISCINFO_0_, UINT32_C(0), UINT32_MAX,
|
---|
270 | (MSI_NUM, GVA_SIZE, PA_SIZE, VA_SIZE, HT_ATS_RESV, RSVD_23_26, MSI_NUM_PPR));
|
---|
271 | /** @} */
|
---|
272 |
|
---|
273 | /**
|
---|
274 | * @name IOMMU Miscellaneous Information Register 1.
|
---|
275 | * In accordance with the AMD spec.
|
---|
276 | * @{
|
---|
277 | */
|
---|
278 | /** MsiNumGA: MSI message number for guest virtual-APIC log. */
|
---|
279 | #define IOMMU_BF_MISCINFO_1_MSI_NUM_GA_SHIFT 0
|
---|
280 | #define IOMMU_BF_MISCINFO_1_MSI_NUM_GA_MASK UINT32_C(0x0000001f)
|
---|
281 | /** Bits 31:5 reserved. */
|
---|
282 | #define IOMMU_BF_MISCINFO_1_RSVD_5_31_SHIFT 5
|
---|
283 | #define IOMMU_BF_MISCINFO_1_RSVD_5_31_MASK UINT32_C(0xffffffe0)
|
---|
284 | RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_BF_MISCINFO_1_, UINT32_C(0), UINT32_MAX,
|
---|
285 | (MSI_NUM_GA, RSVD_5_31));
|
---|
286 | /** @} */
|
---|
287 |
|
---|
288 | /**
|
---|
289 | * @name MSI Capability Header Register.
|
---|
290 | * In accordance with the AMD spec.
|
---|
291 | * @{
|
---|
292 | */
|
---|
293 | /** MsiCapId: Capability ID. */
|
---|
294 | #define IOMMU_BF_MSI_CAPHDR_CAP_ID_SHIFT 0
|
---|
295 | #define IOMMU_BF_MSI_CAPHDR_CAP_ID_MASK UINT32_C(0x000000ff)
|
---|
296 | /** MsiCapPtr: Pointer (PCI config offset) to the next capability. */
|
---|
297 | #define IOMMU_BF_MSI_CAPHDR_CAP_PTR_SHIFT 8
|
---|
298 | #define IOMMU_BF_MSI_CAPHDR_CAP_PTR_MASK UINT32_C(0x0000ff00)
|
---|
299 | /** MsiEn: Message Signal Interrupt enable. */
|
---|
300 | #define IOMMU_BF_MSI_CAPHDR_EN_SHIFT 16
|
---|
301 | #define IOMMU_BF_MSI_CAPHDR_EN_MASK UINT32_C(0x00010000)
|
---|
302 | /** MsiMultMessCap: MSI Multi-Message Capability. */
|
---|
303 | #define IOMMU_BF_MSI_CAPHDR_MULTMESS_CAP_SHIFT 17
|
---|
304 | #define IOMMU_BF_MSI_CAPHDR_MULTMESS_CAP_MASK UINT32_C(0x000e0000)
|
---|
305 | /** MsiMultMessEn: MSI Mult-Message Enable. */
|
---|
306 | #define IOMMU_BF_MSI_CAPHDR_MULTMESS_EN_SHIFT 20
|
---|
307 | #define IOMMU_BF_MSI_CAPHDR_MULTMESS_EN_MASK UINT32_C(0x00700000)
|
---|
308 | /** Msi64BitEn: MSI 64-bit Enabled. */
|
---|
309 | #define IOMMU_BF_MSI_CAPHDR_64BIT_EN_SHIFT 23
|
---|
310 | #define IOMMU_BF_MSI_CAPHDR_64BIT_EN_MASK UINT32_C(0x00800000)
|
---|
311 | /** Bits 31:24 reserved. */
|
---|
312 | #define IOMMU_BF_MSI_CAPHDR_RSVD_24_31_SHIFT 24
|
---|
313 | #define IOMMU_BF_MSI_CAPHDR_RSVD_24_31_MASK UINT32_C(0xff000000)
|
---|
314 | RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_BF_MSI_CAPHDR_, UINT32_C(0), UINT32_MAX,
|
---|
315 | (CAP_ID, CAP_PTR, EN, MULTMESS_CAP, MULTMESS_EN, 64BIT_EN, RSVD_24_31));
|
---|
316 | /** @} */
|
---|
317 |
|
---|
318 | /**
|
---|
319 | * @name MSI Mapping Capability Header Register.
|
---|
320 | * In accordance with the AMD spec.
|
---|
321 | * @{
|
---|
322 | */
|
---|
323 | /** MsiMapCapId: Capability ID. */
|
---|
324 | #define IOMMU_BF_MSI_MAP_CAPHDR_CAP_ID_SHIFT 0
|
---|
325 | #define IOMMU_BF_MSI_MAP_CAPHDR_CAP_ID_MASK UINT32_C(0x000000ff)
|
---|
326 | /** MsiMapCapPtr: Pointer (PCI config offset) to the next capability. */
|
---|
327 | #define IOMMU_BF_MSI_MAP_CAPHDR_CAP_PTR_SHIFT 8
|
---|
328 | #define IOMMU_BF_MSI_MAP_CAPHDR_CAP_PTR_MASK UINT32_C(0x0000ff00)
|
---|
329 | /** MsiMapEn: MSI mapping capability enable. */
|
---|
330 | #define IOMMU_BF_MSI_MAP_CAPHDR_EN_SHIFT 16
|
---|
331 | #define IOMMU_BF_MSI_MAP_CAPHDR_EN_MASK UINT32_C(0x00010000)
|
---|
332 | /** MsiMapFixd: MSI interrupt mapping range is not programmable. */
|
---|
333 | #define IOMMU_BF_MSI_MAP_CAPHDR_FIXED_SHIFT 17
|
---|
334 | #define IOMMU_BF_MSI_MAP_CAPHDR_FIXED_MASK UINT32_C(0x00020000)
|
---|
335 | /** Bits 18:28 reserved. */
|
---|
336 | #define IOMMU_BF_MSI_MAP_CAPHDR_RSVD_18_28_SHIFT 18
|
---|
337 | #define IOMMU_BF_MSI_MAP_CAPHDR_RSVD_18_28_MASK UINT32_C(0x07fc0000)
|
---|
338 | /** MsiMapCapType: MSI mapping capability. */
|
---|
339 | #define IOMMU_BF_MSI_MAP_CAPHDR_CAP_TYPE_SHIFT 27
|
---|
340 | #define IOMMU_BF_MSI_MAP_CAPHDR_CAP_TYPE_MASK UINT32_C(0xf8000000)
|
---|
341 | RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_BF_MSI_MAP_CAPHDR_, UINT32_C(0), UINT32_MAX,
|
---|
342 | (CAP_ID, CAP_PTR, EN, FIXED, RSVD_18_28, CAP_TYPE));
|
---|
343 | /** @} */
|
---|
344 |
|
---|
345 | /** @name Miscellaneous IOMMU defines.
|
---|
346 | * @{ */
|
---|
347 | #define IOMMU_LOG_PFX "AMD_IOMMU" /**< Log prefix string. */
|
---|
348 | #define IOMMU_SAVED_STATE_VERSION 1 /**< The current saved state version. */
|
---|
349 | #define IOMMU_PCI_VENDOR_ID 0x1022 /**< AMD's vendor ID. */
|
---|
350 | #define IOMMU_PCI_DEVICE_ID 0xc0de /**< VirtualBox IOMMU device ID. */
|
---|
351 | #define IOMMU_PCI_REVISION_ID 0x01 /**< VirtualBox IOMMU device revision ID. */
|
---|
352 | #define IOMMU_MMIO_REGION_SIZE _16K /**< Size of the MMIO region in bytes. */
|
---|
353 | /** @} */
|
---|
354 |
|
---|
355 |
|
---|
356 | /*********************************************************************************************************************************
|
---|
357 | * Structures and Typedefs *
|
---|
358 | *********************************************************************************************************************************/
|
---|
359 | /**
|
---|
360 | * The Device ID.
|
---|
361 | * In accordance with the AMD spec.
|
---|
362 | */
|
---|
363 | typedef union
|
---|
364 | {
|
---|
365 | struct
|
---|
366 | {
|
---|
367 | uint16_t uFunction : 3; /**< Bits 2:0 - Function. */
|
---|
368 | uint16_t uDevice : 5; /**< Bits 7:3 - Device. */
|
---|
369 | uint16_t uBus : 8; /**< Bits 15:8 - Bus. */
|
---|
370 | } n;
|
---|
371 | /** The unsigned integer view. */
|
---|
372 | uint16_t u;
|
---|
373 | } DEVICE_ID_T;
|
---|
374 | AssertCompileSize(DEVICE_ID_T, 2);
|
---|
375 |
|
---|
376 | /**
|
---|
377 | * Device Table Entry (DTE).
|
---|
378 | * In accordance with the AMD spec.
|
---|
379 | */
|
---|
380 | typedef union
|
---|
381 | {
|
---|
382 | struct
|
---|
383 | {
|
---|
384 | uint32_t u1Valid : 1; /**< Bit 0 - V: Valid. */
|
---|
385 | uint32_t u1TranslationValid : 1; /**< Bit 1 - TV: Translation information Valid. */
|
---|
386 | uint32_t u5Rsvd0 : 5; /**< Bits 6:2 - Reserved. */
|
---|
387 | uint32_t u2Had : 2; /**< Bits 8:7 - HAD: Host Access Dirty. */
|
---|
388 | uint32_t u3Mode : 3; /**< Bits 11:9 - Mode: Paging mode. */
|
---|
389 | uint32_t u20PageTableRootPtrLo : 20; /**< Bits 31:12 - Page Table Root Pointer (Lo). */
|
---|
390 | uint32_t u20PageTableRootPtrHi : 20; /**< Bits 51:32 - Page Table Root Pointer (Hi). */
|
---|
391 | uint32_t u1Ppr : 1; /**< Bit 52 - PPR: Peripheral Page Request. */
|
---|
392 | uint32_t u1GstPprRespPasid : 1; /**< Bit 53 - GRPR: Guest PPR Response with PASID. */
|
---|
393 | uint32_t u1GstIoValid : 1; /**< Bit 54 - GIoV: Guest I/O Protection Valid. */
|
---|
394 | uint32_t u1GstTranslateValid : 1; /**< Bit 55 - GV: Guest translation Valid. */
|
---|
395 | uint32_t u2GstCr3RootTblTranslated : 2; /**< Bits 57:56 - GLX: Guest Levels Translated. */
|
---|
396 | uint32_t u3GstCr3TableRootPtrLo : 2; /**< Bits 60:58 - GCR3 TRP: Guest CR3 Table Root Pointer (Lo). */
|
---|
397 | uint32_t u1IoRead : 1; /**< Bit 61 - IR: I/O Read permission. */
|
---|
398 | uint32_t u1IoWrite : 1; /**< Bit 62 - IW: I/O Write permission. */
|
---|
399 | uint32_t u1Rsvd0 : 1; /**< Bit 63 - Reserved. */
|
---|
400 | uint32_t u16DomainId : 1; /**< Bits 79:64 - Domain ID. */
|
---|
401 | uint32_t u16GstCr3TableRootPtrMed : 16; /**< Bits 95:80 - GCR3 TRP: Guest CR3 Table Root Pointer (Mid). */
|
---|
402 | uint32_t u1IoTlbEnable : 1; /**< Bit 96 - IOTLB Enable. */
|
---|
403 | uint32_t u1SuppressPfEvents : 1; /**< Bit 97 - SE: Supress Page-fault events. */
|
---|
404 | uint32_t u1SuppressAllPfEvents : 1; /**< Bit 98 - SA: Supress All Page-fault events. */
|
---|
405 | uint32_t u2IoCtl : 1; /**< Bits 100:99 - IoCtl: Port I/O Control. */
|
---|
406 | uint32_t u1Cache : 1; /**< Bit 101 - Cache: IOTLB Cache Hint. */
|
---|
407 | uint32_t u1SnoopDisable : 1; /**< Bit 102 - SD: Snoop Disable. */
|
---|
408 | uint32_t u1AllowExclusion : 1; /**< Bit 103 - EX: Allow Exclusion. */
|
---|
409 | uint32_t u2SysMgt : 2; /**< Bits 105:104 - SysMgt: System Management message enable. */
|
---|
410 | uint32_t u1Rsvd1 : 1; /**< Bit 106 - Reserved. */
|
---|
411 | uint32_t u21GstCr3TableRootPtrHi : 21; /**< Bits 127:107 - GCR3 TRP: Guest CR3 Table Root Pointer (Hi). */
|
---|
412 | uint32_t u1IntrMapValid : 1; /**< Bit 128 - IV: Interrupt map Valid. */
|
---|
413 | uint32_t u4IntrTableLength : 4; /**< Bits 132:129 - IntTabLen: Interrupt Table Length. */
|
---|
414 | uint32_t u1IgnoreUnmappedIntrs : 1; /**< Bits 133 - IG: Ignore unmapped interrupts. */
|
---|
415 | uint32_t u26IntrTableRootPtr : 26; /**< Bits 159:134 - Interrupt Root Table Pointer (Lo). */
|
---|
416 | uint32_t u20IntrTableRootPtr : 20; /**< Bits 179:160 - Interrupt Root Table Pointer (Hi). */
|
---|
417 | uint32_t u4Rsvd0 : 4; /**< Bits 183:180 - Reserved. */
|
---|
418 | uint32_t u1InitPassthru : 1; /**< Bits 184 - INIT Pass-through. */
|
---|
419 | uint32_t u1ExtIntPassthru : 1; /**< Bits 185 - External Interrupt Pass-through. */
|
---|
420 | uint32_t u1NmiPassthru : 1; /**< Bits 186 - NMI Pass-through. */
|
---|
421 | uint32_t u1Rsvd2 : 1; /**< Bits 187 - Reserved. */
|
---|
422 | uint32_t u2IntrCtrl : 2; /**< Bits 189:188 - IntCtl: Interrupt Control. */
|
---|
423 | uint32_t u1Lint0Passthru : 1; /**< Bit 190 - Lint0Pass: LINT0 (Legacy PIC NMI) Pass-thru. */
|
---|
424 | uint32_t u1Lint1Passthru : 1; /**< Bit 191 - Lint1Pass: LINT1 (Legacy PIC NMI) Pass-thru. */
|
---|
425 | uint32_t u32Rsvd0; /**< Bits 223:192 - Reserved. */
|
---|
426 | uint32_t u22Rsvd0 : 22; /**< Bits 245:224 - Reserved. */
|
---|
427 | uint32_t u1AttrOverride : 1; /**< Bit 246 - AttrV: Attribute Override. */
|
---|
428 | uint32_t u1Mode0FC: 1; /**< Bit 247 - Mode0FC. */
|
---|
429 | uint32_t u8SnoopAttr: 1; /**< Bits 255:248 - Snoop Attribute. */
|
---|
430 | } n;
|
---|
431 | /** The 32-bit unsigned integer view. */
|
---|
432 | uint32_t au32[8];
|
---|
433 | } DEV_TAB_ENTRY_T;
|
---|
434 | AssertCompileSize(DEV_TAB_ENTRY_T, 32);
|
---|
435 |
|
---|
436 | /**
|
---|
437 | * I/O Page Table Entry.
|
---|
438 | * In accordance with the AMD spec.
|
---|
439 | */
|
---|
440 | typedef union
|
---|
441 | {
|
---|
442 | struct
|
---|
443 | {
|
---|
444 | RT_GCC_EXTENSION uint64_t u1Present : 1; /**< Bit 0 - PR: Present. */
|
---|
445 | RT_GCC_EXTENSION uint64_t u4Ign0 : 4; /**< Bits 4:1 - Ignored. */
|
---|
446 | RT_GCC_EXTENSION uint64_t u1Accessed : 1; /**< Bit 5 - A: Accessed. */
|
---|
447 | RT_GCC_EXTENSION uint64_t u1Dirty : 1; /**< Bit 6 - D: Dirty. */
|
---|
448 | RT_GCC_EXTENSION uint64_t u2Ign0 : 2; /**< Bits 8:7 - Ignored. */
|
---|
449 | RT_GCC_EXTENSION uint64_t u3NextLevel : 3; /**< Bits 11:9 - Next Level: Next page translation level. */
|
---|
450 | RT_GCC_EXTENSION uint64_t u40PageAddr : 40; /**< Bits 51:12 - Page address. */
|
---|
451 | RT_GCC_EXTENSION uint64_t u7Rsvd0 : 7; /**< Bits 58:52 - Reserved. */
|
---|
452 | RT_GCC_EXTENSION uint64_t u1UntranslatedAccess : 1; /**< Bit 59 - U: Untranslated Access Only. */
|
---|
453 | RT_GCC_EXTENSION uint64_t u1ForceCoherent : 1; /**< Bit 60 - FC: Force Coherent. */
|
---|
454 | RT_GCC_EXTENSION uint64_t u1IoRead : 1; /**< Bit 61 - IR: I/O Read permission. */
|
---|
455 | RT_GCC_EXTENSION uint64_t u1IoWrite : 1; /**< Bit 62 - IW: I/O Wead permission. */
|
---|
456 | RT_GCC_EXTENSION uint64_t u1Ign0 : 1; /**< Bit 63 - Ignored. */
|
---|
457 | } n;
|
---|
458 | /** The 64-bit unsigned integer view. */
|
---|
459 | uint64_t u;
|
---|
460 | } IOPTE_T;
|
---|
461 | AssertCompileSize(IOPTE_T, 8);
|
---|
462 |
|
---|
463 | /**
|
---|
464 | * I/O Page Directory Entry.
|
---|
465 | * In accordance with the AMD spec.
|
---|
466 | */
|
---|
467 | typedef union
|
---|
468 | {
|
---|
469 | struct
|
---|
470 | {
|
---|
471 | RT_GCC_EXTENSION uint64_t u1Present : 1; /**< Bit 0 - PR: Present. */
|
---|
472 | RT_GCC_EXTENSION uint64_t u4Ign0 : 4; /**< Bits 4:1 - Ignored. */
|
---|
473 | RT_GCC_EXTENSION uint64_t u1Accessed : 1; /**< Bit 5 - A: Accessed. */
|
---|
474 | RT_GCC_EXTENSION uint64_t u3Ign0 : 3; /**< Bits 8:6 - Ignored. */
|
---|
475 | RT_GCC_EXTENSION uint64_t u3NextLevel : 3; /**< Bits 11:9 - Next Level: Next page translation level. */
|
---|
476 | RT_GCC_EXTENSION uint64_t u40PageAddr : 40; /**< Bits 51:12 - Page address (Next Table Address). */
|
---|
477 | RT_GCC_EXTENSION uint64_t u9Rsvd0 : 9; /**< Bits 60:52 - Reserved. */
|
---|
478 | RT_GCC_EXTENSION uint64_t u1IoRead : 1; /**< Bit 61 - IR: I/O Read permission. */
|
---|
479 | RT_GCC_EXTENSION uint64_t u1IoWrite : 1; /**< Bit 62 - IW: I/O Wead permission. */
|
---|
480 | RT_GCC_EXTENSION uint64_t u1Ign0 : 1; /**< Bit 63 - Ignored. */
|
---|
481 | } n;
|
---|
482 | /** The 64-bit unsigned integer view. */
|
---|
483 | uint64_t u;
|
---|
484 | } IOPDE_T;
|
---|
485 | AssertCompileSize(IOPDE_T, 8);
|
---|
486 |
|
---|
487 | /**
|
---|
488 | * Interrupt Remapping Table Entry.
|
---|
489 | * In accordance with the AMD spec.
|
---|
490 | */
|
---|
491 | typedef union
|
---|
492 | {
|
---|
493 | struct
|
---|
494 | {
|
---|
495 | uint32_t u1RemapEnable : 1; /**< Bit 0 - RemapEn: Remap Enable. */
|
---|
496 | uint32_t u1SuppressPf : 1; /**< Bit 1 - SupIOPF: Supress I/O Page Fault. */
|
---|
497 | uint32_t u3IntrType : 1; /**< Bits 4:2 - IntType: Interrupt Type. */
|
---|
498 | uint32_t u1ReqEoi : 1; /**< Bit 5 - RqEoi: Request EOI. */
|
---|
499 | uint32_t u1DstMode : 1; /**< Bit 6 - DM: Destination Mode. */
|
---|
500 | uint32_t u1GuestMode : 1; /**< Bit 7 - GuestMode. */
|
---|
501 | uint32_t u8Dst : 8; /**< Bits 15:8 - Destination. */
|
---|
502 | uint32_t u8Vector : 8; /**< Bits 23:16 - Vector. */
|
---|
503 | uint32_t u8Rsvd0 : 8; /**< Bits 31:24 - Reserved. */
|
---|
504 | } n;
|
---|
505 | /** The 32-bit unsigned integer view. */
|
---|
506 | uint32_t u;
|
---|
507 | } IRTE_T;
|
---|
508 | AssertCompileSize(IRTE_T, 4);
|
---|
509 |
|
---|
510 | /**
|
---|
511 | * Command: Generic Command Buffer Entry.
|
---|
512 | * In accordance with the AMD spec.
|
---|
513 | */
|
---|
514 | typedef union
|
---|
515 | {
|
---|
516 | struct
|
---|
517 | {
|
---|
518 | uint32_t u32Operand1Lo; /**< Bits 31:0 - Operand 1 (Lo). */
|
---|
519 | uint32_t u32Operand1Hi : 28; /**< Bits 59:32 - Operand 1 (Hi). */
|
---|
520 | uint32_t u4Opcode : 4; /**< Bits 63:60 - Op Code. */
|
---|
521 | uint64_t u64Operand2; /**< Bits 127:64 - Operand 2. */
|
---|
522 | } n;
|
---|
523 | /** The 64-bit unsigned integer view. */
|
---|
524 | uint64_t au64[2];
|
---|
525 | } CMD_GENERIC_T;
|
---|
526 | AssertCompileSize(CMD_GENERIC_T, 16);
|
---|
527 |
|
---|
528 | /**
|
---|
529 | * Command: COMPLETION_WAIT.
|
---|
530 | * In accordance with the AMD spec.
|
---|
531 | */
|
---|
532 | typedef union
|
---|
533 | {
|
---|
534 | struct
|
---|
535 | {
|
---|
536 | uint32_t u1Store : 1; /**< Bit 0 - S: Completion Store. */
|
---|
537 | uint32_t u1Interrupt : 1; /**< Bit 1 - I: Completion Interrupt. */
|
---|
538 | uint32_t u1Flush : 1; /**< Bit 2 - F: Flush Queue. */
|
---|
539 | uint32_t u29StoreAddrLo : 29; /**< Bits 31:3 - Store Address (Lo). */
|
---|
540 | uint32_t u20StoreAddrHi : 20; /**< Bits 51:32 - Store Address (Hi). */
|
---|
541 | uint32_t u8Rsvd0 : 8; /**< Bits 59:52 - Reserved. */
|
---|
542 | uint32_t u4OpCode : 4; /**< Bits 63:60 - OpCode (Command). */
|
---|
543 | uint64_t u64StoreData; /**< Bits 127:64 - Store Data. */
|
---|
544 | } n;
|
---|
545 | /** The 64-bit unsigned integer view. */
|
---|
546 | uint32_t au64[2];
|
---|
547 | } CMD_COMPLETION_WAIT_T;
|
---|
548 | AssertCompileSize(CMD_COMPLETION_WAIT_T, 16);
|
---|
549 |
|
---|
550 | /**
|
---|
551 | * Command: INVALIDATE_DEVTAB_ENTRY.
|
---|
552 | * In accordance with the AMD spec.
|
---|
553 | */
|
---|
554 | typedef union
|
---|
555 | {
|
---|
556 | struct
|
---|
557 | {
|
---|
558 | uint16_t u16DeviceId; /**< Bits 15:0 - DeviceID. */
|
---|
559 | uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved. */
|
---|
560 | uint32_t u28Rsvd0 : 28; /**< Bits 59:32 - Reserved. */
|
---|
561 | uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
|
---|
562 | uint64_t u64Rsvd0; /**< Bits 127:64 - Reserved. */
|
---|
563 | } n;
|
---|
564 | /** The 64-bit unsigned integer view. */
|
---|
565 | uint64_t au64[2];
|
---|
566 | } CMD_INV_DEV_TAB_ENTRY_T;
|
---|
567 | AssertCompileSize(CMD_INV_DEV_TAB_ENTRY_T, 16);
|
---|
568 |
|
---|
569 | /**
|
---|
570 | * Command: INVALIDATE_IOMMU_PAGES.
|
---|
571 | * In accordance with the AMD spec.
|
---|
572 | */
|
---|
573 | typedef union
|
---|
574 | {
|
---|
575 | struct
|
---|
576 | {
|
---|
577 | uint32_t u20Pasid : 20; /**< Bits 19:0 - PASID: Process Address-Space ID. */
|
---|
578 | uint32_t u12Rsvd0 : 12; /**< Bits 31:20 - Reserved. */
|
---|
579 | uint32_t u16DomainId : 16; /**< Bits 47:32 - Domain ID. */
|
---|
580 | uint32_t u12Rsvd1 : 12; /**< Bits 59:48 - Reserved. */
|
---|
581 | uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
|
---|
582 | uint32_t u1Size : 1; /**< Bit 64 - S: Size. */
|
---|
583 | uint32_t u1PageDirEntries : 1; /**< Bit 65 - PDE: Page Directory Entries. */
|
---|
584 | uint32_t u1GuestOrNested : 1; /**< Bit 66 - GN: Guest (GPA) or Nested (GVA). */
|
---|
585 | uint32_t u9Rsvd0 : 9; /**< Bits 75:67 - Reserved. */
|
---|
586 | uint32_t u20AddrLo : 20; /**< Bits 95:76 - Address (Lo). */
|
---|
587 | uint32_t u32AddrHi; /**< Bits 127:96 - Address (Hi). */
|
---|
588 | } n;
|
---|
589 | /** The 64-bit unsigned integer view. */
|
---|
590 | uint64_t au64[2];
|
---|
591 | } CMD_INV_IOMMU_PAGES_T;
|
---|
592 | AssertCompileSize(CMD_INV_IOMMU_PAGES_T, 16);
|
---|
593 |
|
---|
594 | /**
|
---|
595 | * Command: INVALIDATE_IOTLB_PAGES.
|
---|
596 | * In accordance with the AMD spec.
|
---|
597 | */
|
---|
598 | typedef union
|
---|
599 | {
|
---|
600 | struct
|
---|
601 | {
|
---|
602 | uint16_t u16DeviceId; /**< Bits 15:0 - Device ID. */
|
---|
603 | uint8_t u8PasidLo; /**< Bits 23:16 - PASID: Process Address-Space ID (Lo). */
|
---|
604 | uint8_t u8MaxPend; /**< Bits 31:24 - Maxpend: Maximum simultaneous in-flight transactions. */
|
---|
605 | uint32_t u16QueueId : 16; /**< Bits 47:32 - Queue ID. */
|
---|
606 | uint32_t u12PasidHi : 12; /**< Bits 59:48 - PASID: Process Address-Space ID (Hi). */
|
---|
607 | uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
|
---|
608 | uint32_t u1Size : 1; /**< Bit 64 - S: Size. */
|
---|
609 | uint32_t u1Rsvd0: 1; /**< Bit 65 - Reserved. */
|
---|
610 | uint32_t u1GuestOrNested : 1; /**< Bit 66 - GN: Guest (GPA) or Nested (GVA). */
|
---|
611 | uint32_t u1Rsvd1 : 1; /**< Bit 67 - Reserved. */
|
---|
612 | uint32_t u2Type : 2; /**< Bit 69:68 - Type. */
|
---|
613 | uint32_t u6Rsvd0 : 6; /**< Bits 75:70 - Reserved. */
|
---|
614 | uint32_t u20AddrLo : 20; /**< Bits 95:76 - Address (Lo). */
|
---|
615 | uint32_t u32AddrHi; /**< Bits 127:96 - Address (Hi). */
|
---|
616 | } n;
|
---|
617 | /** The 64-bit unsigned integer view. */
|
---|
618 | uint64_t au64[2];
|
---|
619 | } CMD_INV_IOTLB_PAGES_T;
|
---|
620 | AssertCompileSize(CMD_INV_IOTLB_PAGES_T, 16);
|
---|
621 |
|
---|
622 | /**
|
---|
623 | * Command: INVALIDATE_INTR_TABLE.
|
---|
624 | * In accordance with the AMD spec.
|
---|
625 | */
|
---|
626 | typedef union
|
---|
627 | {
|
---|
628 | struct
|
---|
629 | {
|
---|
630 | uint16_t u16DeviceId; /**< Bits 15:0 - Device ID. */
|
---|
631 | uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved. */
|
---|
632 | uint32_t u32Rsvd0 : 28; /**< Bits 59:32 - Reserved. */
|
---|
633 | uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
|
---|
634 | uint64_t u64Rsvd0; /**< Bits 127:64 - Reserved. */
|
---|
635 | } u;
|
---|
636 | /** The 64-bit unsigned integer view. */
|
---|
637 | uint64_t au64[2];
|
---|
638 | } CMD_INV_INTR_TABLE_T;
|
---|
639 | AssertCompileSize(CMD_INV_INTR_TABLE_T, 16);
|
---|
640 |
|
---|
641 | /**
|
---|
642 | * Command: COMPLETE_PPR_REQ.
|
---|
643 | * In accordance with the AMD spec.
|
---|
644 | */
|
---|
645 | typedef union
|
---|
646 | {
|
---|
647 | struct
|
---|
648 | {
|
---|
649 | uint16_t u16DeviceId; /**< Bits 15:0 - Device ID. */
|
---|
650 | uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved. */
|
---|
651 | uint32_t u20Pasid : 20; /**< Bits 51:32 - PASID: Process Address-Space ID. */
|
---|
652 | uint32_t u8Rsvd0 : 8; /**< Bits 59:52 - Reserved. */
|
---|
653 | uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
|
---|
654 | uint32_t u2Rsvd0 : 2; /**< Bits 65:64 - Reserved. */
|
---|
655 | uint32_t u1GuestOrNested : 1; /**< Bit 66 - GN: Guest (GPA) or Nested (GVA). */
|
---|
656 | uint32_t u29Rsvd0 : 29; /**< Bits 95:67 - Reserved. */
|
---|
657 | uint32_t u16CompletionTag : 16; /**< Bits 111:96 - Completion Tag. */
|
---|
658 | uint32_t u16Rsvd1 : 16; /**< Bits 127:112 - Reserved. */
|
---|
659 | } n;
|
---|
660 | /** The 64-bit unsigned integer view. */
|
---|
661 | uint64_t au64[2];
|
---|
662 | } CMD_COMPLETE_PPR_REQ_T;
|
---|
663 | AssertCompileSize(CMD_COMPLETE_PPR_REQ_T, 16);
|
---|
664 |
|
---|
665 | /**
|
---|
666 | * Command: INV_IOMMU_ALL.
|
---|
667 | * In accordance with the AMD spec.
|
---|
668 | */
|
---|
669 | typedef union
|
---|
670 | {
|
---|
671 | struct
|
---|
672 | {
|
---|
673 | uint32_t u32Rsvd0; /**< Bits 31:0 - Reserved. */
|
---|
674 | uint32_t u28Rsvd0 : 28; /**< Bits 59:32 - Reserved. */
|
---|
675 | uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
|
---|
676 | uint64_t u64Rsvd0; /**< Bits 127:64 - Reserved. */
|
---|
677 | } n;
|
---|
678 | /** The 64-bit unsigned integer view. */
|
---|
679 | uint64_t au64[2];
|
---|
680 | } CMD_IOMMU_ALL_T;
|
---|
681 | AssertCompileSize(CMD_IOMMU_ALL_T, 16);
|
---|
682 |
|
---|
683 | /**
|
---|
684 | * Event Log Entry: Generic.
|
---|
685 | * In accordance with the AMD spec.
|
---|
686 | */
|
---|
687 | typedef union
|
---|
688 | {
|
---|
689 | struct
|
---|
690 | {
|
---|
691 | uint32_t u32Operand1Lo; /**< Bits 31:0 - Operand 1 (Lo). */
|
---|
692 | uint32_t u32Operand1Hi : 28; /**< Bits 59:32 - Operand 1 (Hi). */
|
---|
693 | uint32_t u4EventCode : 4; /**< Bits 63:60 - Event code. */
|
---|
694 | uint32_t u32Operand2Lo; /**< Bits 95:64 - Operand 2 (Lo). */
|
---|
695 | uint32_t u32Operand2Hi; /**< Bits 127:96 - Operand 2 (Hi). */
|
---|
696 | } n;
|
---|
697 | /** The 32-bit unsigned integer view. */
|
---|
698 | uint32_t au32[4];
|
---|
699 | } EVT_GENERIC_T;
|
---|
700 | AssertCompileSize(EVT_GENERIC_T, 16);
|
---|
701 |
|
---|
702 | /**
|
---|
703 | * Event Log Entry: ILLEGAL_DEV_TAB_ENTRY.
|
---|
704 | * In accordance with the AMD spec.
|
---|
705 | */
|
---|
706 | typedef union
|
---|
707 | {
|
---|
708 | struct
|
---|
709 | {
|
---|
710 | uint16_t u16DeviceId; /**< Bits 15:0 - Device ID. */
|
---|
711 | uint16_t u4PasidHi : 4; /**< Bits 19:16 - PASID: Process Address-Space ID (Hi). */
|
---|
712 | uint16_t u12Rsvd0 : 12; /**< Bits 31:20 - Reserved. */
|
---|
713 | uint16_t u16PasidLo; /**< Bits 47:32 - PASID: Process Address-Space ID (Lo). */
|
---|
714 | uint16_t u1GuestOrNested : 1; /**< Bit 48 - GN: Guest (GPA) or Nested (GVA). */
|
---|
715 | uint16_t u2Rsvd0 : 2; /**< Bits 50:49 - Reserved. */
|
---|
716 | uint16_t u1Interrupt : 1; /**< Bit 51 - I: Interrupt. */
|
---|
717 | uint16_t u1Rsvd0 : 1; /**< Bit 52 - Reserved. */
|
---|
718 | uint16_t u1ReadWrite : 1; /**< Bit 53 - RW: Read/Write. */
|
---|
719 | uint16_t u1Rsvd1 : 1; /**< Bit 54 - Reserved. */
|
---|
720 | uint16_t u1RsvdZero : 1; /**< Bit 55 - RZ: Reserved bit not Zero or invalid level encoding. */
|
---|
721 | uint16_t u1Translation : 1; /**< Bit 56 - TN: Translation. */
|
---|
722 | uint16_t u3Rsvd0 : 3; /**< Bits 59:57 - Reserved. */
|
---|
723 | uint16_t u4EventCode : 4; /**< Bits 63:60 - Event code. */
|
---|
724 | uint32_t u2Rsvd1 : 2; /**< Bits 65:64 - Reserved. */
|
---|
725 | uint32_t u30AddrLo : 2; /**< Bits 95:66 - Address: Device Virtual Address (Lo). */
|
---|
726 | uint32_t u30AddrHi; /**< Bits 127:96 - Address: Device Virtual Address (Hi). */
|
---|
727 | } n;
|
---|
728 | /** The 32-bit unsigned integer view. */
|
---|
729 | uint32_t au32[4];
|
---|
730 | } EVT_ILLEGAL_DEV_TAB_ENTRY_T;
|
---|
731 | AssertCompileSize(EVT_ILLEGAL_DEV_TAB_ENTRY_T, 16);
|
---|
732 |
|
---|
733 | /**
|
---|
734 | * Event Log Entry: IO_PAGE_FAULT_EVENT.
|
---|
735 | * In accordance with the AMD spec.
|
---|
736 | */
|
---|
737 | typedef union
|
---|
738 | {
|
---|
739 | struct
|
---|
740 | {
|
---|
741 | uint16_t u16DeviceId; /**< Bits 15:0 - Device ID. */
|
---|
742 | uint16_t u4PasidHi : 4; /**< Bits 19:16 - PASID: Process Address-Space ID (Hi). */
|
---|
743 | uint16_t u16DomainOrPasidLo; /**< Bits 47:32 - D/P: Domain ID or Process Address-Space ID (Lo). */
|
---|
744 | uint16_t u1GuestOrNested : 1; /**< Bit 48 - GN: Guest (GPA) or Nested (GVA). */
|
---|
745 | uint16_t u1NoExecute : 1; /**< Bit 49 - NX: No Execute. */
|
---|
746 | uint16_t u1User : 1; /**< Bit 50 - US: User/Supervisor. */
|
---|
747 | uint16_t u1Interrupt : 1; /**< Bit 51 - I: Interrupt. */
|
---|
748 | uint16_t u1Present : 1; /**< Bit 52 - PR: Present. */
|
---|
749 | uint16_t u1ReadWrite : 1; /**< Bit 53 - RW: Read/Write. */
|
---|
750 | uint16_t u1Perm : 1; /**< Bit 54 - PE: Permission Indicator. */
|
---|
751 | uint16_t u1RsvdZero : 1; /**< Bit 55 - RZ: Reserved bit not Zero or invalid level encoding. */
|
---|
752 | uint16_t u1Translation : 1; /**< Bit 56 - TN: Translation. */
|
---|
753 | uint16_t u3Rsvd0 : 3; /**< Bit 59:57 - Reserved. */
|
---|
754 | uint16_t u4EventCode : 4; /**< Bits 63:60 - Event code. */
|
---|
755 | uint64_t u64Addr; /**< Bits 127:64 - Address: Device Virtual Address. */
|
---|
756 | } n;
|
---|
757 | /** The 32-bit unsigned integer view. */
|
---|
758 | uint32_t au32[4];
|
---|
759 | } EVT_IO_PAGE_FAULT_T;
|
---|
760 | AssertCompileSize(EVT_IO_PAGE_FAULT_T, 16);
|
---|
761 |
|
---|
762 | /**
|
---|
763 | * Event Log Entry: DEV_TAB_HARDWARE_ERROR.
|
---|
764 | * In accordance with the AMD spec.
|
---|
765 | */
|
---|
766 | typedef union
|
---|
767 | {
|
---|
768 | struct
|
---|
769 | {
|
---|
770 | uint16_t u16DeviceId; /**< Bits 15:0 - Device ID. */
|
---|
771 | uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved. */
|
---|
772 | uint32_t u19Rsvd0 : 19; /**< Bits 50:32 - Reserved. */
|
---|
773 | uint32_t u1Intr : 1; /**< Bit 51 - I: Interrupt. */
|
---|
774 | uint32_t u1Rsvd0 : 1; /**< Bit 52 - Reserved. */
|
---|
775 | uint32_t u1ReadWrite : 1; /**< Bit 53 - RW: Read/Write. */
|
---|
776 | uint32_t u2Rsvd0 : 2; /**< Bits 55:54 - Reserved. */
|
---|
777 | uint32_t u1Translation : 1; /**< Bit 56 - TR: Translation. */
|
---|
778 | uint32_t u2Type : 2; /**< Bits 58:57 - Type: The type of hardware error. */
|
---|
779 | uint32_t u1Rsvd1 : 1; /**< Bit 59 - Reserved. */
|
---|
780 | uint32_t u4EventCode : 4; /**< Bits 63:60 - Event code. */
|
---|
781 | uint32_t u4Rsvd0 : 4; /**< Bits 67:64 - Reserved. */
|
---|
782 | uint32_t u28AddrLo : 28; /**< Bits 95:68 - Address: System Physical Address (Lo). */
|
---|
783 | uint32_t u32AddrHi; /**< Bits 127:96 - Address: System Physical Address (Hi). */
|
---|
784 | } n;
|
---|
785 | /** The 32-bit unsigned integer view. */
|
---|
786 | uint32_t au32[4];
|
---|
787 | } EVT_DEV_TAB_HARDWARE_ERROR;
|
---|
788 | AssertCompileSize(EVT_DEV_TAB_HARDWARE_ERROR, 16);
|
---|
789 |
|
---|
790 | /**
|
---|
791 | * Event Log Entry: EVT_PAGE_TAB_HARDWARE_ERROR.
|
---|
792 | * In accordance with the AMD spec.
|
---|
793 | */
|
---|
794 | typedef union
|
---|
795 | {
|
---|
796 | struct
|
---|
797 | {
|
---|
798 | uint16_t u16DeviceId; /**< Bits 15:0 - Device ID. */
|
---|
799 | uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved. */
|
---|
800 | uint32_t u16DomainOrPasidLo : 16; /**< Bits 47:32 - D/P: Domain ID or Process Address-Space ID (Lo). */
|
---|
801 | uint32_t u1GuestOrNested : 1; /**< Bit 48 - GN: Guest (GPA) or Nested (GVA). */
|
---|
802 | uint32_t u2Rsvd0 : 2; /**< Bits 50:49 - Reserved. */
|
---|
803 | uint32_t u1Interrupt : 1; /**< Bit 51 - I: Interrupt. */
|
---|
804 | uint32_t u1Rsvd0 : 1; /**< Bit 52 - Reserved. */
|
---|
805 | uint32_t u1ReadWrite : 1; /**< Bit 53 - RW: Read/Write. */
|
---|
806 | uint32_t u2Rsvd1 : 2; /**< Bit 55:54 - Reserved. */
|
---|
807 | uint32_t u1Translation : 1; /**< Bit 56 - TR: Translation. */
|
---|
808 | uint32_t u2Type : 2; /**< Bits 58:57 - Type: The type of hardware error. */
|
---|
809 | uint32_t u1Rsvd1 : 1; /**< Bit 59 - Reserved. */
|
---|
810 | uint32_t u4EventCode : 4; /**< Bit 63:60 - Event code. */
|
---|
811 | /** @todo r=ramshankar: Figure 55: PAGE_TAB_HARDWARE_ERROR says Addr[31:3] but
|
---|
812 | * table 58 mentions Addr[31:4]. Looks like a typo in the figure. Use
|
---|
813 | * table as it makes more sense and matches address size in
|
---|
814 | * EVT_DEV_TAB_HARDWARE_ERROR. See AMD AMD IOMMU spec (3.05-PUB, Jan
|
---|
815 | * 2020). */
|
---|
816 | uint32_t u4Rsvd0 : 4; /**< Bits 67:64 - Reserved. */
|
---|
817 | uint32_t u28AddrLo : 28; /**< Bits 95:68 - Address: SPA of page table entry (Lo). */
|
---|
818 | uint32_t u32AddrHi; /**< Bits 127:96 - Address: SPA of page table entry (Hi). */
|
---|
819 | } n;
|
---|
820 | /** The 32-bit unsigned integer view. */
|
---|
821 | uint32_t au32[4];
|
---|
822 | } EVT_PAGE_TAB_HARDWARE_ERROR;
|
---|
823 | AssertCompileSize(EVT_PAGE_TAB_HARDWARE_ERROR, 16);
|
---|
824 |
|
---|
825 | /**
|
---|
826 | * Event Log Entry: ILLEGAL_COMMAND_ERROR.
|
---|
827 | * In accordance with the AMD spec.
|
---|
828 | */
|
---|
829 | typedef union
|
---|
830 | {
|
---|
831 | struct
|
---|
832 | {
|
---|
833 | uint32_t u32Rsvd0; /**< Bits 31:0 - Reserved. */
|
---|
834 | uint32_t u28Rsvd0 : 28; /**< Bits 47:32 - Reserved. */
|
---|
835 | uint32_t u4EventCode : 4; /**< Bits 63:60 - Event code. */
|
---|
836 | uint32_t u4Rsvd0 : 4; /**< Bits 67:64 - Reserved. */
|
---|
837 | uint32_t u28AddrLo : 28; /**< Bits 95:68 - Address: SPA of the invalid command (Lo). */
|
---|
838 | uint32_t u32AddrHi; /**< Bits 127:96 - Address: SPA of the invalid command (Hi). */
|
---|
839 | } n;
|
---|
840 | /** The 32-bit unsigned integer view. */
|
---|
841 | uint32_t au32[4];
|
---|
842 | } EVT_ILLEGAL_COMMAND_ENTRY;
|
---|
843 | AssertCompileSize(EVT_ILLEGAL_COMMAND_ENTRY, 16);
|
---|
844 |
|
---|
845 | /**
|
---|
846 | * Event Log Entry: COMMAND_HARDWARE_ERROR.
|
---|
847 | * In accordance with the AMD spec.
|
---|
848 | */
|
---|
849 | typedef union
|
---|
850 | {
|
---|
851 | struct
|
---|
852 | {
|
---|
853 | uint32_t u32Rsvd0; /**< Bits 31:0 - Reserved. */
|
---|
854 | uint32_t u4Rsvd0 : 4; /**< Bits 35:32 - Reserved. */
|
---|
855 | uint32_t u28AddrLo : 28; /**< Bits 63:36 - Address: SPA of the attempted access (Lo). */
|
---|
856 | uint32_t u32AddrHi; /**< Bits 95:64 - Address: SPA of the attempted access (Hi). */
|
---|
857 | } n;
|
---|
858 | /** The 32-bit unsigned integer view. */
|
---|
859 | uint32_t au32[3];
|
---|
860 | } EVT_COMMAND_HARDWARE_ERROR;
|
---|
861 | AssertCompileSize(EVT_COMMAND_HARDWARE_ERROR, 12);
|
---|
862 |
|
---|
863 | /**
|
---|
864 | * Event Log Entry: IOTLB_INV_TIMEOUT.
|
---|
865 | * In accordance with the AMD spec.
|
---|
866 | */
|
---|
867 | typedef union
|
---|
868 | {
|
---|
869 | struct
|
---|
870 | {
|
---|
871 | uint16_t u16DeviceId; /**< Bits 15:0 - Device ID. */
|
---|
872 | uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved.*/
|
---|
873 | uint32_t u28Rsvd0 : 28; /**< Bits 59:32 - Reserved. */
|
---|
874 | uint32_t u4EventCode : 4; /**< Bits 63:60 - Event code. */
|
---|
875 | uint32_t u4Rsvd0 : 4; /**< Bits 67:64 - Reserved. */
|
---|
876 | uint32_t u28AddrLo : 28; /**< Bits 95:68 - Address: SPA of the invalidation command that timedout (Lo). */
|
---|
877 | uint32_t u32AddrHi; /**< Bits 127:96 - Address: SPA of the invalidation command that timedout (Hi). */
|
---|
878 | } n;
|
---|
879 | /** The 32-bit unsigned integer view. */
|
---|
880 | uint32_t au32[4];
|
---|
881 | } EVT_IOTLB_INV_TIMEOUT;
|
---|
882 | AssertCompileSize(EVT_IOTLB_INV_TIMEOUT, 16);
|
---|
883 |
|
---|
884 | /**
|
---|
885 | * Event Log Entry: INVALID_DEVICE_REQUEST.
|
---|
886 | * In accordance with the AMD spec.
|
---|
887 | */
|
---|
888 | typedef union
|
---|
889 | {
|
---|
890 | struct
|
---|
891 | {
|
---|
892 | uint32_t u16DeviceId : 16; /***< Bits 15:0 - Device ID. */
|
---|
893 | uint32_t u4PasidHi : 4; /***< Bits 19:16 - PASID: Process Address-Space ID (Hi). */
|
---|
894 | uint32_t u12Rsvd0 : 12; /***< Bits 31:20 - Reserved. */
|
---|
895 | uint32_t u16PasidLo : 16; /***< Bits 47:32 - PASID: Process Address-Space ID (Lo). */
|
---|
896 | uint32_t u1GuestOrNested : 1; /***< Bit 48 - GN: Guest (GPA) or Nested (GVA). */
|
---|
897 | uint32_t u1User : 1; /***< Bit 49 - US: User/Supervisor. */
|
---|
898 | uint32_t u6Rsvd0 : 6; /***< Bits 55:50 - Reserved. */
|
---|
899 | uint32_t u1Translation: 1; /***< Bit 56 - TR: Translation. */
|
---|
900 | uint32_t u3Type: 3; /***< Bits 59:57 - Type: The type of hardware error. */
|
---|
901 | uint32_t u4EventCode : 4; /***< Bits 63:60 - Event code. */
|
---|
902 | uint64_t u64Addr; /***< Bits 127:64 - Address: Translation or access address. */
|
---|
903 | } n;
|
---|
904 | /** The 32-bit unsigned integer view. */
|
---|
905 | uint32_t au32[4];
|
---|
906 | } EVT_INVALID_DEVICE_REQUEST;
|
---|
907 | AssertCompileSize(EVT_INVALID_DEVICE_REQUEST, 16);
|
---|
908 |
|
---|
909 | /**
|
---|
910 | * Event Log Entry: EVENT_COUNTER_ZERO.
|
---|
911 | * In accordance with the AMD spec.
|
---|
912 | */
|
---|
913 | typedef union
|
---|
914 | {
|
---|
915 | struct
|
---|
916 | {
|
---|
917 | uint32_t u32Rsvd0; /**< Bits 31:0 - Reserved. */
|
---|
918 | uint32_t u28Rsvd0 : 28; /**< Bits 59:32 - Reserved. */
|
---|
919 | uint32_t u4EventCode : 4; /**< Bits 63:60 - Event code. */
|
---|
920 | uint32_t u20CounterNoteHi : 20; /**< Bits 83:64 - CounterNote: Counter value for the event counter register (Hi). */
|
---|
921 | uint32_t u12Rsvd0 : 12; /**< Bits 95:84 - Reserved. */
|
---|
922 | uint32_t u32CounterNoteLo; /**< Bits 127:96 - CounterNote: Counter value for the event cuonter register (Lo). */
|
---|
923 | } n;
|
---|
924 | /** The 32-bit unsigned integer view. */
|
---|
925 | uint32_t au32[4];
|
---|
926 | } EVT_EVENT_COUNTER_ZERO;
|
---|
927 | AssertCompileSize(EVT_EVENT_COUNTER_ZERO, 16);
|
---|
928 |
|
---|
929 | /* Not needed as we can initialize from bitfields and set/get using PCI config PDM helpers. */
|
---|
930 | #if 0
|
---|
931 | /**
|
---|
932 | * IOMMU Capability Header (PCI).
|
---|
933 | * In accordance with the AMD spec.
|
---|
934 | */
|
---|
935 | typedef union
|
---|
936 | {
|
---|
937 | struct
|
---|
938 | {
|
---|
939 | uint32_t u8CapId : 8; /**< Bits 7:0 - CapId: Capability ID. */
|
---|
940 | uint32_t u8CapPtr : 8; /**< Bits 15:8 - CapPtr: Pointer (PCI config offset) to the next capability. */
|
---|
941 | uint32_t u3CapType : 3; /**< Bits 18:16 - CapType: Capability Type. */
|
---|
942 | uint32_t u5CapRev : 5; /**< Bits 23:19 - CapRev: Capability revision. */
|
---|
943 | uint32_t u1IoTlbSup : 1; /**< Bit 24 - IotlbSup: IOTLB Support. */
|
---|
944 | uint32_t u1HtTunnel : 1; /**< Bit 25 - HtTunnel: HyperTransport Tunnel translation support. */
|
---|
945 | uint32_t u1NpCache : 1; /**< Bit 26 - NpCache: Not Present table entries are cached. */
|
---|
946 | uint32_t u1EfrSup : 1; /**< Bit 27 - EFRSup: Extended Feature Register Support. */
|
---|
947 | uint32_t u1CapExt : 1; /**< Bit 28 - CapExt: Misc. Information Register 1 Support. */
|
---|
948 | uint32_t u4Rsvd0 : 4; /**< Bits 31:29 - Reserved. */
|
---|
949 | } n;
|
---|
950 | /** The 32-bit unsigned integer view. */
|
---|
951 | uint32_t u32;
|
---|
952 | } IOMMU_CAP_HDR_T;
|
---|
953 | AssertCompileSize(IOMMU_CAP_HDR_T, 4);
|
---|
954 | #endif
|
---|
955 |
|
---|
956 | /**
|
---|
957 | * Device Table Base Address Register (MMIO).
|
---|
958 | * In accordance with the AMD spec.
|
---|
959 | */
|
---|
960 | typedef union
|
---|
961 | {
|
---|
962 | struct
|
---|
963 | {
|
---|
964 | RT_GCC_EXTENSION uint64_t u9Size : 9; /**< Bits 8:0 - Size: Size of the device table. */
|
---|
965 | RT_GCC_EXTENSION uint64_t u3Rsvd0 : 3; /**< Bits 11:9 - Reserved. */
|
---|
966 | RT_GCC_EXTENSION uint64_t u40DevTabBase : 40; /**< Bits 51:12 - DevTabBase: Device table base address. */
|
---|
967 | RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 63:52 - Reserved. */
|
---|
968 | } n;
|
---|
969 | /** The 64-bit unsigned integer view. */
|
---|
970 | uint64_t u64;
|
---|
971 | } DEV_TAB_BAR_T;
|
---|
972 | AssertCompileSize(DEV_TAB_BAR_T, 8);
|
---|
973 |
|
---|
974 | /**
|
---|
975 | * Command Buffer Base Address Register (MMIO).
|
---|
976 | * In accordance with the AMD spec.
|
---|
977 | */
|
---|
978 | typedef union
|
---|
979 | {
|
---|
980 | struct
|
---|
981 | {
|
---|
982 | RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 11:0 - Reserved. */
|
---|
983 | RT_GCC_EXTENSION uint64_t u40CmdBase : 40; /**< Bits 51:12 - ComBase: Command buffer base address. */
|
---|
984 | RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 55:52 - Reserved. */
|
---|
985 | RT_GCC_EXTENSION uint64_t u4CmdLen : 4; /**< Bits 59:56 - ComLen: Command buffer length. */
|
---|
986 | RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; /**< Bits 63:60 - Reserved. */
|
---|
987 | } n;
|
---|
988 | /** The 64-bit unsigned integer view. */
|
---|
989 | uint64_t u64;
|
---|
990 | } CMD_BUF_BAR_T;
|
---|
991 | AssertCompileSize(CMD_BUF_BAR_T, 8);
|
---|
992 |
|
---|
993 | /**
|
---|
994 | * Event Log Base Address Register (MMIO).
|
---|
995 | * In accordance with the AMD spec.
|
---|
996 | */
|
---|
997 | typedef union
|
---|
998 | {
|
---|
999 | struct
|
---|
1000 | {
|
---|
1001 | RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 11:0 - Reserved. */
|
---|
1002 | RT_GCC_EXTENSION uint64_t u40EvtBase : 40; /**< Bits 51:12 - EventBase: Event log base address. */
|
---|
1003 | RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 55:52 - Reserved. */
|
---|
1004 | RT_GCC_EXTENSION uint64_t u4EvtLen : 4; /**< Bits 59:56 - EventLen: Event log length. */
|
---|
1005 | RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; /**< Bits 63:60 - Reserved. */
|
---|
1006 | } n;
|
---|
1007 | /** The 64-bit unsigned integer view. */
|
---|
1008 | uint64_t u64;
|
---|
1009 | } EVT_LOG_BAR_T;
|
---|
1010 | AssertCompileSize(EVT_LOG_BAR_T, 8);
|
---|
1011 |
|
---|
1012 | /**
|
---|
1013 | * IOMMU Control Register (MMIO).
|
---|
1014 | * In accordance with the AMD spec.
|
---|
1015 | */
|
---|
1016 | typedef union
|
---|
1017 | {
|
---|
1018 | struct
|
---|
1019 | {
|
---|
1020 | uint32_t u1IommuEn : 1; /**< Bit 0 - IommuEn: IOMMU Enable. */
|
---|
1021 | uint32_t u1HtTunEn : 1; /**< Bit 1 - HtTunEn: HyperTransport Tunnel Enable. */
|
---|
1022 | uint32_t u1EvtLogEn : 1; /**< Bit 2 - EventLogEn: Event Log Enable. */
|
---|
1023 | uint32_t u1EvtIntrEn : 1; /**< Bit 3 - EventIntEn: Event Log Interrupt Enable. */
|
---|
1024 | uint32_t u1CompWaitIntrEn : 1; /**< Bit 4 - ComWaitIntEn: Completion Wait Interrupt Enable. */
|
---|
1025 | uint32_t u3InvTimeOut : 3; /**< Bits 7:5 - InvTimeOut: Invalidation Timeout. */
|
---|
1026 | uint32_t u1PassPW : 1; /**< Bit 8 - PassPW: Pass Posted Write. */
|
---|
1027 | uint32_t u1ResPassPW : 1; /**< Bit 9 - ResPassPW: Response Pass Posted Write. */
|
---|
1028 | uint32_t u1Coherent : 1; /**< Bit 10 - Coherent: HT read request packet Coherent bit. */
|
---|
1029 | uint32_t u1Isoc : 1; /**< Bit 11 - Isoc: HT read request packet Isochronous bit. */
|
---|
1030 | uint32_t u1CmdBufEn : 1; /**< Bit 12 - CmdBufEn: Command Buffer Enable. */
|
---|
1031 | uint32_t u1PprLogEn : 1; /**< Bit 13 - PprLogEn: Peripheral Page Request (PPR) Log Enable. */
|
---|
1032 | uint32_t u1PprIntrEn : 1; /**< Bit 14 - PprIntrEn: Peripheral Page Request Interrupt Enable. */
|
---|
1033 | uint32_t u1PprEn : 1; /**< Bit 15 - PprEn: Peripheral Page Request processing Enable. */
|
---|
1034 | uint32_t u1GstTranslateEn : 1; /**< Bit 16 - GTEn: Guest Translate Enable. */
|
---|
1035 | uint32_t u1GstVirtApicEn : 1; /**< Bit 17 - GAEn: Guest Virtual-APIC Enable. */
|
---|
1036 | uint32_t u4Crw : 1; /**< Bits 21:18 - CRW: Intended for future use (not documented). */
|
---|
1037 | uint32_t u1SmiFilterEn : 1; /**< Bit 22 - SmiFEn: SMI Filter Enable. */
|
---|
1038 | uint32_t u1SelfWriteBackDis : 1; /**< Bit 23 - SlfWBDis: Self Write-Back Disable. */
|
---|
1039 | uint32_t u1SmiFilterLogEn : 1; /**< Bit 24 - SmiFLogEn: SMI Filter Log Enable. */
|
---|
1040 | uint32_t u3GstVirtApicModeEn : 3; /**< Bits 27:25 - GAMEn: Guest Virtual-APIC Mode Enable. */
|
---|
1041 | uint32_t u1GstLogEn : 1; /**< Bit 28 - GALogEn: Guest Virtual-APIC GA Log Enable. */
|
---|
1042 | uint32_t u1GstIntrEn : 1; /**< Bit 29 - GAIntEn: Guest Virtual-APIC Interrupt Enable. */
|
---|
1043 | uint32_t u2DualPprLogEn : 2; /**< Bits 31:30 - DualPprLogEn: Dual Peripheral Page Request Log Enable. */
|
---|
1044 | uint32_t u2DualEvtLogEn : 2; /**< Bits 33:32 - DualEventLogEn: Dual Event Log Enable. */
|
---|
1045 | uint32_t u3DevTabSegEn : 3; /**< Bits 36:34 - DevTblSegEn: Device Table Segment Enable. */
|
---|
1046 | uint32_t u2PrivAbortEn : 2; /**< Bits 38:37 - PrivAbrtEn: Privilege Abort Enable. */
|
---|
1047 | uint32_t u1PprAutoRespEn : 1; /**< Bit 39 - PprAutoRspEn: Peripheral Page Request Auto Response Enable. */
|
---|
1048 | uint32_t u1MarcEn : 1; /**< Bit 40 - MarcEn: Memory Address Routing and Control Enable. */
|
---|
1049 | uint32_t u1BlockStopMarkEn : 1; /**< Bit 41 - BlkStopMarkEn: Block StopMark messages Enable. */
|
---|
1050 | uint32_t u1PprAutoRespAlwaysOnEn : 1; /**< Bit 42 - PprAutoRspAon:: PPR Auto Response - Always On Enable. */
|
---|
1051 | uint32_t u1DomainIDPNE : 1; /**< Bit 43 - DomainIDPE: Reserved (not documented). */
|
---|
1052 | uint32_t u1Rsvd0 : 1; /**< Bit 44 - Reserved. */
|
---|
1053 | uint32_t u1EnhancedPpr : 1; /**< Bit 45 - EPHEn: Enhanced Peripheral Page Request Handling Enable. */
|
---|
1054 | uint32_t u2HstAccDirtyBitUpdate : 2; /**< Bits 47:46 - HADUpdate: Access and Dirty Bit updated in host page table. */
|
---|
1055 | uint32_t u1GstDirtyUpdateDis : 1; /**< Bit 48 - GDUpdateDis: Disable hardare update of Dirty bit in GPT. */
|
---|
1056 | uint32_t u1Rsvd1 : 1; /**< Bit 49 - Reserved. */
|
---|
1057 | uint32_t u1X2ApicEn : 1; /**< Bit 50 - XTEn: Enable X2APIC. */
|
---|
1058 | uint32_t u1X2ApicIntrGenEn : 1; /**< Bit 51 - IntCapXTEn: Enable IOMMU X2APIC Interrupt generation. */
|
---|
1059 | uint32_t u2Rsvd0 : 2; /**< Bits 53:52 - Reserved. */
|
---|
1060 | uint32_t u1GstAccessUpdateDis : 1; /**< Bit 54 - GAUpdateDis: Disable hardare update of Access bit in GPT. */
|
---|
1061 | uint32_t u8Rsvd0 : 8; /**< Bits 63:55 - Reserved. */
|
---|
1062 | } n;
|
---|
1063 | /** The 64-bit unsigned integer view. */
|
---|
1064 | uint64_t u64;
|
---|
1065 | } IOMMU_CTRL_T;
|
---|
1066 | AssertCompileSize(IOMMU_CTRL_T, 8);
|
---|
1067 |
|
---|
1068 | /**
|
---|
1069 | * IOMMU Exclusion Base Register (MMIO).
|
---|
1070 | * In accordance with the AMD spec.
|
---|
1071 | */
|
---|
1072 | typedef union
|
---|
1073 | {
|
---|
1074 | struct
|
---|
1075 | {
|
---|
1076 | RT_GCC_EXTENSION uint64_t u1ExclEnable : 1; /**< Bit 0 - ExEn: Exclusion Range Enable. */
|
---|
1077 | RT_GCC_EXTENSION uint64_t u1AllowAll : 1; /**< Bit 1 - Allow: Allow All Devices. */
|
---|
1078 | RT_GCC_EXTENSION uint64_t u10Rsvd0 : 10; /**< Bits 11:2 - Reserved. */
|
---|
1079 | RT_GCC_EXTENSION uint64_t u40ExclRangeBase : 40; /**< Bits 51:12 - Exclusion Range Base Address. */
|
---|
1080 | RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 63:52 - Reserved. */
|
---|
1081 | } n;
|
---|
1082 | /** The 64-bit unsigned integer view. */
|
---|
1083 | uint64_t u64;
|
---|
1084 | } IOMMU_EXCL_BASE_T;
|
---|
1085 | AssertCompileSize(IOMMU_EXCL_BASE_T, 8);
|
---|
1086 |
|
---|
1087 | /**
|
---|
1088 | * IOMMU Exclusion Range Limit Register (MMIO).
|
---|
1089 | * In accordance with the AMD spec.
|
---|
1090 | */
|
---|
1091 | typedef union
|
---|
1092 | {
|
---|
1093 | struct
|
---|
1094 | {
|
---|
1095 | RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 11:0 - Reserved. */
|
---|
1096 | RT_GCC_EXTENSION uint64_t u40ExclLimit : 40; /**< Bits 51:12 - Exclusion Range Limit. */
|
---|
1097 | RT_GCC_EXTENSION uint64_t u12Rsvd1 : 12; /**< Bits 63:52 - Reserved. */
|
---|
1098 | } n;
|
---|
1099 | /** The 64-bit unsigned integer view. */
|
---|
1100 | uint64_t u64;
|
---|
1101 | } IOMMU_EXCL_RANGE_LIMIT_T;
|
---|
1102 | AssertCompileSize(IOMMU_EXCL_RANGE_LIMIT_T, 8);
|
---|
1103 |
|
---|
1104 | /**
|
---|
1105 | * IOMMU Extended Feature Register (MMIO).
|
---|
1106 | * In accordance with the AMD spec.
|
---|
1107 | */
|
---|
1108 | typedef union
|
---|
1109 | {
|
---|
1110 | struct
|
---|
1111 | {
|
---|
1112 | uint32_t u1PrefetchSup : 1; /**< Bit 0 - PreFSup: Prefetch Support. */
|
---|
1113 | uint32_t u1PprSup : 1; /**< Bit 1 - PPRSup: Peripheral Page Request Support. */
|
---|
1114 | uint32_t u1X2ApicSup : 1; /**< Bit 2 - XTSup: x2Apic Support. */
|
---|
1115 | uint32_t u1NoExecuteSup : 1; /**< Bit 3 - NXSup: No-Execute and Privilege Level Support. */
|
---|
1116 | uint32_t u1GstTranslateSup : 1; /**< Bit 4 - GTSup: Guest Translations Support. */
|
---|
1117 | uint32_t u1Rsvd0 : 1; /**< Bit 5 - Reserved. */
|
---|
1118 | uint32_t u1InvAllSup : 1; /**< Bit 6 - IASup: Invalidate-All Support. */
|
---|
1119 | uint32_t u1GstVirtApicSup : 1; /**< Bit 7 - GASup: Guest Virtual-APIC Support. */
|
---|
1120 | uint32_t u1HwErrorSup : 1; /**< Bit 8 - HESup: Hardware Error registers Support. */
|
---|
1121 | uint32_t u1PerfCounterSup : 1; /**< Bit 8 - PCSup: Performance Counter Support. */
|
---|
1122 | uint32_t u2HostAddrTranslateSize : 2; /**< Bits 11:10 - HATS: Host Address Translation Size. */
|
---|
1123 | uint32_t u2GstAddrTranslateSize : 2; /**< Bits 13:12 - GATS: Guest Address Translation Size. */
|
---|
1124 | uint32_t u2GstCr3RootTblLevel : 2; /**< Bits 15:14 - GLXSup: Guest CR3 Root Table Level (Max) Size Support. */
|
---|
1125 | uint32_t u2SmiFilterSup : 2; /**< Bits 17:16 - SmiFSup: SMI Filter Register Support. */
|
---|
1126 | uint32_t u3SmiFilterCount : 3; /**< Bits 20:18 - SmiFRC: SMI Filter Register Count. */
|
---|
1127 | uint32_t u3GstVirtApicModeSup : 3; /**< Bits 23:21 - GAMSup: Guest Virtual-APIC Modes Supported. */
|
---|
1128 | uint32_t u2DualPprLogSup : 2; /**< Bits 25:24 - DualPprLogSup: Dual Peripheral Page Request Log Support. */
|
---|
1129 | uint32_t u2Rsvd0 : 2; /**< Bits 27:26 - Reserved. */
|
---|
1130 | uint32_t u2DualEvtLogSup : 2; /**< Bits 29:28 - DualEventLogSup: Dual Event Log Support. */
|
---|
1131 | uint32_t u2Rsvd1 : 2; /**< Bits 31:30 - Reserved. */
|
---|
1132 |
|
---|
1133 | uint32_t u5MaxPasidSup : 5; /**< Bits 36:32 - PASMax: Maximum PASID Supported. */
|
---|
1134 | uint32_t u1UserSupervisorSup : 1; /**< Bit 37 - USSup: User/Supervisor Page Protection Support. */
|
---|
1135 | uint32_t u2DevTabSegSup : 2; /**< Bits 39:38 - DevTlbSegSup: Segmented Device Table Support. */
|
---|
1136 | uint32_t u1PprLogOverflowWarn : 1; /**< Bit 40 - PprOvrflwEarlySup: PPR Log Overflow Early Warning Support. */
|
---|
1137 | uint32_t u1PprAutoRespSup : 1; /**< Bit 41 - PprAutoRspSup: PPR Automatic Response Support. */
|
---|
1138 | uint32_t u2MarcSup : 2; /**< Bit 43:42 - MarcSup: Memory Access Routing and Control Support. */
|
---|
1139 | uint32_t u1BlockStopMarkSup : 1; /**< Bit 44 - BlkStopMarkSup: Block StopMark messages Support. */
|
---|
1140 | uint32_t u1PerfOptSup : 1; /**< Bit 45 - PerfOptSup: IOMMU Performance Optimization Support. */
|
---|
1141 | uint32_t u1MsiCapMmioSup : 1; /**< Bit 46 - MsiCapMmioSup: MSI Capability Register MMIO Access Support. */
|
---|
1142 | uint32_t u1Rsvd1 : 1; /**< Bit 47 - Reserved. */
|
---|
1143 | uint32_t u1GstIoSup : 1; /**< Bit 48 - GIoSup: Guest I/O Protection Support. */
|
---|
1144 | uint32_t u1HostAccessSup : 1; /**< Bit 49 - HASup: Host Access Support. */
|
---|
1145 | uint32_t u1EnhancedPprSup : 1; /**< Bit 50 - EPHSup: Enhanced Peripheral Page Request Handling Support. */
|
---|
1146 | uint32_t u1AttrForwardSup : 1; /**< Bit 51 - AttrFWSup: Attribute Forward Support. */
|
---|
1147 | uint32_t u1HostDirtySup : 1; /**< Bit 52 - HDSup: Host Dirty Support. */
|
---|
1148 | uint32_t u1Rsvd2 : 1; /**< Bit 53 - Reserved. */
|
---|
1149 | uint32_t u1InvIoTlbTypeSup : 1; /**< Bit 54 - InvIotlbTypeSup: Invalidate IOTLB Type Support. */
|
---|
1150 | uint32_t u6Rsvd0 : 6; /**< Bit 60:55 - Reserved. */
|
---|
1151 | uint32_t u1GstUpdateDisSup : 1; /**< Bit 61 - GAUpdateDisSup: Disable hardware update on GPT Support. */
|
---|
1152 | uint32_t u1ForcePhysDstSup : 1; /**< Bit 62 - ForcePhyDestSup: Force Phys. Dst. Mode for Remapped Intr. */
|
---|
1153 | uint32_t u1Rsvd3 : 1; /**< Bit 63 - Reserved. */
|
---|
1154 | } n;
|
---|
1155 | /** The 64-bit unsigned integer view. */
|
---|
1156 | uint64_t u64;
|
---|
1157 | } IOMMU_EFR_T;
|
---|
1158 | AssertCompileSize(IOMMU_EFR_T, 8);
|
---|
1159 |
|
---|
1160 | /**
|
---|
1161 | * Peripheral Page Request Log Base Address Register (MMIO).
|
---|
1162 | * In accordance with the AMD spec.
|
---|
1163 | */
|
---|
1164 | typedef union
|
---|
1165 | {
|
---|
1166 | struct
|
---|
1167 | {
|
---|
1168 | RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bit 11:0 - Reserved. */
|
---|
1169 | RT_GCC_EXTENSION uint64_t u40PprLogBase : 40; /**< Bits 51:12 - PPRLogBase: Peripheral Page Request Log Base Address. */
|
---|
1170 | RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 55:52 - Reserved. */
|
---|
1171 | RT_GCC_EXTENSION uint64_t u4PprLogLen : 4; /**< Bits 59:56 - PPRLogLen: Peripheral Page Request Log Length. */
|
---|
1172 | RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; /**< Bits 63:60 - Reserved. */
|
---|
1173 | } n;
|
---|
1174 | /** The 64-bit unsigned integer view. */
|
---|
1175 | uint64_t u64;
|
---|
1176 | } PPR_LOG_BAR_T;
|
---|
1177 | AssertCompileSize(PPR_LOG_BAR_T, 8);
|
---|
1178 |
|
---|
1179 | /**
|
---|
1180 | * IOMMU Hardware Event Upper Register (MMIO).
|
---|
1181 | * In accordance with the AMD spec.
|
---|
1182 | */
|
---|
1183 | typedef union
|
---|
1184 | {
|
---|
1185 | struct
|
---|
1186 | {
|
---|
1187 | RT_GCC_EXTENSION uint64_t u60FirstOperand : 60; /**< Bits 59:0 - First event code dependent operand. */
|
---|
1188 | RT_GCC_EXTENSION uint64_t u4EvtCode : 4; /**< Bits 63:60 - Event Code. */
|
---|
1189 | } n;
|
---|
1190 | /** The 64-bit unsigned integer view. */
|
---|
1191 | uint64_t u64;
|
---|
1192 | } IOMMU_HW_EVT_HI_T;
|
---|
1193 | AssertCompileSize(IOMMU_HW_EVT_HI_T, 8);
|
---|
1194 |
|
---|
1195 | /**
|
---|
1196 | * IOMMU Hardware Event Lower Register (MMIO).
|
---|
1197 | * In accordance with the AMD spec.
|
---|
1198 | */
|
---|
1199 | typedef uint64_t IOMMU_HW_EVT_LO_T;
|
---|
1200 |
|
---|
1201 | /**
|
---|
1202 | * IOMMU Hardware Event Status (MMIO).
|
---|
1203 | * In accordance with the AMD spec.
|
---|
1204 | */
|
---|
1205 | typedef union
|
---|
1206 | {
|
---|
1207 | struct
|
---|
1208 | {
|
---|
1209 | uint32_t u1HwEventValid : 1; /**< Bit 0 - HEV: Hardware Event Valid. */
|
---|
1210 | uint32_t u1HwEventOverflow : 1; /**< Bit 1 - HEO: Hardware Event Overflow. */
|
---|
1211 | uint32_t u30Rsvd0 : 30; /**< Bits 31:2 - Reserved. */
|
---|
1212 | uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved. */
|
---|
1213 | } n;
|
---|
1214 | /** The 64-bit unsigned integer view. */
|
---|
1215 | uint64_t u64;
|
---|
1216 | } IOMMU_HW_EVT_STATUS_T;
|
---|
1217 | AssertCompileSize(IOMMU_HW_EVT_STATUS_T, 8);
|
---|
1218 |
|
---|
1219 | /**
|
---|
1220 | * Guest Virtual-APIC Log Base Address Register (MMIO).
|
---|
1221 | * In accordance with the AMD spec.
|
---|
1222 | */
|
---|
1223 | typedef union
|
---|
1224 | {
|
---|
1225 | struct
|
---|
1226 | {
|
---|
1227 | RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bit 11:0 - Reserved. */
|
---|
1228 | RT_GCC_EXTENSION uint64_t u40GALogBase : 40; /**< Bits 51:12 - GALogBase: Guest Virtual-APIC Log Base Address. */
|
---|
1229 | RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 55:52 - Reserved. */
|
---|
1230 | RT_GCC_EXTENSION uint64_t u4GALogLen : 4; /**< Bits 59:56 - GALogLen: Guest Virtual-APIC Log Length. */
|
---|
1231 | RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; /**< Bits 63:60 - Reserved. */
|
---|
1232 | } n;
|
---|
1233 | /** The 64-bit unsigned integer view. */
|
---|
1234 | uint64_t u64;
|
---|
1235 | } GALOG_BAR_T;
|
---|
1236 | AssertCompileSize(GALOG_BAR_T, 8);
|
---|
1237 |
|
---|
1238 | /**
|
---|
1239 | * Guest Virtual-APIC Log Tail Address Register (MMIO).
|
---|
1240 | * In accordance with the AMD spec.
|
---|
1241 | */
|
---|
1242 | typedef union
|
---|
1243 | {
|
---|
1244 | struct
|
---|
1245 | {
|
---|
1246 | RT_GCC_EXTENSION uint64_t u3Rsvd0 : 3; /**< Bits 2:0 - Reserved. */
|
---|
1247 | RT_GCC_EXTENSION uint64_t u40GALogTailAddr : 48; /**< Bits 51:3 - GATAddr: Guest Virtual-APIC Tail Log Address. */
|
---|
1248 | RT_GCC_EXTENSION uint64_t u11Rsvd1 : 11; /**< Bits 63:52 - Reserved. */
|
---|
1249 | } n;
|
---|
1250 | /** The 64-bit unsigned integer view. */
|
---|
1251 | uint64_t u64;
|
---|
1252 | } GALOG_TAIL_ADDR_T;
|
---|
1253 | AssertCompileSize(GALOG_TAIL_ADDR_T, 8);
|
---|
1254 |
|
---|
1255 | /**
|
---|
1256 | * PPR Log B Base Address Register (MMIO).
|
---|
1257 | * In accordance with the AMD spec.
|
---|
1258 | * Currently identical to PPR_LOG_BAR_T.
|
---|
1259 | */
|
---|
1260 | typedef PPR_LOG_BAR_T PPR_LOG_B_BAR_T;
|
---|
1261 |
|
---|
1262 | /**
|
---|
1263 | * Event Log B Base Address Register (MMIO).
|
---|
1264 | * In accordance with the AMD spec.
|
---|
1265 | * Currently identical to EVT_LOG_BAR_T.
|
---|
1266 | */
|
---|
1267 | typedef EVT_LOG_BAR_T EVT_LOG_B_BAR_T;
|
---|
1268 |
|
---|
1269 | /**
|
---|
1270 | * Device Table Segment Register (MMIO).
|
---|
1271 | * In accordance with the AMD spec.
|
---|
1272 | */
|
---|
1273 | typedef union
|
---|
1274 | {
|
---|
1275 | struct
|
---|
1276 | {
|
---|
1277 | RT_GCC_EXTENSION uint64_t u8Size : 8; /**< Bits 7:0 - Size: Size of the Device Table segment. */
|
---|
1278 | RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 11:8 - Reserved. */
|
---|
1279 | RT_GCC_EXTENSION uint64_t u40DevTabBase : 40; /**< Bits 51:12 - DevTabBase: Device Table Segment Base Address. */
|
---|
1280 | RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 63:52 - Reserved. */
|
---|
1281 | } n;
|
---|
1282 | /** The 64-bit unsigned integer view. */
|
---|
1283 | uint64_t u64;
|
---|
1284 | } DEV_TAB_SEG_BAR_T;
|
---|
1285 | AssertCompileSize(DEV_TAB_SEG_BAR_T, 8);
|
---|
1286 |
|
---|
1287 | /**
|
---|
1288 | * Device-specific Feature Extension (DSFX) Register (MMIO).
|
---|
1289 | * In accordance with the AMD spec.
|
---|
1290 | */
|
---|
1291 | typedef union
|
---|
1292 | {
|
---|
1293 | struct
|
---|
1294 | {
|
---|
1295 | uint32_t u24DevSpecFeatSup : 24; /**< Bits 23:0 - DevSpecificFeatSupp: Implementation specific features. */
|
---|
1296 | uint32_t u4RevMinor : 4; /**< Bits 27:24 - RevMinor: Minor revision identifier. */
|
---|
1297 | uint32_t u4RevMajor : 4; /**< Bits 31:28 - RevMajor: Major revision identifier. */
|
---|
1298 | uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved.*/
|
---|
1299 | } n;
|
---|
1300 | /** The 64-bit unsigned integer view. */
|
---|
1301 | uint64_t u64;
|
---|
1302 | } DEV_SPECIFIC_FEAT_T;
|
---|
1303 | AssertCompileSize(DEV_SPECIFIC_FEAT_T, 8);
|
---|
1304 |
|
---|
1305 | /**
|
---|
1306 | * Device-specific Control Extension (DSCX) Register (MMIO).
|
---|
1307 | * In accordance with the AMD spec.
|
---|
1308 | */
|
---|
1309 | typedef union
|
---|
1310 | {
|
---|
1311 | struct
|
---|
1312 | {
|
---|
1313 | uint32_t u24DevSpecFeatSup : 24; /**< Bits 23:0 - DevSpecificFeatCntrl: Implementation specific control. */
|
---|
1314 | uint32_t u4RevMinor : 4; /**< Bits 27:24 - RevMinor: Minor revision identifier. */
|
---|
1315 | uint32_t u4RevMajor : 4; /**< Bits 31:28 - RevMajor: Major revision identifier. */
|
---|
1316 | uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved.*/
|
---|
1317 | } n;
|
---|
1318 | /** The 64-bit unsigned integer view. */
|
---|
1319 | uint64_t u64;
|
---|
1320 | } DEV_SPECIFIC_CTRL_T;
|
---|
1321 | AssertCompileSize(DEV_SPECIFIC_CTRL_T, 8);
|
---|
1322 |
|
---|
1323 | /**
|
---|
1324 | * Device-specific Status Extension (DSSX) Register (MMIO).
|
---|
1325 | * In accordance with the AMD spec.
|
---|
1326 | */
|
---|
1327 | typedef union
|
---|
1328 | {
|
---|
1329 | struct
|
---|
1330 | {
|
---|
1331 | uint32_t u24DevSpecStatus : 24; /**< Bits 23:0 - DevSpecificFeatStatus: Implementation specific status. */
|
---|
1332 | uint32_t u4RevMinor : 4; /**< Bits 27:24 - RevMinor: Minor revision identifier. */
|
---|
1333 | uint32_t u4RevMajor : 4; /**< Bits 31:28 - RevMajor: Major revision identifier. */
|
---|
1334 | uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved.*/
|
---|
1335 | } n;
|
---|
1336 | /** The 64-bit unsigned integer view. */
|
---|
1337 | uint64_t u64;
|
---|
1338 | } DEV_SPECIFIC_STATUS_T;
|
---|
1339 | AssertCompileSize(DEV_SPECIFIC_STATUS_T, 8);
|
---|
1340 |
|
---|
1341 | /**
|
---|
1342 | * MSI Information Register 0 and 1 (PCI) / MSI Vector Register 0 and 1 (MMIO).
|
---|
1343 | * In accordance with the AMD spec.
|
---|
1344 | */
|
---|
1345 | typedef union
|
---|
1346 | {
|
---|
1347 | struct
|
---|
1348 | {
|
---|
1349 | uint32_t u5MsiNum : 5; /**< Bits 4:0 - MsiNum: MSI Vector used for interrupt messages generated by the IOMMU. */
|
---|
1350 | uint32_t u3GstVirtAddrSize: 3; /**< Bits 7:5 - GVAsize: Guest Virtual Address Size. */
|
---|
1351 | uint32_t u7PhysAddrSize : 7; /**< Bits 14:8 - PAsize: Physical Address Size. */
|
---|
1352 | uint32_t u7VirtAddrSize : 7; /**< Bits 21:15 - VAsize: Virtual Address Size. */
|
---|
1353 | uint32_t u1HtAtsResv: 1; /**< Bit 22 - HtAtsResv: HyperTransport ATS Response Address range Reserved. */
|
---|
1354 | uint32_t u4Rsvd0 : 4; /**< Bits 26:23 - Reserved. */
|
---|
1355 | uint32_t u5MsiNumPpr : 5; /**< Bits 31:27 - MsiNumPPR: Peripheral Page Request MSI message number. */
|
---|
1356 | uint32_t u5MsiNumGa : 5; /**< Bits 36:32 - MsiNumGa: MSI message number for guest virtual-APIC log. */
|
---|
1357 | uint32_t u27Rsvd0: 27; /**< Bits 63:37 - Reserved. */
|
---|
1358 | } n;
|
---|
1359 | /** The 32-bit unsigned integer view. */
|
---|
1360 | uint32_t au32[2];
|
---|
1361 | /** The 64-bit unsigned integer view. */
|
---|
1362 | uint64_t u64;
|
---|
1363 | } MSI_MISC_INFO_T;
|
---|
1364 | AssertCompileSize(MSI_MISC_INFO_T, 8);
|
---|
1365 | /** MSI Vector Register 0 and 1 (MMIO). */
|
---|
1366 | typedef MSI_MISC_INFO_T MSI_VECTOR_T;
|
---|
1367 |
|
---|
1368 | /**
|
---|
1369 | * MSI Capability Header Register (PCI + MMIO).
|
---|
1370 | * In accordance with the AMD spec.
|
---|
1371 | */
|
---|
1372 | typedef union
|
---|
1373 | {
|
---|
1374 | struct
|
---|
1375 | {
|
---|
1376 | uint32_t u8MsiCapId : 8; /**< Bits 7:0 - MsiCapId: Capability ID. */
|
---|
1377 | uint32_t u8MsiCapPtr : 8; /**< Bits 15:8 - MsiCapPtr: Pointer (PCI config offset) to the next capability. */
|
---|
1378 | uint32_t u1MsiEnable : 1; /**< Bit 16 - MsiEn: Message Signal Interrupt Enable. */
|
---|
1379 | uint32_t u3MsiMultiMessCap : 3; /**< Bits 19:17 - MsiMultMessCap: MSI Multi-Message Capability. */
|
---|
1380 | uint32_t u3MsiMultiMessEn : 3; /**< Bits 22:20 - MsiMultMessEn: MSI Multi-Message Enable. */
|
---|
1381 | uint32_t u1Msi64BitEn : 1; /**< Bit 23 - Msi64BitEn: MSI 64-bit Enable. */
|
---|
1382 | uint32_t u8Rsvd0 : 8; /**< Bits 31:24 - Reserved. */
|
---|
1383 | } n;
|
---|
1384 | /** The 32-bit unsigned integer view. */
|
---|
1385 | uint32_t u32;
|
---|
1386 | } MSI_CAP_HDR_T;
|
---|
1387 | AssertCompileSize(MSI_CAP_HDR_T, 4);
|
---|
1388 |
|
---|
1389 | /**
|
---|
1390 | * MSI Address Register (PCI + MMIO).
|
---|
1391 | * In accordance with the AMD spec.
|
---|
1392 | */
|
---|
1393 | typedef union
|
---|
1394 | {
|
---|
1395 | struct
|
---|
1396 | {
|
---|
1397 | uint32_t u2Rsvd : 2; /**< Bits 1:0 - Reserved. */
|
---|
1398 | uint32_t u30MsiAddrLo : 30; /**< Bits 31:2 - MsiAddr: MSI Address (Lo). */
|
---|
1399 | uint32_t u32MsiAddrHi; /**< Bits 63:32 - MsiAddr: MSI Address (Hi). */
|
---|
1400 | } n;
|
---|
1401 | /** The 32-bit unsigned integer view. */
|
---|
1402 | uint32_t au32[2];
|
---|
1403 | /** The 64-bit unsigned integer view. */
|
---|
1404 | uint64_t u64;
|
---|
1405 | } MSI_ADDR_T;
|
---|
1406 | AssertCompileSize(MSI_ADDR_T, 8);
|
---|
1407 |
|
---|
1408 | /**
|
---|
1409 | * MSI Data Register (PCI + MMIO).
|
---|
1410 | * In accordance with the AMD spec.
|
---|
1411 | */
|
---|
1412 | typedef union
|
---|
1413 | {
|
---|
1414 | struct
|
---|
1415 | {
|
---|
1416 | uint16_t u16MsiData; /**< Bits 15:0 - MsiData: MSI Data. */
|
---|
1417 | uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved. */
|
---|
1418 | } n;
|
---|
1419 | /** The 32-bit unsigned integer view. */
|
---|
1420 | uint32_t u32;
|
---|
1421 | } MSI_DATA_T;
|
---|
1422 | AssertCompileSize(MSI_DATA_T, 4);
|
---|
1423 |
|
---|
1424 | /**
|
---|
1425 | * MSI Mapping Capability Header Register (PCI + MMIO).
|
---|
1426 | * In accordance with the AMD spec.
|
---|
1427 | */
|
---|
1428 | typedef union
|
---|
1429 | {
|
---|
1430 | struct
|
---|
1431 | {
|
---|
1432 | uint32_t u8MsiMapCapId : 8; /**< Bits 7:0 - MsiMapCapId: MSI Map capability ID. */
|
---|
1433 | uint32_t u8Rsvd0 : 8; /**< Bits 15:8 - Reserved. */
|
---|
1434 | uint32_t u1MsiMapEn : 1; /**< Bit 16 - MsiMapEn: MSI Map enable. */
|
---|
1435 | uint32_t u1MsiMapFixed : 1; /**< Bit 17 - MsiMapFixd: MSI Map fixed. */
|
---|
1436 | uint32_t u9Rsvd0 : 9; /**< Bits 26:18 - Reserved. */
|
---|
1437 | uint32_t u5MapCapType : 5; /**< Bits 31:27 - MsiMapCapType: MSI Mapping capability type. */
|
---|
1438 | } n;
|
---|
1439 | /** The 32-bit unsigned integer view. */
|
---|
1440 | uint32_t u32;
|
---|
1441 | } MSI_MAP_CAP_HDR_T;
|
---|
1442 | AssertCompileSize(MSI_MAP_CAP_HDR_T, 4);
|
---|
1443 |
|
---|
1444 | /**
|
---|
1445 | * Performance Optimization Control Register (MMIO).
|
---|
1446 | * In accordance with the AMD spec.
|
---|
1447 | */
|
---|
1448 | typedef union
|
---|
1449 | {
|
---|
1450 | struct
|
---|
1451 | {
|
---|
1452 | uint32_t u13Rsvd0 : 13; /**< Bits 12:0 - Reserved. */
|
---|
1453 | uint32_t u1PerfOptEn : 1; /**< Bit 13 - PerfOptEn: Performance Optimization Enable. */
|
---|
1454 | uint32_t u17Rsvd0 : 18; /**< Bits 31:14 - Reserved. */
|
---|
1455 | } n;
|
---|
1456 | /** The 32-bit unsigned integer view. */
|
---|
1457 | uint32_t u32;
|
---|
1458 | } IOMMU_PERF_OPT_CTRL_T;
|
---|
1459 | AssertCompileSize(IOMMU_PERF_OPT_CTRL_T, 4);
|
---|
1460 |
|
---|
1461 | /**
|
---|
1462 | * XT (x2APIC) IOMMU General Interrupt Control Register (MMIO).
|
---|
1463 | * In accordance with the AMD spec.
|
---|
1464 | */
|
---|
1465 | typedef union
|
---|
1466 | {
|
---|
1467 | struct
|
---|
1468 | {
|
---|
1469 | uint32_t u2Rsvd0 : 2; /**< Bits 1:0 - Reserved.*/
|
---|
1470 | uint32_t u1X2ApicIntrDstMode : 1; /**< Bit 2 - Destination Mode for general interrupt.*/
|
---|
1471 | uint32_t u4Rsvd0 : 4; /**< Bits 7:3 - Reserved.*/
|
---|
1472 | uint32_t u24X2ApicIntrDstLo : 24; /**< Bits 31:8 - Destination for general interrupt (Lo).*/
|
---|
1473 | uint32_t u8X2ApicIntrVector : 8; /**< Bits 39:32 - Vector for general interrupt.*/
|
---|
1474 | uint32_t u1X2ApicIntrDeliveryMode : 1; /**< Bit 40 - Delivery Mode for general interrupt.*/
|
---|
1475 | uint32_t u15Rsvd0 : 15; /**< Bits 55:41 - Reserved.*/
|
---|
1476 | uint32_t u7X2ApicIntrDstHi : 7; /**< Bits 63:56 - Destination for general interrupt (Hi) .*/
|
---|
1477 | } n;
|
---|
1478 | /** The 64-bit unsigned integer view. */
|
---|
1479 | uint64_t u64;
|
---|
1480 | } IOMMU_XT_GEN_INTR_CTRL_T;
|
---|
1481 | AssertCompileSize(IOMMU_XT_GEN_INTR_CTRL_T, 8);
|
---|
1482 |
|
---|
1483 | /**
|
---|
1484 | * XT (x2APIC) IOMMU General Interrupt Control Register (MMIO).
|
---|
1485 | * In accordance with the AMD spec.
|
---|
1486 | */
|
---|
1487 | typedef union
|
---|
1488 | {
|
---|
1489 | struct
|
---|
1490 | {
|
---|
1491 | uint32_t u2Rsvd0 : 2; /**< Bits 1:0 - Reserved.*/
|
---|
1492 | uint32_t u1X2ApicIntrDstMode : 1; /**< Bit 2 - Destination Mode for the interrupt.*/
|
---|
1493 | uint32_t u4Rsvd0 : 4; /**< Bits 7:3 - Reserved.*/
|
---|
1494 | uint32_t u24X2ApicIntrDstLo : 24; /**< Bits 31:8 - Destination for the interrupt (Lo).*/
|
---|
1495 | uint32_t u8X2ApicIntrVector : 8; /**< Bits 39:32 - Vector for the interrupt.*/
|
---|
1496 | uint32_t u1X2ApicIntrDeliveryMode : 1; /**< Bit 40 - Delivery Mode for the interrupt.*/
|
---|
1497 | uint32_t u15Rsvd0 : 15; /**< Bits 55:41 - Reserved.*/
|
---|
1498 | uint32_t u7X2ApicIntrDstHi : 7; /**< Bits 63:56 - Destination for the interrupt (Hi) .*/
|
---|
1499 | } n;
|
---|
1500 | /** The 64-bit unsigned integer view. */
|
---|
1501 | uint64_t u64;
|
---|
1502 | } IOMMU_XT_INTR_CTRL_T;
|
---|
1503 | AssertCompileSize(IOMMU_XT_INTR_CTRL_T, 8);
|
---|
1504 |
|
---|
1505 | /**
|
---|
1506 | * XT (x2APIC) IOMMU PPR Interrupt Control Register (MMIO).
|
---|
1507 | * In accordance with the AMD spec.
|
---|
1508 | * Currently identical to IOMMU_XT_INTR_CTRL_T.
|
---|
1509 | */
|
---|
1510 | typedef IOMMU_XT_INTR_CTRL_T IOMMU_XT_PPR_INTR_CTRL_T;
|
---|
1511 |
|
---|
1512 | /**
|
---|
1513 | * XT (x2APIC) IOMMU GA (Guest Address) Log Control Register (MMIO).
|
---|
1514 | * In accordance with the AMD spec.
|
---|
1515 | * Currently identical to IOMMU_XT_INTR_CTRL_T.
|
---|
1516 | */
|
---|
1517 | typedef IOMMU_XT_INTR_CTRL_T IOMMU_XT_GALOG_INTR_CTRL_T;
|
---|
1518 |
|
---|
1519 | /**
|
---|
1520 | * Memory Access and Routing Control (MARC) Aperture Base Register (MMIO).
|
---|
1521 | * In accordance with the AMD spec.
|
---|
1522 | */
|
---|
1523 | typedef union
|
---|
1524 | {
|
---|
1525 | struct
|
---|
1526 | {
|
---|
1527 | RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 11:0 - Reserved. */
|
---|
1528 | RT_GCC_EXTENSION uint64_t u40MarcBaseAddr : 40; /**< Bits 51:12 - MarcBaseAddr: MARC Aperture Base Address. */
|
---|
1529 | RT_GCC_EXTENSION uint64_t u12Rsvd1 : 12; /**< Bits 63:52 - Reserved. */
|
---|
1530 | } n;
|
---|
1531 | /** The 64-bit unsigned integer view. */
|
---|
1532 | uint64_t u64;
|
---|
1533 | } MARC_APER_BAR_T;
|
---|
1534 | AssertCompileSize(MARC_APER_BAR_T, 8);
|
---|
1535 |
|
---|
1536 | /**
|
---|
1537 | * Memory Access and Routing Control (MARC) Relocation Register (MMIO).
|
---|
1538 | * In accordance with the AMD spec.
|
---|
1539 | */
|
---|
1540 | typedef union
|
---|
1541 | {
|
---|
1542 | struct
|
---|
1543 | {
|
---|
1544 | RT_GCC_EXTENSION uint64_t u1RelocEn : 1; /**< Bit 0 - RelocEn: Relocation Enabled. */
|
---|
1545 | RT_GCC_EXTENSION uint64_t u1ReadOnly : 1; /**< Bit 1 - ReadOnly: Whether only read-only acceses allowed. */
|
---|
1546 | RT_GCC_EXTENSION uint64_t u10Rsvd0 : 10; /**< Bits 11:2 - Reserved. */
|
---|
1547 | RT_GCC_EXTENSION uint64_t u40MarcRelocAddr : 40; /**< Bits 51:12 - MarcRelocAddr: MARC Aperture Relocation Address. */
|
---|
1548 | RT_GCC_EXTENSION uint64_t u12Rsvd1 : 12; /**< Bits 63:52 - Reserved. */
|
---|
1549 | } n;
|
---|
1550 | /** The 64-bit unsigned integer view. */
|
---|
1551 | uint64_t u64;
|
---|
1552 | } MARC_APER_RELOC_T;
|
---|
1553 | AssertCompileSize(MARC_APER_RELOC_T, 8);
|
---|
1554 |
|
---|
1555 | /**
|
---|
1556 | * Memory Access and Routing Control (MARC) Length Register (MMIO).
|
---|
1557 | * In accordance with the AMD spec.
|
---|
1558 | */
|
---|
1559 | typedef union
|
---|
1560 | {
|
---|
1561 | struct
|
---|
1562 | {
|
---|
1563 | RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 11:0 - Reserved. */
|
---|
1564 | RT_GCC_EXTENSION uint64_t u40MarcLength : 40; /**< Bits 51:12 - MarcLength: MARC Aperture Length. */
|
---|
1565 | RT_GCC_EXTENSION uint64_t u12Rsvd1 : 12; /**< Bits 63:52 - Reserved. */
|
---|
1566 | } n;
|
---|
1567 | /** The 64-bit unsigned integer view. */
|
---|
1568 | uint64_t u64;
|
---|
1569 | } MARC_APER_LEN_T;
|
---|
1570 |
|
---|
1571 | /**
|
---|
1572 | * Memory Access and Routing Control (MARC) Aperture Register.
|
---|
1573 | * This combines other registers to match the MMIO layout for convenient access.
|
---|
1574 | */
|
---|
1575 | typedef struct
|
---|
1576 | {
|
---|
1577 | MARC_APER_BAR_T Base;
|
---|
1578 | MARC_APER_RELOC_T Reloc;
|
---|
1579 | MARC_APER_LEN_T Length;
|
---|
1580 | } MARC_APER_T;
|
---|
1581 | AssertCompileSize(MARC_APER_T, 24);
|
---|
1582 |
|
---|
1583 | /**
|
---|
1584 | * IOMMU Reserved Register (MMIO).
|
---|
1585 | * In accordance with the AMD spec.
|
---|
1586 | * This register is reserved for hardware use (although RW?).
|
---|
1587 | */
|
---|
1588 | typedef uint64_t IOMMU_RSVD_REG_T;
|
---|
1589 |
|
---|
1590 | /**
|
---|
1591 | * Command Buffer Head Pointer Register (MMIO).
|
---|
1592 | * In accordance with the AMD spec.
|
---|
1593 | */
|
---|
1594 | typedef union
|
---|
1595 | {
|
---|
1596 | struct
|
---|
1597 | {
|
---|
1598 | uint32_t u4Rsvd0 : 4; /**< Bits 3:0 - Reserved. */
|
---|
1599 | uint32_t u15Ptr : 15; /**< Bits 18:4 - Buffer pointer. */
|
---|
1600 | uint32_t u13Rsvd0 : 13; /**< Bits 31:19 - Reserved. */
|
---|
1601 | uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved. */
|
---|
1602 | } n;
|
---|
1603 | /** The 32-bit unsigned integer view. */
|
---|
1604 | uint32_t au32[2];
|
---|
1605 | /** The 64-bit unsigned integer view. */
|
---|
1606 | uint64_t u64;
|
---|
1607 | } CMD_BUF_HEAD_PTR_T;
|
---|
1608 | AssertCompileSize(CMD_BUF_HEAD_PTR_T, 8);
|
---|
1609 |
|
---|
1610 | /**
|
---|
1611 | * Command Buffer Tail Pointer Register (MMIO).
|
---|
1612 | * In accordance with the AMD spec.
|
---|
1613 | * Currently identical to CMD_BUF_HEAD_PTR_T.
|
---|
1614 | */
|
---|
1615 | typedef CMD_BUF_HEAD_PTR_T CMD_BUF_TAIL_PTR_T;
|
---|
1616 |
|
---|
1617 | /**
|
---|
1618 | * Event Log Head Pointer Register (MMIO).
|
---|
1619 | * In accordance with the AMD spec.
|
---|
1620 | * Currently identical to CMD_BUF_HEAD_PTR_T.
|
---|
1621 | */
|
---|
1622 | typedef CMD_BUF_HEAD_PTR_T EVT_LOG_HEAD_PTR_T;
|
---|
1623 |
|
---|
1624 | /**
|
---|
1625 | * Event Log Tail Pointer Register (MMIO).
|
---|
1626 | * In accordance with the AMD spec.
|
---|
1627 | * Currently identical to CMD_BUF_HEAD_PTR_T.
|
---|
1628 | */
|
---|
1629 | typedef CMD_BUF_HEAD_PTR_T EVT_LOG_TAIL_PTR_T;
|
---|
1630 |
|
---|
1631 | /**
|
---|
1632 | * IOMMU Status Register (MMIO).
|
---|
1633 | * In accordance with the AMD spec.
|
---|
1634 | */
|
---|
1635 | typedef union
|
---|
1636 | {
|
---|
1637 | struct
|
---|
1638 | {
|
---|
1639 | uint32_t u1EvtOverflow : 1; /**< Bit 0 - EventOverflow: Event log overflow. */
|
---|
1640 | uint32_t u1EvtLogIntr : 1; /**< Bit 1 - EventLogInt: Event log interrupt. */
|
---|
1641 | uint32_t u1CompWaitIntr : 1; /**< Bit 2 - ComWaitInt: Completion wait interrupt . */
|
---|
1642 | uint32_t u1EvtLogRunning : 1; /**< Bit 3 - EventLogRun: Event logging is running. */
|
---|
1643 | uint32_t u1CmdBufRunning : 1; /**< Bit 4 - CmdBufRun: Command buffer is running. */
|
---|
1644 | uint32_t u1PprOverflow : 1; /**< Bit 5 - PprOverflow: Peripheral Page Request Log (PPR) overflow. */
|
---|
1645 | uint32_t u1PprIntr : 1; /**< Bit 6 - PprInt: PPR interrupt. */
|
---|
1646 | uint32_t u1PprLogRunning : 1; /**< Bit 7 - PprLogRun: PPR logging is running. */
|
---|
1647 | uint32_t u1GstLogRunning : 1; /**< Bit 8 - GALogRun: Guest virtual-APIC logging is running. */
|
---|
1648 | uint32_t u1GstLogOverflow : 1; /**< Bit 9 - GALOverflow: Guest virtual-APIC log overflow. */
|
---|
1649 | uint32_t u1GstLogIntr : 1; /**< Bit 10 - GAInt: Guest virtual-APIC log interrupt. */
|
---|
1650 | uint32_t u1PprOverflowB : 1; /**< Bit 11 - PprOverflowB: PPR log B overflow. */
|
---|
1651 | uint32_t u1PprLogActive : 1; /**< Bit 12 - PprLogActive: PPR log A is active. */
|
---|
1652 | uint32_t u2Rsvd0 : 2; /**< Bits 14:13 - Reserved. */
|
---|
1653 | uint32_t u1EvtOverflowB : 1; /**< Bit 15 - EvtOverflowB: Event log B overflow. */
|
---|
1654 | uint32_t u1EvtLogActive : 1; /**< Bit 16 - EvtLogActive: Event log A active. */
|
---|
1655 | uint32_t u1PprOverflowEarlyB : 1; /**< Bit 17 - PprOverflowEarlyB: PPR log B overflow early warning. */
|
---|
1656 | uint32_t u1PprOverflowEarly : 1; /**< Bit 18 - PprOverflowEarly: PPR log overflow early warning. */
|
---|
1657 | uint32_t u13Rsvd0 : 13; /**< Bits 31:19 - Reserved. */
|
---|
1658 | uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved . */
|
---|
1659 | } n;
|
---|
1660 | /** The 32-bit unsigned integer view. */
|
---|
1661 | uint32_t au32[2];
|
---|
1662 | /** The 64-bit unsigned integer view. */
|
---|
1663 | uint64_t u64;
|
---|
1664 | } IOMMU_STATUS_T;
|
---|
1665 | AssertCompileSize(IOMMU_STATUS_T, 8);
|
---|
1666 |
|
---|
1667 | /**
|
---|
1668 | * PPR Log Head Pointer Register (MMIO).
|
---|
1669 | * In accordance with the AMD spec.
|
---|
1670 | * Currently identical to CMD_BUF_HEAD_PTR_T.
|
---|
1671 | */
|
---|
1672 | typedef CMD_BUF_HEAD_PTR_T PPR_LOG_HEAD_PTR_T;
|
---|
1673 |
|
---|
1674 | /**
|
---|
1675 | * PPR Log Tail Pointer Register (MMIO).
|
---|
1676 | * In accordance with the AMD spec.
|
---|
1677 | * Currently identical to CMD_BUF_HEAD_PTR_T.
|
---|
1678 | */
|
---|
1679 | typedef CMD_BUF_HEAD_PTR_T PPR_LOG_TAIL_PTR_T;
|
---|
1680 |
|
---|
1681 | /**
|
---|
1682 | * Guest Virtual-APIC Log Head Pointer Register (MMIO).
|
---|
1683 | * In accordance with the AMD spec.
|
---|
1684 | */
|
---|
1685 | typedef union
|
---|
1686 | {
|
---|
1687 | struct
|
---|
1688 | {
|
---|
1689 | uint32_t u2Rsvd0 : 2; /**< Bits 2:0 - Reserved. */
|
---|
1690 | uint32_t u12GALogPtr : 12; /**< Bits 15:3 - Guest Virtual-APIC Log Head or Tail Pointer. */
|
---|
1691 | uint32_t u16Rsvd0 : 16; /**< Bits 31:16 - Reserved. */
|
---|
1692 | uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved. */
|
---|
1693 | } n;
|
---|
1694 | /** The 32-bit unsigned integer view. */
|
---|
1695 | uint32_t au32[2];
|
---|
1696 | /** The 64-bit unsigned integer view. */
|
---|
1697 | uint64_t u64;
|
---|
1698 | } GALOG_HEAD_PTR_T;
|
---|
1699 | AssertCompileSize(GALOG_HEAD_PTR_T, 8);
|
---|
1700 |
|
---|
1701 | /**
|
---|
1702 | * Guest Virtual-APIC Log Tail Pointer Register (MMIO).
|
---|
1703 | * In accordance with the AMD spec.
|
---|
1704 | * Currently identical to GALOG_HEAD_PTR_T.
|
---|
1705 | */
|
---|
1706 | typedef GALOG_HEAD_PTR_T GALOG_TAIL_PTR_T;
|
---|
1707 |
|
---|
1708 | /**
|
---|
1709 | * PPR Log B Head Pointer Register (MMIO).
|
---|
1710 | * In accordance with the AMD spec.
|
---|
1711 | * Currently identical to CMD_BUF_HEAD_PTR_T.
|
---|
1712 | */
|
---|
1713 | typedef CMD_BUF_HEAD_PTR_T PPR_LOG_B_HEAD_PTR_T;
|
---|
1714 |
|
---|
1715 | /**
|
---|
1716 | * PPR Log B Tail Pointer Register (MMIO).
|
---|
1717 | * In accordance with the AMD spec.
|
---|
1718 | * Currently identical to CMD_BUF_HEAD_PTR_T.
|
---|
1719 | */
|
---|
1720 | typedef CMD_BUF_HEAD_PTR_T PPR_LOG_B_TAIL_PTR_T;
|
---|
1721 |
|
---|
1722 | /**
|
---|
1723 | * Event Log B Head Pointer Register (MMIO).
|
---|
1724 | * In accordance with the AMD spec.
|
---|
1725 | * Currently identical to CMD_BUF_HEAD_PTR_T.
|
---|
1726 | */
|
---|
1727 | typedef CMD_BUF_HEAD_PTR_T EVT_LOG_B_HEAD_PTR_T;
|
---|
1728 |
|
---|
1729 | /**
|
---|
1730 | * Event Log B Tail Pointer Register (MMIO).
|
---|
1731 | * In accordance with the AMD spec.
|
---|
1732 | * Currently identical to CMD_BUF_HEAD_PTR_T.
|
---|
1733 | */
|
---|
1734 | typedef CMD_BUF_HEAD_PTR_T EVT_LOG_B_TAIL_PTR_T;
|
---|
1735 |
|
---|
1736 | /**
|
---|
1737 | * PPR Log Auto Response Register (MMIO).
|
---|
1738 | * In accordance with the AMD spec.
|
---|
1739 | */
|
---|
1740 | typedef union
|
---|
1741 | {
|
---|
1742 | struct
|
---|
1743 | {
|
---|
1744 | uint32_t u3AutoRespCode : 4; /**< Bits 3:0 - PprAutoRespCode: PPR log Auto Response Code. */
|
---|
1745 | uint32_t u1AutoRespMaskGen : 1; /**< Bit 4 - PprAutoRespMaskGn: PPR log Auto Response Mask Gen. */
|
---|
1746 | uint32_t u27Rsvd0 : 27; /**< Bits 31:5 - Reserved. */
|
---|
1747 | uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved.*/
|
---|
1748 | } n;
|
---|
1749 | /** The 32-bit unsigned integer view. */
|
---|
1750 | uint32_t au32[2];
|
---|
1751 | /** The 64-bit unsigned integer view. */
|
---|
1752 | uint64_t u64;
|
---|
1753 | } PPR_LOG_AUTO_RESP_T;
|
---|
1754 | AssertCompileSize(PPR_LOG_AUTO_RESP_T, 8);
|
---|
1755 |
|
---|
1756 | /**
|
---|
1757 | * PPR Log Overflow Early Indicator Register (MMIO).
|
---|
1758 | * In accordance with the AMD spec.
|
---|
1759 | */
|
---|
1760 | typedef union
|
---|
1761 | {
|
---|
1762 | struct
|
---|
1763 | {
|
---|
1764 | uint32_t u15Threshold : 15; /**< Bits 14:0 - PprOvrflwEarlyThreshold: Overflow early indicator threshold. */
|
---|
1765 | uint32_t u15Rsvd0 : 15; /**< Bits 29:15 - Reserved. */
|
---|
1766 | uint32_t u1IntrEn : 1; /**< Bit 30 - PprOvrflwEarlyIntEn: Overflow early indicator interrupt enable. */
|
---|
1767 | uint32_t u1Enable : 1; /**< Bit 31 - PprOvrflwEarlyEn: Overflow early indicator enable. */
|
---|
1768 | uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved. */
|
---|
1769 | } n;
|
---|
1770 | /** The 32-bit unsigned integer view. */
|
---|
1771 | uint32_t au32[2];
|
---|
1772 | /** The 64-bit unsigned integer view. */
|
---|
1773 | uint64_t u64;
|
---|
1774 | } PPR_LOG_OVERFLOW_EARLY_T;
|
---|
1775 | AssertCompileSize(PPR_LOG_OVERFLOW_EARLY_T, 8);
|
---|
1776 |
|
---|
1777 | /**
|
---|
1778 | * PPR Log B Overflow Early Indicator Register (MMIO).
|
---|
1779 | * In accordance with the AMD spec.
|
---|
1780 | * Currently identical to PPR_LOG_OVERFLOW_EARLY_T.
|
---|
1781 | */
|
---|
1782 | typedef PPR_LOG_OVERFLOW_EARLY_T PPR_LOG_B_OVERFLOW_EARLY_T;
|
---|
1783 |
|
---|
1784 |
|
---|
1785 | /**
|
---|
1786 | * The shared IOMMU device state.
|
---|
1787 | */
|
---|
1788 | typedef struct IOMMU
|
---|
1789 | {
|
---|
1790 | /** Whether this IOMMU is at the top of the PCI tree hierarchy or not. */
|
---|
1791 | bool fRootComplex;
|
---|
1792 | /** Alignment padding. */
|
---|
1793 | bool afPadding[3];
|
---|
1794 | /** The MMIO handle. */
|
---|
1795 | IOMMMIOHANDLE hMmio;
|
---|
1796 |
|
---|
1797 | /** @name MMIO: Control and status registers.
|
---|
1798 | * @{ */
|
---|
1799 | DEV_TAB_BAR_T DevTabBaseAddr; /**< Device table base address register. */
|
---|
1800 | CMD_BUF_BAR_T CmdBufBaseAddr; /**< Command buffer base address register. */
|
---|
1801 | EVT_LOG_BAR_T EvtLogBaseAddr; /**< Event log base address register. */
|
---|
1802 | IOMMU_CTRL_T Ctrl; /**< IOMMU control register. */
|
---|
1803 | IOMMU_EXCL_BASE_T ExclBase; /**< IOMMU exclusion base register. */
|
---|
1804 | IOMMU_EXCL_RANGE_LIMIT_T ExclRangeLimit; /**< IOMMU exclusion range limit. */
|
---|
1805 | IOMMU_EFR_T ExtFeat; /**< IOMMU extended feature register. */
|
---|
1806 | /** @} */
|
---|
1807 |
|
---|
1808 | /** @name MMIO: PPR Log registers.
|
---|
1809 | * @{ */
|
---|
1810 | PPR_LOG_BAR_T PprLogBaseAddr; /**< PPR Log base address register. */
|
---|
1811 | IOMMU_HW_EVT_HI_T HwEvtHi; /**< IOMMU hardware event register (Hi). */
|
---|
1812 | IOMMU_HW_EVT_LO_T HwEvtLo; /**< IOMMU hardware event register (Lo). */
|
---|
1813 | IOMMU_HW_EVT_STATUS_T HwEvtStatus; /**< IOMMU hardware event status. */
|
---|
1814 | /** @} */
|
---|
1815 |
|
---|
1816 | /** @todo IOMMU: SMI filter. */
|
---|
1817 |
|
---|
1818 | /** @name MMIO: Guest Virtual-APIC Log registers.
|
---|
1819 | * @{ */
|
---|
1820 | GALOG_BAR_T GALogBaseAddr; /**< Guest Virtual-APIC Log base address register. */
|
---|
1821 | GALOG_TAIL_ADDR_T GALogTailAddr; /**< Guest Virtual-APIC Log Tail address register. */
|
---|
1822 | /** @} */
|
---|
1823 |
|
---|
1824 | /** @name MMIO: Alternate PPR and Event Log registers.
|
---|
1825 | * @{ */
|
---|
1826 | PPR_LOG_B_BAR_T PprLogBBaseAddr; /**< PPR Log B base address register. */
|
---|
1827 | EVT_LOG_B_BAR_T EvtLogBBaseAddr; /**< Event Log B base address register. */
|
---|
1828 | /** @} */
|
---|
1829 |
|
---|
1830 | /** @name MMIO: Device table segment registers.
|
---|
1831 | * @{ */
|
---|
1832 | DEV_TAB_SEG_BAR_T DevTabSeg[7]; /**< Device Table Segment base address register. */
|
---|
1833 | /** @} */
|
---|
1834 |
|
---|
1835 | /** @name MMIO: Device-specific feature registers.
|
---|
1836 | * @{ */
|
---|
1837 | DEV_SPECIFIC_FEAT_T DevSpecificFeat; /**< Device-specific feature extension register (DSFX). */
|
---|
1838 | DEV_SPECIFIC_CTRL_T DevSpecificCtrl; /**< Device-specific control extension register (DSCX). */
|
---|
1839 | DEV_SPECIFIC_STATUS_T DevSpecificStatus; /**< Device-specific status extension register (DSSX). */
|
---|
1840 | /** @} */
|
---|
1841 |
|
---|
1842 | /** @name MMIO: MSI Capability Block registers.
|
---|
1843 | * @{ */
|
---|
1844 | MSI_MISC_INFO_T MsiMiscInfo; /**< MSI Misc. info registers / MSI Vector registers. */
|
---|
1845 | MSI_CAP_HDR_T MsiCapHdr; /**< MSI Capability header register. */
|
---|
1846 | MSI_ADDR_T MsiAddr; /**< MSI Address register.*/
|
---|
1847 | MSI_DATA_T MsiData; /**< MSI Data register. */
|
---|
1848 | MSI_MAP_CAP_HDR_T MsiMapCapHdr; /**< MSI Mapping capability header register. */
|
---|
1849 | /** @} */
|
---|
1850 |
|
---|
1851 | /** @name MMIO: Performance Optimization Control registers.
|
---|
1852 | * @{ */
|
---|
1853 | IOMMU_PERF_OPT_CTRL_T PerfOptCtrl; /**< IOMMU Performance optimization control register. */
|
---|
1854 | /** @} */
|
---|
1855 |
|
---|
1856 | /** @name MMIO: x2APIC Control registers.
|
---|
1857 | * @{ */
|
---|
1858 | IOMMU_XT_GEN_INTR_CTRL_T XtGenIntrCtrl; /**< IOMMU X2APIC General interrupt control register. */
|
---|
1859 | IOMMU_XT_PPR_INTR_CTRL_T XtPprIntrCtrl; /**< IOMMU X2APIC PPR interrupt control register. */
|
---|
1860 | IOMMU_XT_GALOG_INTR_CTRL_T XtGALogIntrCtrl; /**< IOMMU X2APIC Guest Log interrupt control register. */
|
---|
1861 | /** @} */
|
---|
1862 |
|
---|
1863 | /** @name MMIO: MARC registers.
|
---|
1864 | * @{ */
|
---|
1865 | MARC_APER_T aMarcApers[4]; /**< MARC Aperture Registers. */
|
---|
1866 | /** @} */
|
---|
1867 |
|
---|
1868 | /** @name MMIO: Reserved register.
|
---|
1869 | * @{ */
|
---|
1870 | IOMMU_RSVD_REG_T RsvdReg; /**< IOMMU Reserved Register. */
|
---|
1871 | /** @} */
|
---|
1872 |
|
---|
1873 | /** @name MMIO: Command and Event Log pointer registers.
|
---|
1874 | * @{ */
|
---|
1875 | CMD_BUF_HEAD_PTR_T CmdBufHeadPtr; /**< Command buffer head pointer register. */
|
---|
1876 | CMD_BUF_TAIL_PTR_T CmdBufTailPtr; /**< Command buffer tail pointer register. */
|
---|
1877 | EVT_LOG_HEAD_PTR_T EvtLogHeadPtr; /**< Event log head pointer register. */
|
---|
1878 | EVT_LOG_TAIL_PTR_T EvtLogTailPtr; /**< Event log tail pointer register. */
|
---|
1879 | /** @} */
|
---|
1880 |
|
---|
1881 | /** @name MMIO: Command and Event Status register.
|
---|
1882 | * @{ */
|
---|
1883 | IOMMU_STATUS_T Status; /**< IOMMU status register. */
|
---|
1884 | /** @} */
|
---|
1885 |
|
---|
1886 | /** @name MMIO: PPR Log Head and Tail pointer registers.
|
---|
1887 | * @{ */
|
---|
1888 | PPR_LOG_HEAD_PTR_T PprLogHeadPtr; /**< IOMMU PPR log head pointer register. */
|
---|
1889 | PPR_LOG_TAIL_PTR_T PprLogTailPtr; /**< IOMMU PPR log tail pointer register. */
|
---|
1890 | /** @} */
|
---|
1891 |
|
---|
1892 | /** @name MMIO: Guest Virtual-APIC Log Head and Tail pointer registers.
|
---|
1893 | * @{ */
|
---|
1894 | GALOG_HEAD_PTR_T GALogHeadPtr; /**< Guest Virtual-APIC log head pointer register. */
|
---|
1895 | GALOG_TAIL_PTR_T GALogTailPtr; /**< Guest Virtual-APIC log tail pointer register. */
|
---|
1896 | /** @} */
|
---|
1897 |
|
---|
1898 | /** @name MMIO: PPR Log B Head and Tail pointer registers.
|
---|
1899 | * @{ */
|
---|
1900 | PPR_LOG_B_HEAD_PTR_T PprLogBHeadPtr; /**< PPR log B head pointer register. */
|
---|
1901 | PPR_LOG_B_TAIL_PTR_T PprLogBTailPtr; /**< PPR log B tail pointer register. */
|
---|
1902 | /** @} */
|
---|
1903 |
|
---|
1904 | /** @name MMIO: Event Log B Head and Tail pointer registers.
|
---|
1905 | * @{ */
|
---|
1906 | EVT_LOG_B_HEAD_PTR_T EvtLogBHeadPtr; /**< Event log B head pointer register. */
|
---|
1907 | EVT_LOG_B_TAIL_PTR_T EvtLogBTailPtr; /**< Event log B tail pointer register. */
|
---|
1908 | /** @} */
|
---|
1909 |
|
---|
1910 | /** @name MMIO: PPR Log Overflow protection registers.
|
---|
1911 | * @{ */
|
---|
1912 | PPR_LOG_AUTO_RESP_T PprLogAutoResp; /**< PPR Log Auto Response register. */
|
---|
1913 | PPR_LOG_OVERFLOW_EARLY_T PprLogOverflowEarly; /**< PPR Log Overflow Early Indicator register. */
|
---|
1914 | PPR_LOG_B_OVERFLOW_EARLY_T PprLogBOverflowEarly; /**< PPR Log B Overflow Early Indicator register. */
|
---|
1915 | /** @} */
|
---|
1916 |
|
---|
1917 | /** @todo IOMMU: IOMMU Event counter registers. */
|
---|
1918 |
|
---|
1919 | /** @todo IOMMU: Stat counters. */
|
---|
1920 | } IOMMU;
|
---|
1921 | /** Pointer to the IOMMU device state. */
|
---|
1922 | typedef struct IOMMU *PIOMMU;
|
---|
1923 | /** Pointer to the const IOMMU device state. */
|
---|
1924 | typedef const struct IOMMU *PCIOMMU;
|
---|
1925 |
|
---|
1926 | /**
|
---|
1927 | * The ring-3 IOMMU device state.
|
---|
1928 | */
|
---|
1929 | typedef struct IOMMUR3
|
---|
1930 | {
|
---|
1931 | /** The IOMMU helpers. */
|
---|
1932 | PCPDMIOMMUHLPR3 pIommuHlp;
|
---|
1933 | } IOMMUR3;
|
---|
1934 | /** Pointer to the ring-3 IOMMU device state. */
|
---|
1935 | typedef IOMMUR3 *PIOMMUR3;
|
---|
1936 |
|
---|
1937 | /**
|
---|
1938 | * The ring-0 IOMMU device state.
|
---|
1939 | */
|
---|
1940 | typedef struct IOMMUR0
|
---|
1941 | {
|
---|
1942 | /** The IOMMU helpers. */
|
---|
1943 | PCPDMIOMMUHLPR0 pIommuHlp;
|
---|
1944 | } IOMMUR0;
|
---|
1945 | /** Pointer to the ring-0 IOMMU device state. */
|
---|
1946 | typedef IOMMUR0 *PIOMMUR0;
|
---|
1947 |
|
---|
1948 | /**
|
---|
1949 | * The raw-mode IOMMU device state.
|
---|
1950 | */
|
---|
1951 | typedef struct IOMMURC
|
---|
1952 | {
|
---|
1953 | /** The IOMMU helpers. */
|
---|
1954 | PCPDMIOMMUHLPRC pIommuHlp;
|
---|
1955 | } IOMMURC;
|
---|
1956 | /** Pointer to the raw-mode IOMMU device state. */
|
---|
1957 | typedef IOMMURC *PIOMMURC;
|
---|
1958 |
|
---|
1959 | /** The IOMMU device state for the current context. */
|
---|
1960 | typedef CTX_SUFF(IOMMU) IOMMUCC;
|
---|
1961 | /** Pointer to the IOMMU device state for the current context. */
|
---|
1962 | typedef CTX_SUFF(PIOMMU) PIOMMUCC;
|
---|
1963 |
|
---|
1964 |
|
---|
1965 | #ifndef VBOX_DEVICE_STRUCT_TESTCASE
|
---|
1966 |
|
---|
1967 | static VBOXSTRICTRC iommuAmdReadRegister(PCIOMMU pThis, uint32_t off, uint8_t cb, uint64_t *puResult)
|
---|
1968 | {
|
---|
1969 | Assert(off < _16K);
|
---|
1970 | Assert(cb == 4 || cb == 8);
|
---|
1971 | Assert(cb == 4 || !(off & 7));
|
---|
1972 | Assert(cb == 8 || !(off & 3));
|
---|
1973 |
|
---|
1974 | switch (off)
|
---|
1975 | {
|
---|
1976 | case IOMMU_MMIO_OFF_DEV_TAB_BAR: *puResult = pThis->DevTabBaseAddr.u64; break;
|
---|
1977 | case IOMMU_MMIO_OFF_CMD_BUF_BAR: *puResult = pThis->CmdBufBaseAddr.u64; break;
|
---|
1978 | case IOMMU_MMIO_OFF_EVT_LOG_BAR: *puResult = pThis->EvtLogBaseAddr.u64; break;
|
---|
1979 | case IOMMU_MMIO_OFF_CTRL: *puResult = pThis->Ctrl.u64; break;
|
---|
1980 | case IOMMU_MMIO_OFF_EXCL_BAR: *puResult = pThis->ExclBase.u64; break;
|
---|
1981 | case IOMMU_MMIO_OFF_EXCL_RANGE_LIMIT: *puResult = pThis->ExclRangeLimit.u64; break;
|
---|
1982 | case IOMMU_MMIO_OFF_EXT_FEAT: *puResult = pThis->ExtFeat.u64; break;
|
---|
1983 |
|
---|
1984 | case IOMMU_MMIO_OFF_PPR_LOG_BAR: *puResult = pThis->PprLogBaseAddr.u64; break;
|
---|
1985 | case IOMMU_MMIO_OFF_HW_EVT_HI: *puResult = pThis->HwEvtHi.u64; break;
|
---|
1986 | case IOMMU_MMIO_OFF_HW_EVT_LO: *puResult = pThis->HwEvtLo; break;
|
---|
1987 | case IOMMU_MMIO_OFF_HW_EVT_STATUS: *puResult = pThis->HwEvtStatus.u64; break;
|
---|
1988 |
|
---|
1989 | case IOMMU_MMIO_OFF_GALOG_BAR: *puResult = pThis->GALogBaseAddr.u64; break;
|
---|
1990 | case IOMMU_MMIO_OFF_GALOG_TAIL_ADDR: *puResult = pThis->GALogTailAddr.u64; break;
|
---|
1991 |
|
---|
1992 | case IOMMU_MMIO_OFF_PPR_LOG_B_BAR: *puResult = pThis->PprLogBBaseAddr.u64; break;
|
---|
1993 | case IOMMU_MMIO_OFF_PPR_EVT_B_BAR: *puResult = pThis->EvtLogBBaseAddr.u64; break;
|
---|
1994 |
|
---|
1995 | case IOMMU_MMIO_OFF_DEV_TAB_SEG_FIRST:
|
---|
1996 | case IOMMU_MMIO_OFF_DEV_TAB_SEG_LAST:
|
---|
1997 | {
|
---|
1998 | uint8_t const idxDevTabSeg = (off - IOMMU_MMIO_OFF_DEV_TAB_SEG_FIRST) >> 3;
|
---|
1999 | Assert(idxDevTabSeg < RT_ELEMENTS(pThis->DevTabSeg));
|
---|
2000 | *puResult = pThis->DevTabSeg[idxDevTabSeg].u64;
|
---|
2001 | break;
|
---|
2002 | }
|
---|
2003 |
|
---|
2004 | case IOMMU_MMIO_OFF_DEV_SPECIFIC_FEAT: *puResult = pThis->DevSpecificFeat.u64; break;
|
---|
2005 | case IOMMU_MMIO_OFF_DEV_SPECIFIC_CTRL: *puResult = pThis->DevSpecificCtrl.u64; break;
|
---|
2006 | case IOMMU_MMIO_OFF_DEV_SPECIFIC_STATUS: *puResult = pThis->DevSpecificStatus.u64; break;
|
---|
2007 |
|
---|
2008 | case IOMMU_MMIO_OFF_MSI_VECTOR_0: *puResult = pThis->MsiMiscInfo.u64; break;
|
---|
2009 | case IOMMU_MMIO_OFF_MSI_VECTOR_1: *puResult = pThis->MsiMiscInfo.au32[1]; break;
|
---|
2010 | case IOMMU_MMIO_OFF_MSI_CAP_HDR: *puResult = RT_MAKE_U64(pThis->MsiCapHdr.u32, pThis->MsiAddr.au32[0]); break;
|
---|
2011 | case IOMMU_MMIO_OFF_MSI_ADDR_LO: *puResult = pThis->MsiAddr.au32[0]; break;
|
---|
2012 | case IOMMU_MMIO_OFF_MSI_ADDR_HI: *puResult = RT_MAKE_U64(pThis->MsiAddr.au32[1], pThis->MsiData.u32); break;
|
---|
2013 | case IOMMU_MMIO_OFF_MSI_DATA: *puResult = pThis->MsiData.u32; break;
|
---|
2014 | case IOMMU_MMIO_OFF_MSI_MAPPING_CAP_HDR: *puResult = RT_MAKE_U64(pThis->MsiMapCapHdr.u32, pThis->PerfOptCtrl.u32); break;
|
---|
2015 |
|
---|
2016 | case IOMMU_MMIO_OFF_PERF_OPT_CTRL: *puResult = pThis->PerfOptCtrl.u32; break;
|
---|
2017 |
|
---|
2018 | case IOMMU_MMIO_OFF_XT_GEN_INTR_CTRL: *puResult = pThis->XtGenIntrCtrl.u64; break;
|
---|
2019 | case IOMMU_MMIO_OFF_XT_PPR_INTR_CTRL: *puResult = pThis->XtPprIntrCtrl.u64; break;
|
---|
2020 | case IOMMU_MMIO_OFF_XT_GALOG_INT_CTRL: *puResult = pThis->XtGALogIntrCtrl.u64; break;
|
---|
2021 |
|
---|
2022 | case IOMMU_MMIO_OFF_MARC_APER_BAR_0: *puResult = pThis->aMarcApers[0].Base.u64; break;
|
---|
2023 | case IOMMU_MMIO_OFF_MARC_APER_RELOC_0: *puResult = pThis->aMarcApers[0].Reloc.u64; break;
|
---|
2024 | case IOMMU_MMIO_OFF_MARC_APER_LEN_0: *puResult = pThis->aMarcApers[0].Length.u64; break;
|
---|
2025 | case IOMMU_MMIO_OFF_MARC_APER_BAR_1: *puResult = pThis->aMarcApers[1].Base.u64; break;
|
---|
2026 | case IOMMU_MMIO_OFF_MARC_APER_RELOC_1: *puResult = pThis->aMarcApers[1].Reloc.u64; break;
|
---|
2027 | case IOMMU_MMIO_OFF_MARC_APER_LEN_1: *puResult = pThis->aMarcApers[1].Length.u64; break;
|
---|
2028 | case IOMMU_MMIO_OFF_MARC_APER_BAR_2: *puResult = pThis->aMarcApers[2].Base.u64; break;
|
---|
2029 | case IOMMU_MMIO_OFF_MARC_APER_RELOC_2: *puResult = pThis->aMarcApers[2].Reloc.u64; break;
|
---|
2030 | case IOMMU_MMIO_OFF_MARC_APER_LEN_2: *puResult = pThis->aMarcApers[2].Length.u64; break;
|
---|
2031 | case IOMMU_MMIO_OFF_MARC_APER_BAR_3: *puResult = pThis->aMarcApers[3].Base.u64; break;
|
---|
2032 | case IOMMU_MMIO_OFF_MARC_APER_RELOC_3: *puResult = pThis->aMarcApers[3].Reloc.u64; break;
|
---|
2033 | case IOMMU_MMIO_OFF_MARC_APER_LEN_3: *puResult = pThis->aMarcApers[3].Length.u64; break;
|
---|
2034 |
|
---|
2035 | case IOMMU_MMIO_OFF_RSVD_REG: *puResult = pThis->RsvdReg; break;
|
---|
2036 |
|
---|
2037 | case IOMMU_MMIO_CMD_BUF_HEAD_PTR: *puResult = pThis->CmdBufHeadPtr.u64; break;
|
---|
2038 | case IOMMU_MMIO_CMD_BUF_TAIL_PTR: *puResult = pThis->CmdBufTailPtr.u64; break;
|
---|
2039 | case IOMMU_MMIO_EVT_LOG_HEAD_PTR: *puResult = pThis->EvtLogHeadPtr.u64; break;
|
---|
2040 | case IOMMU_MMIO_EVT_LOG_TAIL_PTR: *puResult = pThis->EvtLogTailPtr.u64; break;
|
---|
2041 |
|
---|
2042 | case IOMMU_MMIO_OFF_STATUS: *puResult = pThis->Status.u64; break;
|
---|
2043 |
|
---|
2044 | case IOMMU_MMIO_OFF_PPR_LOG_HEAD_PTR: *puResult = pThis->PprLogHeadPtr.u64; break;
|
---|
2045 | case IOMMU_MMIO_OFF_PPR_LOG_TAIL_PTR: *puResult = pThis->PprLogTailPtr.u64; break;
|
---|
2046 |
|
---|
2047 | case IOMMU_MMIO_OFF_GALOG_HEAD_PTR: *puResult = pThis->GALogHeadPtr.u64; break;
|
---|
2048 | case IOMMU_MMIO_OFF_GALOG_TAIL_PTR: *puResult = pThis->GALogTailPtr.u64; break;
|
---|
2049 |
|
---|
2050 | case IOMMU_MMIO_OFF_PPR_LOG_B_HEAD_PTR: *puResult = pThis->PprLogBHeadPtr.u64; break;
|
---|
2051 | case IOMMU_MMIO_OFF_PPR_LOG_B_TAIL_PTR: *puResult = pThis->PprLogBTailPtr.u64; break;
|
---|
2052 |
|
---|
2053 | case IOMMU_MMIO_OFF_EVT_LOG_B_HEAD_PTR: *puResult = pThis->EvtLogBHeadPtr.u64; break;
|
---|
2054 | case IOMMU_MMIO_OFF_EVT_LOG_B_TAIL_PTR: *puResult = pThis->EvtLogBTailPtr.u64; break;
|
---|
2055 |
|
---|
2056 | case IOMMU_MMIO_OFF_PPR_LOG_AUTO_RESP: *puResult = pThis->PprLogAutoResp.u64; break;
|
---|
2057 | case IOMMU_MMIO_OFF_PPR_LOG_OVERFLOW_EARLY: *puResult = pThis->PprLogOverflowEarly.u64; break;
|
---|
2058 | case IOMMU_MMIO_OFF_PPR_LOG_B_OVERFLOW_EARLY: *puResult = pThis->PprLogBOverflowEarly.u64; break;
|
---|
2059 |
|
---|
2060 | /* Not implemented. */
|
---|
2061 | case IOMMU_MMIO_OFF_SMI_FLT_FIRST:
|
---|
2062 | case IOMMU_MMIO_OFF_SMI_FLT_LAST:
|
---|
2063 | {
|
---|
2064 | *puResult = 0;
|
---|
2065 | break;
|
---|
2066 | }
|
---|
2067 |
|
---|
2068 | /* Unknown */
|
---|
2069 | default:
|
---|
2070 | {
|
---|
2071 | *puResult = 0;
|
---|
2072 | ASSERT_GUEST_MSG_FAILED((IOMMU_LOG_PFX ": iommuAmdReadRegister: Unknown offset %u (cb=%u)\n", off, cb));
|
---|
2073 | break;
|
---|
2074 | }
|
---|
2075 | }
|
---|
2076 | }
|
---|
2077 |
|
---|
2078 |
|
---|
2079 | /**
|
---|
2080 | * @callback_method_impl{FNIOMMMIONEWWRITE}
|
---|
2081 | */
|
---|
2082 | static DECLCALLBACK(VBOXSTRICTRC) iommuAmdMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb)
|
---|
2083 | {
|
---|
2084 | /** @todo IOMMU: MMIO write. */
|
---|
2085 | RT_NOREF5(pDevIns, pvUser, off, pv, cb);
|
---|
2086 | return VERR_NOT_IMPLEMENTED;
|
---|
2087 | }
|
---|
2088 |
|
---|
2089 |
|
---|
2090 | /**
|
---|
2091 | * @callback_method_impl{FNIOMMMIONEWREAD}
|
---|
2092 | */
|
---|
2093 | static DECLCALLBACK(VBOXSTRICTRC) iommuAmdMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb)
|
---|
2094 | {
|
---|
2095 | NOREF(pvUser);
|
---|
2096 | Assert(cb == 4 || cb == 8);
|
---|
2097 |
|
---|
2098 | uint64_t uResult = 0;
|
---|
2099 | PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
|
---|
2100 | VBOXSTRICTRC rcStrict = iommuAmdReadRegister(pThis, off, cb, &uResult);
|
---|
2101 | if (cb == 8)
|
---|
2102 | *(uint64_t *)pv = uResult;
|
---|
2103 | else
|
---|
2104 | *(uint32_t *)pv = (uint32_t)uResult;
|
---|
2105 |
|
---|
2106 | return rcStrict;
|
---|
2107 | }
|
---|
2108 |
|
---|
2109 |
|
---|
2110 | # ifdef IN_RING3
|
---|
2111 | /**
|
---|
2112 | * @callback_method_impl{FNSSMDEVSAVEEXEC}
|
---|
2113 | */
|
---|
2114 | static DECLCALLBACK(int) iommuAmdR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
|
---|
2115 | {
|
---|
2116 | /** @todo IOMMU: Save state. */
|
---|
2117 | RT_NOREF2(pDevIns, pSSM);
|
---|
2118 | return VERR_NOT_IMPLEMENTED;
|
---|
2119 | }
|
---|
2120 |
|
---|
2121 | /**
|
---|
2122 | * @callback_method_impl{FNSSMDEVLOADEXEC}
|
---|
2123 | */
|
---|
2124 | static DECLCALLBACK(int) iommuAmdR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
|
---|
2125 | {
|
---|
2126 | /** @todo IOMMU: Load state. */
|
---|
2127 | RT_NOREF4(pDevIns, pSSM, uVersion, uPass);
|
---|
2128 | return VERR_NOT_IMPLEMENTED;
|
---|
2129 | }
|
---|
2130 |
|
---|
2131 |
|
---|
2132 | /**
|
---|
2133 | * @interface_method_impl{PDMDEVREG,pfnReset}
|
---|
2134 | */
|
---|
2135 | static DECLCALLBACK(void) iommuAmdR3Reset(PPDMDEVINS pDevIns)
|
---|
2136 | {
|
---|
2137 | NOREF(pDevIns);
|
---|
2138 | }
|
---|
2139 |
|
---|
2140 |
|
---|
2141 | /**
|
---|
2142 | * @interface_method_impl{PDMDEVREG,pfnDestruct}
|
---|
2143 | */
|
---|
2144 | static DECLCALLBACK(int) iommuAmdR3Destruct(PPDMDEVINS pDevIns)
|
---|
2145 | {
|
---|
2146 | NOREF(pDevIns);
|
---|
2147 | return VINF_SUCCESS;
|
---|
2148 | }
|
---|
2149 |
|
---|
2150 |
|
---|
2151 | /**
|
---|
2152 | * @interface_method_impl{PDMDEVREG,pfnConstruct}
|
---|
2153 | */
|
---|
2154 | static DECLCALLBACK(int) iommuAmdR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
|
---|
2155 | {
|
---|
2156 | NOREF(iInstance);
|
---|
2157 |
|
---|
2158 | PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
|
---|
2159 | PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
|
---|
2160 | PIOMMUCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PIOMMUCC);
|
---|
2161 | PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3;
|
---|
2162 | int rc;
|
---|
2163 | LogFlowFunc(("\n"));
|
---|
2164 |
|
---|
2165 | NOREF(pThisCC); /** @todo IOMMU: populate CC data. */
|
---|
2166 |
|
---|
2167 | /*
|
---|
2168 | * Validate and read the configuration.
|
---|
2169 | */
|
---|
2170 | PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "Device|Function|MmioBase", "");
|
---|
2171 |
|
---|
2172 | uint64_t u64MmioBase;
|
---|
2173 | rc = pHlp->pfnCFGMQueryU64Def(pCfg, "MmioBase", &u64MmioBase, 0);
|
---|
2174 | if (RT_FAILURE(rc))
|
---|
2175 | return PDMDEV_SET_ERROR(pDevIns, rc, N_("IOMMU: Failed to query \"MmioBase\""));
|
---|
2176 | /* Must be 16KB aligned when we don't support IOMMU performance counters. */
|
---|
2177 | if (u64MmioBase & 0x3fff)
|
---|
2178 | return PDMDEV_SET_ERROR(pDevIns, rc, N_("IOMMU: \"MmioBase\" must be 16 KB aligned"));
|
---|
2179 | /** @todo IOMMU: Ensure u64MmioBase isn't 0. */
|
---|
2180 |
|
---|
2181 | uint8_t uPciDevice;
|
---|
2182 | rc = pHlp->pfnCFGMQueryU8Def(pCfg, "Device", &uPciDevice, 0);
|
---|
2183 | if (RT_FAILURE(rc))
|
---|
2184 | return PDMDEV_SET_ERROR(pDevIns, rc, N_("IOMMU: Failed to query \"Device\""));
|
---|
2185 |
|
---|
2186 | uint8_t uPciFunction;
|
---|
2187 | rc = pHlp->pfnCFGMQueryU8Def(pCfg, "Function", &uPciFunction, 2);
|
---|
2188 | if (RT_FAILURE(rc))
|
---|
2189 | return PDMDEV_SET_ERROR(pDevIns, rc, N_("IOMMU: Failed to query \"Function\""));
|
---|
2190 |
|
---|
2191 | /*
|
---|
2192 | * Initialize the PCI configuration space.
|
---|
2193 | */
|
---|
2194 | PPDMPCIDEV pPciDev = pDevIns->apPciDevs[0];
|
---|
2195 | PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev);
|
---|
2196 |
|
---|
2197 | uint8_t const offCapHdr = 0x40;
|
---|
2198 | uint8_t const offBaseAddrLo = offCapHdr + 0x4;
|
---|
2199 | uint8_t const offBaseAddrHi = offCapHdr + 0x8;
|
---|
2200 | uint8_t const offRange = offCapHdr + 0xc;
|
---|
2201 | uint8_t const offMiscInfo0 = offCapHdr + 0x10;
|
---|
2202 | uint8_t const offMiscInfo1 = offCapHdr + 0x14;
|
---|
2203 | uint8_t const offMsiCapHdr = offCapHdr + 0x24;
|
---|
2204 | uint8_t const offMsiAddrLo = offCapHdr + 0x28;
|
---|
2205 | uint8_t const offMsiAddrHi = offCapHdr + 0x2c;
|
---|
2206 | uint8_t const offMsiData = offCapHdr + 0x30;
|
---|
2207 | uint8_t const offMsiMapCapHdr = offCapHdr + 0x34;
|
---|
2208 |
|
---|
2209 | /* Header. */
|
---|
2210 | PDMPciDevSetVendorId(pPciDev, IOMMU_PCI_VENDOR_ID); /* RO - AMD */
|
---|
2211 | PDMPciDevSetDeviceId(pPciDev, IOMMU_PCI_DEVICE_ID); /* RO - VirtualBox IOMMU device */
|
---|
2212 | PDMPciDevSetCommand(pPciDev, 0); /* RW - Command */
|
---|
2213 | PDMPciDevSetStatus(pPciDev, 0x5); /* RW - Status - CapList supported */
|
---|
2214 | PDMPciDevSetRevisionId(pPciDev, IOMMU_PCI_REVISION_ID); /* RO - VirtualBox specific device implementation revision */
|
---|
2215 | PDMPciDevSetClassBase(pPciDev, 0x08); /* RO - System Base Peripheral */
|
---|
2216 | PDMPciDevSetClassSub(pPciDev, 0x06); /* RO - IOMMU */
|
---|
2217 | PDMPciDevSetClassProg(pPciDev, 0x00); /* RO - IOMMU Programming interface */
|
---|
2218 | PDMPciDevSetHeaderType(pPciDev, 0x00); /* RO - Single function, type 0. */
|
---|
2219 | PDMPciDevSetSubSystemId(pPciDev, IOMMU_PCI_DEVICE_ID); /* RO - AMD */
|
---|
2220 | PDMPciDevSetSubSystemVendorId(pPciDev, IOMMU_PCI_VENDOR_ID); /* RO - VirtualBox IOMMU device */
|
---|
2221 | PDMPciDevSetCapabilityList(pPciDev, offCapHdr); /* RO - Offset into capability registers. */
|
---|
2222 | PDMPciDevSetInterruptPin(pPciDev, 0x01); /* RO - INTA#. */
|
---|
2223 | PDMPciDevSetInterruptLine(pPciDev, 0x00); /* RW - For software compatibility; no effect on hardware. */
|
---|
2224 |
|
---|
2225 | /* Capability Header. */
|
---|
2226 | PDMPciDevSetDWord(pPciDev, offCapHdr,
|
---|
2227 | RT_BF_MAKE(IOMMU_BF_CAPHDR_CAP_ID, 0xf) /* RO - Secure Device capability block */
|
---|
2228 | | RT_BF_MAKE(IOMMU_BF_CAPHDR_CAP_PTR, offMsiCapHdr) /* RO - Offset to next capability block */
|
---|
2229 | | RT_BF_MAKE(IOMMU_BF_CAPHDR_CAP_TYPE, 0x3) /* RO - IOMMU capability block */
|
---|
2230 | | RT_BF_MAKE(IOMMU_BF_CAPHDR_CAP_REV, 0x1) /* RO - IOMMU interface revision */
|
---|
2231 | | RT_BF_MAKE(IOMMU_BF_CAPHDR_IOTLB_SUP, 0x0) /* RO - Remote IOTLB support */
|
---|
2232 | | RT_BF_MAKE(IOMMU_BF_CAPHDR_HT_TUNNEL, 0x0) /* RO - HyperTransport Tunnel support */
|
---|
2233 | | RT_BF_MAKE(IOMMU_BF_CAPHDR_NP_CACHE, 0x0) /* RO - Cache Not-present page table entries */
|
---|
2234 | | RT_BF_MAKE(IOMMU_BF_CAPHDR_EFR_SUP, 0x1) /* RO - Extended Feature Register support */
|
---|
2235 | | RT_BF_MAKE(IOMMU_BF_CAPHDR_CAP_EXT, 0x1)); /* RO - Misc. Information Register support */
|
---|
2236 |
|
---|
2237 | /* Base Address Low Register. */
|
---|
2238 | PDMPciDevSetDWord(pPciDev, offBaseAddrLo,
|
---|
2239 | RT_BF_MAKE(IOMMU_BF_BASEADDR_LO_ENABLE, 0x1) /* RW1S - Enable */
|
---|
2240 | | RT_BF_MAKE(IOMMU_BF_BASEADDR_LO_ADDR, (u64MmioBase >> 14))); /* RO - Base address (Lo) */
|
---|
2241 |
|
---|
2242 | /* Base Address High Register. */
|
---|
2243 | PDMPciDevSetDWord(pPciDev, offBaseAddrHi, RT_HI_U32(u64MmioBase)); /* RO - Base address (Hi) */
|
---|
2244 |
|
---|
2245 | /* IOMMU Range Register. */
|
---|
2246 | PDMPciDevSetDWord(pPciDev, offRange, 0x0); /* RO - Range register. */
|
---|
2247 |
|
---|
2248 | /* Misc. Information Register 0. */
|
---|
2249 | PDMPciDevSetDWord(pPciDev, offMiscInfo0,
|
---|
2250 | RT_BF_MAKE(IOMMU_BF_MISCINFO_0_MSI_NUM, 0x0) /* RO - MSI number */
|
---|
2251 | | RT_BF_MAKE(IOMMU_BF_MISCINFO_0_GVA_SIZE, 0x2) /* RO - Guest Virt. Addr size (2=48 bits) */
|
---|
2252 | | RT_BF_MAKE(IOMMU_BF_MISCINFO_0_PA_SIZE, 0x30) /* RO - Physical Addr size (48 bits) */
|
---|
2253 | | RT_BF_MAKE(IOMMU_BF_MISCINFO_0_VA_SIZE, 0x40) /* RO - Virt. Addr size (64 bits) */
|
---|
2254 | | RT_BF_MAKE(IOMMU_BF_MISCINFO_0_HT_ATS_RESV, 0x0) /* RW - HT ATS reserved */
|
---|
2255 | | RT_BF_MAKE(IOMMU_BF_MISCINFO_0_MSI_NUM_PPR, 0x0)); /* RW - PPR interrupt number */
|
---|
2256 |
|
---|
2257 | /* Misc. Information Register 1. */
|
---|
2258 | PDMPciDevSetDWord(pPciDev, offMiscInfo1, 0);
|
---|
2259 |
|
---|
2260 | /* MSI Capability Header register. */
|
---|
2261 | PDMPciDevSetDWord(pPciDev, offMsiCapHdr,
|
---|
2262 | RT_BF_MAKE(IOMMU_BF_MSI_CAPHDR_CAP_ID, 0x5) /* RO - Capability ID. */
|
---|
2263 | | RT_BF_MAKE(IOMMU_BF_MSI_CAPHDR_CAP_PTR, offMsiMapCapHdr) /* RO - Offset to mapping capability block */
|
---|
2264 | | RT_BF_MAKE(IOMMU_BF_MSI_CAPHDR_EN, 0x0) /* RW - MSI capability enable */
|
---|
2265 | | RT_BF_MAKE(IOMMU_BF_MSI_CAPHDR_MULTMESS_CAP, 0x0) /* RO - MSI multi-message capability */
|
---|
2266 | | RT_BF_MAKE(IOMMU_BF_MSI_CAPHDR_MULTMESS_EN, 0x0) /* RW - MSI multi-message enable */
|
---|
2267 | | RT_BF_MAKE(IOMMU_BF_MSI_CAPHDR_64BIT_EN, 0x1)); /* RO - MSI 64-bit enable */
|
---|
2268 |
|
---|
2269 | /* MSI Address Lo. */
|
---|
2270 | PDMPciDevSetDWord(pPciDev, offMsiAddrLo, 0); /* RW - MSI message address (Lo). */
|
---|
2271 |
|
---|
2272 | /* MSI Address Hi. */
|
---|
2273 | PDMPciDevSetDWord(pPciDev, offMsiAddrHi, 0); /* RW - MSI message address (Hi). */
|
---|
2274 |
|
---|
2275 | /* MSI Data. */
|
---|
2276 | PDMPciDevSetDWord(pPciDev, offMsiData, 0); /* RW - MSI data. */
|
---|
2277 |
|
---|
2278 | /* MSI Mapping Capability Header register. */
|
---|
2279 | PDMPciDevSetDWord(pPciDev, offMsiMapCapHdr,
|
---|
2280 | RT_BF_MAKE(IOMMU_BF_MSI_MAP_CAPHDR_CAP_ID, 0x8) /* RO - Capability ID */
|
---|
2281 | | RT_BF_MAKE(IOMMU_BF_MSI_MAP_CAPHDR_CAP_PTR, 0x0) /* RO - Offset to next capability (NULL) */
|
---|
2282 | | RT_BF_MAKE(IOMMU_BF_MSI_MAP_CAPHDR_EN, 0x1) /* RO - MSI mapping capability enable */
|
---|
2283 | | RT_BF_MAKE(IOMMU_BF_MSI_MAP_CAPHDR_FIXED, 0x1) /* RO - MSI mapping range is fixed */
|
---|
2284 | | RT_BF_MAKE(IOMMU_BF_MSI_MAP_CAPHDR_CAP_TYPE, 0x15)); /* RO - MSI mapping capability */
|
---|
2285 |
|
---|
2286 | /*
|
---|
2287 | * Register the PCI function with PDM.
|
---|
2288 | */
|
---|
2289 | rc = PDMDevHlpPCIRegisterEx(pDevIns, pPciDev, 0 /* fFlags */, uPciDevice, uPciFunction, "amd-iommu");
|
---|
2290 | AssertLogRelRCReturn(rc, rc);
|
---|
2291 |
|
---|
2292 | /*
|
---|
2293 | * Map MMIO registers.
|
---|
2294 | */
|
---|
2295 | rc = PDMDevHlpMmioCreateAndMap(pDevIns, u64MmioBase, IOMMU_MMIO_REGION_SIZE, iommuAmdMmioWrite, iommuAmdMmioRead,
|
---|
2296 | IOMMMIO_FLAGS_READ_DWORD_QWORD | IOMMMIO_FLAGS_WRITE_DWORD_QWORD_READ_MISSING,
|
---|
2297 | "IOMMU-AMD", &pThis->hMmio);
|
---|
2298 | AssertRCReturn(rc, rc);
|
---|
2299 |
|
---|
2300 | /*
|
---|
2301 | * Register saved state.
|
---|
2302 | */
|
---|
2303 | rc = PDMDevHlpSSMRegisterEx(pDevIns, IOMMU_SAVED_STATE_VERSION, sizeof(IOMMU), NULL,
|
---|
2304 | NULL, NULL, NULL,
|
---|
2305 | NULL, iommuAmdR3SaveExec, NULL,
|
---|
2306 | NULL, iommuAmdR3LoadExec, NULL);
|
---|
2307 | AssertRCReturn(rc, rc);
|
---|
2308 |
|
---|
2309 | return VINF_SUCCESS;
|
---|
2310 | }
|
---|
2311 |
|
---|
2312 | # else /* !IN_RING3 */
|
---|
2313 |
|
---|
2314 | /**
|
---|
2315 | * @callback_method_impl{PDMDEVREGR0,pfnConstruct}
|
---|
2316 | */
|
---|
2317 | static DECLCALLBACK(int) iommuAmdRZConstruct(PPDMDEVINS pDevIns)
|
---|
2318 | {
|
---|
2319 | PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
|
---|
2320 | return VINF_SUCCESS;
|
---|
2321 | }
|
---|
2322 |
|
---|
2323 | # endif /* !IN_RING3 */
|
---|
2324 |
|
---|
2325 | /**
|
---|
2326 | * The device registration structure.
|
---|
2327 | */
|
---|
2328 | const PDMDEVREG g_DeviceIommuAmd =
|
---|
2329 | {
|
---|
2330 | /* .u32Version = */ PDM_DEVREG_VERSION,
|
---|
2331 | /* .uReserved0 = */ 0,
|
---|
2332 | /* .szName = */ "iommu-amd",
|
---|
2333 | /* .fFlags = */ PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RZ | PDM_DEVREG_FLAGS_NEW_STYLE,
|
---|
2334 | /* .fClass = */ PDM_DEVREG_CLASS_BUS_ISA, /* Instantiate after PDM_DEVREG_CLASS_BUS_PCI */
|
---|
2335 | /* .cMaxInstances = */ ~0U,
|
---|
2336 | /* .uSharedVersion = */ 42,
|
---|
2337 | /* .cbInstanceShared = */ sizeof(IOMMU),
|
---|
2338 | /* .cbInstanceCC = */ sizeof(IOMMUCC),
|
---|
2339 | /* .cbInstanceRC = */ sizeof(IOMMURC),
|
---|
2340 | /* .cMaxPciDevices = */ 1,
|
---|
2341 | /* .cMaxMsixVectors = */ 0,
|
---|
2342 | /* .pszDescription = */ "IOMMU (AMD)",
|
---|
2343 | #if defined(IN_RING3)
|
---|
2344 | /* .pszRCMod = */ "VBoxDDRC.rc",
|
---|
2345 | /* .pszR0Mod = */ "VBoxDDR0.r0",
|
---|
2346 | /* .pfnConstruct = */ iommuAmdR3Construct,
|
---|
2347 | /* .pfnDestruct = */ iommuAmdR3Destruct,
|
---|
2348 | /* .pfnRelocate = */ NULL,
|
---|
2349 | /* .pfnMemSetup = */ NULL,
|
---|
2350 | /* .pfnPowerOn = */ NULL,
|
---|
2351 | /* .pfnReset = */ iommuAmdR3Reset,
|
---|
2352 | /* .pfnSuspend = */ NULL,
|
---|
2353 | /* .pfnResume = */ NULL,
|
---|
2354 | /* .pfnAttach = */ NULL,
|
---|
2355 | /* .pfnDetach = */ NULL,
|
---|
2356 | /* .pfnQueryInterface = */ NULL,
|
---|
2357 | /* .pfnInitComplete = */ NULL,
|
---|
2358 | /* .pfnPowerOff = */ NULL,
|
---|
2359 | /* .pfnSoftReset = */ NULL,
|
---|
2360 | /* .pfnReserved0 = */ NULL,
|
---|
2361 | /* .pfnReserved1 = */ NULL,
|
---|
2362 | /* .pfnReserved2 = */ NULL,
|
---|
2363 | /* .pfnReserved3 = */ NULL,
|
---|
2364 | /* .pfnReserved4 = */ NULL,
|
---|
2365 | /* .pfnReserved5 = */ NULL,
|
---|
2366 | /* .pfnReserved6 = */ NULL,
|
---|
2367 | /* .pfnReserved7 = */ NULL,
|
---|
2368 | #elif defined(IN_RING0)
|
---|
2369 | /* .pfnEarlyConstruct = */ NULL,
|
---|
2370 | /* .pfnConstruct = */ iommuAmdRZConstruct,
|
---|
2371 | /* .pfnDestruct = */ NULL,
|
---|
2372 | /* .pfnFinalDestruct = */ NULL,
|
---|
2373 | /* .pfnRequest = */ NULL,
|
---|
2374 | /* .pfnReserved0 = */ NULL,
|
---|
2375 | /* .pfnReserved1 = */ NULL,
|
---|
2376 | /* .pfnReserved2 = */ NULL,
|
---|
2377 | /* .pfnReserved3 = */ NULL,
|
---|
2378 | /* .pfnReserved4 = */ NULL,
|
---|
2379 | /* .pfnReserved5 = */ NULL,
|
---|
2380 | /* .pfnReserved6 = */ NULL,
|
---|
2381 | /* .pfnReserved7 = */ NULL,
|
---|
2382 | #elif defined(IN_RC)
|
---|
2383 | /* .pfnConstruct = */ iommuAmdRZConstruct,
|
---|
2384 | /* .pfnReserved0 = */ NULL,
|
---|
2385 | /* .pfnReserved1 = */ NULL,
|
---|
2386 | /* .pfnReserved2 = */ NULL,
|
---|
2387 | /* .pfnReserved3 = */ NULL,
|
---|
2388 | /* .pfnReserved4 = */ NULL,
|
---|
2389 | /* .pfnReserved5 = */ NULL,
|
---|
2390 | /* .pfnReserved6 = */ NULL,
|
---|
2391 | /* .pfnReserved7 = */ NULL,
|
---|
2392 | #else
|
---|
2393 | # error "Not in IN_RING3, IN_RING0 or IN_RC!"
|
---|
2394 | #endif
|
---|
2395 | /* .u32VersionEnd = */ PDM_DEVREG_VERSION
|
---|
2396 | };
|
---|
2397 |
|
---|
2398 | #endif /* !VBOX_DEVICE_STRUCT_TESTCASE */
|
---|
2399 |
|
---|