1 | /* $Id: DevIommuAmd.cpp 84132 2020-05-02 18:26:46Z 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/msi.h>
|
---|
24 | #include <VBox/vmm/pdmdev.h>
|
---|
25 | #include <VBox/AssertGuest.h>
|
---|
26 |
|
---|
27 | #include "VBoxDD.h"
|
---|
28 | #include <iprt/x86.h>
|
---|
29 | #include <iprt/string.h>
|
---|
30 |
|
---|
31 |
|
---|
32 | /*********************************************************************************************************************************
|
---|
33 | * Defined Constants And Macros *
|
---|
34 | *********************************************************************************************************************************/
|
---|
35 | /**
|
---|
36 | * @name PCI configuration register offsets.
|
---|
37 | * In accordance with the AMD spec.
|
---|
38 | * @{
|
---|
39 | */
|
---|
40 | #define IOMMU_PCI_OFF_CAP_HDR 0x40
|
---|
41 | #define IOMMU_PCI_OFF_BASE_ADDR_REG_LO 0x44
|
---|
42 | #define IOMMU_PCI_OFF_BASE_ADDR_REG_HI 0x48
|
---|
43 | #define IOMMU_PCI_OFF_RANGE_REG 0x4c
|
---|
44 | #define IOMMU_PCI_OFF_MISCINFO_REG_0 0x50
|
---|
45 | #define IOMMU_PCI_OFF_MISCINFO_REG_1 0x54
|
---|
46 | #define IOMMU_PCI_OFF_MSI_CAP_HDR 0x64
|
---|
47 | #define IOMMU_PCI_OFF_MSI_ADDR_LO 0x68
|
---|
48 | #define IOMMU_PCI_OFF_MSI_ADDR_HI 0x6c
|
---|
49 | #define IOMMU_PCI_OFF_MSI_DATA 0x70
|
---|
50 | #define IOMMU_PCI_OFF_MSI_MAP_CAP_HDR 0x74
|
---|
51 | /** @} */
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * @name MMIO register offsets.
|
---|
55 | * In accordance with the AMD spec.
|
---|
56 | * @{
|
---|
57 | */
|
---|
58 | #define IOMMU_MMIO_OFF_DEV_TAB_BAR 0x00
|
---|
59 | #define IOMMU_MMIO_OFF_CMD_BUF_BAR 0x08
|
---|
60 | #define IOMMU_MMIO_OFF_EVT_LOG_BAR 0x10
|
---|
61 | #define IOMMU_MMIO_OFF_CTRL 0x18
|
---|
62 | #define IOMMU_MMIO_OFF_EXCL_BAR 0x20
|
---|
63 | #define IOMMU_MMIO_OFF_EXCL_RANGE_LIMIT 0x28
|
---|
64 | #define IOMMU_MMIO_OFF_EXT_FEAT 0x30
|
---|
65 |
|
---|
66 | #define IOMMU_MMIO_OFF_PPR_LOG_BAR 0x38
|
---|
67 | #define IOMMU_MMIO_OFF_HW_EVT_HI 0x40
|
---|
68 | #define IOMMU_MMIO_OFF_HW_EVT_LO 0x48
|
---|
69 | #define IOMMU_MMIO_OFF_HW_EVT_STATUS 0x50
|
---|
70 |
|
---|
71 | #define IOMMU_MMIO_OFF_SMI_FLT_FIRST 0x60
|
---|
72 | #define IOMMU_MMIO_OFF_SMI_FLT_LAST 0xd8
|
---|
73 |
|
---|
74 | #define IOMMU_MMIO_OFF_GALOG_BAR 0xe0
|
---|
75 | #define IOMMU_MMIO_OFF_GALOG_TAIL_ADDR 0xe8
|
---|
76 |
|
---|
77 | #define IOMMU_MMIO_OFF_PPR_LOG_B_BAR 0xf0
|
---|
78 | #define IOMMU_MMIO_OFF_PPR_EVT_B_BAR 0xf8
|
---|
79 |
|
---|
80 | #define IOMMU_MMIO_OFF_DEV_TAB_SEG_FIRST 0x100
|
---|
81 | #define IOMMU_MMIO_OFF_DEV_TAB_SEG_1 0x100
|
---|
82 | #define IOMMU_MMIO_OFF_DEV_TAB_SEG_2 0x108
|
---|
83 | #define IOMMU_MMIO_OFF_DEV_TAB_SEG_3 0x110
|
---|
84 | #define IOMMU_MMIO_OFF_DEV_TAB_SEG_4 0x118
|
---|
85 | #define IOMMU_MMIO_OFF_DEV_TAB_SEG_5 0x120
|
---|
86 | #define IOMMU_MMIO_OFF_DEV_TAB_SEG_6 0x128
|
---|
87 | #define IOMMU_MMIO_OFF_DEV_TAB_SEG_7 0x130
|
---|
88 | #define IOMMU_MMIO_OFF_DEV_TAB_SEG_LAST 0x130
|
---|
89 |
|
---|
90 | #define IOMMU_MMIO_OFF_DEV_SPECIFIC_FEAT 0x138
|
---|
91 | #define IOMMU_MMIO_OFF_DEV_SPECIFIC_CTRL 0x140
|
---|
92 | #define IOMMU_MMIO_OFF_DEV_SPECIFIC_STATUS 0x148
|
---|
93 |
|
---|
94 | #define IOMMU_MMIO_OFF_MSI_VECTOR_0 0x150
|
---|
95 | #define IOMMU_MMIO_OFF_MSI_VECTOR_1 0x154
|
---|
96 | #define IOMMU_MMIO_OFF_MSI_CAP_HDR 0x158
|
---|
97 | #define IOMMU_MMIO_OFF_MSI_ADDR_LO 0x15c
|
---|
98 | #define IOMMU_MMIO_OFF_MSI_ADDR_HI 0x160
|
---|
99 | #define IOMMU_MMIO_OFF_MSI_DATA 0x164
|
---|
100 | #define IOMMU_MMIO_OFF_MSI_MAPPING_CAP_HDR 0x168
|
---|
101 |
|
---|
102 | #define IOMMU_MMIO_OFF_PERF_OPT_CTRL 0x16c
|
---|
103 |
|
---|
104 | #define IOMMU_MMIO_OFF_XT_GEN_INTR_CTRL 0x170
|
---|
105 | #define IOMMU_MMIO_OFF_XT_PPR_INTR_CTRL 0x178
|
---|
106 | #define IOMMU_MMIO_OFF_XT_GALOG_INT_CTRL 0x180
|
---|
107 |
|
---|
108 | #define IOMMU_MMIO_OFF_MARC_APER_BAR_0 0x200
|
---|
109 | #define IOMMU_MMIO_OFF_MARC_APER_RELOC_0 0x208
|
---|
110 | #define IOMMU_MMIO_OFF_MARC_APER_LEN_0 0x210
|
---|
111 | #define IOMMU_MMIO_OFF_MARC_APER_BAR_1 0x218
|
---|
112 | #define IOMMU_MMIO_OFF_MARC_APER_RELOC_1 0x220
|
---|
113 | #define IOMMU_MMIO_OFF_MARC_APER_LEN_1 0x228
|
---|
114 | #define IOMMU_MMIO_OFF_MARC_APER_BAR_2 0x230
|
---|
115 | #define IOMMU_MMIO_OFF_MARC_APER_RELOC_2 0x238
|
---|
116 | #define IOMMU_MMIO_OFF_MARC_APER_LEN_2 0x240
|
---|
117 | #define IOMMU_MMIO_OFF_MARC_APER_BAR_3 0x248
|
---|
118 | #define IOMMU_MMIO_OFF_MARC_APER_RELOC_3 0x250
|
---|
119 | #define IOMMU_MMIO_OFF_MARC_APER_LEN_3 0x258
|
---|
120 |
|
---|
121 | #define IOMMU_MMIO_OFF_RSVD_REG 0x1ff8
|
---|
122 |
|
---|
123 | #define IOMMU_MMIO_CMD_BUF_HEAD_PTR 0x2000
|
---|
124 | #define IOMMU_MMIO_CMD_BUF_TAIL_PTR 0x2008
|
---|
125 | #define IOMMU_MMIO_EVT_LOG_HEAD_PTR 0x2010
|
---|
126 | #define IOMMU_MMIO_EVT_LOG_TAIL_PTR 0x2018
|
---|
127 |
|
---|
128 | #define IOMMU_MMIO_OFF_STATUS 0x2020
|
---|
129 |
|
---|
130 | #define IOMMU_MMIO_OFF_PPR_LOG_HEAD_PTR 0x2030
|
---|
131 | #define IOMMU_MMIO_OFF_PPR_LOG_TAIL_PTR 0x2038
|
---|
132 |
|
---|
133 | #define IOMMU_MMIO_OFF_GALOG_HEAD_PTR 0x2040
|
---|
134 | #define IOMMU_MMIO_OFF_GALOG_TAIL_PTR 0x2048
|
---|
135 |
|
---|
136 | #define IOMMU_MMIO_OFF_PPR_LOG_B_HEAD_PTR 0x2050
|
---|
137 | #define IOMMU_MMIO_OFF_PPR_LOG_B_TAIL_PTR 0x2058
|
---|
138 |
|
---|
139 | #define IOMMU_MMIO_OFF_EVT_LOG_B_HEAD_PTR 0x2070
|
---|
140 | #define IOMMU_MMIO_OFF_EVT_LOG_B_TAIL_PTR 0x2078
|
---|
141 |
|
---|
142 | #define IOMMU_MMIO_OFF_PPR_LOG_AUTO_RESP 0x2080
|
---|
143 | #define IOMMU_MMIO_OFF_PPR_LOG_OVERFLOW_EARLY 0x2088
|
---|
144 | #define IOMMU_MMIO_OFF_PPR_LOG_B_OVERFLOW_EARLY 0x2090
|
---|
145 | /** @} */
|
---|
146 |
|
---|
147 | /**
|
---|
148 | * @name MMIO register-access table offsets.
|
---|
149 | * Each table [first..last] (both inclusive) represents the range of registers
|
---|
150 | * covered by a distinct register-access table. This is done due to arbitrary large
|
---|
151 | * gaps in the MMIO register offsets themselves.
|
---|
152 | * @{
|
---|
153 | */
|
---|
154 | #define IOMMU_MMIO_OFF_TABLE_0_FIRST 0x00
|
---|
155 | #define IOMMU_MMIO_OFF_TABLE_0_LAST 0x258
|
---|
156 |
|
---|
157 | #define IOMMU_MMIO_OFF_TABLE_1_FIRST 0x1ff8
|
---|
158 | #define IOMMU_MMIO_OFF_TABLE_1_LAST 0x2090
|
---|
159 | /** @} */
|
---|
160 |
|
---|
161 | /**
|
---|
162 | * @name Commands.
|
---|
163 | * In accordance with the AMD spec.
|
---|
164 | * @{
|
---|
165 | */
|
---|
166 | #define IOMMU_CMD_COMPLETION_WAIT 0x01
|
---|
167 | #define IOMMU_CMD_INV_DEV_TAB_ENTRY 0x02
|
---|
168 | #define IOMMU_CMD_INV_IOMMU_PAGES 0x03
|
---|
169 | #define IOMMU_CMD_INV_IOTLB_PAGES 0x04
|
---|
170 | #define IOMMU_CMD_INV_INTR_TABLE 0x05
|
---|
171 | #define IOMMU_CMD_PREFETCH_IOMMU_PAGES 0x06
|
---|
172 | #define IOMMU_CMD_COMPLETE_PPR_REQ 0x07
|
---|
173 | #define IOMMU_CMD_INV_IOMMU_ALL 0x08
|
---|
174 | /** @} */
|
---|
175 |
|
---|
176 | /**
|
---|
177 | * @name Event codes.
|
---|
178 | * In accordance with the AMD spec.
|
---|
179 | * @{
|
---|
180 | */
|
---|
181 | #define IOMMU_EVT_ILLEGAL_DEV_TAB_ENTRY 0x01
|
---|
182 | #define IOMMU_EVT_IO_PAGE_FAULT 0x02
|
---|
183 | #define IOMMU_EVT_DEV_TAB_HW_ERROR 0x03
|
---|
184 | #define IOMMU_EVT_PAGE_TAB_HW_ERROR 0x04
|
---|
185 | #define IOMMU_EVT_ILLEGAL_CMD_ERROR 0x05
|
---|
186 | #define IOMMU_EVT_COMMAND_HW_ERROR 0x06
|
---|
187 | #define IOMMU_EVT_IOTLB_INV_TIMEOUT 0x07
|
---|
188 | #define IOMMU_EVT_INVALID_DEV_REQ 0x08
|
---|
189 | #define IOMMU_EVT_INVALID_PPR_REQ 0x09
|
---|
190 | #define IOMMU_EVT_EVENT_COUNTER_ZERO 0x10
|
---|
191 | #define IOMMU_EVT_GUEST_EVENT_FAULT 0x11
|
---|
192 | /** @} */
|
---|
193 |
|
---|
194 | /**
|
---|
195 | * @name IOMMU Capability Header.
|
---|
196 | * In accordance with the AMD spec.
|
---|
197 | * @{
|
---|
198 | */
|
---|
199 | /** CapId: Capability ID. */
|
---|
200 | #define IOMMU_BF_CAPHDR_CAP_ID_SHIFT 0
|
---|
201 | #define IOMMU_BF_CAPHDR_CAP_ID_MASK UINT32_C(0x000000ff)
|
---|
202 | /** CapPtr: Capability Pointer. */
|
---|
203 | #define IOMMU_BF_CAPHDR_CAP_PTR_SHIFT 8
|
---|
204 | #define IOMMU_BF_CAPHDR_CAP_PTR_MASK UINT32_C(0x0000ff00)
|
---|
205 | /** CapType: Capability Type. */
|
---|
206 | #define IOMMU_BF_CAPHDR_CAP_TYPE_SHIFT 16
|
---|
207 | #define IOMMU_BF_CAPHDR_CAP_TYPE_MASK UINT32_C(0x00070000)
|
---|
208 | /** CapRev: Capability Revision. */
|
---|
209 | #define IOMMU_BF_CAPHDR_CAP_REV_SHIFT 19
|
---|
210 | #define IOMMU_BF_CAPHDR_CAP_REV_MASK UINT32_C(0x00f80000)
|
---|
211 | /** IoTlbSup: IO TLB Support. */
|
---|
212 | #define IOMMU_BF_CAPHDR_IOTLB_SUP_SHIFT 24
|
---|
213 | #define IOMMU_BF_CAPHDR_IOTLB_SUP_MASK UINT32_C(0x01000000)
|
---|
214 | /** HtTunnel: HyperTransport Tunnel translation support. */
|
---|
215 | #define IOMMU_BF_CAPHDR_HT_TUNNEL_SHIFT 25
|
---|
216 | #define IOMMU_BF_CAPHDR_HT_TUNNEL_MASK UINT32_C(0x02000000)
|
---|
217 | /** NpCache: Not Present table entries Cached. */
|
---|
218 | #define IOMMU_BF_CAPHDR_NP_CACHE_SHIFT 26
|
---|
219 | #define IOMMU_BF_CAPHDR_NP_CACHE_MASK UINT32_C(0x04000000)
|
---|
220 | /** EFRSup: Extended Feature Register (EFR) Supported. */
|
---|
221 | #define IOMMU_BF_CAPHDR_EFR_SUP_SHIFT 27
|
---|
222 | #define IOMMU_BF_CAPHDR_EFR_SUP_MASK UINT32_C(0x08000000)
|
---|
223 | /** CapExt: Miscellaneous Information Register Supported . */
|
---|
224 | #define IOMMU_BF_CAPHDR_CAP_EXT_SHIFT 28
|
---|
225 | #define IOMMU_BF_CAPHDR_CAP_EXT_MASK UINT32_C(0x10000000)
|
---|
226 | /** Bits 31:29 reserved. */
|
---|
227 | #define IOMMU_BF_CAPHDR_RSVD_29_31_SHIFT 29
|
---|
228 | #define IOMMU_BF_CAPHDR_RSVD_29_31_MASK UINT32_C(0xe0000000)
|
---|
229 | RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_BF_CAPHDR_, UINT32_C(0), UINT32_MAX,
|
---|
230 | (CAP_ID, CAP_PTR, CAP_TYPE, CAP_REV, IOTLB_SUP, HT_TUNNEL, NP_CACHE, EFR_SUP, CAP_EXT, RSVD_29_31));
|
---|
231 | /** @} */
|
---|
232 |
|
---|
233 | /**
|
---|
234 | * @name IOMMU Base Address Low Register.
|
---|
235 | * In accordance with the AMD spec.
|
---|
236 | * @{
|
---|
237 | */
|
---|
238 | /** Enable: Enables access to the address specified in the Base Address Register. */
|
---|
239 | #define IOMMU_BF_BASEADDR_LO_ENABLE_SHIFT 0
|
---|
240 | #define IOMMU_BF_BASEADDR_LO_ENABLE_MASK UINT32_C(0x00000001)
|
---|
241 | /** Bits 13:1 reserved. */
|
---|
242 | #define IOMMU_BF_BASEADDR_LO_RSVD_1_13_SHIFT 1
|
---|
243 | #define IOMMU_BF_BASEADDR_LO_RSVD_1_13_MASK UINT32_C(0x00003ffe)
|
---|
244 | /** Base Address[31:14]: Low Base address of IOMMU MMIO control registers. */
|
---|
245 | #define IOMMU_BF_BASEADDR_LO_ADDR_SHIFT 14
|
---|
246 | #define IOMMU_BF_BASEADDR_LO_ADDR_MASK UINT32_C(0xffffc000)
|
---|
247 | RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_BF_BASEADDR_LO_, UINT32_C(0), UINT32_MAX,
|
---|
248 | (ENABLE, RSVD_1_13, ADDR));
|
---|
249 | /** @} */
|
---|
250 |
|
---|
251 | /**
|
---|
252 | * @name IOMMU Range Register.
|
---|
253 | * In accordance with the AMD spec.
|
---|
254 | * @{
|
---|
255 | */
|
---|
256 | /** UnitID: HyperTransport Unit ID. */
|
---|
257 | #define IOMMU_BF_RANGE_UNIT_ID_SHIFT 0
|
---|
258 | #define IOMMU_BF_RANGE_UNIT_ID_MASK UINT32_C(0x0000001f)
|
---|
259 | /** Bits 6:5 reserved. */
|
---|
260 | #define IOMMU_BF_RANGE_RSVD_5_6_SHIFT 5
|
---|
261 | #define IOMMU_BF_RANGE_RSVD_5_6_MASK UINT32_C(0x00000060)
|
---|
262 | /** RngValid: Range valid. */
|
---|
263 | #define IOMMU_BF_RANGE_VALID_SHIFT 7
|
---|
264 | #define IOMMU_BF_RANGE_VALID_MASK UINT32_C(0x00000080)
|
---|
265 | /** BusNumber: Device range bus number. */
|
---|
266 | #define IOMMU_BF_RANGE_BUS_NUMBER_SHIFT 8
|
---|
267 | #define IOMMU_BF_RANGE_BUS_NUMBER_MASK UINT32_C(0x0000ff00)
|
---|
268 | /** First Device. */
|
---|
269 | #define IOMMU_BF_RANGE_FIRST_DEVICE_SHIFT 16
|
---|
270 | #define IOMMU_BF_RANGE_FIRST_DEVICE_MASK UINT32_C(0x00ff0000)
|
---|
271 | /** Last Device. */
|
---|
272 | #define IOMMU_BF_RANGE_LAST_DEVICE_SHIFT 24
|
---|
273 | #define IOMMU_BF_RANGE_LAST_DEVICE_MASK UINT32_C(0xff000000)
|
---|
274 | RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_BF_RANGE_, UINT32_C(0), UINT32_MAX,
|
---|
275 | (UNIT_ID, RSVD_5_6, VALID, BUS_NUMBER, FIRST_DEVICE, LAST_DEVICE));
|
---|
276 | /** @} */
|
---|
277 |
|
---|
278 | /**
|
---|
279 | * @name IOMMU Miscellaneous Information Register 0.
|
---|
280 | * In accordance with the AMD spec.
|
---|
281 | * @{
|
---|
282 | */
|
---|
283 | /** MsiNum: MSI message number. */
|
---|
284 | #define IOMMU_BF_MISCINFO_0_MSI_NUM_SHIFT 0
|
---|
285 | #define IOMMU_BF_MISCINFO_0_MSI_NUM_MASK UINT32_C(0x0000001f)
|
---|
286 | /** GvaSize: Guest Virtual Address Size. */
|
---|
287 | #define IOMMU_BF_MISCINFO_0_GVA_SIZE_SHIFT 5
|
---|
288 | #define IOMMU_BF_MISCINFO_0_GVA_SIZE_MASK UINT32_C(0x000000e0)
|
---|
289 | /** PaSize: Physical Address Size. */
|
---|
290 | #define IOMMU_BF_MISCINFO_0_PA_SIZE_SHIFT 8
|
---|
291 | #define IOMMU_BF_MISCINFO_0_PA_SIZE_MASK UINT32_C(0x00007f00)
|
---|
292 | /** VaSize: Virtual Address Size. */
|
---|
293 | #define IOMMU_BF_MISCINFO_0_VA_SIZE_SHIFT 15
|
---|
294 | #define IOMMU_BF_MISCINFO_0_VA_SIZE_MASK UINT32_C(0x003f8000)
|
---|
295 | /** HtAtsResv: HyperTransport ATS Response Address range Reserved. */
|
---|
296 | #define IOMMU_BF_MISCINFO_0_HT_ATS_RESV_SHIFT 22
|
---|
297 | #define IOMMU_BF_MISCINFO_0_HT_ATS_RESV_MASK UINT32_C(0x00400000)
|
---|
298 | /** Bits 26:23 reserved. */
|
---|
299 | #define IOMMU_BF_MISCINFO_0_RSVD_23_26_SHIFT 23
|
---|
300 | #define IOMMU_BF_MISCINFO_0_RSVD_23_26_MASK UINT32_C(0x07800000)
|
---|
301 | /** MsiNumPPR: Peripheral Page Request MSI message number. */
|
---|
302 | #define IOMMU_BF_MISCINFO_0_MSI_NUM_PPR_SHIFT 27
|
---|
303 | #define IOMMU_BF_MISCINFO_0_MSI_NUM_PPR_MASK UINT32_C(0xf8000000)
|
---|
304 | RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_BF_MISCINFO_0_, UINT32_C(0), UINT32_MAX,
|
---|
305 | (MSI_NUM, GVA_SIZE, PA_SIZE, VA_SIZE, HT_ATS_RESV, RSVD_23_26, MSI_NUM_PPR));
|
---|
306 | /** @} */
|
---|
307 |
|
---|
308 | /**
|
---|
309 | * @name IOMMU Miscellaneous Information Register 1.
|
---|
310 | * In accordance with the AMD spec.
|
---|
311 | * @{
|
---|
312 | */
|
---|
313 | /** MsiNumGA: MSI message number for guest virtual-APIC log. */
|
---|
314 | #define IOMMU_BF_MISCINFO_1_MSI_NUM_GA_SHIFT 0
|
---|
315 | #define IOMMU_BF_MISCINFO_1_MSI_NUM_GA_MASK UINT32_C(0x0000001f)
|
---|
316 | /** Bits 31:5 reserved. */
|
---|
317 | #define IOMMU_BF_MISCINFO_1_RSVD_5_31_SHIFT 5
|
---|
318 | #define IOMMU_BF_MISCINFO_1_RSVD_5_31_MASK UINT32_C(0xffffffe0)
|
---|
319 | RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_BF_MISCINFO_1_, UINT32_C(0), UINT32_MAX,
|
---|
320 | (MSI_NUM_GA, RSVD_5_31));
|
---|
321 | /** @} */
|
---|
322 |
|
---|
323 | /**
|
---|
324 | * @name MSI Capability Header Register.
|
---|
325 | * In accordance with the AMD spec.
|
---|
326 | * @{
|
---|
327 | */
|
---|
328 | /** MsiCapId: Capability ID. */
|
---|
329 | #define IOMMU_BF_MSI_CAP_HDR_CAP_ID_SHIFT 0
|
---|
330 | #define IOMMU_BF_MSI_CAP_HDR_CAP_ID_MASK UINT32_C(0x000000ff)
|
---|
331 | /** MsiCapPtr: Pointer (PCI config offset) to the next capability. */
|
---|
332 | #define IOMMU_BF_MSI_CAP_HDR_CAP_PTR_SHIFT 8
|
---|
333 | #define IOMMU_BF_MSI_CAP_HDR_CAP_PTR_MASK UINT32_C(0x0000ff00)
|
---|
334 | /** MsiEn: Message Signal Interrupt enable. */
|
---|
335 | #define IOMMU_BF_MSI_CAP_HDR_EN_SHIFT 16
|
---|
336 | #define IOMMU_BF_MSI_CAP_HDR_EN_MASK UINT32_C(0x00010000)
|
---|
337 | /** MsiMultMessCap: MSI Multi-Message Capability. */
|
---|
338 | #define IOMMU_BF_MSI_CAP_HDR_MULTMESS_CAP_SHIFT 17
|
---|
339 | #define IOMMU_BF_MSI_CAP_HDR_MULTMESS_CAP_MASK UINT32_C(0x000e0000)
|
---|
340 | /** MsiMultMessEn: MSI Mult-Message Enable. */
|
---|
341 | #define IOMMU_BF_MSI_CAP_HDR_MULTMESS_EN_SHIFT 20
|
---|
342 | #define IOMMU_BF_MSI_CAP_HDR_MULTMESS_EN_MASK UINT32_C(0x00700000)
|
---|
343 | /** Msi64BitEn: MSI 64-bit Enabled. */
|
---|
344 | #define IOMMU_BF_MSI_CAP_HDR_64BIT_EN_SHIFT 23
|
---|
345 | #define IOMMU_BF_MSI_CAP_HDR_64BIT_EN_MASK UINT32_C(0x00800000)
|
---|
346 | /** Bits 31:24 reserved. */
|
---|
347 | #define IOMMU_BF_MSI_CAP_HDR_RSVD_24_31_SHIFT 24
|
---|
348 | #define IOMMU_BF_MSI_CAP_HDR_RSVD_24_31_MASK UINT32_C(0xff000000)
|
---|
349 | RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_BF_MSI_CAP_HDR_, UINT32_C(0), UINT32_MAX,
|
---|
350 | (CAP_ID, CAP_PTR, EN, MULTMESS_CAP, MULTMESS_EN, 64BIT_EN, RSVD_24_31));
|
---|
351 | /** @} */
|
---|
352 |
|
---|
353 | /**
|
---|
354 | * @name MSI Mapping Capability Header Register.
|
---|
355 | * In accordance with the AMD spec.
|
---|
356 | * @{
|
---|
357 | */
|
---|
358 | /** MsiMapCapId: Capability ID. */
|
---|
359 | #define IOMMU_BF_MSI_MAP_CAPHDR_CAP_ID_SHIFT 0
|
---|
360 | #define IOMMU_BF_MSI_MAP_CAPHDR_CAP_ID_MASK UINT32_C(0x000000ff)
|
---|
361 | /** MsiMapCapPtr: Pointer (PCI config offset) to the next capability. */
|
---|
362 | #define IOMMU_BF_MSI_MAP_CAPHDR_CAP_PTR_SHIFT 8
|
---|
363 | #define IOMMU_BF_MSI_MAP_CAPHDR_CAP_PTR_MASK UINT32_C(0x0000ff00)
|
---|
364 | /** MsiMapEn: MSI mapping capability enable. */
|
---|
365 | #define IOMMU_BF_MSI_MAP_CAPHDR_EN_SHIFT 16
|
---|
366 | #define IOMMU_BF_MSI_MAP_CAPHDR_EN_MASK UINT32_C(0x00010000)
|
---|
367 | /** MsiMapFixd: MSI interrupt mapping range is not programmable. */
|
---|
368 | #define IOMMU_BF_MSI_MAP_CAPHDR_FIXED_SHIFT 17
|
---|
369 | #define IOMMU_BF_MSI_MAP_CAPHDR_FIXED_MASK UINT32_C(0x00020000)
|
---|
370 | /** Bits 18:28 reserved. */
|
---|
371 | #define IOMMU_BF_MSI_MAP_CAPHDR_RSVD_18_28_SHIFT 18
|
---|
372 | #define IOMMU_BF_MSI_MAP_CAPHDR_RSVD_18_28_MASK UINT32_C(0x07fc0000)
|
---|
373 | /** MsiMapCapType: MSI mapping capability. */
|
---|
374 | #define IOMMU_BF_MSI_MAP_CAPHDR_CAP_TYPE_SHIFT 27
|
---|
375 | #define IOMMU_BF_MSI_MAP_CAPHDR_CAP_TYPE_MASK UINT32_C(0xf8000000)
|
---|
376 | RT_BF_ASSERT_COMPILE_CHECKS(IOMMU_BF_MSI_MAP_CAPHDR_, UINT32_C(0), UINT32_MAX,
|
---|
377 | (CAP_ID, CAP_PTR, EN, FIXED, RSVD_18_28, CAP_TYPE));
|
---|
378 | /** @} */
|
---|
379 |
|
---|
380 | /**
|
---|
381 | * @name IOMMU Status Register Bits.
|
---|
382 | * In accordance with the AMD spec.
|
---|
383 | * @{
|
---|
384 | */
|
---|
385 | /** EventOverflow: Event log overflow. */
|
---|
386 | #define IOMMU_STATUS_EVT_LOG_OVERFLOW RT_BIT_64(0)
|
---|
387 | /** EventLogInt: Event log interrupt. */
|
---|
388 | #define IOMMU_STATUS_EVT_LOG_INTR RT_BIT_64(1)
|
---|
389 | /** ComWaitInt: Completion wait interrupt. */
|
---|
390 | #define IOMMU_STATUS_COMPLETION_WAIT_INTR RT_BIT_64(2)
|
---|
391 | /** EventLogRun: Event log is running. */
|
---|
392 | #define IOMMU_STATUS_EVT_LOG_RUNNING RT_BIT_64(3)
|
---|
393 | /** CmdBufRun: Command buffer is running. */
|
---|
394 | #define IOMMU_STATUS_CMD_BUF_RUNNING RT_BIT_64(4)
|
---|
395 | /** PprOverflow: Peripheral page request log overflow. */
|
---|
396 | #define IOMMU_STATUS_PPR_LOG_OVERFLOW RT_BIT_64(5)
|
---|
397 | /** PprInt: Peripheral page request log interrupt. */
|
---|
398 | #define IOMMU_STATUS_PPR_LOG_INTR RT_BIT_64(6)
|
---|
399 | /** PprLogRun: Peripheral page request log is running. */
|
---|
400 | #define IOMMU_STATUS_PPR_LOG_RUN RT_BIT_64(7)
|
---|
401 | /** GALogRun: Guest virtual-APIC log is running. */
|
---|
402 | #define IOMMU_STATUS_GA_LOG_RUN RT_BIT_64(8)
|
---|
403 | /** GALOverflow: Guest virtual-APIC log overflow. */
|
---|
404 | #define IOMMU_STATUS_GA_LOG_OVERFLOW RT_BIT_64(9)
|
---|
405 | /** GAInt: Guest virtual-APIC log interrupt. */
|
---|
406 | #define IOMMU_STATUS_GA_LOG_INTR RT_BIT_64(10)
|
---|
407 | /** PprOvrflwB: PPR Log B overflow. */
|
---|
408 | #define IOMMU_STATUS_PPR_LOG_B_OVERFLOW RT_BIT_64(11)
|
---|
409 | /** PprLogActive: PPR Log B is active. */
|
---|
410 | #define IOMMU_STATUS_PPR_LOG_B_ACTIVE RT_BIT_64(12)
|
---|
411 | /** EvtOvrflwB: Event log B overflow. */
|
---|
412 | #define IOMMU_STATUS_EVT_LOG_B_OVERFLOW RT_BIT_64(15)
|
---|
413 | /** EventLogActive: Event log B active. */
|
---|
414 | #define IOMMU_STATUS_EVT_LOG_B_ACTIVE RT_BIT_64(16)
|
---|
415 | /** PprOvrflwEarlyB: PPR log B overflow early warning. */
|
---|
416 | #define IOMMU_STATUS_PPR_LOG_B_OVERFLOW_EARLY RT_BIT_64(17)
|
---|
417 | /** PprOverflowEarly: PPR log overflow early warning. */
|
---|
418 | #define IOMMU_STATUS_PPR_LOG_OVERFLOW_EARLY RT_BIT_64(18)
|
---|
419 | /** @} */
|
---|
420 |
|
---|
421 | /**
|
---|
422 | * @name IOMMU Control Register Bits.
|
---|
423 | * In accordance with the AMD spec.
|
---|
424 | * @{
|
---|
425 | */
|
---|
426 | /** IommuEn: Enable the IOMMU. */
|
---|
427 | #define IOMMU_CTRL_IOMMU_EN RT_BIT_64(0)
|
---|
428 | /** HtTunEn: HyperTransport tunnel translation enable. */
|
---|
429 | #define IOMMU_CTRL_HT_TUNNEL_EN RT_BIT_64(1)
|
---|
430 | /** EventLogEn: Event log enable. */
|
---|
431 | #define IOMMU_CTRL_EVT_LOG_EN RT_BIT_64(2)
|
---|
432 | /** EventIntEn: Event interrupt enable. */
|
---|
433 | #define IOMMU_CTRL_EVT_INTR_EN RT_BIT_64(3)
|
---|
434 | /** ComWaitIntEn: Completion wait interrupt enable. */
|
---|
435 | #define IOMMU_CTRL_COMPLETION_WAIT_INTR_EN RT_BIT_64(4)
|
---|
436 | /** InvTimeout: Invalidation timeout. */
|
---|
437 | #define IOMMU_CTRL_INV_TIMEOUT RT_BIT_64(5) | RT_BIT_64(6) | RT_BIT_64(7)
|
---|
438 | /** @todo IOMMU: the rest or remove it. */
|
---|
439 | /** @} */
|
---|
440 |
|
---|
441 | /** @name Miscellaneous IOMMU defines.
|
---|
442 | * @{ */
|
---|
443 | /** Log prefix string. */
|
---|
444 | #define IOMMU_LOG_PFX "AMD_IOMMU"
|
---|
445 | /** The current saved state version. */
|
---|
446 | #define IOMMU_SAVED_STATE_VERSION 1
|
---|
447 | /** AMD's vendor ID. */
|
---|
448 | #define IOMMU_PCI_VENDOR_ID 0x1022
|
---|
449 | /** VirtualBox IOMMU device ID. */
|
---|
450 | #define IOMMU_PCI_DEVICE_ID 0xc0de
|
---|
451 | /** VirtualBox IOMMU device revision ID. */
|
---|
452 | #define IOMMU_PCI_REVISION_ID 0x01
|
---|
453 | /** Size of the MMIO region in bytes. */
|
---|
454 | #define IOMMU_MMIO_REGION_SIZE _16K
|
---|
455 | /** Number of device table segments supported (power of 2). */
|
---|
456 | #define IOMMU_MAX_DEV_TAB_SEGMENTS 3
|
---|
457 | /** Maximum number of host address translation levels supported. */
|
---|
458 | #define IOMMU_MAX_HOST_PT_LEVEL 6
|
---|
459 | /** @} */
|
---|
460 |
|
---|
461 | /**
|
---|
462 | * Acquires the IOMMU PDM lock or returns @a a_rcBusy if it's busy.
|
---|
463 | */
|
---|
464 | #define IOMMU_LOCK_RET(a_pDevIns, a_pThis, a_rcBusy) \
|
---|
465 | do { \
|
---|
466 | NOREF(pThis); \
|
---|
467 | int rcLock = PDMDevHlpCritSectEnter((a_pDevIns), (a_pDevIns)->CTX_SUFF(pCritSectRo), (a_rcBusy)); \
|
---|
468 | if (RT_LIKELY(rcLock == VINF_SUCCESS)) \
|
---|
469 | { /* likely */ } \
|
---|
470 | else \
|
---|
471 | return rcLock; \
|
---|
472 | } while (0)
|
---|
473 |
|
---|
474 | /**
|
---|
475 | * Releases the IOMMU PDM lock.
|
---|
476 | */
|
---|
477 | #define IOMMU_UNLOCK(a_pDevIns, a_pThis) \
|
---|
478 | do { \
|
---|
479 | PDMDevHlpCritSectLeave((a_pDevIns), (a_pDevIns)->CTX_SUFF(pCritSectRo)); \
|
---|
480 | } while (0)
|
---|
481 |
|
---|
482 | /**
|
---|
483 | * Asserts that the critsect is owned by this thread.
|
---|
484 | */
|
---|
485 | #define IOMMU_ASSERT_LOCKED(a_pDevIns) \
|
---|
486 | do { \
|
---|
487 | Assert(PDMDevHlpCritSectIsOwner(pDevIns, pDevIns->CTX_SUFF(pCritSectRo))); \
|
---|
488 | } while (0)
|
---|
489 |
|
---|
490 | /**
|
---|
491 | * Gets the device table size given the size field.
|
---|
492 | */
|
---|
493 | #define IOMMU_GET_DEV_TAB_SIZE(a_uSize) (((a_uSize) + 1) << X86_PAGE_4K_SHIFT)
|
---|
494 |
|
---|
495 |
|
---|
496 | /*********************************************************************************************************************************
|
---|
497 | * Structures and Typedefs *
|
---|
498 | *********************************************************************************************************************************/
|
---|
499 | /**
|
---|
500 | * The Device ID.
|
---|
501 | * In accordance with VirtualBox's PCI configuration.
|
---|
502 | */
|
---|
503 | typedef union
|
---|
504 | {
|
---|
505 | struct
|
---|
506 | {
|
---|
507 | uint16_t u3Function : 3; /**< Bits 2:0 - Function. */
|
---|
508 | uint16_t u9Device : 9; /**< Bits 11:3 - Device. */
|
---|
509 | uint16_t u4Bus : 4; /**< Bits 15:12 - Bus. */
|
---|
510 | } n;
|
---|
511 | /** The unsigned integer view. */
|
---|
512 | uint16_t u;
|
---|
513 | } DEVICE_ID_T;
|
---|
514 | AssertCompileSize(DEVICE_ID_T, 2);
|
---|
515 |
|
---|
516 | /**
|
---|
517 | * Device Table Entry (DTE).
|
---|
518 | * In accordance with the AMD spec.
|
---|
519 | */
|
---|
520 | typedef union
|
---|
521 | {
|
---|
522 | struct
|
---|
523 | {
|
---|
524 | uint32_t u1Valid : 1; /**< Bit 0 - V: Valid. */
|
---|
525 | uint32_t u1TranslationValid : 1; /**< Bit 1 - TV: Translation information Valid. */
|
---|
526 | uint32_t u5Rsvd0 : 5; /**< Bits 6:2 - Reserved. */
|
---|
527 | uint32_t u2Had : 2; /**< Bits 8:7 - HAD: Host Access Dirty. */
|
---|
528 | uint32_t u3Mode : 3; /**< Bits 11:9 - Mode: Paging mode. */
|
---|
529 | uint32_t u20PageTableRootPtrLo : 20; /**< Bits 31:12 - Page Table Root Pointer (Lo). */
|
---|
530 | uint32_t u20PageTableRootPtrHi : 20; /**< Bits 51:32 - Page Table Root Pointer (Hi). */
|
---|
531 | uint32_t u1Ppr : 1; /**< Bit 52 - PPR: Peripheral Page Request. */
|
---|
532 | uint32_t u1GstPprRespPasid : 1; /**< Bit 53 - GRPR: Guest PPR Response with PASID. */
|
---|
533 | uint32_t u1GstIoValid : 1; /**< Bit 54 - GIoV: Guest I/O Protection Valid. */
|
---|
534 | uint32_t u1GstTranslateValid : 1; /**< Bit 55 - GV: Guest translation Valid. */
|
---|
535 | uint32_t u2GstCr3RootTblTranslated : 2; /**< Bits 57:56 - GLX: Guest Levels Translated. */
|
---|
536 | uint32_t u3GstCr3TableRootPtrLo : 2; /**< Bits 60:58 - GCR3 TRP: Guest CR3 Table Root Pointer (Lo). */
|
---|
537 | uint32_t u1IoRead : 1; /**< Bit 61 - IR: I/O Read permission. */
|
---|
538 | uint32_t u1IoWrite : 1; /**< Bit 62 - IW: I/O Write permission. */
|
---|
539 | uint32_t u1Rsvd0 : 1; /**< Bit 63 - Reserved. */
|
---|
540 | uint32_t u16DomainId : 1; /**< Bits 79:64 - Domain ID. */
|
---|
541 | uint32_t u16GstCr3TableRootPtrMed : 16; /**< Bits 95:80 - GCR3 TRP: Guest CR3 Table Root Pointer (Mid). */
|
---|
542 | uint32_t u1IoTlbEnable : 1; /**< Bit 96 - IOTLB Enable. */
|
---|
543 | uint32_t u1SuppressPfEvents : 1; /**< Bit 97 - SE: Supress Page-fault events. */
|
---|
544 | uint32_t u1SuppressAllPfEvents : 1; /**< Bit 98 - SA: Supress All Page-fault events. */
|
---|
545 | uint32_t u2IoCtl : 1; /**< Bits 100:99 - IoCtl: Port I/O Control. */
|
---|
546 | uint32_t u1Cache : 1; /**< Bit 101 - Cache: IOTLB Cache Hint. */
|
---|
547 | uint32_t u1SnoopDisable : 1; /**< Bit 102 - SD: Snoop Disable. */
|
---|
548 | uint32_t u1AllowExclusion : 1; /**< Bit 103 - EX: Allow Exclusion. */
|
---|
549 | uint32_t u2SysMgt : 2; /**< Bits 105:104 - SysMgt: System Management message enable. */
|
---|
550 | uint32_t u1Rsvd1 : 1; /**< Bit 106 - Reserved. */
|
---|
551 | uint32_t u21GstCr3TableRootPtrHi : 21; /**< Bits 127:107 - GCR3 TRP: Guest CR3 Table Root Pointer (Hi). */
|
---|
552 | uint32_t u1IntrMapValid : 1; /**< Bit 128 - IV: Interrupt map Valid. */
|
---|
553 | uint32_t u4IntrTableLength : 4; /**< Bits 132:129 - IntTabLen: Interrupt Table Length. */
|
---|
554 | uint32_t u1IgnoreUnmappedIntrs : 1; /**< Bits 133 - IG: Ignore unmapped interrupts. */
|
---|
555 | uint32_t u26IntrTableRootPtr : 26; /**< Bits 159:134 - Interrupt Root Table Pointer (Lo). */
|
---|
556 | uint32_t u20IntrTableRootPtr : 20; /**< Bits 179:160 - Interrupt Root Table Pointer (Hi). */
|
---|
557 | uint32_t u4Rsvd0 : 4; /**< Bits 183:180 - Reserved. */
|
---|
558 | uint32_t u1InitPassthru : 1; /**< Bits 184 - INIT Pass-through. */
|
---|
559 | uint32_t u1ExtIntPassthru : 1; /**< Bits 185 - External Interrupt Pass-through. */
|
---|
560 | uint32_t u1NmiPassthru : 1; /**< Bits 186 - NMI Pass-through. */
|
---|
561 | uint32_t u1Rsvd2 : 1; /**< Bits 187 - Reserved. */
|
---|
562 | uint32_t u2IntrCtrl : 2; /**< Bits 189:188 - IntCtl: Interrupt Control. */
|
---|
563 | uint32_t u1Lint0Passthru : 1; /**< Bit 190 - Lint0Pass: LINT0 (Legacy PIC NMI) Pass-thru. */
|
---|
564 | uint32_t u1Lint1Passthru : 1; /**< Bit 191 - Lint1Pass: LINT1 (Legacy PIC NMI) Pass-thru. */
|
---|
565 | uint32_t u32Rsvd0; /**< Bits 223:192 - Reserved. */
|
---|
566 | uint32_t u22Rsvd0 : 22; /**< Bits 245:224 - Reserved. */
|
---|
567 | uint32_t u1AttrOverride : 1; /**< Bit 246 - AttrV: Attribute Override. */
|
---|
568 | uint32_t u1Mode0FC: 1; /**< Bit 247 - Mode0FC. */
|
---|
569 | uint32_t u8SnoopAttr: 1; /**< Bits 255:248 - Snoop Attribute. */
|
---|
570 | } n;
|
---|
571 | /** The 32-bit unsigned integer view. */
|
---|
572 | uint32_t au32[8];
|
---|
573 | /** The 64-bit unsigned integer view. */
|
---|
574 | uint64_t au64[4];
|
---|
575 | } DEV_TAB_ENTRY_T;
|
---|
576 | AssertCompileSize(DEV_TAB_ENTRY_T, 32);
|
---|
577 | #define IOMMU_DEV_TAB_ENTRY_QWORD_0_VALID_MASK UINT64_C(0x7fffffffffffff83)
|
---|
578 | #define IOMMU_DEV_TAB_ENTRY_QWORD_1_VALID_MASK UINT64_C(0xfffffbffffffffff)
|
---|
579 | #define IOMMU_DEV_TAB_ENTRY_QWORD_2_VALID_MASK UINT64_C(0xf70fffffffffffff)
|
---|
580 | #define IOMMU_DEV_TAB_ENTRY_QWORD_3_VALID_MASK UINT64_C(0xffc0000000000000)
|
---|
581 | /** Pointer to a device table entry. */
|
---|
582 | typedef DEV_TAB_ENTRY_T *PDEV_TAB_ENTRY_T;
|
---|
583 | /** Pointer to a const device table entry. */
|
---|
584 | typedef DEV_TAB_ENTRY_T const *PCDEV_TAB_ENTRY_T;
|
---|
585 |
|
---|
586 | /**
|
---|
587 | * I/O Page Table Entry.
|
---|
588 | * In accordance with the AMD spec.
|
---|
589 | */
|
---|
590 | typedef union
|
---|
591 | {
|
---|
592 | struct
|
---|
593 | {
|
---|
594 | RT_GCC_EXTENSION uint64_t u1Present : 1; /**< Bit 0 - PR: Present. */
|
---|
595 | RT_GCC_EXTENSION uint64_t u4Ign0 : 4; /**< Bits 4:1 - Ignored. */
|
---|
596 | RT_GCC_EXTENSION uint64_t u1Accessed : 1; /**< Bit 5 - A: Accessed. */
|
---|
597 | RT_GCC_EXTENSION uint64_t u1Dirty : 1; /**< Bit 6 - D: Dirty. */
|
---|
598 | RT_GCC_EXTENSION uint64_t u2Ign0 : 2; /**< Bits 8:7 - Ignored. */
|
---|
599 | RT_GCC_EXTENSION uint64_t u3NextLevel : 3; /**< Bits 11:9 - Next Level: Next page translation level. */
|
---|
600 | RT_GCC_EXTENSION uint64_t u40PageAddr : 40; /**< Bits 51:12 - Page address. */
|
---|
601 | RT_GCC_EXTENSION uint64_t u7Rsvd0 : 7; /**< Bits 58:52 - Reserved. */
|
---|
602 | RT_GCC_EXTENSION uint64_t u1UntranslatedAccess : 1; /**< Bit 59 - U: Untranslated Access Only. */
|
---|
603 | RT_GCC_EXTENSION uint64_t u1ForceCoherent : 1; /**< Bit 60 - FC: Force Coherent. */
|
---|
604 | RT_GCC_EXTENSION uint64_t u1IoRead : 1; /**< Bit 61 - IR: I/O Read permission. */
|
---|
605 | RT_GCC_EXTENSION uint64_t u1IoWrite : 1; /**< Bit 62 - IW: I/O Wead permission. */
|
---|
606 | RT_GCC_EXTENSION uint64_t u1Ign0 : 1; /**< Bit 63 - Ignored. */
|
---|
607 | } n;
|
---|
608 | /** The 64-bit unsigned integer view. */
|
---|
609 | uint64_t u;
|
---|
610 | } IOPTE_T;
|
---|
611 | AssertCompileSize(IOPTE_T, 8);
|
---|
612 |
|
---|
613 | /**
|
---|
614 | * I/O Page Directory Entry.
|
---|
615 | * In accordance with the AMD spec.
|
---|
616 | */
|
---|
617 | typedef union
|
---|
618 | {
|
---|
619 | struct
|
---|
620 | {
|
---|
621 | RT_GCC_EXTENSION uint64_t u1Present : 1; /**< Bit 0 - PR: Present. */
|
---|
622 | RT_GCC_EXTENSION uint64_t u4Ign0 : 4; /**< Bits 4:1 - Ignored. */
|
---|
623 | RT_GCC_EXTENSION uint64_t u1Accessed : 1; /**< Bit 5 - A: Accessed. */
|
---|
624 | RT_GCC_EXTENSION uint64_t u3Ign0 : 3; /**< Bits 8:6 - Ignored. */
|
---|
625 | RT_GCC_EXTENSION uint64_t u3NextLevel : 3; /**< Bits 11:9 - Next Level: Next page translation level. */
|
---|
626 | RT_GCC_EXTENSION uint64_t u40PageAddr : 40; /**< Bits 51:12 - Page address (Next Table Address). */
|
---|
627 | RT_GCC_EXTENSION uint64_t u9Rsvd0 : 9; /**< Bits 60:52 - Reserved. */
|
---|
628 | RT_GCC_EXTENSION uint64_t u1IoRead : 1; /**< Bit 61 - IR: I/O Read permission. */
|
---|
629 | RT_GCC_EXTENSION uint64_t u1IoWrite : 1; /**< Bit 62 - IW: I/O Wead permission. */
|
---|
630 | RT_GCC_EXTENSION uint64_t u1Ign0 : 1; /**< Bit 63 - Ignored. */
|
---|
631 | } n;
|
---|
632 | /** The 64-bit unsigned integer view. */
|
---|
633 | uint64_t u;
|
---|
634 | } IOPDE_T;
|
---|
635 | AssertCompileSize(IOPDE_T, 8);
|
---|
636 |
|
---|
637 | /**
|
---|
638 | * Interrupt Remapping Table Entry.
|
---|
639 | * In accordance with the AMD spec.
|
---|
640 | */
|
---|
641 | typedef union
|
---|
642 | {
|
---|
643 | struct
|
---|
644 | {
|
---|
645 | uint32_t u1RemapEnable : 1; /**< Bit 0 - RemapEn: Remap Enable. */
|
---|
646 | uint32_t u1SuppressPf : 1; /**< Bit 1 - SupIOPF: Supress I/O Page Fault. */
|
---|
647 | uint32_t u3IntrType : 1; /**< Bits 4:2 - IntType: Interrupt Type. */
|
---|
648 | uint32_t u1ReqEoi : 1; /**< Bit 5 - RqEoi: Request EOI. */
|
---|
649 | uint32_t u1DstMode : 1; /**< Bit 6 - DM: Destination Mode. */
|
---|
650 | uint32_t u1GuestMode : 1; /**< Bit 7 - GuestMode. */
|
---|
651 | uint32_t u8Dst : 8; /**< Bits 15:8 - Destination. */
|
---|
652 | uint32_t u8Vector : 8; /**< Bits 23:16 - Vector. */
|
---|
653 | uint32_t u8Rsvd0 : 8; /**< Bits 31:24 - Reserved. */
|
---|
654 | } n;
|
---|
655 | /** The 32-bit unsigned integer view. */
|
---|
656 | uint32_t u;
|
---|
657 | } IRTE_T;
|
---|
658 | AssertCompileSize(IRTE_T, 4);
|
---|
659 |
|
---|
660 | /**
|
---|
661 | * Command: Generic Command Buffer Entry.
|
---|
662 | * In accordance with the AMD spec.
|
---|
663 | */
|
---|
664 | typedef union
|
---|
665 | {
|
---|
666 | struct
|
---|
667 | {
|
---|
668 | uint32_t u32Operand1Lo; /**< Bits 31:0 - Operand 1 (Lo). */
|
---|
669 | uint32_t u32Operand1Hi : 28; /**< Bits 59:32 - Operand 1 (Hi). */
|
---|
670 | uint32_t u4Opcode : 4; /**< Bits 63:60 - Op Code. */
|
---|
671 | uint64_t u64Operand2; /**< Bits 127:64 - Operand 2. */
|
---|
672 | } n;
|
---|
673 | /** The 64-bit unsigned integer view. */
|
---|
674 | uint64_t au64[2];
|
---|
675 | } CMD_GENERIC_T;
|
---|
676 | AssertCompileSize(CMD_GENERIC_T, 16);
|
---|
677 | /** Number of bits to shift the byte offset of a command in the command buffer to
|
---|
678 | * get its index. */
|
---|
679 | #define IOMMU_CMD_GENERIC_SHIFT 4
|
---|
680 |
|
---|
681 | /**
|
---|
682 | * Command: COMPLETION_WAIT.
|
---|
683 | * In accordance with the AMD spec.
|
---|
684 | */
|
---|
685 | typedef union
|
---|
686 | {
|
---|
687 | struct
|
---|
688 | {
|
---|
689 | uint32_t u1Store : 1; /**< Bit 0 - S: Completion Store. */
|
---|
690 | uint32_t u1Interrupt : 1; /**< Bit 1 - I: Completion Interrupt. */
|
---|
691 | uint32_t u1Flush : 1; /**< Bit 2 - F: Flush Queue. */
|
---|
692 | uint32_t u29StoreAddrLo : 29; /**< Bits 31:3 - Store Address (Lo). */
|
---|
693 | uint32_t u20StoreAddrHi : 20; /**< Bits 51:32 - Store Address (Hi). */
|
---|
694 | uint32_t u8Rsvd0 : 8; /**< Bits 59:52 - Reserved. */
|
---|
695 | uint32_t u4OpCode : 4; /**< Bits 63:60 - OpCode (Command). */
|
---|
696 | uint64_t u64StoreData; /**< Bits 127:64 - Store Data. */
|
---|
697 | } n;
|
---|
698 | /** The 64-bit unsigned integer view. */
|
---|
699 | uint32_t au64[2];
|
---|
700 | } CMD_COMPLETION_WAIT_T;
|
---|
701 | AssertCompileSize(CMD_COMPLETION_WAIT_T, 16);
|
---|
702 |
|
---|
703 | /**
|
---|
704 | * Command: INVALIDATE_DEVTAB_ENTRY.
|
---|
705 | * In accordance with the AMD spec.
|
---|
706 | */
|
---|
707 | typedef union
|
---|
708 | {
|
---|
709 | struct
|
---|
710 | {
|
---|
711 | uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
|
---|
712 | uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved. */
|
---|
713 | uint32_t u28Rsvd0 : 28; /**< Bits 59:32 - Reserved. */
|
---|
714 | uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
|
---|
715 | uint64_t u64Rsvd0; /**< Bits 127:64 - Reserved. */
|
---|
716 | } n;
|
---|
717 | /** The 64-bit unsigned integer view. */
|
---|
718 | uint64_t au64[2];
|
---|
719 | } CMD_INV_DEV_TAB_ENTRY_T;
|
---|
720 | AssertCompileSize(CMD_INV_DEV_TAB_ENTRY_T, 16);
|
---|
721 |
|
---|
722 | /**
|
---|
723 | * Command: INVALIDATE_IOMMU_PAGES.
|
---|
724 | * In accordance with the AMD spec.
|
---|
725 | */
|
---|
726 | typedef union
|
---|
727 | {
|
---|
728 | struct
|
---|
729 | {
|
---|
730 | uint32_t u20Pasid : 20; /**< Bits 19:0 - PASID: Process Address-Space ID. */
|
---|
731 | uint32_t u12Rsvd0 : 12; /**< Bits 31:20 - Reserved. */
|
---|
732 | uint32_t u16DomainId : 16; /**< Bits 47:32 - Domain ID. */
|
---|
733 | uint32_t u12Rsvd1 : 12; /**< Bits 59:48 - Reserved. */
|
---|
734 | uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
|
---|
735 | uint32_t u1Size : 1; /**< Bit 64 - S: Size. */
|
---|
736 | uint32_t u1PageDirEntries : 1; /**< Bit 65 - PDE: Page Directory Entries. */
|
---|
737 | uint32_t u1GuestOrNested : 1; /**< Bit 66 - GN: Guest (GPA) or Nested (GVA). */
|
---|
738 | uint32_t u9Rsvd0 : 9; /**< Bits 75:67 - Reserved. */
|
---|
739 | uint32_t u20AddrLo : 20; /**< Bits 95:76 - Address (Lo). */
|
---|
740 | uint32_t u32AddrHi; /**< Bits 127:96 - Address (Hi). */
|
---|
741 | } n;
|
---|
742 | /** The 64-bit unsigned integer view. */
|
---|
743 | uint64_t au64[2];
|
---|
744 | } CMD_INV_IOMMU_PAGES_T;
|
---|
745 | AssertCompileSize(CMD_INV_IOMMU_PAGES_T, 16);
|
---|
746 |
|
---|
747 | /**
|
---|
748 | * Command: INVALIDATE_IOTLB_PAGES.
|
---|
749 | * In accordance with the AMD spec.
|
---|
750 | */
|
---|
751 | typedef union
|
---|
752 | {
|
---|
753 | struct
|
---|
754 | {
|
---|
755 | uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
|
---|
756 | uint8_t u8PasidLo; /**< Bits 23:16 - PASID: Process Address-Space ID (Lo). */
|
---|
757 | uint8_t u8MaxPend; /**< Bits 31:24 - Maxpend: Maximum simultaneous in-flight transactions. */
|
---|
758 | uint32_t u16QueueId : 16; /**< Bits 47:32 - Queue ID. */
|
---|
759 | uint32_t u12PasidHi : 12; /**< Bits 59:48 - PASID: Process Address-Space ID (Hi). */
|
---|
760 | uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
|
---|
761 | uint32_t u1Size : 1; /**< Bit 64 - S: Size. */
|
---|
762 | uint32_t u1Rsvd0: 1; /**< Bit 65 - Reserved. */
|
---|
763 | uint32_t u1GuestOrNested : 1; /**< Bit 66 - GN: Guest (GPA) or Nested (GVA). */
|
---|
764 | uint32_t u1Rsvd1 : 1; /**< Bit 67 - Reserved. */
|
---|
765 | uint32_t u2Type : 2; /**< Bit 69:68 - Type. */
|
---|
766 | uint32_t u6Rsvd0 : 6; /**< Bits 75:70 - Reserved. */
|
---|
767 | uint32_t u20AddrLo : 20; /**< Bits 95:76 - Address (Lo). */
|
---|
768 | uint32_t u32AddrHi; /**< Bits 127:96 - Address (Hi). */
|
---|
769 | } n;
|
---|
770 | /** The 64-bit unsigned integer view. */
|
---|
771 | uint64_t au64[2];
|
---|
772 | } CMD_INV_IOTLB_PAGES_T;
|
---|
773 | AssertCompileSize(CMD_INV_IOTLB_PAGES_T, 16);
|
---|
774 |
|
---|
775 | /**
|
---|
776 | * Command: INVALIDATE_INTR_TABLE.
|
---|
777 | * In accordance with the AMD spec.
|
---|
778 | */
|
---|
779 | typedef union
|
---|
780 | {
|
---|
781 | struct
|
---|
782 | {
|
---|
783 | uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
|
---|
784 | uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved. */
|
---|
785 | uint32_t u32Rsvd0 : 28; /**< Bits 59:32 - Reserved. */
|
---|
786 | uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
|
---|
787 | uint64_t u64Rsvd0; /**< Bits 127:64 - Reserved. */
|
---|
788 | } u;
|
---|
789 | /** The 64-bit unsigned integer view. */
|
---|
790 | uint64_t au64[2];
|
---|
791 | } CMD_INV_INTR_TABLE_T;
|
---|
792 | AssertCompileSize(CMD_INV_INTR_TABLE_T, 16);
|
---|
793 |
|
---|
794 | /**
|
---|
795 | * Command: COMPLETE_PPR_REQ.
|
---|
796 | * In accordance with the AMD spec.
|
---|
797 | */
|
---|
798 | typedef union
|
---|
799 | {
|
---|
800 | struct
|
---|
801 | {
|
---|
802 | uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
|
---|
803 | uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved. */
|
---|
804 | uint32_t u20Pasid : 20; /**< Bits 51:32 - PASID: Process Address-Space ID. */
|
---|
805 | uint32_t u8Rsvd0 : 8; /**< Bits 59:52 - Reserved. */
|
---|
806 | uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
|
---|
807 | uint32_t u2Rsvd0 : 2; /**< Bits 65:64 - Reserved. */
|
---|
808 | uint32_t u1GuestOrNested : 1; /**< Bit 66 - GN: Guest (GPA) or Nested (GVA). */
|
---|
809 | uint32_t u29Rsvd0 : 29; /**< Bits 95:67 - Reserved. */
|
---|
810 | uint32_t u16CompletionTag : 16; /**< Bits 111:96 - Completion Tag. */
|
---|
811 | uint32_t u16Rsvd1 : 16; /**< Bits 127:112 - Reserved. */
|
---|
812 | } n;
|
---|
813 | /** The 64-bit unsigned integer view. */
|
---|
814 | uint64_t au64[2];
|
---|
815 | } CMD_COMPLETE_PPR_REQ_T;
|
---|
816 | AssertCompileSize(CMD_COMPLETE_PPR_REQ_T, 16);
|
---|
817 |
|
---|
818 | /**
|
---|
819 | * Command: INV_IOMMU_ALL.
|
---|
820 | * In accordance with the AMD spec.
|
---|
821 | */
|
---|
822 | typedef union
|
---|
823 | {
|
---|
824 | struct
|
---|
825 | {
|
---|
826 | uint32_t u32Rsvd0; /**< Bits 31:0 - Reserved. */
|
---|
827 | uint32_t u28Rsvd0 : 28; /**< Bits 59:32 - Reserved. */
|
---|
828 | uint32_t u4OpCode : 4; /**< Bits 63:60 - Op Code (Command). */
|
---|
829 | uint64_t u64Rsvd0; /**< Bits 127:64 - Reserved. */
|
---|
830 | } n;
|
---|
831 | /** The 64-bit unsigned integer view. */
|
---|
832 | uint64_t au64[2];
|
---|
833 | } CMD_IOMMU_ALL_T;
|
---|
834 | AssertCompileSize(CMD_IOMMU_ALL_T, 16);
|
---|
835 |
|
---|
836 | /**
|
---|
837 | * Event Log Entry: Generic.
|
---|
838 | * In accordance with the AMD spec.
|
---|
839 | */
|
---|
840 | typedef union
|
---|
841 | {
|
---|
842 | struct
|
---|
843 | {
|
---|
844 | uint32_t u32Operand1Lo; /**< Bits 31:0 - Operand 1 (Lo). */
|
---|
845 | uint32_t u32Operand1Hi : 28; /**< Bits 59:32 - Operand 1 (Hi). */
|
---|
846 | uint32_t u4EvtCode : 4; /**< Bits 63:60 - Event code. */
|
---|
847 | uint32_t u32Operand2Lo; /**< Bits 95:64 - Operand 2 (Lo). */
|
---|
848 | uint32_t u32Operand2Hi; /**< Bits 127:96 - Operand 2 (Hi). */
|
---|
849 | } n;
|
---|
850 | /** The 32-bit unsigned integer view. */
|
---|
851 | uint32_t au32[4];
|
---|
852 | } EVT_GENERIC_T;
|
---|
853 | AssertCompileSize(EVT_GENERIC_T, 16);
|
---|
854 | /** Number of bits to shift the byte offset of an event entry in the event log
|
---|
855 | * buffer to get its index. */
|
---|
856 | #define IOMMU_EVT_GENERIC_SHIFT 4
|
---|
857 | /** Pointer to a generic event log entry. */
|
---|
858 | typedef EVT_GENERIC_T *PEVT_GENERIC_T;
|
---|
859 | /** Pointer to a const generic event log entry. */
|
---|
860 | typedef const EVT_GENERIC_T *PCEVT_GENERIC_T;
|
---|
861 |
|
---|
862 | /**
|
---|
863 | * Hardware event types.
|
---|
864 | * In accordance with the AMD spec.
|
---|
865 | */
|
---|
866 | typedef enum HWEVTTYPE
|
---|
867 | {
|
---|
868 | HWEVTTYPE_RSVD = 0,
|
---|
869 | HWEVTTYPE_MASTER_ABORT,
|
---|
870 | HWEVTTYPE_TARGET_ABORT,
|
---|
871 | HWEVTTYPE_DATA_ERROR
|
---|
872 | } HWEVTTYPE;
|
---|
873 | AssertCompileSize(HWEVTTYPE, 4);
|
---|
874 |
|
---|
875 | /**
|
---|
876 | * Event Log Entry: ILLEGAL_DEV_TABLE_ENTRY.
|
---|
877 | * In accordance with the AMD spec.
|
---|
878 | */
|
---|
879 | typedef union
|
---|
880 | {
|
---|
881 | struct
|
---|
882 | {
|
---|
883 | uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
|
---|
884 | uint16_t u4PasidHi : 4; /**< Bits 19:16 - PASID: Process Address-Space ID (Hi). */
|
---|
885 | uint16_t u12Rsvd0 : 12; /**< Bits 31:20 - Reserved. */
|
---|
886 | uint16_t u16PasidLo; /**< Bits 47:32 - PASID: Process Address-Space ID (Lo). */
|
---|
887 | uint16_t u1GuestOrNested : 1; /**< Bit 48 - GN: Guest (GPA) or Nested (GVA). */
|
---|
888 | uint16_t u2Rsvd0 : 2; /**< Bits 50:49 - Reserved. */
|
---|
889 | uint16_t u1Interrupt : 1; /**< Bit 51 - I: Interrupt. */
|
---|
890 | uint16_t u1Rsvd0 : 1; /**< Bit 52 - Reserved. */
|
---|
891 | uint16_t u1ReadWrite : 1; /**< Bit 53 - RW: Read/Write. */
|
---|
892 | uint16_t u1Rsvd1 : 1; /**< Bit 54 - Reserved. */
|
---|
893 | uint16_t u1RsvdNotZero : 1; /**< Bit 55 - RZ: Reserved bit not Zero or invalid level encoding. */
|
---|
894 | uint16_t u1Translation : 1; /**< Bit 56 - TN: Translation. */
|
---|
895 | uint16_t u3Rsvd0 : 3; /**< Bits 59:57 - Reserved. */
|
---|
896 | uint16_t u4EvtCode : 4; /**< Bits 63:60 - Event code. */
|
---|
897 | uint64_t u64Addr; /**< Bits 127:64 - Address: Device Virtual Address. */
|
---|
898 | } n;
|
---|
899 | /** The 32-bit unsigned integer view. */
|
---|
900 | uint32_t au32[4];
|
---|
901 | } EVT_ILLEGAL_DEV_TAB_ENTRY_T;
|
---|
902 | AssertCompileSize(EVT_ILLEGAL_DEV_TAB_ENTRY_T, 16);
|
---|
903 | /** Pointer to an illegal device table entry event. */
|
---|
904 | typedef EVT_ILLEGAL_DEV_TAB_ENTRY_T *PEVT_ILLEGAL_DEV_TAB_ENTRY_T;
|
---|
905 |
|
---|
906 | /**
|
---|
907 | * Event Log Entry: IO_PAGE_FAULT_EVENT.
|
---|
908 | * In accordance with the AMD spec.
|
---|
909 | */
|
---|
910 | typedef union
|
---|
911 | {
|
---|
912 | struct
|
---|
913 | {
|
---|
914 | uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
|
---|
915 | uint16_t u4PasidHi : 4; /**< Bits 19:16 - PASID: Process Address-Space ID (Hi). */
|
---|
916 | uint16_t u16DomainOrPasidLo; /**< Bits 47:32 - D/P: Domain ID or Process Address-Space ID (Lo). */
|
---|
917 | uint16_t u1GuestOrNested : 1; /**< Bit 48 - GN: Guest (GPA) or Nested (GVA). */
|
---|
918 | uint16_t u1NoExecute : 1; /**< Bit 49 - NX: No Execute. */
|
---|
919 | uint16_t u1User : 1; /**< Bit 50 - US: User/Supervisor. */
|
---|
920 | uint16_t u1Interrupt : 1; /**< Bit 51 - I: Interrupt. */
|
---|
921 | uint16_t u1Present : 1; /**< Bit 52 - PR: Present. */
|
---|
922 | uint16_t u1ReadWrite : 1; /**< Bit 53 - RW: Read/Write. */
|
---|
923 | uint16_t u1Perm : 1; /**< Bit 54 - PE: Permission Indicator. */
|
---|
924 | uint16_t u1RsvdNotZero : 1; /**< Bit 55 - RZ: Reserved bit not Zero or invalid level encoding. */
|
---|
925 | uint16_t u1Translation : 1; /**< Bit 56 - TN: Translation. */
|
---|
926 | uint16_t u3Rsvd0 : 3; /**< Bit 59:57 - Reserved. */
|
---|
927 | uint16_t u4EvtCode : 4; /**< Bits 63:60 - Event code. */
|
---|
928 | uint64_t u64Addr; /**< Bits 127:64 - Address: Device Virtual Address. */
|
---|
929 | } n;
|
---|
930 | /** The 32-bit unsigned integer view. */
|
---|
931 | uint32_t au32[4];
|
---|
932 | } EVT_IO_PAGE_FAULT_T;
|
---|
933 | AssertCompileSize(EVT_IO_PAGE_FAULT_T, 16);
|
---|
934 |
|
---|
935 | /**
|
---|
936 | * Event Log Entry: DEV_TAB_HARDWARE_ERROR.
|
---|
937 | * In accordance with the AMD spec.
|
---|
938 | */
|
---|
939 | typedef union
|
---|
940 | {
|
---|
941 | struct
|
---|
942 | {
|
---|
943 | uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
|
---|
944 | uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved. */
|
---|
945 | uint32_t u19Rsvd0 : 19; /**< Bits 50:32 - Reserved. */
|
---|
946 | uint32_t u1Intr : 1; /**< Bit 51 - I: Interrupt (1=interrupt request, 0=memory request). */
|
---|
947 | uint32_t u1Rsvd0 : 1; /**< Bit 52 - Reserved. */
|
---|
948 | uint32_t u1ReadWrite : 1; /**< Bit 53 - RW: Read/Write transaction (only meaninful when I=0 and TR=0). */
|
---|
949 | uint32_t u2Rsvd0 : 2; /**< Bits 55:54 - Reserved. */
|
---|
950 | uint32_t u1Translation : 1; /**< Bit 56 - TR: Translation (1=translation, 0=transaction). */
|
---|
951 | uint32_t u2Type : 2; /**< Bits 58:57 - Type: The type of hardware error. */
|
---|
952 | uint32_t u1Rsvd1 : 1; /**< Bit 59 - Reserved. */
|
---|
953 | uint32_t u4EvtCode : 4; /**< Bits 63:60 - Event code. */
|
---|
954 | uint64_t u64Addr; /**< Bits 127:64 - Address. */
|
---|
955 | } n;
|
---|
956 | /** The 32-bit unsigned integer view. */
|
---|
957 | uint32_t au32[4];
|
---|
958 | } EVT_DEV_TAB_HW_ERROR_T;
|
---|
959 | AssertCompileSize(EVT_DEV_TAB_HW_ERROR_T, 16);
|
---|
960 | /** Pointer to a device table hardware error event. */
|
---|
961 | typedef EVT_DEV_TAB_HW_ERROR_T *PEVT_DEV_TAB_HW_ERROR_T;
|
---|
962 |
|
---|
963 | /**
|
---|
964 | * Event Log Entry: EVT_PAGE_TAB_HARDWARE_ERROR.
|
---|
965 | * In accordance with the AMD spec.
|
---|
966 | */
|
---|
967 | typedef union
|
---|
968 | {
|
---|
969 | struct
|
---|
970 | {
|
---|
971 | uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
|
---|
972 | uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved. */
|
---|
973 | uint32_t u16DomainOrPasidLo : 16; /**< Bits 47:32 - D/P: Domain ID or Process Address-Space ID (Lo). */
|
---|
974 | uint32_t u1GuestOrNested : 1; /**< Bit 48 - GN: Guest (GPA) or Nested (GVA). */
|
---|
975 | uint32_t u2Rsvd0 : 2; /**< Bits 50:49 - Reserved. */
|
---|
976 | uint32_t u1Interrupt : 1; /**< Bit 51 - I: Interrupt. */
|
---|
977 | uint32_t u1Rsvd0 : 1; /**< Bit 52 - Reserved. */
|
---|
978 | uint32_t u1ReadWrite : 1; /**< Bit 53 - RW: Read/Write. */
|
---|
979 | uint32_t u2Rsvd1 : 2; /**< Bit 55:54 - Reserved. */
|
---|
980 | uint32_t u1Translation : 1; /**< Bit 56 - TR: Translation. */
|
---|
981 | uint32_t u2Type : 2; /**< Bits 58:57 - Type: The type of hardware error. */
|
---|
982 | uint32_t u1Rsvd1 : 1; /**< Bit 59 - Reserved. */
|
---|
983 | uint32_t u4EvtCode : 4; /**< Bit 63:60 - Event code. */
|
---|
984 | /** @todo r=ramshankar: Figure 55: PAGE_TAB_HARDWARE_ERROR says Addr[31:3] but
|
---|
985 | * table 58 mentions Addr[31:4]. Looks like a typo in the figure. Use
|
---|
986 | * table as it makes more sense and matches address size in
|
---|
987 | * EVT_DEV_TAB_HARDWARE_ERROR. See AMD AMD IOMMU spec (3.05-PUB, Jan
|
---|
988 | * 2020). */
|
---|
989 | uint32_t u4Rsvd0 : 4; /**< Bits 67:64 - Reserved. */
|
---|
990 | uint32_t u28AddrLo : 28; /**< Bits 95:68 - Address: SPA of page table entry (Lo). */
|
---|
991 | uint32_t u32AddrHi; /**< Bits 127:96 - Address: SPA of page table entry (Hi). */
|
---|
992 | } n;
|
---|
993 | /** The 32-bit unsigned integer view. */
|
---|
994 | uint32_t au32[4];
|
---|
995 | } EVT_PAGE_TAB_HW_ERR_T;
|
---|
996 | AssertCompileSize(EVT_PAGE_TAB_HW_ERR_T, 16);
|
---|
997 |
|
---|
998 | /**
|
---|
999 | * Event Log Entry: ILLEGAL_COMMAND_ERROR.
|
---|
1000 | * In accordance with the AMD spec.
|
---|
1001 | */
|
---|
1002 | typedef union
|
---|
1003 | {
|
---|
1004 | struct
|
---|
1005 | {
|
---|
1006 | uint32_t u32Rsvd0; /**< Bits 31:0 - Reserved. */
|
---|
1007 | uint32_t u28Rsvd0 : 28; /**< Bits 47:32 - Reserved. */
|
---|
1008 | uint32_t u4EvtCode : 4; /**< Bits 63:60 - Event code. */
|
---|
1009 | uint32_t u4Rsvd0 : 4; /**< Bits 67:64 - Reserved. */
|
---|
1010 | uint32_t u28AddrLo : 28; /**< Bits 95:68 - Address: SPA of the invalid command (Lo). */
|
---|
1011 | uint32_t u32AddrHi; /**< Bits 127:96 - Address: SPA of the invalid command (Hi). */
|
---|
1012 | } n;
|
---|
1013 | /** The 32-bit unsigned integer view. */
|
---|
1014 | uint32_t au32[4];
|
---|
1015 | } EVT_ILLEGAL_CMD_ERR_T;
|
---|
1016 | AssertCompileSize(EVT_ILLEGAL_CMD_ERR_T, 16);
|
---|
1017 |
|
---|
1018 | /**
|
---|
1019 | * Event Log Entry: COMMAND_HARDWARE_ERROR.
|
---|
1020 | * In accordance with the AMD spec.
|
---|
1021 | */
|
---|
1022 | typedef union
|
---|
1023 | {
|
---|
1024 | struct
|
---|
1025 | {
|
---|
1026 | uint32_t u32Rsvd0; /**< Bits 31:0 - Reserved. */
|
---|
1027 | uint32_t u4Rsvd0 : 4; /**< Bits 35:32 - Reserved. */
|
---|
1028 | uint32_t u28AddrLo : 28; /**< Bits 63:36 - Address: SPA of the attempted access (Lo). */
|
---|
1029 | uint32_t u32AddrHi; /**< Bits 95:64 - Address: SPA of the attempted access (Hi). */
|
---|
1030 | } n;
|
---|
1031 | /** The 32-bit unsigned integer view. */
|
---|
1032 | uint32_t au32[3];
|
---|
1033 | } EVT_CMD_HW_ERROR_T;
|
---|
1034 | AssertCompileSize(EVT_CMD_HW_ERROR_T, 12);
|
---|
1035 |
|
---|
1036 | /**
|
---|
1037 | * Event Log Entry: IOTLB_INV_TIMEOUT.
|
---|
1038 | * In accordance with the AMD spec.
|
---|
1039 | */
|
---|
1040 | typedef union
|
---|
1041 | {
|
---|
1042 | struct
|
---|
1043 | {
|
---|
1044 | uint16_t u16DevId; /**< Bits 15:0 - Device ID. */
|
---|
1045 | uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved.*/
|
---|
1046 | uint32_t u28Rsvd0 : 28; /**< Bits 59:32 - Reserved. */
|
---|
1047 | uint32_t u4EvtCode : 4; /**< Bits 63:60 - Event code. */
|
---|
1048 | uint32_t u4Rsvd0 : 4; /**< Bits 67:64 - Reserved. */
|
---|
1049 | uint32_t u28AddrLo : 28; /**< Bits 95:68 - Address: SPA of the invalidation command that timedout (Lo). */
|
---|
1050 | uint32_t u32AddrHi; /**< Bits 127:96 - Address: SPA of the invalidation command that timedout (Hi). */
|
---|
1051 | } n;
|
---|
1052 | /** The 32-bit unsigned integer view. */
|
---|
1053 | uint32_t au32[4];
|
---|
1054 | } EVT_IOTLB_INV_TIMEOUT_T;
|
---|
1055 | AssertCompileSize(EVT_IOTLB_INV_TIMEOUT_T, 16);
|
---|
1056 |
|
---|
1057 | /**
|
---|
1058 | * Event Log Entry: INVALID_DEVICE_REQUEST.
|
---|
1059 | * In accordance with the AMD spec.
|
---|
1060 | */
|
---|
1061 | typedef union
|
---|
1062 | {
|
---|
1063 | struct
|
---|
1064 | {
|
---|
1065 | uint32_t u16DevId : 16; /***< Bits 15:0 - Device ID. */
|
---|
1066 | uint32_t u4PasidHi : 4; /***< Bits 19:16 - PASID: Process Address-Space ID (Hi). */
|
---|
1067 | uint32_t u12Rsvd0 : 12; /***< Bits 31:20 - Reserved. */
|
---|
1068 | uint32_t u16PasidLo : 16; /***< Bits 47:32 - PASID: Process Address-Space ID (Lo). */
|
---|
1069 | uint32_t u1GuestOrNested : 1; /***< Bit 48 - GN: Guest (GPA) or Nested (GVA). */
|
---|
1070 | uint32_t u1User : 1; /***< Bit 49 - US: User/Supervisor. */
|
---|
1071 | uint32_t u6Rsvd0 : 6; /***< Bits 55:50 - Reserved. */
|
---|
1072 | uint32_t u1Translation: 1; /***< Bit 56 - TR: Translation. */
|
---|
1073 | uint32_t u3Type: 3; /***< Bits 59:57 - Type: The type of hardware error. */
|
---|
1074 | uint32_t u4EvtCode : 4; /***< Bits 63:60 - Event code. */
|
---|
1075 | uint64_t u64Addr; /***< Bits 127:64 - Address: Translation or access address. */
|
---|
1076 | } n;
|
---|
1077 | /** The 32-bit unsigned integer view. */
|
---|
1078 | uint32_t au32[4];
|
---|
1079 | } EVT_INVALID_DEV_REQ_T;
|
---|
1080 | AssertCompileSize(EVT_INVALID_DEV_REQ_T, 16);
|
---|
1081 |
|
---|
1082 | /**
|
---|
1083 | * Event Log Entry: EVENT_COUNTER_ZERO.
|
---|
1084 | * In accordance with the AMD spec.
|
---|
1085 | */
|
---|
1086 | typedef union
|
---|
1087 | {
|
---|
1088 | struct
|
---|
1089 | {
|
---|
1090 | uint32_t u32Rsvd0; /**< Bits 31:0 - Reserved. */
|
---|
1091 | uint32_t u28Rsvd0 : 28; /**< Bits 59:32 - Reserved. */
|
---|
1092 | uint32_t u4EvtCode : 4; /**< Bits 63:60 - Event code. */
|
---|
1093 | uint32_t u20CounterNoteHi : 20; /**< Bits 83:64 - CounterNote: Counter value for the event counter register (Hi). */
|
---|
1094 | uint32_t u12Rsvd0 : 12; /**< Bits 95:84 - Reserved. */
|
---|
1095 | uint32_t u32CounterNoteLo; /**< Bits 127:96 - CounterNote: Counter value for the event cuonter register (Lo). */
|
---|
1096 | } n;
|
---|
1097 | /** The 32-bit unsigned integer view. */
|
---|
1098 | uint32_t au32[4];
|
---|
1099 | } EVT_EVENT_COUNTER_ZERO_T;
|
---|
1100 | AssertCompileSize(EVT_EVENT_COUNTER_ZERO_T, 16);
|
---|
1101 |
|
---|
1102 | /**
|
---|
1103 | * IOMMU Capability Header (PCI).
|
---|
1104 | * In accordance with the AMD spec.
|
---|
1105 | */
|
---|
1106 | typedef union
|
---|
1107 | {
|
---|
1108 | struct
|
---|
1109 | {
|
---|
1110 | uint32_t u8CapId : 8; /**< Bits 7:0 - CapId: Capability ID. */
|
---|
1111 | uint32_t u8CapPtr : 8; /**< Bits 15:8 - CapPtr: Pointer (PCI config offset) to the next capability. */
|
---|
1112 | uint32_t u3CapType : 3; /**< Bits 18:16 - CapType: Capability Type. */
|
---|
1113 | uint32_t u5CapRev : 5; /**< Bits 23:19 - CapRev: Capability revision. */
|
---|
1114 | uint32_t u1IoTlbSup : 1; /**< Bit 24 - IotlbSup: IOTLB Support. */
|
---|
1115 | uint32_t u1HtTunnel : 1; /**< Bit 25 - HtTunnel: HyperTransport Tunnel translation support. */
|
---|
1116 | uint32_t u1NpCache : 1; /**< Bit 26 - NpCache: Not Present table entries are cached. */
|
---|
1117 | uint32_t u1EfrSup : 1; /**< Bit 27 - EFRSup: Extended Feature Register Support. */
|
---|
1118 | uint32_t u1CapExt : 1; /**< Bit 28 - CapExt: Misc. Information Register 1 Support. */
|
---|
1119 | uint32_t u3Rsvd0 : 3; /**< Bits 31:29 - Reserved. */
|
---|
1120 | } n;
|
---|
1121 | /** The 32-bit unsigned integer view. */
|
---|
1122 | uint32_t u32;
|
---|
1123 | } IOMMU_CAP_HDR_T;
|
---|
1124 | AssertCompileSize(IOMMU_CAP_HDR_T, 4);
|
---|
1125 |
|
---|
1126 | /**
|
---|
1127 | * IOMMU Base Address (Lo and Hi) Register (PCI).
|
---|
1128 | * In accordance with the AMD spec.
|
---|
1129 | */
|
---|
1130 | typedef union
|
---|
1131 | {
|
---|
1132 | struct
|
---|
1133 | {
|
---|
1134 | uint32_t u1Enable : 1; /**< Bit 1 - Enable: RW1S - Enable IOMMU MMIO region. */
|
---|
1135 | uint32_t u12Rsvd0 : 12; /**< Bits 13:1 - Reserved. */
|
---|
1136 | uint32_t u18BaseAddrLo : 18; /**< Bits 31:14 - Base address (Lo) of the MMIO region. */
|
---|
1137 | uint32_t u32BaseAddrHi; /**< Bits 63:32 - Base address (Hi) of the MMIO region. */
|
---|
1138 | } n;
|
---|
1139 | /** The 32-bit unsigned integer view. */
|
---|
1140 | uint32_t au32[2];
|
---|
1141 | /** The 64-bit unsigned integer view. */
|
---|
1142 | uint64_t u64;
|
---|
1143 | } IOMMU_BAR_T;
|
---|
1144 | AssertCompileSize(IOMMU_BAR_T, 8);
|
---|
1145 | #define IOMMU_BAR_VALID_MASK UINT64_C(0xffffffffffffc001)
|
---|
1146 |
|
---|
1147 | /**
|
---|
1148 | * IOMMU Range Register (PCI).
|
---|
1149 | * In accordance with the AMD spec.
|
---|
1150 | */
|
---|
1151 | typedef union
|
---|
1152 | {
|
---|
1153 | struct
|
---|
1154 | {
|
---|
1155 | uint32_t u5HtUnitId : 5; /**< Bits 4:0 - UnitID: IOMMU HyperTransport Unit ID (not used). */
|
---|
1156 | uint32_t u2Rsvd0 : 2; /**< Bits 6:5 - Reserved. */
|
---|
1157 | uint32_t u1RangeValid : 1; /**< Bit 7 - RngValid: Range Valid. */
|
---|
1158 | uint32_t u8Bus : 8; /**< Bits 15:8 - BusNumber: Bus number of the first and last device. */
|
---|
1159 | uint32_t u8FirstDevice : 8; /**< Bits 23:16 - FirstDevice: Device and function number of the first device. */
|
---|
1160 | uint32_t u8LastDevice: 8; /**< Bits 31:24 - LastDevice: Device and function number of the last device. */
|
---|
1161 | } n;
|
---|
1162 | /** The 32-bit unsigned integer view. */
|
---|
1163 | uint32_t u32;
|
---|
1164 | } IOMMU_RANGE_T;
|
---|
1165 | AssertCompileSize(IOMMU_RANGE_T, 4);
|
---|
1166 |
|
---|
1167 | /**
|
---|
1168 | * Device Table Base Address Register (MMIO).
|
---|
1169 | * In accordance with the AMD spec.
|
---|
1170 | */
|
---|
1171 | typedef union
|
---|
1172 | {
|
---|
1173 | struct
|
---|
1174 | {
|
---|
1175 | RT_GCC_EXTENSION uint64_t u9Size : 9; /**< Bits 8:0 - Size: Size of the device table. */
|
---|
1176 | RT_GCC_EXTENSION uint64_t u3Rsvd0 : 3; /**< Bits 11:9 - Reserved. */
|
---|
1177 | RT_GCC_EXTENSION uint64_t u40Base : 40; /**< Bits 51:12 - DevTabBase: Device table base address. */
|
---|
1178 | RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 63:52 - Reserved. */
|
---|
1179 | } n;
|
---|
1180 | /** The 64-bit unsigned integer view. */
|
---|
1181 | uint64_t u64;
|
---|
1182 | } DEV_TAB_BAR_T;
|
---|
1183 | AssertCompileSize(DEV_TAB_BAR_T, 8);
|
---|
1184 | #define IOMMU_DEV_TAB_BAR_VALID_MASK UINT64_C(0x000ffffffffff1ff)
|
---|
1185 | #define IOMMU_DEV_TAB_SEG_BAR_VALID_MASK UINT64_C(0x000ffffffffff0ff)
|
---|
1186 |
|
---|
1187 | /**
|
---|
1188 | * Command Buffer Base Address Register (MMIO).
|
---|
1189 | * In accordance with the AMD spec.
|
---|
1190 | */
|
---|
1191 | typedef union
|
---|
1192 | {
|
---|
1193 | struct
|
---|
1194 | {
|
---|
1195 | RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 11:0 - Reserved. */
|
---|
1196 | RT_GCC_EXTENSION uint64_t u40Base : 40; /**< Bits 51:12 - ComBase: Command buffer base address. */
|
---|
1197 | RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 55:52 - Reserved. */
|
---|
1198 | RT_GCC_EXTENSION uint64_t u4Len : 4; /**< Bits 59:56 - ComLen: Command buffer length. */
|
---|
1199 | RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; /**< Bits 63:60 - Reserved. */
|
---|
1200 | } n;
|
---|
1201 | /** The 64-bit unsigned integer view. */
|
---|
1202 | uint64_t u64;
|
---|
1203 | } CMD_BUF_BAR_T;
|
---|
1204 | AssertCompileSize(CMD_BUF_BAR_T, 8);
|
---|
1205 | #define IOMMU_CMD_BUF_BAR_VALID_MASK UINT64_C(0x0f0ffffffffff000)
|
---|
1206 |
|
---|
1207 | /**
|
---|
1208 | * Event Log Base Address Register (MMIO).
|
---|
1209 | * In accordance with the AMD spec.
|
---|
1210 | */
|
---|
1211 | typedef union
|
---|
1212 | {
|
---|
1213 | struct
|
---|
1214 | {
|
---|
1215 | RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 11:0 - Reserved. */
|
---|
1216 | RT_GCC_EXTENSION uint64_t u40Base : 40; /**< Bits 51:12 - EventBase: Event log base address. */
|
---|
1217 | RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 55:52 - Reserved. */
|
---|
1218 | RT_GCC_EXTENSION uint64_t u4Len : 4; /**< Bits 59:56 - EventLen: Event log length. */
|
---|
1219 | RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; /**< Bits 63:60 - Reserved. */
|
---|
1220 | } n;
|
---|
1221 | /** The 64-bit unsigned integer view. */
|
---|
1222 | uint64_t u64;
|
---|
1223 | } EVT_LOG_BAR_T;
|
---|
1224 | AssertCompileSize(EVT_LOG_BAR_T, 8);
|
---|
1225 | #define IOMMU_EVT_LOG_BAR_VALID_MASK UINT64_C(0x0f0ffffffffff000)
|
---|
1226 |
|
---|
1227 | /**
|
---|
1228 | * IOMMU Control Register (MMIO).
|
---|
1229 | * In accordance with the AMD spec.
|
---|
1230 | */
|
---|
1231 | typedef union
|
---|
1232 | {
|
---|
1233 | struct
|
---|
1234 | {
|
---|
1235 | uint32_t u1IommuEn : 1; /**< Bit 0 - IommuEn: IOMMU Enable. */
|
---|
1236 | uint32_t u1HtTunEn : 1; /**< Bit 1 - HtTunEn: HyperTransport Tunnel Enable. */
|
---|
1237 | uint32_t u1EvtLogEn : 1; /**< Bit 2 - EventLogEn: Event Log Enable. */
|
---|
1238 | uint32_t u1EvtIntrEn : 1; /**< Bit 3 - EventIntEn: Event Log Interrupt Enable. */
|
---|
1239 | uint32_t u1CompWaitIntrEn : 1; /**< Bit 4 - ComWaitIntEn: Completion Wait Interrupt Enable. */
|
---|
1240 | uint32_t u3InvTimeOut : 3; /**< Bits 7:5 - InvTimeOut: Invalidation Timeout. */
|
---|
1241 | uint32_t u1PassPW : 1; /**< Bit 8 - PassPW: Pass Posted Write. */
|
---|
1242 | uint32_t u1ResPassPW : 1; /**< Bit 9 - ResPassPW: Response Pass Posted Write. */
|
---|
1243 | uint32_t u1Coherent : 1; /**< Bit 10 - Coherent: HT read request packet Coherent bit. */
|
---|
1244 | uint32_t u1Isoc : 1; /**< Bit 11 - Isoc: HT read request packet Isochronous bit. */
|
---|
1245 | uint32_t u1CmdBufEn : 1; /**< Bit 12 - CmdBufEn: Command Buffer Enable. */
|
---|
1246 | uint32_t u1PprLogEn : 1; /**< Bit 13 - PprLogEn: Peripheral Page Request (PPR) Log Enable. */
|
---|
1247 | uint32_t u1PprIntrEn : 1; /**< Bit 14 - PprIntrEn: Peripheral Page Request Interrupt Enable. */
|
---|
1248 | uint32_t u1PprEn : 1; /**< Bit 15 - PprEn: Peripheral Page Request processing Enable. */
|
---|
1249 | uint32_t u1GstTranslateEn : 1; /**< Bit 16 - GTEn: Guest Translate Enable. */
|
---|
1250 | uint32_t u1GstVirtApicEn : 1; /**< Bit 17 - GAEn: Guest Virtual-APIC Enable. */
|
---|
1251 | uint32_t u4Crw : 1; /**< Bits 21:18 - CRW: Intended for future use (not documented). */
|
---|
1252 | uint32_t u1SmiFilterEn : 1; /**< Bit 22 - SmiFEn: SMI Filter Enable. */
|
---|
1253 | uint32_t u1SelfWriteBackDis : 1; /**< Bit 23 - SlfWBDis: Self Write-Back Disable. */
|
---|
1254 | uint32_t u1SmiFilterLogEn : 1; /**< Bit 24 - SmiFLogEn: SMI Filter Log Enable. */
|
---|
1255 | uint32_t u3GstVirtApicModeEn : 3; /**< Bits 27:25 - GAMEn: Guest Virtual-APIC Mode Enable. */
|
---|
1256 | uint32_t u1GstLogEn : 1; /**< Bit 28 - GALogEn: Guest Virtual-APIC GA Log Enable. */
|
---|
1257 | uint32_t u1GstIntrEn : 1; /**< Bit 29 - GAIntEn: Guest Virtual-APIC Interrupt Enable. */
|
---|
1258 | uint32_t u2DualPprLogEn : 2; /**< Bits 31:30 - DualPprLogEn: Dual Peripheral Page Request Log Enable. */
|
---|
1259 | uint32_t u2DualEvtLogEn : 2; /**< Bits 33:32 - DualEventLogEn: Dual Event Log Enable. */
|
---|
1260 | uint32_t u3DevTabSegEn : 3; /**< Bits 36:34 - DevTblSegEn: Device Table Segment Enable. */
|
---|
1261 | uint32_t u2PrivAbortEn : 2; /**< Bits 38:37 - PrivAbrtEn: Privilege Abort Enable. */
|
---|
1262 | uint32_t u1PprAutoRespEn : 1; /**< Bit 39 - PprAutoRspEn: Peripheral Page Request Auto Response Enable. */
|
---|
1263 | uint32_t u1MarcEn : 1; /**< Bit 40 - MarcEn: Memory Address Routing and Control Enable. */
|
---|
1264 | uint32_t u1BlockStopMarkEn : 1; /**< Bit 41 - BlkStopMarkEn: Block StopMark messages Enable. */
|
---|
1265 | uint32_t u1PprAutoRespAlwaysOnEn : 1; /**< Bit 42 - PprAutoRspAon:: PPR Auto Response - Always On Enable. */
|
---|
1266 | uint32_t u1DomainIDPNE : 1; /**< Bit 43 - DomainIDPE: Reserved (not documented). */
|
---|
1267 | uint32_t u1Rsvd0 : 1; /**< Bit 44 - Reserved. */
|
---|
1268 | uint32_t u1EnhancedPpr : 1; /**< Bit 45 - EPHEn: Enhanced Peripheral Page Request Handling Enable. */
|
---|
1269 | uint32_t u2HstAccDirtyBitUpdate : 2; /**< Bits 47:46 - HADUpdate: Access and Dirty Bit updated in host page table. */
|
---|
1270 | uint32_t u1GstDirtyUpdateDis : 1; /**< Bit 48 - GDUpdateDis: Disable hardare update of Dirty bit in GPT. */
|
---|
1271 | uint32_t u1Rsvd1 : 1; /**< Bit 49 - Reserved. */
|
---|
1272 | uint32_t u1X2ApicEn : 1; /**< Bit 50 - XTEn: Enable X2APIC. */
|
---|
1273 | uint32_t u1X2ApicIntrGenEn : 1; /**< Bit 51 - IntCapXTEn: Enable IOMMU X2APIC Interrupt generation. */
|
---|
1274 | uint32_t u2Rsvd0 : 2; /**< Bits 53:52 - Reserved. */
|
---|
1275 | uint32_t u1GstAccessUpdateDis : 1; /**< Bit 54 - GAUpdateDis: Disable hardare update of Access bit in GPT. */
|
---|
1276 | uint32_t u8Rsvd0 : 8; /**< Bits 63:55 - Reserved. */
|
---|
1277 | } n;
|
---|
1278 | /** The 64-bit unsigned integer view. */
|
---|
1279 | uint64_t u64;
|
---|
1280 | } IOMMU_CTRL_T;
|
---|
1281 | AssertCompileSize(IOMMU_CTRL_T, 8);
|
---|
1282 | #define IOMMU_CTRL_VALID_MASK UINT64_C(0x004defffffffffff)
|
---|
1283 |
|
---|
1284 | /**
|
---|
1285 | * IOMMU Exclusion Base Register (MMIO).
|
---|
1286 | * In accordance with the AMD spec.
|
---|
1287 | */
|
---|
1288 | typedef union
|
---|
1289 | {
|
---|
1290 | struct
|
---|
1291 | {
|
---|
1292 | RT_GCC_EXTENSION uint64_t u1ExclEnable : 1; /**< Bit 0 - ExEn: Exclusion Range Enable. */
|
---|
1293 | RT_GCC_EXTENSION uint64_t u1AllowAll : 1; /**< Bit 1 - Allow: Allow All Devices. */
|
---|
1294 | RT_GCC_EXTENSION uint64_t u10Rsvd0 : 10; /**< Bits 11:2 - Reserved. */
|
---|
1295 | RT_GCC_EXTENSION uint64_t u40ExclRangeBase : 40; /**< Bits 51:12 - Exclusion Range Base Address. */
|
---|
1296 | RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 63:52 - Reserved. */
|
---|
1297 | } n;
|
---|
1298 | /** The 64-bit unsigned integer view. */
|
---|
1299 | uint64_t u64;
|
---|
1300 | } IOMMU_EXCL_RANGE_BAR_T;
|
---|
1301 | AssertCompileSize(IOMMU_EXCL_RANGE_BAR_T, 8);
|
---|
1302 | #define IOMMU_EXCL_RANGE_BAR_VALID_MASK UINT64_C(0x000ffffffffff003)
|
---|
1303 |
|
---|
1304 | /**
|
---|
1305 | * IOMMU Exclusion Range Limit Register (MMIO).
|
---|
1306 | * In accordance with the AMD spec.
|
---|
1307 | */
|
---|
1308 | typedef union
|
---|
1309 | {
|
---|
1310 | struct
|
---|
1311 | {
|
---|
1312 | RT_GCC_EXTENSION uint64_t u52ExclLimit : 52; /**< Bits 51:0 - Exclusion Range Limit (last 12 bits are treated as 1s). */
|
---|
1313 | RT_GCC_EXTENSION uint64_t u12Rsvd1 : 12; /**< Bits 63:52 - Reserved. */
|
---|
1314 | } n;
|
---|
1315 | /** The 64-bit unsigned integer view. */
|
---|
1316 | uint64_t u64;
|
---|
1317 | } IOMMU_EXCL_RANGE_LIMIT_T;
|
---|
1318 | AssertCompileSize(IOMMU_EXCL_RANGE_LIMIT_T, 8);
|
---|
1319 | #define IOMMU_EXCL_RANGE_LIMIT_VALID_MASK UINT64_C(0x000fffffffffffff)
|
---|
1320 |
|
---|
1321 | /**
|
---|
1322 | * IOMMU Extended Feature Register (MMIO).
|
---|
1323 | * In accordance with the AMD spec.
|
---|
1324 | */
|
---|
1325 | typedef union
|
---|
1326 | {
|
---|
1327 | struct
|
---|
1328 | {
|
---|
1329 | uint32_t u1PrefetchSup : 1; /**< Bit 0 - PreFSup: Prefetch Support. */
|
---|
1330 | uint32_t u1PprSup : 1; /**< Bit 1 - PPRSup: Peripheral Page Request Support. */
|
---|
1331 | uint32_t u1X2ApicSup : 1; /**< Bit 2 - XTSup: x2Apic Support. */
|
---|
1332 | uint32_t u1NoExecuteSup : 1; /**< Bit 3 - NXSup: No-Execute and Privilege Level Support. */
|
---|
1333 | uint32_t u1GstTranslateSup : 1; /**< Bit 4 - GTSup: Guest Translations Support. */
|
---|
1334 | uint32_t u1Rsvd0 : 1; /**< Bit 5 - Reserved. */
|
---|
1335 | uint32_t u1InvAllSup : 1; /**< Bit 6 - IASup: Invalidate-All Support. */
|
---|
1336 | uint32_t u1GstVirtApicSup : 1; /**< Bit 7 - GASup: Guest Virtual-APIC Support. */
|
---|
1337 | uint32_t u1HwErrorSup : 1; /**< Bit 8 - HESup: Hardware Error registers Support. */
|
---|
1338 | uint32_t u1PerfCounterSup : 1; /**< Bit 8 - PCSup: Performance Counter Support. */
|
---|
1339 | uint32_t u2HostAddrTranslateSize : 2; /**< Bits 11:10 - HATS: Host Address Translation Size. */
|
---|
1340 | uint32_t u2GstAddrTranslateSize : 2; /**< Bits 13:12 - GATS: Guest Address Translation Size. */
|
---|
1341 | uint32_t u2GstCr3RootTblLevel : 2; /**< Bits 15:14 - GLXSup: Guest CR3 Root Table Level (Max) Size Support. */
|
---|
1342 | uint32_t u2SmiFilterSup : 2; /**< Bits 17:16 - SmiFSup: SMI Filter Register Support. */
|
---|
1343 | uint32_t u3SmiFilterCount : 3; /**< Bits 20:18 - SmiFRC: SMI Filter Register Count. */
|
---|
1344 | uint32_t u3GstVirtApicModeSup : 3; /**< Bits 23:21 - GAMSup: Guest Virtual-APIC Modes Supported. */
|
---|
1345 | uint32_t u2DualPprLogSup : 2; /**< Bits 25:24 - DualPprLogSup: Dual Peripheral Page Request Log Support. */
|
---|
1346 | uint32_t u2Rsvd0 : 2; /**< Bits 27:26 - Reserved. */
|
---|
1347 | uint32_t u2DualEvtLogSup : 2; /**< Bits 29:28 - DualEventLogSup: Dual Event Log Support. */
|
---|
1348 | uint32_t u2Rsvd1 : 2; /**< Bits 31:30 - Reserved. */
|
---|
1349 | uint32_t u5MaxPasidSup : 5; /**< Bits 36:32 - PASMax: Maximum PASID Supported. */
|
---|
1350 | uint32_t u1UserSupervisorSup : 1; /**< Bit 37 - USSup: User/Supervisor Page Protection Support. */
|
---|
1351 | uint32_t u2DevTabSegSup : 2; /**< Bits 39:38 - DevTlbSegSup: Segmented Device Table Support. */
|
---|
1352 | uint32_t u1PprLogOverflowWarn : 1; /**< Bit 40 - PprOvrflwEarlySup: PPR Log Overflow Early Warning Support. */
|
---|
1353 | uint32_t u1PprAutoRespSup : 1; /**< Bit 41 - PprAutoRspSup: PPR Automatic Response Support. */
|
---|
1354 | uint32_t u2MarcSup : 2; /**< Bit 43:42 - MarcSup: Memory Access Routing and Control Support. */
|
---|
1355 | uint32_t u1BlockStopMarkSup : 1; /**< Bit 44 - BlkStopMarkSup: Block StopMark messages Support. */
|
---|
1356 | uint32_t u1PerfOptSup : 1; /**< Bit 45 - PerfOptSup: IOMMU Performance Optimization Support. */
|
---|
1357 | uint32_t u1MsiCapMmioSup : 1; /**< Bit 46 - MsiCapMmioSup: MSI Capability Register MMIO Access Support. */
|
---|
1358 | uint32_t u1Rsvd1 : 1; /**< Bit 47 - Reserved. */
|
---|
1359 | uint32_t u1GstIoSup : 1; /**< Bit 48 - GIoSup: Guest I/O Protection Support. */
|
---|
1360 | uint32_t u1HostAccessSup : 1; /**< Bit 49 - HASup: Host Access Support. */
|
---|
1361 | uint32_t u1EnhancedPprSup : 1; /**< Bit 50 - EPHSup: Enhanced Peripheral Page Request Handling Support. */
|
---|
1362 | uint32_t u1AttrForwardSup : 1; /**< Bit 51 - AttrFWSup: Attribute Forward Support. */
|
---|
1363 | uint32_t u1HostDirtySup : 1; /**< Bit 52 - HDSup: Host Dirty Support. */
|
---|
1364 | uint32_t u1Rsvd2 : 1; /**< Bit 53 - Reserved. */
|
---|
1365 | uint32_t u1InvIoTlbTypeSup : 1; /**< Bit 54 - InvIotlbTypeSup: Invalidate IOTLB Type Support. */
|
---|
1366 | uint32_t u6Rsvd0 : 6; /**< Bit 60:55 - Reserved. */
|
---|
1367 | uint32_t u1GstUpdateDisSup : 1; /**< Bit 61 - GAUpdateDisSup: Disable hardware update on GPT Support. */
|
---|
1368 | uint32_t u1ForcePhysDstSup : 1; /**< Bit 62 - ForcePhyDestSup: Force Phys. Dst. Mode for Remapped Intr. */
|
---|
1369 | uint32_t u1Rsvd3 : 1; /**< Bit 63 - Reserved. */
|
---|
1370 | } n;
|
---|
1371 | /** The 64-bit unsigned integer view. */
|
---|
1372 | uint64_t u64;
|
---|
1373 | } IOMMU_EXT_FEAT_T;
|
---|
1374 | AssertCompileSize(IOMMU_EXT_FEAT_T, 8);
|
---|
1375 |
|
---|
1376 | /**
|
---|
1377 | * Peripheral Page Request Log Base Address Register (MMIO).
|
---|
1378 | * In accordance with the AMD spec.
|
---|
1379 | */
|
---|
1380 | typedef union
|
---|
1381 | {
|
---|
1382 | struct
|
---|
1383 | {
|
---|
1384 | RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bit 11:0 - Reserved. */
|
---|
1385 | RT_GCC_EXTENSION uint64_t u40Base : 40; /**< Bits 51:12 - PPRLogBase: Peripheral Page Request Log Base Address. */
|
---|
1386 | RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 55:52 - Reserved. */
|
---|
1387 | RT_GCC_EXTENSION uint64_t u4Len : 4; /**< Bits 59:56 - PPRLogLen: Peripheral Page Request Log Length. */
|
---|
1388 | RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; /**< Bits 63:60 - Reserved. */
|
---|
1389 | } n;
|
---|
1390 | /** The 64-bit unsigned integer view. */
|
---|
1391 | uint64_t u64;
|
---|
1392 | } PPR_LOG_BAR_T;
|
---|
1393 | AssertCompileSize(PPR_LOG_BAR_T, 8);
|
---|
1394 | #define IOMMU_PPR_LOG_BAR_VALID_MASK UINT64_C(0x0f0ffffffffff000)
|
---|
1395 |
|
---|
1396 | /**
|
---|
1397 | * IOMMU Hardware Event Upper Register (MMIO).
|
---|
1398 | * In accordance with the AMD spec.
|
---|
1399 | */
|
---|
1400 | typedef union
|
---|
1401 | {
|
---|
1402 | struct
|
---|
1403 | {
|
---|
1404 | RT_GCC_EXTENSION uint64_t u60FirstOperand : 60; /**< Bits 59:0 - First event code dependent operand. */
|
---|
1405 | RT_GCC_EXTENSION uint64_t u4EvtCode : 4; /**< Bits 63:60 - Event Code. */
|
---|
1406 | } n;
|
---|
1407 | /** The 64-bit unsigned integer view. */
|
---|
1408 | uint64_t u64;
|
---|
1409 | } IOMMU_HW_EVT_HI_T;
|
---|
1410 | AssertCompileSize(IOMMU_HW_EVT_HI_T, 8);
|
---|
1411 |
|
---|
1412 | /**
|
---|
1413 | * IOMMU Hardware Event Lower Register (MMIO).
|
---|
1414 | * In accordance with the AMD spec.
|
---|
1415 | */
|
---|
1416 | typedef uint64_t IOMMU_HW_EVT_LO_T;
|
---|
1417 |
|
---|
1418 | /**
|
---|
1419 | * IOMMU Hardware Event Status (MMIO).
|
---|
1420 | * In accordance with the AMD spec.
|
---|
1421 | */
|
---|
1422 | typedef union
|
---|
1423 | {
|
---|
1424 | struct
|
---|
1425 | {
|
---|
1426 | uint32_t u1Valid : 1; /**< Bit 0 - HEV: Hardware Event Valid. */
|
---|
1427 | uint32_t u1Overflow : 1; /**< Bit 1 - HEO: Hardware Event Overflow. */
|
---|
1428 | uint32_t u30Rsvd0 : 30; /**< Bits 31:2 - Reserved. */
|
---|
1429 | uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved. */
|
---|
1430 | } n;
|
---|
1431 | /** The 64-bit unsigned integer view. */
|
---|
1432 | uint64_t u64;
|
---|
1433 | } IOMMU_HW_EVT_STATUS_T;
|
---|
1434 | AssertCompileSize(IOMMU_HW_EVT_STATUS_T, 8);
|
---|
1435 | #define IOMMU_HW_EVT_STATUS_VALID_MASK UINT64_C(0x0000000000000003)
|
---|
1436 |
|
---|
1437 | /**
|
---|
1438 | * Guest Virtual-APIC Log Base Address Register (MMIO).
|
---|
1439 | * In accordance with the AMD spec.
|
---|
1440 | */
|
---|
1441 | typedef union
|
---|
1442 | {
|
---|
1443 | struct
|
---|
1444 | {
|
---|
1445 | RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bit 11:0 - Reserved. */
|
---|
1446 | RT_GCC_EXTENSION uint64_t u40Base : 40; /**< Bits 51:12 - GALogBase: Guest Virtual-APIC Log Base Address. */
|
---|
1447 | RT_GCC_EXTENSION uint64_t u4Rsvd0 : 4; /**< Bits 55:52 - Reserved. */
|
---|
1448 | RT_GCC_EXTENSION uint64_t u4Len : 4; /**< Bits 59:56 - GALogLen: Guest Virtual-APIC Log Length. */
|
---|
1449 | RT_GCC_EXTENSION uint64_t u4Rsvd1 : 4; /**< Bits 63:60 - Reserved. */
|
---|
1450 | } n;
|
---|
1451 | /** The 64-bit unsigned integer view. */
|
---|
1452 | uint64_t u64;
|
---|
1453 | } GALOG_BAR_T;
|
---|
1454 | AssertCompileSize(GALOG_BAR_T, 8);
|
---|
1455 |
|
---|
1456 | /**
|
---|
1457 | * Guest Virtual-APIC Log Tail Address Register (MMIO).
|
---|
1458 | * In accordance with the AMD spec.
|
---|
1459 | */
|
---|
1460 | typedef union
|
---|
1461 | {
|
---|
1462 | struct
|
---|
1463 | {
|
---|
1464 | RT_GCC_EXTENSION uint64_t u3Rsvd0 : 3; /**< Bits 2:0 - Reserved. */
|
---|
1465 | RT_GCC_EXTENSION uint64_t u40GALogTailAddr : 48; /**< Bits 51:3 - GATAddr: Guest Virtual-APIC Tail Log Address. */
|
---|
1466 | RT_GCC_EXTENSION uint64_t u11Rsvd1 : 11; /**< Bits 63:52 - Reserved. */
|
---|
1467 | } n;
|
---|
1468 | /** The 64-bit unsigned integer view. */
|
---|
1469 | uint64_t u64;
|
---|
1470 | } GALOG_TAIL_ADDR_T;
|
---|
1471 | AssertCompileSize(GALOG_TAIL_ADDR_T, 8);
|
---|
1472 |
|
---|
1473 | /**
|
---|
1474 | * PPR Log B Base Address Register (MMIO).
|
---|
1475 | * In accordance with the AMD spec.
|
---|
1476 | * Currently identical to PPR_LOG_BAR_T.
|
---|
1477 | */
|
---|
1478 | typedef PPR_LOG_BAR_T PPR_LOG_B_BAR_T;
|
---|
1479 |
|
---|
1480 | /**
|
---|
1481 | * Event Log B Base Address Register (MMIO).
|
---|
1482 | * In accordance with the AMD spec.
|
---|
1483 | * Currently identical to EVT_LOG_BAR_T.
|
---|
1484 | */
|
---|
1485 | typedef EVT_LOG_BAR_T EVT_LOG_B_BAR_T;
|
---|
1486 |
|
---|
1487 | /**
|
---|
1488 | * Device-specific Feature Extension (DSFX) Register (MMIO).
|
---|
1489 | * In accordance with the AMD spec.
|
---|
1490 | */
|
---|
1491 | typedef union
|
---|
1492 | {
|
---|
1493 | struct
|
---|
1494 | {
|
---|
1495 | uint32_t u24DevSpecFeat : 24; /**< Bits 23:0 - DevSpecificFeatSupp: Implementation specific features. */
|
---|
1496 | uint32_t u4RevMinor : 4; /**< Bits 27:24 - RevMinor: Minor revision identifier. */
|
---|
1497 | uint32_t u4RevMajor : 4; /**< Bits 31:28 - RevMajor: Major revision identifier. */
|
---|
1498 | uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved.*/
|
---|
1499 | } n;
|
---|
1500 | /** The 64-bit unsigned integer view. */
|
---|
1501 | uint64_t u64;
|
---|
1502 | } DEV_SPECIFIC_FEAT_T;
|
---|
1503 | AssertCompileSize(DEV_SPECIFIC_FEAT_T, 8);
|
---|
1504 |
|
---|
1505 | /**
|
---|
1506 | * Device-specific Control Extension (DSCX) Register (MMIO).
|
---|
1507 | * In accordance with the AMD spec.
|
---|
1508 | */
|
---|
1509 | typedef union
|
---|
1510 | {
|
---|
1511 | struct
|
---|
1512 | {
|
---|
1513 | uint32_t u24DevSpecCtrl : 24; /**< Bits 23:0 - DevSpecificFeatCntrl: Implementation specific control. */
|
---|
1514 | uint32_t u4RevMinor : 4; /**< Bits 27:24 - RevMinor: Minor revision identifier. */
|
---|
1515 | uint32_t u4RevMajor : 4; /**< Bits 31:28 - RevMajor: Major revision identifier. */
|
---|
1516 | uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved.*/
|
---|
1517 | } n;
|
---|
1518 | /** The 64-bit unsigned integer view. */
|
---|
1519 | uint64_t u64;
|
---|
1520 | } DEV_SPECIFIC_CTRL_T;
|
---|
1521 | AssertCompileSize(DEV_SPECIFIC_CTRL_T, 8);
|
---|
1522 |
|
---|
1523 | /**
|
---|
1524 | * Device-specific Status Extension (DSSX) Register (MMIO).
|
---|
1525 | * In accordance with the AMD spec.
|
---|
1526 | */
|
---|
1527 | typedef union
|
---|
1528 | {
|
---|
1529 | struct
|
---|
1530 | {
|
---|
1531 | uint32_t u24DevSpecStatus : 24; /**< Bits 23:0 - DevSpecificFeatStatus: Implementation specific status. */
|
---|
1532 | uint32_t u4RevMinor : 4; /**< Bits 27:24 - RevMinor: Minor revision identifier. */
|
---|
1533 | uint32_t u4RevMajor : 4; /**< Bits 31:28 - RevMajor: Major revision identifier. */
|
---|
1534 | uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved.*/
|
---|
1535 | } n;
|
---|
1536 | /** The 64-bit unsigned integer view. */
|
---|
1537 | uint64_t u64;
|
---|
1538 | } DEV_SPECIFIC_STATUS_T;
|
---|
1539 | AssertCompileSize(DEV_SPECIFIC_STATUS_T, 8);
|
---|
1540 |
|
---|
1541 | /**
|
---|
1542 | * MSI Information Register 0 and 1 (PCI) / MSI Vector Register 0 and 1 (MMIO).
|
---|
1543 | * In accordance with the AMD spec.
|
---|
1544 | */
|
---|
1545 | typedef union
|
---|
1546 | {
|
---|
1547 | struct
|
---|
1548 | {
|
---|
1549 | uint32_t u5MsiNumEvtLog : 5; /**< Bits 4:0 - MsiNum: Event Log MSI message number. */
|
---|
1550 | uint32_t u3GstVirtAddrSize: 3; /**< Bits 7:5 - GVAsize: Guest Virtual Address Size. */
|
---|
1551 | uint32_t u7PhysAddrSize : 7; /**< Bits 14:8 - PAsize: Physical Address Size. */
|
---|
1552 | uint32_t u7VirtAddrSize : 7; /**< Bits 21:15 - VAsize: Virtual Address Size. */
|
---|
1553 | uint32_t u1HtAtsResv: 1; /**< Bit 22 - HtAtsResv: HyperTransport ATS Response Address range Reserved. */
|
---|
1554 | uint32_t u4Rsvd0 : 4; /**< Bits 26:23 - Reserved. */
|
---|
1555 | uint32_t u5MsiNumPpr : 5; /**< Bits 31:27 - MsiNumPPR: Peripheral Page Request MSI message number. */
|
---|
1556 | uint32_t u5MsiNumGa : 5; /**< Bits 36:32 - MsiNumGa: MSI message number for guest virtual-APIC log. */
|
---|
1557 | uint32_t u27Rsvd0: 27; /**< Bits 63:37 - Reserved. */
|
---|
1558 | } n;
|
---|
1559 | /** The 32-bit unsigned integer view. */
|
---|
1560 | uint32_t au32[2];
|
---|
1561 | /** The 64-bit unsigned integer view. */
|
---|
1562 | uint64_t u64;
|
---|
1563 | } MSI_MISC_INFO_T;
|
---|
1564 | AssertCompileSize(MSI_MISC_INFO_T, 8);
|
---|
1565 | /** MSI Vector Register 0 and 1 (MMIO). */
|
---|
1566 | typedef MSI_MISC_INFO_T MSI_VECTOR_T;
|
---|
1567 |
|
---|
1568 | /**
|
---|
1569 | * MSI Capability Header Register (PCI + MMIO).
|
---|
1570 | * In accordance with the AMD spec.
|
---|
1571 | */
|
---|
1572 | typedef union
|
---|
1573 | {
|
---|
1574 | struct
|
---|
1575 | {
|
---|
1576 | uint32_t u8MsiCapId : 8; /**< Bits 7:0 - MsiCapId: Capability ID. */
|
---|
1577 | uint32_t u8MsiCapPtr : 8; /**< Bits 15:8 - MsiCapPtr: Pointer (PCI config offset) to the next capability. */
|
---|
1578 | uint32_t u1MsiEnable : 1; /**< Bit 16 - MsiEn: Message Signal Interrupt Enable. */
|
---|
1579 | uint32_t u3MsiMultiMessCap : 3; /**< Bits 19:17 - MsiMultMessCap: MSI Multi-Message Capability. */
|
---|
1580 | uint32_t u3MsiMultiMessEn : 3; /**< Bits 22:20 - MsiMultMessEn: MSI Multi-Message Enable. */
|
---|
1581 | uint32_t u1Msi64BitEn : 1; /**< Bit 23 - Msi64BitEn: MSI 64-bit Enable. */
|
---|
1582 | uint32_t u8Rsvd0 : 8; /**< Bits 31:24 - Reserved. */
|
---|
1583 | } n;
|
---|
1584 | /** The 32-bit unsigned integer view. */
|
---|
1585 | uint32_t u32;
|
---|
1586 | } MSI_CAP_HDR_T;
|
---|
1587 | AssertCompileSize(MSI_CAP_HDR_T, 4);
|
---|
1588 | #define IOMMU_MSI_CAP_HDR_MSI_EN_MASK RT_BIT(16)
|
---|
1589 |
|
---|
1590 | /**
|
---|
1591 | * MSI Address Register (PCI + MMIO).
|
---|
1592 | * In accordance with the AMD spec.
|
---|
1593 | */
|
---|
1594 | typedef union
|
---|
1595 | {
|
---|
1596 | struct
|
---|
1597 | {
|
---|
1598 | RT_GCC_EXTENSION uint64_t u2Rsvd : 2; /**< Bits 1:0 - Reserved. */
|
---|
1599 | RT_GCC_EXTENSION uint64_t u62MsiAddr : 62; /**< Bits 31:2 - MsiAddr: MSI Address. */
|
---|
1600 | } n;
|
---|
1601 | /** The 32-bit unsigned integer view. */
|
---|
1602 | uint32_t au32[2];
|
---|
1603 | /** The 64-bit unsigned integer view. */
|
---|
1604 | uint64_t u64;
|
---|
1605 | } MSI_ADDR_T;
|
---|
1606 | AssertCompileSize(MSI_ADDR_T, 8);
|
---|
1607 | #define IOMMU_MSI_ADDR_VALID_MASK UINT64_C(0xfffffffffffffffc)
|
---|
1608 |
|
---|
1609 | /**
|
---|
1610 | * MSI Data Register (PCI + MMIO).
|
---|
1611 | * In accordance with the AMD spec.
|
---|
1612 | */
|
---|
1613 | typedef union
|
---|
1614 | {
|
---|
1615 | struct
|
---|
1616 | {
|
---|
1617 | uint16_t u16MsiData; /**< Bits 15:0 - MsiData: MSI Data. */
|
---|
1618 | uint16_t u16Rsvd0; /**< Bits 31:16 - Reserved. */
|
---|
1619 | } n;
|
---|
1620 | /** The 32-bit unsigned integer view. */
|
---|
1621 | uint32_t u32;
|
---|
1622 | } MSI_DATA_T;
|
---|
1623 | AssertCompileSize(MSI_DATA_T, 4);
|
---|
1624 | #define IOMMU_MSI_DATA_VALID_MASK UINT64_C(0x000000000000ffff)
|
---|
1625 |
|
---|
1626 | /**
|
---|
1627 | * MSI Mapping Capability Header Register (PCI + MMIO).
|
---|
1628 | * In accordance with the AMD spec.
|
---|
1629 | */
|
---|
1630 | typedef union
|
---|
1631 | {
|
---|
1632 | struct
|
---|
1633 | {
|
---|
1634 | uint32_t u8MsiMapCapId : 8; /**< Bits 7:0 - MsiMapCapId: MSI Map capability ID. */
|
---|
1635 | uint32_t u8Rsvd0 : 8; /**< Bits 15:8 - Reserved. */
|
---|
1636 | uint32_t u1MsiMapEn : 1; /**< Bit 16 - MsiMapEn: MSI Map enable. */
|
---|
1637 | uint32_t u1MsiMapFixed : 1; /**< Bit 17 - MsiMapFixd: MSI Map fixed. */
|
---|
1638 | uint32_t u9Rsvd0 : 9; /**< Bits 26:18 - Reserved. */
|
---|
1639 | uint32_t u5MapCapType : 5; /**< Bits 31:27 - MsiMapCapType: MSI Mapping capability type. */
|
---|
1640 | } n;
|
---|
1641 | /** The 32-bit unsigned integer view. */
|
---|
1642 | uint32_t u32;
|
---|
1643 | } MSI_MAP_CAP_HDR_T;
|
---|
1644 | AssertCompileSize(MSI_MAP_CAP_HDR_T, 4);
|
---|
1645 |
|
---|
1646 | /**
|
---|
1647 | * Performance Optimization Control Register (MMIO).
|
---|
1648 | * In accordance with the AMD spec.
|
---|
1649 | */
|
---|
1650 | typedef union
|
---|
1651 | {
|
---|
1652 | struct
|
---|
1653 | {
|
---|
1654 | uint32_t u13Rsvd0 : 13; /**< Bits 12:0 - Reserved. */
|
---|
1655 | uint32_t u1PerfOptEn : 1; /**< Bit 13 - PerfOptEn: Performance Optimization Enable. */
|
---|
1656 | uint32_t u17Rsvd0 : 18; /**< Bits 31:14 - Reserved. */
|
---|
1657 | } n;
|
---|
1658 | /** The 32-bit unsigned integer view. */
|
---|
1659 | uint32_t u32;
|
---|
1660 | } IOMMU_PERF_OPT_CTRL_T;
|
---|
1661 | AssertCompileSize(IOMMU_PERF_OPT_CTRL_T, 4);
|
---|
1662 |
|
---|
1663 | /**
|
---|
1664 | * XT (x2APIC) IOMMU General Interrupt Control Register (MMIO).
|
---|
1665 | * In accordance with the AMD spec.
|
---|
1666 | */
|
---|
1667 | typedef union
|
---|
1668 | {
|
---|
1669 | struct
|
---|
1670 | {
|
---|
1671 | uint32_t u2Rsvd0 : 2; /**< Bits 1:0 - Reserved.*/
|
---|
1672 | uint32_t u1X2ApicIntrDstMode : 1; /**< Bit 2 - Destination Mode for general interrupt.*/
|
---|
1673 | uint32_t u4Rsvd0 : 4; /**< Bits 7:3 - Reserved.*/
|
---|
1674 | uint32_t u24X2ApicIntrDstLo : 24; /**< Bits 31:8 - Destination for general interrupt (Lo).*/
|
---|
1675 | uint32_t u8X2ApicIntrVector : 8; /**< Bits 39:32 - Vector for general interrupt.*/
|
---|
1676 | uint32_t u1X2ApicIntrDeliveryMode : 1; /**< Bit 40 - Delivery Mode for general interrupt.*/
|
---|
1677 | uint32_t u15Rsvd0 : 15; /**< Bits 55:41 - Reserved.*/
|
---|
1678 | uint32_t u7X2ApicIntrDstHi : 7; /**< Bits 63:56 - Destination for general interrupt (Hi) .*/
|
---|
1679 | } n;
|
---|
1680 | /** The 64-bit unsigned integer view. */
|
---|
1681 | uint64_t u64;
|
---|
1682 | } IOMMU_XT_GEN_INTR_CTRL_T;
|
---|
1683 | AssertCompileSize(IOMMU_XT_GEN_INTR_CTRL_T, 8);
|
---|
1684 |
|
---|
1685 | /**
|
---|
1686 | * XT (x2APIC) IOMMU General Interrupt Control Register (MMIO).
|
---|
1687 | * In accordance with the AMD spec.
|
---|
1688 | */
|
---|
1689 | typedef union
|
---|
1690 | {
|
---|
1691 | struct
|
---|
1692 | {
|
---|
1693 | uint32_t u2Rsvd0 : 2; /**< Bits 1:0 - Reserved.*/
|
---|
1694 | uint32_t u1X2ApicIntrDstMode : 1; /**< Bit 2 - Destination Mode for the interrupt.*/
|
---|
1695 | uint32_t u4Rsvd0 : 4; /**< Bits 7:3 - Reserved.*/
|
---|
1696 | uint32_t u24X2ApicIntrDstLo : 24; /**< Bits 31:8 - Destination for the interrupt (Lo).*/
|
---|
1697 | uint32_t u8X2ApicIntrVector : 8; /**< Bits 39:32 - Vector for the interrupt.*/
|
---|
1698 | uint32_t u1X2ApicIntrDeliveryMode : 1; /**< Bit 40 - Delivery Mode for the interrupt.*/
|
---|
1699 | uint32_t u15Rsvd0 : 15; /**< Bits 55:41 - Reserved.*/
|
---|
1700 | uint32_t u7X2ApicIntrDstHi : 7; /**< Bits 63:56 - Destination for the interrupt (Hi) .*/
|
---|
1701 | } n;
|
---|
1702 | /** The 64-bit unsigned integer view. */
|
---|
1703 | uint64_t u64;
|
---|
1704 | } IOMMU_XT_INTR_CTRL_T;
|
---|
1705 | AssertCompileSize(IOMMU_XT_INTR_CTRL_T, 8);
|
---|
1706 |
|
---|
1707 | /**
|
---|
1708 | * XT (x2APIC) IOMMU PPR Interrupt Control Register (MMIO).
|
---|
1709 | * In accordance with the AMD spec.
|
---|
1710 | * Currently identical to IOMMU_XT_INTR_CTRL_T.
|
---|
1711 | */
|
---|
1712 | typedef IOMMU_XT_INTR_CTRL_T IOMMU_XT_PPR_INTR_CTRL_T;
|
---|
1713 |
|
---|
1714 | /**
|
---|
1715 | * XT (x2APIC) IOMMU GA (Guest Address) Log Control Register (MMIO).
|
---|
1716 | * In accordance with the AMD spec.
|
---|
1717 | * Currently identical to IOMMU_XT_INTR_CTRL_T.
|
---|
1718 | */
|
---|
1719 | typedef IOMMU_XT_INTR_CTRL_T IOMMU_XT_GALOG_INTR_CTRL_T;
|
---|
1720 |
|
---|
1721 | /**
|
---|
1722 | * Memory Access and Routing Control (MARC) Aperture Base Register (MMIO).
|
---|
1723 | * In accordance with the AMD spec.
|
---|
1724 | */
|
---|
1725 | typedef union
|
---|
1726 | {
|
---|
1727 | struct
|
---|
1728 | {
|
---|
1729 | RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 11:0 - Reserved. */
|
---|
1730 | RT_GCC_EXTENSION uint64_t u40MarcBaseAddr : 40; /**< Bits 51:12 - MarcBaseAddr: MARC Aperture Base Address. */
|
---|
1731 | RT_GCC_EXTENSION uint64_t u12Rsvd1 : 12; /**< Bits 63:52 - Reserved. */
|
---|
1732 | } n;
|
---|
1733 | /** The 64-bit unsigned integer view. */
|
---|
1734 | uint64_t u64;
|
---|
1735 | } MARC_APER_BAR_T;
|
---|
1736 | AssertCompileSize(MARC_APER_BAR_T, 8);
|
---|
1737 |
|
---|
1738 | /**
|
---|
1739 | * Memory Access and Routing Control (MARC) Relocation Register (MMIO).
|
---|
1740 | * In accordance with the AMD spec.
|
---|
1741 | */
|
---|
1742 | typedef union
|
---|
1743 | {
|
---|
1744 | struct
|
---|
1745 | {
|
---|
1746 | RT_GCC_EXTENSION uint64_t u1RelocEn : 1; /**< Bit 0 - RelocEn: Relocation Enabled. */
|
---|
1747 | RT_GCC_EXTENSION uint64_t u1ReadOnly : 1; /**< Bit 1 - ReadOnly: Whether only read-only acceses allowed. */
|
---|
1748 | RT_GCC_EXTENSION uint64_t u10Rsvd0 : 10; /**< Bits 11:2 - Reserved. */
|
---|
1749 | RT_GCC_EXTENSION uint64_t u40MarcRelocAddr : 40; /**< Bits 51:12 - MarcRelocAddr: MARC Aperture Relocation Address. */
|
---|
1750 | RT_GCC_EXTENSION uint64_t u12Rsvd1 : 12; /**< Bits 63:52 - Reserved. */
|
---|
1751 | } n;
|
---|
1752 | /** The 64-bit unsigned integer view. */
|
---|
1753 | uint64_t u64;
|
---|
1754 | } MARC_APER_RELOC_T;
|
---|
1755 | AssertCompileSize(MARC_APER_RELOC_T, 8);
|
---|
1756 |
|
---|
1757 | /**
|
---|
1758 | * Memory Access and Routing Control (MARC) Length Register (MMIO).
|
---|
1759 | * In accordance with the AMD spec.
|
---|
1760 | */
|
---|
1761 | typedef union
|
---|
1762 | {
|
---|
1763 | struct
|
---|
1764 | {
|
---|
1765 | RT_GCC_EXTENSION uint64_t u12Rsvd0 : 12; /**< Bits 11:0 - Reserved. */
|
---|
1766 | RT_GCC_EXTENSION uint64_t u40MarcLength : 40; /**< Bits 51:12 - MarcLength: MARC Aperture Length. */
|
---|
1767 | RT_GCC_EXTENSION uint64_t u12Rsvd1 : 12; /**< Bits 63:52 - Reserved. */
|
---|
1768 | } n;
|
---|
1769 | /** The 64-bit unsigned integer view. */
|
---|
1770 | uint64_t u64;
|
---|
1771 | } MARC_APER_LEN_T;
|
---|
1772 |
|
---|
1773 | /**
|
---|
1774 | * Memory Access and Routing Control (MARC) Aperture Register.
|
---|
1775 | * This combines other registers to match the MMIO layout for convenient access.
|
---|
1776 | */
|
---|
1777 | typedef struct
|
---|
1778 | {
|
---|
1779 | MARC_APER_BAR_T Base;
|
---|
1780 | MARC_APER_RELOC_T Reloc;
|
---|
1781 | MARC_APER_LEN_T Length;
|
---|
1782 | } MARC_APER_T;
|
---|
1783 | AssertCompileSize(MARC_APER_T, 24);
|
---|
1784 |
|
---|
1785 | /**
|
---|
1786 | * IOMMU Reserved Register (MMIO).
|
---|
1787 | * In accordance with the AMD spec.
|
---|
1788 | * This register is reserved for hardware use (although RW?).
|
---|
1789 | */
|
---|
1790 | typedef uint64_t IOMMU_RSVD_REG_T;
|
---|
1791 |
|
---|
1792 | /**
|
---|
1793 | * Command Buffer Head Pointer Register (MMIO).
|
---|
1794 | * In accordance with the AMD spec.
|
---|
1795 | */
|
---|
1796 | typedef union
|
---|
1797 | {
|
---|
1798 | struct
|
---|
1799 | {
|
---|
1800 | uint32_t off; /**< Bits 31:0 - Buffer pointer (offset; 16 byte aligned, 512 KB max). */
|
---|
1801 | uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved. */
|
---|
1802 | } n;
|
---|
1803 | /** The 32-bit unsigned integer view. */
|
---|
1804 | uint32_t au32[2];
|
---|
1805 | /** The 64-bit unsigned integer view. */
|
---|
1806 | uint64_t u64;
|
---|
1807 | } CMD_BUF_HEAD_PTR_T;
|
---|
1808 | AssertCompileSize(CMD_BUF_HEAD_PTR_T, 8);
|
---|
1809 | #define IOMMU_CMD_BUF_HEAD_PTR_VALID_MASK UINT64_C(0x000000000007fff0)
|
---|
1810 |
|
---|
1811 | /**
|
---|
1812 | * Command Buffer Tail Pointer Register (MMIO).
|
---|
1813 | * In accordance with the AMD spec.
|
---|
1814 | * Currently identical to CMD_BUF_HEAD_PTR_T.
|
---|
1815 | */
|
---|
1816 | typedef CMD_BUF_HEAD_PTR_T CMD_BUF_TAIL_PTR_T;
|
---|
1817 | #define IOMMU_CMD_BUF_TAIL_PTR_VALID_MASK IOMMU_CMD_BUF_HEAD_PTR_VALID_MASK
|
---|
1818 |
|
---|
1819 | /**
|
---|
1820 | * Event Log Head Pointer Register (MMIO).
|
---|
1821 | * In accordance with the AMD spec.
|
---|
1822 | * Currently identical to CMD_BUF_HEAD_PTR_T.
|
---|
1823 | */
|
---|
1824 | typedef CMD_BUF_HEAD_PTR_T EVT_LOG_HEAD_PTR_T;
|
---|
1825 | #define IOMMU_EVT_LOG_HEAD_PTR_VALID_MASK IOMMU_CMD_BUF_HEAD_PTR_VALID_MASK
|
---|
1826 |
|
---|
1827 | /**
|
---|
1828 | * Event Log Tail Pointer Register (MMIO).
|
---|
1829 | * In accordance with the AMD spec.
|
---|
1830 | * Currently identical to CMD_BUF_HEAD_PTR_T.
|
---|
1831 | */
|
---|
1832 | typedef CMD_BUF_HEAD_PTR_T EVT_LOG_TAIL_PTR_T;
|
---|
1833 | #define IOMMU_EVT_LOG_TAIL_PTR_VALID_MASK IOMMU_CMD_BUF_HEAD_PTR_VALID_MASK
|
---|
1834 |
|
---|
1835 |
|
---|
1836 | /**
|
---|
1837 | * IOMMU Status Register (MMIO).
|
---|
1838 | * In accordance with the AMD spec.
|
---|
1839 | */
|
---|
1840 | typedef union
|
---|
1841 | {
|
---|
1842 | struct
|
---|
1843 | {
|
---|
1844 | uint32_t u1EvtOverflow : 1; /**< Bit 0 - EventOverflow: Event log overflow. */
|
---|
1845 | uint32_t u1EvtLogIntr : 1; /**< Bit 1 - EventLogInt: Event log interrupt. */
|
---|
1846 | uint32_t u1CompWaitIntr : 1; /**< Bit 2 - ComWaitInt: Completion wait interrupt . */
|
---|
1847 | uint32_t u1EvtLogRunning : 1; /**< Bit 3 - EventLogRun: Event logging is running. */
|
---|
1848 | uint32_t u1CmdBufRunning : 1; /**< Bit 4 - CmdBufRun: Command buffer is running. */
|
---|
1849 | uint32_t u1PprOverflow : 1; /**< Bit 5 - PprOverflow: Peripheral Page Request Log (PPR) overflow. */
|
---|
1850 | uint32_t u1PprIntr : 1; /**< Bit 6 - PprInt: PPR interrupt. */
|
---|
1851 | uint32_t u1PprLogRunning : 1; /**< Bit 7 - PprLogRun: PPR logging is running. */
|
---|
1852 | uint32_t u1GstLogRunning : 1; /**< Bit 8 - GALogRun: Guest virtual-APIC logging is running. */
|
---|
1853 | uint32_t u1GstLogOverflow : 1; /**< Bit 9 - GALOverflow: Guest virtual-APIC log overflow. */
|
---|
1854 | uint32_t u1GstLogIntr : 1; /**< Bit 10 - GAInt: Guest virtual-APIC log interrupt. */
|
---|
1855 | uint32_t u1PprOverflowB : 1; /**< Bit 11 - PprOverflowB: PPR log B overflow. */
|
---|
1856 | uint32_t u1PprLogActive : 1; /**< Bit 12 - PprLogActive: PPR log A is active. */
|
---|
1857 | uint32_t u2Rsvd0 : 2; /**< Bits 14:13 - Reserved. */
|
---|
1858 | uint32_t u1EvtOverflowB : 1; /**< Bit 15 - EvtOverflowB: Event log B overflow. */
|
---|
1859 | uint32_t u1EvtLogActive : 1; /**< Bit 16 - EvtLogActive: Event log A active. */
|
---|
1860 | uint32_t u1PprOverflowEarlyB : 1; /**< Bit 17 - PprOverflowEarlyB: PPR log B overflow early warning. */
|
---|
1861 | uint32_t u1PprOverflowEarly : 1; /**< Bit 18 - PprOverflowEarly: PPR log overflow early warning. */
|
---|
1862 | uint32_t u13Rsvd0 : 13; /**< Bits 31:19 - Reserved. */
|
---|
1863 | uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved . */
|
---|
1864 | } n;
|
---|
1865 | /** The 32-bit unsigned integer view. */
|
---|
1866 | uint32_t au32[2];
|
---|
1867 | /** The 64-bit unsigned integer view. */
|
---|
1868 | uint64_t u64;
|
---|
1869 | } IOMMU_STATUS_T;
|
---|
1870 | AssertCompileSize(IOMMU_STATUS_T, 8);
|
---|
1871 | #define IOMMU_STATUS_VALID_MASK UINT64_C(0x0000000000079fff)
|
---|
1872 | #define IOMMU_STATUS_RW1C_MASK UINT64_C(0x0000000000068e67)
|
---|
1873 |
|
---|
1874 | /**
|
---|
1875 | * PPR Log Head Pointer Register (MMIO).
|
---|
1876 | * In accordance with the AMD spec.
|
---|
1877 | * Currently identical to CMD_BUF_HEAD_PTR_T.
|
---|
1878 | */
|
---|
1879 | typedef CMD_BUF_HEAD_PTR_T PPR_LOG_HEAD_PTR_T;
|
---|
1880 |
|
---|
1881 | /**
|
---|
1882 | * PPR Log Tail Pointer Register (MMIO).
|
---|
1883 | * In accordance with the AMD spec.
|
---|
1884 | * Currently identical to CMD_BUF_HEAD_PTR_T.
|
---|
1885 | */
|
---|
1886 | typedef CMD_BUF_HEAD_PTR_T PPR_LOG_TAIL_PTR_T;
|
---|
1887 |
|
---|
1888 | /**
|
---|
1889 | * Guest Virtual-APIC Log Head Pointer Register (MMIO).
|
---|
1890 | * In accordance with the AMD spec.
|
---|
1891 | */
|
---|
1892 | typedef union
|
---|
1893 | {
|
---|
1894 | struct
|
---|
1895 | {
|
---|
1896 | uint32_t u2Rsvd0 : 2; /**< Bits 2:0 - Reserved. */
|
---|
1897 | uint32_t u12GALogPtr : 12; /**< Bits 15:3 - Guest Virtual-APIC Log Head or Tail Pointer. */
|
---|
1898 | uint32_t u16Rsvd0 : 16; /**< Bits 31:16 - Reserved. */
|
---|
1899 | uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved. */
|
---|
1900 | } n;
|
---|
1901 | /** The 32-bit unsigned integer view. */
|
---|
1902 | uint32_t au32[2];
|
---|
1903 | /** The 64-bit unsigned integer view. */
|
---|
1904 | uint64_t u64;
|
---|
1905 | } GALOG_HEAD_PTR_T;
|
---|
1906 | AssertCompileSize(GALOG_HEAD_PTR_T, 8);
|
---|
1907 |
|
---|
1908 | /**
|
---|
1909 | * Guest Virtual-APIC Log Tail Pointer Register (MMIO).
|
---|
1910 | * In accordance with the AMD spec.
|
---|
1911 | * Currently identical to GALOG_HEAD_PTR_T.
|
---|
1912 | */
|
---|
1913 | typedef GALOG_HEAD_PTR_T GALOG_TAIL_PTR_T;
|
---|
1914 |
|
---|
1915 | /**
|
---|
1916 | * PPR Log B Head Pointer Register (MMIO).
|
---|
1917 | * In accordance with the AMD spec.
|
---|
1918 | * Currently identical to CMD_BUF_HEAD_PTR_T.
|
---|
1919 | */
|
---|
1920 | typedef CMD_BUF_HEAD_PTR_T PPR_LOG_B_HEAD_PTR_T;
|
---|
1921 |
|
---|
1922 | /**
|
---|
1923 | * PPR Log B Tail Pointer Register (MMIO).
|
---|
1924 | * In accordance with the AMD spec.
|
---|
1925 | * Currently identical to CMD_BUF_HEAD_PTR_T.
|
---|
1926 | */
|
---|
1927 | typedef CMD_BUF_HEAD_PTR_T PPR_LOG_B_TAIL_PTR_T;
|
---|
1928 |
|
---|
1929 | /**
|
---|
1930 | * Event Log B Head Pointer Register (MMIO).
|
---|
1931 | * In accordance with the AMD spec.
|
---|
1932 | * Currently identical to CMD_BUF_HEAD_PTR_T.
|
---|
1933 | */
|
---|
1934 | typedef CMD_BUF_HEAD_PTR_T EVT_LOG_B_HEAD_PTR_T;
|
---|
1935 |
|
---|
1936 | /**
|
---|
1937 | * Event Log B Tail Pointer Register (MMIO).
|
---|
1938 | * In accordance with the AMD spec.
|
---|
1939 | * Currently identical to CMD_BUF_HEAD_PTR_T.
|
---|
1940 | */
|
---|
1941 | typedef CMD_BUF_HEAD_PTR_T EVT_LOG_B_TAIL_PTR_T;
|
---|
1942 |
|
---|
1943 | /**
|
---|
1944 | * PPR Log Auto Response Register (MMIO).
|
---|
1945 | * In accordance with the AMD spec.
|
---|
1946 | */
|
---|
1947 | typedef union
|
---|
1948 | {
|
---|
1949 | struct
|
---|
1950 | {
|
---|
1951 | uint32_t u4AutoRespCode : 4; /**< Bits 3:0 - PprAutoRespCode: PPR log Auto Response Code. */
|
---|
1952 | uint32_t u1AutoRespMaskGen : 1; /**< Bit 4 - PprAutoRespMaskGn: PPR log Auto Response Mask Gen. */
|
---|
1953 | uint32_t u27Rsvd0 : 27; /**< Bits 31:5 - Reserved. */
|
---|
1954 | uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved.*/
|
---|
1955 | } n;
|
---|
1956 | /** The 32-bit unsigned integer view. */
|
---|
1957 | uint32_t au32[2];
|
---|
1958 | /** The 64-bit unsigned integer view. */
|
---|
1959 | uint64_t u64;
|
---|
1960 | } PPR_LOG_AUTO_RESP_T;
|
---|
1961 | AssertCompileSize(PPR_LOG_AUTO_RESP_T, 8);
|
---|
1962 |
|
---|
1963 | /**
|
---|
1964 | * PPR Log Overflow Early Indicator Register (MMIO).
|
---|
1965 | * In accordance with the AMD spec.
|
---|
1966 | */
|
---|
1967 | typedef union
|
---|
1968 | {
|
---|
1969 | struct
|
---|
1970 | {
|
---|
1971 | uint32_t u15Threshold : 15; /**< Bits 14:0 - PprOvrflwEarlyThreshold: Overflow early indicator threshold. */
|
---|
1972 | uint32_t u15Rsvd0 : 15; /**< Bits 29:15 - Reserved. */
|
---|
1973 | uint32_t u1IntrEn : 1; /**< Bit 30 - PprOvrflwEarlyIntEn: Overflow early indicator interrupt enable. */
|
---|
1974 | uint32_t u1Enable : 1; /**< Bit 31 - PprOvrflwEarlyEn: Overflow early indicator enable. */
|
---|
1975 | uint32_t u32Rsvd0; /**< Bits 63:32 - Reserved. */
|
---|
1976 | } n;
|
---|
1977 | /** The 32-bit unsigned integer view. */
|
---|
1978 | uint32_t au32[2];
|
---|
1979 | /** The 64-bit unsigned integer view. */
|
---|
1980 | uint64_t u64;
|
---|
1981 | } PPR_LOG_OVERFLOW_EARLY_T;
|
---|
1982 | AssertCompileSize(PPR_LOG_OVERFLOW_EARLY_T, 8);
|
---|
1983 |
|
---|
1984 | /**
|
---|
1985 | * PPR Log B Overflow Early Indicator Register (MMIO).
|
---|
1986 | * In accordance with the AMD spec.
|
---|
1987 | * Currently identical to PPR_LOG_OVERFLOW_EARLY_T.
|
---|
1988 | */
|
---|
1989 | typedef PPR_LOG_OVERFLOW_EARLY_T PPR_LOG_B_OVERFLOW_EARLY_T;
|
---|
1990 |
|
---|
1991 | /**
|
---|
1992 | * IOMMU operation types.
|
---|
1993 | */
|
---|
1994 | typedef enum IOMMUOP
|
---|
1995 | {
|
---|
1996 | /** Address translation request. */
|
---|
1997 | IOMMUOP_TRANSLATE_REQ = 0,
|
---|
1998 | /** Memory read request. */
|
---|
1999 | IOMMUOP_MEM_READ,
|
---|
2000 | /** Memory write request. */
|
---|
2001 | IOMMUOP_MEM_WRITE,
|
---|
2002 | /** Interrupt request. */
|
---|
2003 | IOMMUOP_INTR_REQ,
|
---|
2004 | /** Command request. */
|
---|
2005 | IOMMUOP_CMD
|
---|
2006 | } IOMMUOP;
|
---|
2007 | AssertCompileSize(IOMMUOP, 4);
|
---|
2008 |
|
---|
2009 |
|
---|
2010 | /**
|
---|
2011 | * The shared IOMMU device state.
|
---|
2012 | */
|
---|
2013 | typedef struct IOMMU
|
---|
2014 | {
|
---|
2015 | /** IOMMU device index (0 is at the top of the PCI tree hierarchy). */
|
---|
2016 | uint32_t idxIommu;
|
---|
2017 | /** Alignment padding. */
|
---|
2018 | uint32_t uPadding0;
|
---|
2019 | /** The event semaphore the command thread waits on. */
|
---|
2020 | SUPSEMEVENT hEvtCmdThread;
|
---|
2021 | /** The MMIO handle. */
|
---|
2022 | IOMMMIOHANDLE hMmio;
|
---|
2023 |
|
---|
2024 | /** @name PCI: Base capability block registers.
|
---|
2025 | * @{ */
|
---|
2026 | IOMMU_BAR_T IommuBar; /**< IOMMU base address register. */
|
---|
2027 | /** @} */
|
---|
2028 |
|
---|
2029 | /** @name MMIO: Control and status registers.
|
---|
2030 | * @{ */
|
---|
2031 | DEV_TAB_BAR_T aDevTabBaseAddrs[8]; /**< Device table base address registers. */
|
---|
2032 | CMD_BUF_BAR_T CmdBufBaseAddr; /**< Command buffer base address register. */
|
---|
2033 | EVT_LOG_BAR_T EvtLogBaseAddr; /**< Event log base address register. */
|
---|
2034 | IOMMU_CTRL_T Ctrl; /**< IOMMU control register. */
|
---|
2035 | IOMMU_EXCL_RANGE_BAR_T ExclRangeBaseAddr; /**< IOMMU exclusion range base register. */
|
---|
2036 | IOMMU_EXCL_RANGE_LIMIT_T ExclRangeLimit; /**< IOMMU exclusion range limit. */
|
---|
2037 | IOMMU_EXT_FEAT_T ExtFeat; /**< IOMMU extended feature register. */
|
---|
2038 | /** @} */
|
---|
2039 |
|
---|
2040 | /** @name MMIO: PPR Log registers.
|
---|
2041 | * @{ */
|
---|
2042 | PPR_LOG_BAR_T PprLogBaseAddr; /**< PPR Log base address register. */
|
---|
2043 | IOMMU_HW_EVT_HI_T HwEvtHi; /**< IOMMU hardware event register (Hi). */
|
---|
2044 | IOMMU_HW_EVT_LO_T HwEvtLo; /**< IOMMU hardware event register (Lo). */
|
---|
2045 | IOMMU_HW_EVT_STATUS_T HwEvtStatus; /**< IOMMU hardware event status. */
|
---|
2046 | /** @} */
|
---|
2047 |
|
---|
2048 | /** @todo IOMMU: SMI filter. */
|
---|
2049 |
|
---|
2050 | /** @name MMIO: Guest Virtual-APIC Log registers.
|
---|
2051 | * @{ */
|
---|
2052 | GALOG_BAR_T GALogBaseAddr; /**< Guest Virtual-APIC Log base address register. */
|
---|
2053 | GALOG_TAIL_ADDR_T GALogTailAddr; /**< Guest Virtual-APIC Log Tail address register. */
|
---|
2054 | /** @} */
|
---|
2055 |
|
---|
2056 | /** @name MMIO: Alternate PPR and Event Log registers.
|
---|
2057 | * @{ */
|
---|
2058 | PPR_LOG_B_BAR_T PprLogBBaseAddr; /**< PPR Log B base address register. */
|
---|
2059 | EVT_LOG_B_BAR_T EvtLogBBaseAddr; /**< Event Log B base address register. */
|
---|
2060 | /** @} */
|
---|
2061 |
|
---|
2062 | /** @name MMIO: Device-specific feature registers.
|
---|
2063 | * @{ */
|
---|
2064 | DEV_SPECIFIC_FEAT_T DevSpecificFeat; /**< Device-specific feature extension register (DSFX). */
|
---|
2065 | DEV_SPECIFIC_CTRL_T DevSpecificCtrl; /**< Device-specific control extension register (DSCX). */
|
---|
2066 | DEV_SPECIFIC_STATUS_T DevSpecificStatus; /**< Device-specific status extension register (DSSX). */
|
---|
2067 | /** @} */
|
---|
2068 |
|
---|
2069 | /** @name MMIO: MSI Capability Block registers.
|
---|
2070 | * @{ */
|
---|
2071 | MSI_MISC_INFO_T MsiMiscInfo; /**< MSI Misc. info registers / MSI Vector registers. */
|
---|
2072 | /** @} */
|
---|
2073 |
|
---|
2074 | /** @name MMIO: Performance Optimization Control registers.
|
---|
2075 | * @{ */
|
---|
2076 | IOMMU_PERF_OPT_CTRL_T PerfOptCtrl; /**< IOMMU Performance optimization control register. */
|
---|
2077 | /** @} */
|
---|
2078 |
|
---|
2079 | /** @name MMIO: x2APIC Control registers.
|
---|
2080 | * @{ */
|
---|
2081 | IOMMU_XT_GEN_INTR_CTRL_T XtGenIntrCtrl; /**< IOMMU X2APIC General interrupt control register. */
|
---|
2082 | IOMMU_XT_PPR_INTR_CTRL_T XtPprIntrCtrl; /**< IOMMU X2APIC PPR interrupt control register. */
|
---|
2083 | IOMMU_XT_GALOG_INTR_CTRL_T XtGALogIntrCtrl; /**< IOMMU X2APIC Guest Log interrupt control register. */
|
---|
2084 | /** @} */
|
---|
2085 |
|
---|
2086 | /** @name MMIO: MARC registers.
|
---|
2087 | * @{ */
|
---|
2088 | MARC_APER_T aMarcApers[4]; /**< MARC Aperture Registers. */
|
---|
2089 | /** @} */
|
---|
2090 |
|
---|
2091 | /** @name MMIO: Reserved register.
|
---|
2092 | * @{ */
|
---|
2093 | IOMMU_RSVD_REG_T RsvdReg; /**< IOMMU Reserved Register. */
|
---|
2094 | /** @} */
|
---|
2095 |
|
---|
2096 | /** @name MMIO: Command and Event Log pointer registers.
|
---|
2097 | * @{ */
|
---|
2098 | CMD_BUF_HEAD_PTR_T CmdBufHeadPtr; /**< Command buffer head pointer register. */
|
---|
2099 | CMD_BUF_TAIL_PTR_T CmdBufTailPtr; /**< Command buffer tail pointer register. */
|
---|
2100 | EVT_LOG_HEAD_PTR_T EvtLogHeadPtr; /**< Event log head pointer register. */
|
---|
2101 | EVT_LOG_TAIL_PTR_T EvtLogTailPtr; /**< Event log tail pointer register. */
|
---|
2102 | /** @} */
|
---|
2103 |
|
---|
2104 | /** @name MMIO: Command and Event Status register.
|
---|
2105 | * @{ */
|
---|
2106 | IOMMU_STATUS_T Status; /**< IOMMU status register. */
|
---|
2107 | /** @} */
|
---|
2108 |
|
---|
2109 | /** @name MMIO: PPR Log Head and Tail pointer registers.
|
---|
2110 | * @{ */
|
---|
2111 | PPR_LOG_HEAD_PTR_T PprLogHeadPtr; /**< IOMMU PPR log head pointer register. */
|
---|
2112 | PPR_LOG_TAIL_PTR_T PprLogTailPtr; /**< IOMMU PPR log tail pointer register. */
|
---|
2113 | /** @} */
|
---|
2114 |
|
---|
2115 | /** @name MMIO: Guest Virtual-APIC Log Head and Tail pointer registers.
|
---|
2116 | * @{ */
|
---|
2117 | GALOG_HEAD_PTR_T GALogHeadPtr; /**< Guest Virtual-APIC log head pointer register. */
|
---|
2118 | GALOG_TAIL_PTR_T GALogTailPtr; /**< Guest Virtual-APIC log tail pointer register. */
|
---|
2119 | /** @} */
|
---|
2120 |
|
---|
2121 | /** @name MMIO: PPR Log B Head and Tail pointer registers.
|
---|
2122 | * @{ */
|
---|
2123 | PPR_LOG_B_HEAD_PTR_T PprLogBHeadPtr; /**< PPR log B head pointer register. */
|
---|
2124 | PPR_LOG_B_TAIL_PTR_T PprLogBTailPtr; /**< PPR log B tail pointer register. */
|
---|
2125 | /** @} */
|
---|
2126 |
|
---|
2127 | /** @name MMIO: Event Log B Head and Tail pointer registers.
|
---|
2128 | * @{ */
|
---|
2129 | EVT_LOG_B_HEAD_PTR_T EvtLogBHeadPtr; /**< Event log B head pointer register. */
|
---|
2130 | EVT_LOG_B_TAIL_PTR_T EvtLogBTailPtr; /**< Event log B tail pointer register. */
|
---|
2131 | /** @} */
|
---|
2132 |
|
---|
2133 | /** @name MMIO: PPR Log Overflow protection registers.
|
---|
2134 | * @{ */
|
---|
2135 | PPR_LOG_AUTO_RESP_T PprLogAutoResp; /**< PPR Log Auto Response register. */
|
---|
2136 | PPR_LOG_OVERFLOW_EARLY_T PprLogOverflowEarly; /**< PPR Log Overflow Early Indicator register. */
|
---|
2137 | PPR_LOG_B_OVERFLOW_EARLY_T PprLogBOverflowEarly; /**< PPR Log B Overflow Early Indicator register. */
|
---|
2138 | /** @} */
|
---|
2139 |
|
---|
2140 | /** @todo IOMMU: IOMMU Event counter registers. */
|
---|
2141 |
|
---|
2142 | /** @todo IOMMU: Stat counters. */
|
---|
2143 | } IOMMU;
|
---|
2144 | /** Pointer to the IOMMU device state. */
|
---|
2145 | typedef struct IOMMU *PIOMMU;
|
---|
2146 | /** Pointer to the const IOMMU device state. */
|
---|
2147 | typedef const struct IOMMU *PCIOMMU;
|
---|
2148 | AssertCompileMemberAlignment(IOMMU, hEvtCmdThread, 8);
|
---|
2149 | AssertCompileMemberAlignment(IOMMU, hMmio, 8);
|
---|
2150 | AssertCompileMemberAlignment(IOMMU, IommuBar, 8);
|
---|
2151 |
|
---|
2152 |
|
---|
2153 | /**
|
---|
2154 | * The ring-3 IOMMU device state.
|
---|
2155 | */
|
---|
2156 | typedef struct IOMMUR3
|
---|
2157 | {
|
---|
2158 | /** Device instance. */
|
---|
2159 | PPDMDEVINSR3 pDevInsR3;
|
---|
2160 | /** The IOMMU helpers. */
|
---|
2161 | PCPDMIOMMUHLPR3 pIommuHlpR3;
|
---|
2162 | /** The command thread handle. */
|
---|
2163 | R3PTRTYPE(PPDMTHREAD) pCmdThread;
|
---|
2164 | } IOMMUR3;
|
---|
2165 | /** Pointer to the ring-3 IOMMU device state. */
|
---|
2166 | typedef IOMMUR3 *PIOMMUR3;
|
---|
2167 |
|
---|
2168 | /**
|
---|
2169 | * The ring-0 IOMMU device state.
|
---|
2170 | */
|
---|
2171 | typedef struct IOMMUR0
|
---|
2172 | {
|
---|
2173 | /** Device instance. */
|
---|
2174 | PPDMDEVINSR0 pDevInsR0;
|
---|
2175 | /** The IOMMU helpers. */
|
---|
2176 | PCPDMIOMMUHLPR0 pIommuHlpR0;
|
---|
2177 | } IOMMUR0;
|
---|
2178 | /** Pointer to the ring-0 IOMMU device state. */
|
---|
2179 | typedef IOMMUR0 *PIOMMUR0;
|
---|
2180 |
|
---|
2181 | /**
|
---|
2182 | * The raw-mode IOMMU device state.
|
---|
2183 | */
|
---|
2184 | typedef struct IOMMURC
|
---|
2185 | {
|
---|
2186 | /** Device instance. */
|
---|
2187 | PPDMDEVINSR0 pDevInsRC;
|
---|
2188 | /** The IOMMU helpers. */
|
---|
2189 | PCPDMIOMMUHLPRC pIommuHlpRC;
|
---|
2190 | } IOMMURC;
|
---|
2191 | /** Pointer to the raw-mode IOMMU device state. */
|
---|
2192 | typedef IOMMURC *PIOMMURC;
|
---|
2193 |
|
---|
2194 | /** The IOMMU device state for the current context. */
|
---|
2195 | typedef CTX_SUFF(IOMMU) IOMMUCC;
|
---|
2196 | /** Pointer to the IOMMU device state for the current context. */
|
---|
2197 | typedef CTX_SUFF(PIOMMU) PIOMMUCC;
|
---|
2198 |
|
---|
2199 | /**
|
---|
2200 | * IOMMU register access routines.
|
---|
2201 | */
|
---|
2202 | typedef struct
|
---|
2203 | {
|
---|
2204 | const char *pszName;
|
---|
2205 | VBOXSTRICTRC (*pfnRead )(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t *pu64Value);
|
---|
2206 | VBOXSTRICTRC (*pfnWrite)(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value);
|
---|
2207 | bool f64BitReg;
|
---|
2208 | } IOMMUREGACC;
|
---|
2209 |
|
---|
2210 |
|
---|
2211 | /*********************************************************************************************************************************
|
---|
2212 | * Global Variables *
|
---|
2213 | *********************************************************************************************************************************/
|
---|
2214 | /**
|
---|
2215 | * An array of the number of device table segments supported.
|
---|
2216 | * Indexed by u2DevTabSegSup.
|
---|
2217 | */
|
---|
2218 | static uint8_t const g_acDevTabSegs[] = { 0, 2, 4, 8 };
|
---|
2219 |
|
---|
2220 | /**
|
---|
2221 | * An array of the masks to select the device table segment index from a device ID.
|
---|
2222 | */
|
---|
2223 | static uint16_t const g_auDevTabSegMasks[] = { 0x0, 0x8000, 0xc000, 0xe000 };
|
---|
2224 |
|
---|
2225 | /**
|
---|
2226 | * The maximum size (inclusive) of each device table segment (0 to 7).
|
---|
2227 | * Indexed by the device table segment index.
|
---|
2228 | */
|
---|
2229 | static uint16_t const g_auDevTabSegMaxSizes[] = { 0x1ff, 0xff, 0x7f, 0x7f, 0x3f, 0x3f, 0x3f, 0x3f };
|
---|
2230 |
|
---|
2231 |
|
---|
2232 | #ifndef VBOX_DEVICE_STRUCT_TESTCASE
|
---|
2233 | /**
|
---|
2234 | * Gets the maximum number of buffer entries for the given buffer length.
|
---|
2235 | *
|
---|
2236 | * @returns Number of buffer entries.
|
---|
2237 | * @param uEncodedLen The length (power-of-2 encoded).
|
---|
2238 | */
|
---|
2239 | DECLINLINE(uint32_t) iommuAmdGetBufMaxEntries(uint8_t uEncodedLen)
|
---|
2240 | {
|
---|
2241 | Assert(uEncodedLen > 7);
|
---|
2242 | return 2 << (uEncodedLen - 1);
|
---|
2243 | }
|
---|
2244 |
|
---|
2245 |
|
---|
2246 | /**
|
---|
2247 | * Gets the total length of the buffer given a base register's encoded length.
|
---|
2248 | *
|
---|
2249 | * @returns The length of the buffer in bytes.
|
---|
2250 | * @param uEncodedLen The length (power-of-2 encoded).
|
---|
2251 | */
|
---|
2252 | DECLINLINE(uint32_t) iommuAmdGetBufLength(uint8_t uEncodedLen)
|
---|
2253 | {
|
---|
2254 | Assert(uEncodedLen > 7);
|
---|
2255 | return (2 << (uEncodedLen - 1)) << 4;
|
---|
2256 | }
|
---|
2257 |
|
---|
2258 |
|
---|
2259 | /**
|
---|
2260 | * Gets the number of (unconsumed) entries in the event log.
|
---|
2261 | *
|
---|
2262 | * @returns The number of entries in the event log.
|
---|
2263 | * @param pThis The IOMMU device state.
|
---|
2264 | */
|
---|
2265 | static uint32_t iommuAmdGetEvtLogEntryCount(PIOMMU pThis)
|
---|
2266 | {
|
---|
2267 | uint32_t const idxTail = pThis->EvtLogTailPtr.n.off >> IOMMU_EVT_GENERIC_SHIFT;
|
---|
2268 | uint32_t const idxHead = pThis->EvtLogHeadPtr.n.off >> IOMMU_EVT_GENERIC_SHIFT;
|
---|
2269 | if (idxTail >= idxHead)
|
---|
2270 | return idxTail - idxHead;
|
---|
2271 |
|
---|
2272 | uint32_t const cMaxEvts = iommuAmdGetBufMaxEntries(pThis->EvtLogBaseAddr.n.u4Len);
|
---|
2273 | return cMaxEvts - idxHead + idxTail;
|
---|
2274 | }
|
---|
2275 |
|
---|
2276 |
|
---|
2277 | /**
|
---|
2278 | * Gets the number of (unconsumed) commands in the command buffer.
|
---|
2279 | *
|
---|
2280 | * @returns The number of commands in the command buffer.
|
---|
2281 | * @param pThis The IOMMU device state.
|
---|
2282 | */
|
---|
2283 | static uint32_t iommuAmdGetCmdBufEntryCount(PIOMMU pThis)
|
---|
2284 | {
|
---|
2285 | uint32_t const idxTail = pThis->CmdBufTailPtr.n.off >> IOMMU_CMD_GENERIC_SHIFT;
|
---|
2286 | uint32_t const idxHead = pThis->CmdBufHeadPtr.n.off >> IOMMU_CMD_GENERIC_SHIFT;
|
---|
2287 | if (idxTail >= idxHead)
|
---|
2288 | return idxTail - idxHead;
|
---|
2289 |
|
---|
2290 | uint32_t const cMaxEvts = iommuAmdGetBufMaxEntries(pThis->CmdBufBaseAddr.n.u4Len);
|
---|
2291 | return cMaxEvts - idxHead + idxTail;
|
---|
2292 | }
|
---|
2293 |
|
---|
2294 |
|
---|
2295 | DECLINLINE(IOMMU_STATUS_T) iommuAmdGetStatus(PCIOMMU pThis)
|
---|
2296 | {
|
---|
2297 | IOMMU_STATUS_T Status;
|
---|
2298 | Status.u64 = ASMAtomicReadU64((volatile uint64_t *)&pThis->Status.u64);
|
---|
2299 | return Status;
|
---|
2300 | }
|
---|
2301 |
|
---|
2302 |
|
---|
2303 | DECLINLINE(IOMMU_CTRL_T) iommuAmdGetCtrl(PCIOMMU pThis)
|
---|
2304 | {
|
---|
2305 | IOMMU_CTRL_T Ctrl;
|
---|
2306 | Ctrl.u64 = ASMAtomicReadU64((volatile uint64_t *)&pThis->Ctrl.u64);
|
---|
2307 | return Ctrl;
|
---|
2308 | }
|
---|
2309 |
|
---|
2310 |
|
---|
2311 | /**
|
---|
2312 | * Returns whether MSI is enabled for the IOMMU.
|
---|
2313 | *
|
---|
2314 | * @returns Whether MSI is enabled.
|
---|
2315 | * @param pDevIns The IOMMU device instance.
|
---|
2316 | *
|
---|
2317 | * @note There should be a PCIDevXxx function for this.
|
---|
2318 | */
|
---|
2319 | static bool iommuAmdIsMsiEnabled(PPDMDEVINS pDevIns)
|
---|
2320 | {
|
---|
2321 | MSI_CAP_HDR_T MsiCapHdr;
|
---|
2322 | MsiCapHdr.u32 = PDMPciDevGetDWord(pDevIns->apPciDevs[0], IOMMU_PCI_OFF_MSI_CAP_HDR);
|
---|
2323 | return MsiCapHdr.n.u1MsiEnable;
|
---|
2324 | }
|
---|
2325 |
|
---|
2326 |
|
---|
2327 | /**
|
---|
2328 | * Signals a PCI target abort.
|
---|
2329 | *
|
---|
2330 | * @param pDevIns The IOMMU device instance.
|
---|
2331 | */
|
---|
2332 | static void iommuAmdSetPciTargetAbort(PPDMDEVINS pDevIns)
|
---|
2333 | {
|
---|
2334 | PPDMPCIDEV pPciDev = pDevIns->apPciDevs[0];
|
---|
2335 | uint16_t const u16Status = PDMPciDevGetStatus(pPciDev) | VBOX_PCI_STATUS_SIG_TARGET_ABORT;
|
---|
2336 | PDMPciDevSetStatus(pPciDev, u16Status);
|
---|
2337 | }
|
---|
2338 |
|
---|
2339 |
|
---|
2340 | /**
|
---|
2341 | * The IOMMU command thread.
|
---|
2342 | *
|
---|
2343 | * @returns VBox status code.
|
---|
2344 | * @param pDevIns The IOMMU device instance.
|
---|
2345 | * @param pThread The command thread.
|
---|
2346 | */
|
---|
2347 | static DECLCALLBACK(int) iommuAmdR3CmdThread(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
|
---|
2348 | {
|
---|
2349 | RT_NOREF(pDevIns, pThread);
|
---|
2350 | }
|
---|
2351 |
|
---|
2352 |
|
---|
2353 | /**
|
---|
2354 | * Unblocks the command thread so it can respond to a state change.
|
---|
2355 | *
|
---|
2356 | * @returns VBox status code.
|
---|
2357 | * @param pDevIns The IOMMU device instance.
|
---|
2358 | * @param pThread The command thread.
|
---|
2359 | */
|
---|
2360 | static DECLCALLBACK(int) iommuAmdR3CmdThreadWakeUp(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
|
---|
2361 | {
|
---|
2362 | RT_NOREF(pThread);
|
---|
2363 | PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
|
---|
2364 | return PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEvtCmdThread);
|
---|
2365 | }
|
---|
2366 |
|
---|
2367 |
|
---|
2368 | /**
|
---|
2369 | * Writes to a read-only register.
|
---|
2370 | */
|
---|
2371 | static VBOXSTRICTRC iommuAmdIgnore_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
|
---|
2372 | {
|
---|
2373 | RT_NOREF(pDevIns, pThis, iReg, u64Value);
|
---|
2374 | Log((IOMMU_LOG_PFX ": Write to read-only register (%#x) with value %#RX64 ignored\n", iReg, u64Value));
|
---|
2375 | return VINF_SUCCESS;
|
---|
2376 | }
|
---|
2377 |
|
---|
2378 |
|
---|
2379 | /**
|
---|
2380 | * Writes the Device Table Base Address Register.
|
---|
2381 | */
|
---|
2382 | static VBOXSTRICTRC iommuAmdDevTabBar_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
|
---|
2383 | {
|
---|
2384 | RT_NOREF(pDevIns, iReg);
|
---|
2385 |
|
---|
2386 | /* Mask out all unrecognized bits. */
|
---|
2387 | u64Value &= IOMMU_DEV_TAB_BAR_VALID_MASK;
|
---|
2388 |
|
---|
2389 | /* Update the register. */
|
---|
2390 | pThis->aDevTabBaseAddrs[0].u64 = u64Value;
|
---|
2391 | return VINF_SUCCESS;
|
---|
2392 | }
|
---|
2393 |
|
---|
2394 |
|
---|
2395 | /**
|
---|
2396 | * Writes the Command Buffer Base Address Register.
|
---|
2397 | */
|
---|
2398 | static VBOXSTRICTRC iommuAmdCmdBufBar_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
|
---|
2399 | {
|
---|
2400 | RT_NOREF(pDevIns, iReg);
|
---|
2401 |
|
---|
2402 | /*
|
---|
2403 | * While this is not explicitly specified like the event log base address register,
|
---|
2404 | * the AMD spec. does specify "CmdBufRun must be 0b to modify the command buffer registers properly".
|
---|
2405 | * Inconsistent specs :/
|
---|
2406 | */
|
---|
2407 | IOMMU_STATUS_T const Status = iommuAmdGetStatus(pThis);
|
---|
2408 | if (Status.n.u1CmdBufRunning)
|
---|
2409 | {
|
---|
2410 | Log((IOMMU_LOG_PFX ": Setting CmdBufBar (%#RX64) when command buffer is running -> Ignored\n", u64Value));
|
---|
2411 | return VINF_SUCCESS;
|
---|
2412 | }
|
---|
2413 |
|
---|
2414 | /* Mask out all unrecognized bits. */
|
---|
2415 | CMD_BUF_BAR_T CmdBufBaseAddr;
|
---|
2416 | CmdBufBaseAddr.u64 = u64Value & IOMMU_CMD_BUF_BAR_VALID_MASK;
|
---|
2417 |
|
---|
2418 | /* Validate the length. */
|
---|
2419 | if (CmdBufBaseAddr.n.u4Len >= 8)
|
---|
2420 | {
|
---|
2421 | /* Update the register. */
|
---|
2422 | pThis->CmdBufBaseAddr.u64 = CmdBufBaseAddr.u64;
|
---|
2423 |
|
---|
2424 | /*
|
---|
2425 | * Writing the command buffer base address, clears the command buffer head and tail pointers.
|
---|
2426 | * See AMD spec. 2.4 "Commands".
|
---|
2427 | */
|
---|
2428 | pThis->CmdBufHeadPtr.u64 = 0;
|
---|
2429 | pThis->CmdBufTailPtr.u64 = 0;
|
---|
2430 | }
|
---|
2431 | else
|
---|
2432 | Log((IOMMU_LOG_PFX ": Command buffer length (%#x) invalid -> Ignored\n", CmdBufBaseAddr.n.u4Len));
|
---|
2433 |
|
---|
2434 | return VINF_SUCCESS;
|
---|
2435 | }
|
---|
2436 |
|
---|
2437 |
|
---|
2438 | /**
|
---|
2439 | * Writes the Event Log Base Address Register.
|
---|
2440 | */
|
---|
2441 | static VBOXSTRICTRC iommuAmdEvtLogBar_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
|
---|
2442 | {
|
---|
2443 | RT_NOREF(pDevIns, iReg);
|
---|
2444 |
|
---|
2445 | /*
|
---|
2446 | * IOMMU behavior is undefined when software writes this register when event logging is running.
|
---|
2447 | * In our emulation, we ignore the write entirely.
|
---|
2448 | * See AMD IOMMU spec. "Event Log Base Address Register".
|
---|
2449 | */
|
---|
2450 | IOMMU_STATUS_T const Status = iommuAmdGetStatus(pThis);
|
---|
2451 | if (Status.n.u1EvtLogRunning)
|
---|
2452 | {
|
---|
2453 | Log((IOMMU_LOG_PFX ": Setting EvtLogBar (%#RX64) when event logging is running -> Ignored\n", u64Value));
|
---|
2454 | return VINF_SUCCESS;
|
---|
2455 | }
|
---|
2456 |
|
---|
2457 | /* Mask out all unrecognized bits. */
|
---|
2458 | u64Value &= IOMMU_EVT_LOG_BAR_VALID_MASK;
|
---|
2459 | EVT_LOG_BAR_T EvtLogBaseAddr;
|
---|
2460 | EvtLogBaseAddr.u64 = u64Value;
|
---|
2461 |
|
---|
2462 | /* Validate the length. */
|
---|
2463 | if (EvtLogBaseAddr.n.u4Len >= 8)
|
---|
2464 | {
|
---|
2465 | /* Update the register. */
|
---|
2466 | pThis->EvtLogBaseAddr.u64 = EvtLogBaseAddr.u64;
|
---|
2467 |
|
---|
2468 | /*
|
---|
2469 | * Writing the event log base address, clears the event log head and tail pointers.
|
---|
2470 | * See AMD spec. 2.5 "Event Logging".
|
---|
2471 | */
|
---|
2472 | pThis->EvtLogHeadPtr.u64 = 0;
|
---|
2473 | pThis->EvtLogTailPtr.u64 = 0;
|
---|
2474 | }
|
---|
2475 | else
|
---|
2476 | Log((IOMMU_LOG_PFX ": Event log length (%#x) invalid -> Ignored\n", EvtLogBaseAddr.n.u4Len));
|
---|
2477 |
|
---|
2478 | return VINF_SUCCESS;
|
---|
2479 | }
|
---|
2480 |
|
---|
2481 |
|
---|
2482 | /**
|
---|
2483 | * Writes the Control Register.
|
---|
2484 | */
|
---|
2485 | static VBOXSTRICTRC iommuAmdCtrl_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
|
---|
2486 | {
|
---|
2487 | RT_NOREF(pDevIns, iReg);
|
---|
2488 |
|
---|
2489 | /* Mask out all unrecognized bits. */
|
---|
2490 | u64Value &= IOMMU_CTRL_VALID_MASK;
|
---|
2491 |
|
---|
2492 | IOMMU_CTRL_T const OldCtrl = iommuAmdGetCtrl(pThis);
|
---|
2493 | IOMMU_CTRL_T NewCtrl;
|
---|
2494 | NewCtrl.u64 = u64Value;
|
---|
2495 |
|
---|
2496 | /* Enable or disable event logging when the bit transitions. */
|
---|
2497 | if (OldCtrl.n.u1EvtLogEn != NewCtrl.n.u1EvtLogEn)
|
---|
2498 | {
|
---|
2499 | if (NewCtrl.n.u1EvtLogEn)
|
---|
2500 | {
|
---|
2501 | ASMAtomicAndU64(&pThis->Status.u64, ~IOMMU_STATUS_EVT_LOG_OVERFLOW);
|
---|
2502 | ASMAtomicOrU64(&pThis->Status.u64, IOMMU_STATUS_EVT_LOG_RUNNING);
|
---|
2503 | }
|
---|
2504 | else
|
---|
2505 | ASMAtomicAndU64(&pThis->Status.u64, ~IOMMU_STATUS_EVT_LOG_RUNNING);
|
---|
2506 | }
|
---|
2507 |
|
---|
2508 | /* Update the register. */
|
---|
2509 | ASMAtomicWriteU64(&pThis->Ctrl.u64, NewCtrl.u64);
|
---|
2510 |
|
---|
2511 | /* Enable or disable command buffer processing when the bit transitions. */
|
---|
2512 | if (OldCtrl.n.u1CmdBufEn != NewCtrl.n.u1CmdBufEn)
|
---|
2513 | {
|
---|
2514 | if (NewCtrl.n.u1CmdBufEn)
|
---|
2515 | {
|
---|
2516 | ASMAtomicOrU64(&pThis->Status.u64, IOMMU_STATUS_CMD_BUF_RUNNING);
|
---|
2517 |
|
---|
2518 | /* If the command buffer isn't empty, kick the command thread to start processing commands. */
|
---|
2519 | if (pThis->CmdBufTailPtr.n.off != pThis->CmdBufHeadPtr.n.off)
|
---|
2520 | PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEvtCmdThread);
|
---|
2521 | }
|
---|
2522 | else
|
---|
2523 | {
|
---|
2524 | ASMAtomicAndU64(&pThis->Status.u64, ~IOMMU_STATUS_CMD_BUF_RUNNING);
|
---|
2525 | /* Kick the command thread to stop processing commands. */
|
---|
2526 | PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEvtCmdThread);
|
---|
2527 | }
|
---|
2528 | }
|
---|
2529 | }
|
---|
2530 |
|
---|
2531 |
|
---|
2532 | /**
|
---|
2533 | * Writes to the Excluse Range Base Address Register.
|
---|
2534 | */
|
---|
2535 | static VBOXSTRICTRC iommuAmdExclRangeBar_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
|
---|
2536 | {
|
---|
2537 | RT_NOREF(pDevIns, iReg);
|
---|
2538 | pThis->ExclRangeBaseAddr.u64 = u64Value & IOMMU_EXCL_RANGE_BAR_VALID_MASK;
|
---|
2539 | return VINF_SUCCESS;
|
---|
2540 | }
|
---|
2541 |
|
---|
2542 |
|
---|
2543 | /**
|
---|
2544 | * Writes to the Excluse Range Limit Register.
|
---|
2545 | */
|
---|
2546 | static VBOXSTRICTRC iommuAmdExclRangeLimit_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
|
---|
2547 | {
|
---|
2548 | RT_NOREF(pDevIns, iReg);
|
---|
2549 | u64Value &= IOMMU_EXCL_RANGE_LIMIT_VALID_MASK;
|
---|
2550 | u64Value |= UINT64_C(0xfff);
|
---|
2551 | pThis->ExclRangeLimit.u64 = u64Value;
|
---|
2552 | return VINF_SUCCESS;
|
---|
2553 | }
|
---|
2554 |
|
---|
2555 |
|
---|
2556 | /**
|
---|
2557 | * Writes the Hardware Event Register (Hi).
|
---|
2558 | */
|
---|
2559 | static VBOXSTRICTRC iommuAmdHwEvtHi_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
|
---|
2560 | {
|
---|
2561 | /** @todo IOMMU: Why the heck is this marked read/write by the AMD IOMMU spec? */
|
---|
2562 | RT_NOREF(pDevIns, iReg);
|
---|
2563 | Log((IOMMU_LOG_PFX ": Writing %#RX64 to hardware event (Hi) register!\n", u64Value));
|
---|
2564 | pThis->HwEvtHi.u64 = u64Value;
|
---|
2565 | return VINF_SUCCESS;
|
---|
2566 | }
|
---|
2567 |
|
---|
2568 |
|
---|
2569 | /**
|
---|
2570 | * Writes the Hardware Event Register (Lo).
|
---|
2571 | */
|
---|
2572 | static VBOXSTRICTRC iommuAmdHwEvtLo_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
|
---|
2573 | {
|
---|
2574 | /** @todo IOMMU: Why the heck is this marked read/write by the AMD IOMMU spec? */
|
---|
2575 | RT_NOREF(pDevIns, iReg);
|
---|
2576 | Log((IOMMU_LOG_PFX ": Writing %#RX64 to hardware event (Lo) register!\n", u64Value));
|
---|
2577 | pThis->HwEvtLo = u64Value;
|
---|
2578 | return VINF_SUCCESS;
|
---|
2579 | }
|
---|
2580 |
|
---|
2581 |
|
---|
2582 | /**
|
---|
2583 | * Writes the Hardware Event Status Register.
|
---|
2584 | */
|
---|
2585 | static VBOXSTRICTRC iommuAmdHwEvtStatus_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
|
---|
2586 | {
|
---|
2587 | RT_NOREF(pDevIns, iReg);
|
---|
2588 |
|
---|
2589 | /* Mask out all unrecognized bits. */
|
---|
2590 | u64Value &= IOMMU_HW_EVT_STATUS_VALID_MASK;
|
---|
2591 |
|
---|
2592 | /*
|
---|
2593 | * The two bits (HEO and HEV) are RW1C (Read/Write 1-to-Clear; writing 0 has no effect).
|
---|
2594 | * If the current status bits or the bits being written are both 0, we've nothing to do.
|
---|
2595 | * The Overflow bit (bit 1) is only valid when the Valid bit (bit 0) is 1.
|
---|
2596 | */
|
---|
2597 | uint64_t HwStatus = pThis->HwEvtStatus.u64;
|
---|
2598 | if (!(HwStatus & RT_BIT(0)))
|
---|
2599 | return VINF_SUCCESS;
|
---|
2600 | if (u64Value & HwStatus & RT_BIT_64(0))
|
---|
2601 | HwStatus &= ~RT_BIT_64(0);
|
---|
2602 | if (u64Value & HwStatus & RT_BIT_64(1))
|
---|
2603 | HwStatus &= ~RT_BIT_64(1);
|
---|
2604 |
|
---|
2605 | /* Update the register. */
|
---|
2606 | pThis->HwEvtStatus.u64 = HwStatus;
|
---|
2607 | return VINF_SUCCESS;
|
---|
2608 | }
|
---|
2609 |
|
---|
2610 |
|
---|
2611 | /**
|
---|
2612 | * Writes the Device Table Segment Base Address Register.
|
---|
2613 | */
|
---|
2614 | static VBOXSTRICTRC iommuAmdDevTabSegBar_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
|
---|
2615 | {
|
---|
2616 | RT_NOREF(pDevIns);
|
---|
2617 |
|
---|
2618 | /* Figure out which segment is being written. */
|
---|
2619 | uint8_t const offSegment = (iReg - IOMMU_MMIO_OFF_DEV_TAB_SEG_FIRST) >> 3;
|
---|
2620 | uint8_t const idxSegment = offSegment + 1;
|
---|
2621 | Assert(idxSegment < RT_ELEMENTS(pThis->aDevTabBaseAddrs));
|
---|
2622 |
|
---|
2623 | /* Mask out all unrecognized bits. */
|
---|
2624 | u64Value &= IOMMU_DEV_TAB_SEG_BAR_VALID_MASK;
|
---|
2625 | DEV_TAB_BAR_T DevTabSegBar;
|
---|
2626 | DevTabSegBar.u64 = u64Value;
|
---|
2627 |
|
---|
2628 | /* Validate the size. */
|
---|
2629 | uint16_t const uSegSize = DevTabSegBar.n.u9Size;
|
---|
2630 | uint16_t const uMaxSegSize = g_auDevTabSegMaxSizes[idxSegment];
|
---|
2631 | if (uSegSize <= uMaxSegSize)
|
---|
2632 | {
|
---|
2633 | /* Update the register. */
|
---|
2634 | pThis->aDevTabBaseAddrs[idxSegment].u64 = u64Value;
|
---|
2635 | }
|
---|
2636 | else
|
---|
2637 | Log((IOMMU_LOG_PFX ": Device table segment (%u) size invalid (%#RX32) -> Ignored\n", idxSegment, uSegSize));
|
---|
2638 |
|
---|
2639 | return VINF_SUCCESS;
|
---|
2640 | }
|
---|
2641 |
|
---|
2642 |
|
---|
2643 | /**
|
---|
2644 | * Writes the MSI Capability Header Register.
|
---|
2645 | */
|
---|
2646 | static VBOXSTRICTRC iommuAmdMsiCapHdr_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
|
---|
2647 | {
|
---|
2648 | RT_NOREF(pThis, iReg);
|
---|
2649 | PPDMPCIDEV pPciDev = pDevIns->apPciDevs[0];
|
---|
2650 | PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev);
|
---|
2651 | MSI_CAP_HDR_T MsiCapHdr;
|
---|
2652 | MsiCapHdr.u32 = PDMPciDevGetDWord(pPciDev, IOMMU_PCI_OFF_MSI_CAP_HDR);
|
---|
2653 | MsiCapHdr.n.u1MsiEnable = RT_BOOL(u64Value & IOMMU_MSI_CAP_HDR_MSI_EN_MASK);
|
---|
2654 | PDMPciDevSetDWord(pPciDev, IOMMU_PCI_OFF_MSI_CAP_HDR, MsiCapHdr.u32);
|
---|
2655 | return VINF_SUCCESS;
|
---|
2656 | }
|
---|
2657 |
|
---|
2658 |
|
---|
2659 | /**
|
---|
2660 | * Writes the MSI Address (Lo) Register (32-bit).
|
---|
2661 | */
|
---|
2662 | static VBOXSTRICTRC iommuAmdMsiAddrLo_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
|
---|
2663 | {
|
---|
2664 | RT_NOREF(pThis, iReg);
|
---|
2665 | Assert(!RT_HI_U32(u64Value));
|
---|
2666 | PPDMPCIDEV pPciDev = pDevIns->apPciDevs[0];
|
---|
2667 | PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev);
|
---|
2668 | PDMPciDevSetDWord(pPciDev, IOMMU_PCI_OFF_MSI_ADDR_LO, u64Value & IOMMU_MSI_ADDR_VALID_MASK);
|
---|
2669 | return VINF_SUCCESS;
|
---|
2670 | }
|
---|
2671 |
|
---|
2672 |
|
---|
2673 | /**
|
---|
2674 | * Writes the MSI Address (Hi) Register (32-bit).
|
---|
2675 | */
|
---|
2676 | static VBOXSTRICTRC iommuAmdMsiAddrHi_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
|
---|
2677 | {
|
---|
2678 | RT_NOREF(pThis, iReg);
|
---|
2679 | Assert(!RT_HI_U32(u64Value));
|
---|
2680 | PPDMPCIDEV pPciDev = pDevIns->apPciDevs[0];
|
---|
2681 | PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev);
|
---|
2682 | PDMPciDevSetDWord(pPciDev, IOMMU_PCI_OFF_MSI_ADDR_HI, u64Value);
|
---|
2683 | return VINF_SUCCESS;
|
---|
2684 | }
|
---|
2685 |
|
---|
2686 |
|
---|
2687 | /**
|
---|
2688 | * Writes the MSI Data Register (32-bit).
|
---|
2689 | */
|
---|
2690 | static VBOXSTRICTRC iommuAmdMsiData_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
|
---|
2691 | {
|
---|
2692 | RT_NOREF(pThis, iReg);
|
---|
2693 | PPDMPCIDEV pPciDev = pDevIns->apPciDevs[0];
|
---|
2694 | PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev);
|
---|
2695 | PDMPciDevSetDWord(pPciDev, IOMMU_PCI_OFF_MSI_DATA, u64Value & IOMMU_MSI_DATA_VALID_MASK);
|
---|
2696 | return VINF_SUCCESS;
|
---|
2697 | }
|
---|
2698 |
|
---|
2699 |
|
---|
2700 | /**
|
---|
2701 | * Writes the Command Buffer Head Pointer Register (32-bit).
|
---|
2702 | */
|
---|
2703 | static VBOXSTRICTRC iommuAmdCmdBufHeadPtr_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
|
---|
2704 | {
|
---|
2705 | RT_NOREF(pDevIns, iReg);
|
---|
2706 |
|
---|
2707 | /*
|
---|
2708 | * IOMMU behavior is undefined when software writes this register when the command buffer is running.
|
---|
2709 | * In our emulation, we ignore the write entirely.
|
---|
2710 | * See AMD IOMMU spec. 3.3.13 "Command and Event Log Pointer Registers".
|
---|
2711 | */
|
---|
2712 | IOMMU_STATUS_T const Status = iommuAmdGetStatus(pThis);
|
---|
2713 | if (Status.n.u1CmdBufRunning)
|
---|
2714 | {
|
---|
2715 | Log((IOMMU_LOG_PFX ": Setting CmdBufHeadPtr (%#RX64) when command buffer is running -> Ignored\n", u64Value));
|
---|
2716 | return VINF_SUCCESS;
|
---|
2717 | }
|
---|
2718 |
|
---|
2719 | /*
|
---|
2720 | * IOMMU behavior is undefined when software writes a value outside the buffer length.
|
---|
2721 | * In our emulation, we ignore the write entirely.
|
---|
2722 | */
|
---|
2723 | uint32_t const offBuf = u64Value & IOMMU_CMD_BUF_HEAD_PTR_VALID_MASK;
|
---|
2724 | uint32_t const cbBuf = iommuAmdGetBufLength(pThis->CmdBufBaseAddr.n.u4Len);
|
---|
2725 | Assert(cbBuf <= _512K);
|
---|
2726 | if (offBuf >= cbBuf)
|
---|
2727 | {
|
---|
2728 | Log((IOMMU_LOG_PFX ": Setting CmdBufHeadPtr (%#RX32) to a value that exceeds buffer length (%#RX23) -> Ignored\n",
|
---|
2729 | offBuf, cbBuf));
|
---|
2730 | return VINF_SUCCESS;
|
---|
2731 | }
|
---|
2732 |
|
---|
2733 | /* Update the register. */
|
---|
2734 | pThis->CmdBufHeadPtr.au32[0] = offBuf;
|
---|
2735 |
|
---|
2736 | LogFlow((IOMMU_LOG_PFX ": Set CmdBufHeadPtr to %#RX32\n", offBuf));
|
---|
2737 | return VINF_SUCCESS;
|
---|
2738 | }
|
---|
2739 |
|
---|
2740 |
|
---|
2741 | /**
|
---|
2742 | * Writes the Command Buffer Tail Pointer Register (32-bit).
|
---|
2743 | */
|
---|
2744 | static VBOXSTRICTRC iommuAmdCmdBufTailPtr_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
|
---|
2745 | {
|
---|
2746 | RT_NOREF(pDevIns, iReg);
|
---|
2747 |
|
---|
2748 | /*
|
---|
2749 | * IOMMU behavior is undefined when software writes a value outside the buffer length.
|
---|
2750 | * In our emulation, we ignore the write entirely.
|
---|
2751 | * See AMD IOMMU spec. 3.3.13 "Command and Event Log Pointer Registers".
|
---|
2752 | */
|
---|
2753 | uint32_t const offBuf = u64Value & IOMMU_CMD_BUF_TAIL_PTR_VALID_MASK;
|
---|
2754 | uint32_t const cbBuf = iommuAmdGetBufLength(pThis->CmdBufBaseAddr.n.u4Len);
|
---|
2755 | Assert(cbBuf <= _512K);
|
---|
2756 | if (offBuf >= cbBuf)
|
---|
2757 | {
|
---|
2758 | Log((IOMMU_LOG_PFX ": Setting CmdBufTailPtr (%#RX32) to a value that exceeds buffer length (%#RX32) -> Ignored\n",
|
---|
2759 | offBuf, cbBuf));
|
---|
2760 | return VINF_SUCCESS;
|
---|
2761 | }
|
---|
2762 |
|
---|
2763 | /*
|
---|
2764 | * IOMMU behavior is undefined if software advances the tail pointer equal to or beyond the
|
---|
2765 | * head pointer after adding one or more commands to the buffer.
|
---|
2766 | *
|
---|
2767 | * However, we cannot enforce this strictly because it's legal for software to shrink the
|
---|
2768 | * command queue (by reducing the offset) as well as wrap around the pointer (when head isn't
|
---|
2769 | * at 0). Software might even make the queue empty by making head and tail equal which is
|
---|
2770 | * allowed. I don't think we can or should try too hard to prevent software shooting itself
|
---|
2771 | * in the foot here. As long as we make sure the offset value is within the circular buffer
|
---|
2772 | * bounds (which we do by masking bits above) it should be sufficient.
|
---|
2773 | */
|
---|
2774 | pThis->CmdBufTailPtr.au32[0] = offBuf;
|
---|
2775 |
|
---|
2776 | LogFlow((IOMMU_LOG_PFX ": Set CmdBufTailPtr to %#RX32\n", offBuf));
|
---|
2777 | return VINF_SUCCESS;
|
---|
2778 | }
|
---|
2779 |
|
---|
2780 |
|
---|
2781 | /**
|
---|
2782 | * Writes the Event Log Head Pointer Register (32-bit).
|
---|
2783 | */
|
---|
2784 | static VBOXSTRICTRC iommuAmdEvtLogHeadPtr_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
|
---|
2785 | {
|
---|
2786 | RT_NOREF(pDevIns, iReg);
|
---|
2787 |
|
---|
2788 | /*
|
---|
2789 | * IOMMU behavior is undefined when software writes a value outside the buffer length.
|
---|
2790 | * In our emulation, we ignore the write entirely.
|
---|
2791 | * See AMD IOMMU spec. 3.3.13 "Command and Event Log Pointer Registers".
|
---|
2792 | */
|
---|
2793 | uint32_t const offBuf = u64Value & IOMMU_EVT_LOG_HEAD_PTR_VALID_MASK;
|
---|
2794 | uint32_t const cbBuf = iommuAmdGetBufLength(pThis->EvtLogBaseAddr.n.u4Len);
|
---|
2795 | Assert(cbBuf <= _512K);
|
---|
2796 | if (offBuf >= cbBuf)
|
---|
2797 | {
|
---|
2798 | Log((IOMMU_LOG_PFX ": Setting EvtLogHeadPtr (%#RX32) to a value that exceeds buffer length (%#RX32) -> Ignored\n",
|
---|
2799 | offBuf, cbBuf));
|
---|
2800 | return VINF_SUCCESS;
|
---|
2801 | }
|
---|
2802 |
|
---|
2803 | /* Update the register. */
|
---|
2804 | pThis->EvtLogHeadPtr.au32[0] = offBuf;
|
---|
2805 |
|
---|
2806 | LogFlow((IOMMU_LOG_PFX ": Set EvtLogHeadPtr to %#RX32\n", offBuf));
|
---|
2807 | return VINF_SUCCESS;
|
---|
2808 | }
|
---|
2809 |
|
---|
2810 |
|
---|
2811 | /**
|
---|
2812 | * Writes the Event Log Tail Pointer Register (32-bit).
|
---|
2813 | */
|
---|
2814 | static VBOXSTRICTRC iommuAmdEvtLogTailPtr_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
|
---|
2815 | {
|
---|
2816 | RT_NOREF(pDevIns, iReg);
|
---|
2817 | NOREF(pThis);
|
---|
2818 |
|
---|
2819 | /*
|
---|
2820 | * IOMMU behavior is undefined when software writes this register when the event log is running.
|
---|
2821 | * In our emulation, we ignore the write entirely.
|
---|
2822 | * See AMD IOMMU spec. 3.3.13 "Command and Event Log Pointer Registers".
|
---|
2823 | */
|
---|
2824 | IOMMU_STATUS_T const Status = iommuAmdGetStatus(pThis);
|
---|
2825 | if (Status.n.u1EvtLogRunning)
|
---|
2826 | {
|
---|
2827 | Log((IOMMU_LOG_PFX ": Setting EvtLogTailPtr (%#RX64) when event log is running -> Ignored\n", u64Value));
|
---|
2828 | return VINF_SUCCESS;
|
---|
2829 | }
|
---|
2830 |
|
---|
2831 | /*
|
---|
2832 | * IOMMU behavior is undefined when software writes a value outside the buffer length.
|
---|
2833 | * In our emulation, we ignore the write entirely.
|
---|
2834 | */
|
---|
2835 | uint32_t const offBuf = u64Value & IOMMU_EVT_LOG_TAIL_PTR_VALID_MASK;
|
---|
2836 | uint32_t const cbBuf = iommuAmdGetBufLength(pThis->EvtLogBaseAddr.n.u4Len);
|
---|
2837 | Assert(cbBuf <= _512K);
|
---|
2838 | if (offBuf >= cbBuf)
|
---|
2839 | {
|
---|
2840 | Log((IOMMU_LOG_PFX ": Setting EvtLogTailPtr (%#RX32) to a value that exceeds buffer length (%#RX32) -> Ignored\n",
|
---|
2841 | offBuf, cbBuf));
|
---|
2842 | return VINF_SUCCESS;
|
---|
2843 | }
|
---|
2844 |
|
---|
2845 | /* Update the register. */
|
---|
2846 | pThis->EvtLogTailPtr.au32[0] = offBuf;
|
---|
2847 |
|
---|
2848 | LogFlow((IOMMU_LOG_PFX ": Set EvtLogTailPtr to %#RX32\n", offBuf));
|
---|
2849 | return VINF_SUCCESS;
|
---|
2850 | }
|
---|
2851 |
|
---|
2852 |
|
---|
2853 | /**
|
---|
2854 | * Writes the Status Register (64-bit).
|
---|
2855 | */
|
---|
2856 | static VBOXSTRICTRC iommuAmdStatus_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
|
---|
2857 | {
|
---|
2858 | RT_NOREF(pDevIns, iReg);
|
---|
2859 |
|
---|
2860 | /* Mask out all unrecognized bits. */
|
---|
2861 | u64Value &= IOMMU_STATUS_VALID_MASK;
|
---|
2862 |
|
---|
2863 | /*
|
---|
2864 | * Compute RW1C (read-only, write-1-to-clear) bits and preserve the rest (which are read-only).
|
---|
2865 | * Writing 0 to an RW1C bit has no effect. Writing 1 to an RW1C bit, clears the bit if it's already 1.
|
---|
2866 | */
|
---|
2867 | IOMMU_STATUS_T const OldStatus = iommuAmdGetStatus(pThis);
|
---|
2868 | uint64_t const fOldRw1cBits = (OldStatus.u64 & IOMMU_STATUS_RW1C_MASK);
|
---|
2869 | uint64_t const fOldRoBits = (OldStatus.u64 & ~IOMMU_STATUS_RW1C_MASK);
|
---|
2870 | uint64_t const fNewRw1cBits = (u64Value & IOMMU_STATUS_RW1C_MASK);
|
---|
2871 |
|
---|
2872 | uint64_t const uNewStatus = (fOldRw1cBits & ~fNewRw1cBits) | fOldRoBits;
|
---|
2873 |
|
---|
2874 | /* Update the register. */
|
---|
2875 | ASMAtomicWriteU64(&pThis->Status.u64, uNewStatus);
|
---|
2876 | return VINF_SUCCESS;
|
---|
2877 | }
|
---|
2878 |
|
---|
2879 |
|
---|
2880 | #if 0
|
---|
2881 | /**
|
---|
2882 | * Table 0: Registers-access table.
|
---|
2883 | */
|
---|
2884 | static const IOMMUREGACC g_aTable0Regs[] =
|
---|
2885 | {
|
---|
2886 |
|
---|
2887 | };
|
---|
2888 |
|
---|
2889 | /**
|
---|
2890 | * Table 1: Registers-access table.
|
---|
2891 | */
|
---|
2892 | static const IOMMUREGACC g_aTable1Regs[] =
|
---|
2893 | {
|
---|
2894 | };
|
---|
2895 | #endif
|
---|
2896 |
|
---|
2897 |
|
---|
2898 | /**
|
---|
2899 | * Writes an IOMMU register (32-bit and 64-bit).
|
---|
2900 | *
|
---|
2901 | * @returns Strict VBox status code.
|
---|
2902 | * @param pDevIns The IOMMU device instance.
|
---|
2903 | * @param off MMIO byte offset to the register.
|
---|
2904 | * @param cb The size of the write access.
|
---|
2905 | * @param uValue The value being written.
|
---|
2906 | */
|
---|
2907 | static VBOXSTRICTRC iommuAmdWriteRegister(PPDMDEVINS pDevIns, uint32_t off, uint8_t cb, uint64_t uValue)
|
---|
2908 | {
|
---|
2909 | Assert(off < IOMMU_MMIO_REGION_SIZE);
|
---|
2910 | Assert(cb == 4 || cb == 8);
|
---|
2911 | Assert(!(off & (cb - 1)));
|
---|
2912 |
|
---|
2913 | PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
|
---|
2914 | switch (off)
|
---|
2915 | {
|
---|
2916 | case IOMMU_MMIO_OFF_DEV_TAB_BAR: return iommuAmdDevTabBar_w(pDevIns, pThis, off, uValue);
|
---|
2917 | case IOMMU_MMIO_OFF_CMD_BUF_BAR: return iommuAmdCmdBufBar_w(pDevIns, pThis, off, uValue);
|
---|
2918 | case IOMMU_MMIO_OFF_EVT_LOG_BAR: return iommuAmdEvtLogBar_w(pDevIns, pThis, off, uValue);
|
---|
2919 | case IOMMU_MMIO_OFF_CTRL: return iommuAmdCtrl_w(pDevIns, pThis, off, uValue);
|
---|
2920 | case IOMMU_MMIO_OFF_EXCL_BAR: return iommuAmdExclRangeBar_w(pDevIns, pThis, off, uValue);
|
---|
2921 | case IOMMU_MMIO_OFF_EXCL_RANGE_LIMIT: return iommuAmdExclRangeLimit_w(pDevIns, pThis, off, uValue);
|
---|
2922 | case IOMMU_MMIO_OFF_EXT_FEAT: return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
|
---|
2923 |
|
---|
2924 | case IOMMU_MMIO_OFF_PPR_LOG_BAR: return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
|
---|
2925 | case IOMMU_MMIO_OFF_HW_EVT_HI: return iommuAmdHwEvtHi_w(pDevIns, pThis, off, uValue);
|
---|
2926 | case IOMMU_MMIO_OFF_HW_EVT_LO: return iommuAmdHwEvtLo_w(pDevIns, pThis, off, uValue);
|
---|
2927 | case IOMMU_MMIO_OFF_HW_EVT_STATUS: return iommuAmdHwEvtStatus_w(pDevIns, pThis, off, uValue);
|
---|
2928 |
|
---|
2929 | case IOMMU_MMIO_OFF_GALOG_BAR:
|
---|
2930 | case IOMMU_MMIO_OFF_GALOG_TAIL_ADDR: return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
|
---|
2931 |
|
---|
2932 | case IOMMU_MMIO_OFF_PPR_LOG_B_BAR:
|
---|
2933 | case IOMMU_MMIO_OFF_PPR_EVT_B_BAR: return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
|
---|
2934 |
|
---|
2935 | case IOMMU_MMIO_OFF_DEV_TAB_SEG_1:
|
---|
2936 | case IOMMU_MMIO_OFF_DEV_TAB_SEG_2:
|
---|
2937 | case IOMMU_MMIO_OFF_DEV_TAB_SEG_3:
|
---|
2938 | case IOMMU_MMIO_OFF_DEV_TAB_SEG_4:
|
---|
2939 | case IOMMU_MMIO_OFF_DEV_TAB_SEG_5:
|
---|
2940 | case IOMMU_MMIO_OFF_DEV_TAB_SEG_6:
|
---|
2941 | case IOMMU_MMIO_OFF_DEV_TAB_SEG_7: return iommuAmdDevTabSegBar_w(pDevIns, pThis, off, uValue);
|
---|
2942 |
|
---|
2943 | case IOMMU_MMIO_OFF_DEV_SPECIFIC_FEAT:
|
---|
2944 | case IOMMU_MMIO_OFF_DEV_SPECIFIC_CTRL:
|
---|
2945 | case IOMMU_MMIO_OFF_DEV_SPECIFIC_STATUS: return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
|
---|
2946 |
|
---|
2947 | case IOMMU_MMIO_OFF_MSI_VECTOR_0:
|
---|
2948 | case IOMMU_MMIO_OFF_MSI_VECTOR_1: return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
|
---|
2949 | case IOMMU_MMIO_OFF_MSI_CAP_HDR:
|
---|
2950 | {
|
---|
2951 | VBOXSTRICTRC rcStrict = iommuAmdMsiCapHdr_w(pDevIns, pThis, off, (uint32_t)uValue);
|
---|
2952 | if (cb == 4 || RT_FAILURE(rcStrict))
|
---|
2953 | return rcStrict;
|
---|
2954 | uValue >>= 32;
|
---|
2955 | RT_FALL_THRU();
|
---|
2956 | }
|
---|
2957 | case IOMMU_MMIO_OFF_MSI_ADDR_LO: return iommuAmdMsiAddrLo_w(pDevIns, pThis, off, uValue);
|
---|
2958 | case IOMMU_MMIO_OFF_MSI_ADDR_HI:
|
---|
2959 | {
|
---|
2960 | VBOXSTRICTRC rcStrict = iommuAmdMsiAddrHi_w(pDevIns, pThis, off, (uint32_t)uValue);
|
---|
2961 | if (cb == 4 || RT_FAILURE(rcStrict))
|
---|
2962 | return rcStrict;
|
---|
2963 | uValue >>= 32;
|
---|
2964 | RT_FALL_THRU();
|
---|
2965 | }
|
---|
2966 | case IOMMU_MMIO_OFF_MSI_DATA: return iommuAmdMsiData_w(pDevIns, pThis, off, uValue);
|
---|
2967 | case IOMMU_MMIO_OFF_MSI_MAPPING_CAP_HDR: return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
|
---|
2968 |
|
---|
2969 | case IOMMU_MMIO_OFF_PERF_OPT_CTRL: return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
|
---|
2970 |
|
---|
2971 | case IOMMU_MMIO_OFF_XT_GEN_INTR_CTRL:
|
---|
2972 | case IOMMU_MMIO_OFF_XT_PPR_INTR_CTRL:
|
---|
2973 | case IOMMU_MMIO_OFF_XT_GALOG_INT_CTRL: return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
|
---|
2974 |
|
---|
2975 | case IOMMU_MMIO_OFF_MARC_APER_BAR_0:
|
---|
2976 | case IOMMU_MMIO_OFF_MARC_APER_RELOC_0:
|
---|
2977 | case IOMMU_MMIO_OFF_MARC_APER_LEN_0:
|
---|
2978 | case IOMMU_MMIO_OFF_MARC_APER_BAR_1:
|
---|
2979 | case IOMMU_MMIO_OFF_MARC_APER_RELOC_1:
|
---|
2980 | case IOMMU_MMIO_OFF_MARC_APER_LEN_1:
|
---|
2981 | case IOMMU_MMIO_OFF_MARC_APER_BAR_2:
|
---|
2982 | case IOMMU_MMIO_OFF_MARC_APER_RELOC_2:
|
---|
2983 | case IOMMU_MMIO_OFF_MARC_APER_LEN_2:
|
---|
2984 | case IOMMU_MMIO_OFF_MARC_APER_BAR_3:
|
---|
2985 | case IOMMU_MMIO_OFF_MARC_APER_RELOC_3:
|
---|
2986 | case IOMMU_MMIO_OFF_MARC_APER_LEN_3: return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
|
---|
2987 |
|
---|
2988 | case IOMMU_MMIO_OFF_RSVD_REG: return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
|
---|
2989 |
|
---|
2990 | case IOMMU_MMIO_CMD_BUF_HEAD_PTR: return iommuAmdCmdBufHeadPtr_w(pDevIns, pThis, off, uValue);
|
---|
2991 | case IOMMU_MMIO_CMD_BUF_TAIL_PTR: return iommuAmdCmdBufTailPtr_w(pDevIns, pThis, off, uValue);
|
---|
2992 | case IOMMU_MMIO_EVT_LOG_HEAD_PTR: return iommuAmdEvtLogHeadPtr_w(pDevIns, pThis, off, uValue);
|
---|
2993 | case IOMMU_MMIO_EVT_LOG_TAIL_PTR: return iommuAmdEvtLogTailPtr_w(pDevIns, pThis, off, uValue);
|
---|
2994 |
|
---|
2995 | case IOMMU_MMIO_OFF_STATUS: return iommuAmdStatus_w(pDevIns, pThis, off, uValue);
|
---|
2996 |
|
---|
2997 | case IOMMU_MMIO_OFF_PPR_LOG_HEAD_PTR:
|
---|
2998 | case IOMMU_MMIO_OFF_PPR_LOG_TAIL_PTR:
|
---|
2999 |
|
---|
3000 | case IOMMU_MMIO_OFF_GALOG_HEAD_PTR:
|
---|
3001 | case IOMMU_MMIO_OFF_GALOG_TAIL_PTR:
|
---|
3002 |
|
---|
3003 | case IOMMU_MMIO_OFF_PPR_LOG_B_HEAD_PTR:
|
---|
3004 | case IOMMU_MMIO_OFF_PPR_LOG_B_TAIL_PTR:
|
---|
3005 |
|
---|
3006 | case IOMMU_MMIO_OFF_EVT_LOG_B_HEAD_PTR:
|
---|
3007 | case IOMMU_MMIO_OFF_EVT_LOG_B_TAIL_PTR: return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
|
---|
3008 |
|
---|
3009 | case IOMMU_MMIO_OFF_PPR_LOG_AUTO_RESP:
|
---|
3010 | case IOMMU_MMIO_OFF_PPR_LOG_OVERFLOW_EARLY:
|
---|
3011 | case IOMMU_MMIO_OFF_PPR_LOG_B_OVERFLOW_EARLY:
|
---|
3012 |
|
---|
3013 | /* Not implemented. */
|
---|
3014 | case IOMMU_MMIO_OFF_SMI_FLT_FIRST:
|
---|
3015 | case IOMMU_MMIO_OFF_SMI_FLT_LAST:
|
---|
3016 | {
|
---|
3017 | Log((IOMMU_LOG_PFX ": Writing unsupported register: SMI filter %u -> Ignored\n",
|
---|
3018 | (off - IOMMU_MMIO_OFF_SMI_FLT_FIRST) >> 3));
|
---|
3019 | return VINF_SUCCESS;
|
---|
3020 | }
|
---|
3021 |
|
---|
3022 | /* Unknown. */
|
---|
3023 | default:
|
---|
3024 | {
|
---|
3025 | Log((IOMMU_LOG_PFX ": Writing unknown register %u (%#x) with %#RX64 -> Ignored\n", off, off, uValue));
|
---|
3026 | return VINF_SUCCESS;
|
---|
3027 | }
|
---|
3028 | }
|
---|
3029 | }
|
---|
3030 |
|
---|
3031 |
|
---|
3032 | /**
|
---|
3033 | * Reads an IOMMU register (64-bit) given its MMIO offset.
|
---|
3034 | *
|
---|
3035 | * All reads are 64-bit but reads to 32-bit registers that are aligned on an 8-byte
|
---|
3036 | * boundary include the lower half of the subsequent register.
|
---|
3037 | *
|
---|
3038 | * This is because most registers are 64-bit and aligned on 8-byte boundaries but
|
---|
3039 | * some are really 32-bit registers aligned on an 8-byte boundary. We cannot assume
|
---|
3040 | * software will only perform 32-bit reads on those 32-bit registers that are
|
---|
3041 | * aligned on 8-byte boundaries.
|
---|
3042 | *
|
---|
3043 | * @returns Strict VBox status code.
|
---|
3044 | * @param pDevIns The IOMMU device instance.
|
---|
3045 | * @param off The MMIO offset of the register in bytes.
|
---|
3046 | * @param puResult Where to store the value being read.
|
---|
3047 | */
|
---|
3048 | static VBOXSTRICTRC iommuAmdReadRegister(PPDMDEVINS pDevIns, uint32_t off, uint64_t *puResult)
|
---|
3049 | {
|
---|
3050 | Assert(off < IOMMU_MMIO_REGION_SIZE);
|
---|
3051 | Assert(!(off & 7) || !(off & 3));
|
---|
3052 |
|
---|
3053 | PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
|
---|
3054 | PPDMPCIDEV pPciDev = pDevIns->apPciDevs[0];
|
---|
3055 | PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev);
|
---|
3056 |
|
---|
3057 | /** @todo IOMMU: fine-grained locking? */
|
---|
3058 | uint64_t uReg;
|
---|
3059 | switch (off)
|
---|
3060 | {
|
---|
3061 | case IOMMU_MMIO_OFF_DEV_TAB_BAR: uReg = pThis->aDevTabBaseAddrs[0].u64; break;
|
---|
3062 | case IOMMU_MMIO_OFF_CMD_BUF_BAR: uReg = pThis->CmdBufBaseAddr.u64; break;
|
---|
3063 | case IOMMU_MMIO_OFF_EVT_LOG_BAR: uReg = pThis->EvtLogBaseAddr.u64; break;
|
---|
3064 | case IOMMU_MMIO_OFF_CTRL: uReg = pThis->Ctrl.u64; break;
|
---|
3065 | case IOMMU_MMIO_OFF_EXCL_BAR: uReg = pThis->ExclRangeBaseAddr.u64; break;
|
---|
3066 | case IOMMU_MMIO_OFF_EXCL_RANGE_LIMIT: uReg = pThis->ExclRangeLimit.u64; break;
|
---|
3067 | case IOMMU_MMIO_OFF_EXT_FEAT: uReg = pThis->ExtFeat.u64; break;
|
---|
3068 |
|
---|
3069 | case IOMMU_MMIO_OFF_PPR_LOG_BAR: uReg = pThis->PprLogBaseAddr.u64; break;
|
---|
3070 | case IOMMU_MMIO_OFF_HW_EVT_HI: uReg = pThis->HwEvtHi.u64; break;
|
---|
3071 | case IOMMU_MMIO_OFF_HW_EVT_LO: uReg = pThis->HwEvtLo; break;
|
---|
3072 | case IOMMU_MMIO_OFF_HW_EVT_STATUS: uReg = pThis->HwEvtStatus.u64; break;
|
---|
3073 |
|
---|
3074 | case IOMMU_MMIO_OFF_GALOG_BAR: uReg = pThis->GALogBaseAddr.u64; break;
|
---|
3075 | case IOMMU_MMIO_OFF_GALOG_TAIL_ADDR: uReg = pThis->GALogTailAddr.u64; break;
|
---|
3076 |
|
---|
3077 | case IOMMU_MMIO_OFF_PPR_LOG_B_BAR: uReg = pThis->PprLogBBaseAddr.u64; break;
|
---|
3078 | case IOMMU_MMIO_OFF_PPR_EVT_B_BAR: uReg = pThis->EvtLogBBaseAddr.u64; break;
|
---|
3079 |
|
---|
3080 | case IOMMU_MMIO_OFF_DEV_TAB_SEG_1:
|
---|
3081 | case IOMMU_MMIO_OFF_DEV_TAB_SEG_2:
|
---|
3082 | case IOMMU_MMIO_OFF_DEV_TAB_SEG_3:
|
---|
3083 | case IOMMU_MMIO_OFF_DEV_TAB_SEG_4:
|
---|
3084 | case IOMMU_MMIO_OFF_DEV_TAB_SEG_5:
|
---|
3085 | case IOMMU_MMIO_OFF_DEV_TAB_SEG_6:
|
---|
3086 | case IOMMU_MMIO_OFF_DEV_TAB_SEG_7:
|
---|
3087 | {
|
---|
3088 | uint8_t const offDevTabSeg = (off - IOMMU_MMIO_OFF_DEV_TAB_SEG_FIRST) >> 3;
|
---|
3089 | uint8_t const idxDevTabSeg = offDevTabSeg + 1;
|
---|
3090 | Assert(idxDevTabSeg < RT_ELEMENTS(pThis->aDevTabBaseAddrs));
|
---|
3091 | uReg = pThis->aDevTabBaseAddrs[idxDevTabSeg].u64;
|
---|
3092 | break;
|
---|
3093 | }
|
---|
3094 |
|
---|
3095 | case IOMMU_MMIO_OFF_DEV_SPECIFIC_FEAT: uReg = pThis->DevSpecificFeat.u64; break;
|
---|
3096 | case IOMMU_MMIO_OFF_DEV_SPECIFIC_CTRL: uReg = pThis->DevSpecificCtrl.u64; break;
|
---|
3097 | case IOMMU_MMIO_OFF_DEV_SPECIFIC_STATUS: uReg = pThis->DevSpecificStatus.u64; break;
|
---|
3098 |
|
---|
3099 | case IOMMU_MMIO_OFF_MSI_VECTOR_0: uReg = pThis->MsiMiscInfo.u64; break;
|
---|
3100 | case IOMMU_MMIO_OFF_MSI_VECTOR_1: uReg = pThis->MsiMiscInfo.au32[1]; break;
|
---|
3101 | case IOMMU_MMIO_OFF_MSI_CAP_HDR:
|
---|
3102 | {
|
---|
3103 | uint32_t const uMsiCapHdr = PDMPciDevGetDWord(pPciDev, IOMMU_PCI_OFF_MSI_CAP_HDR);
|
---|
3104 | uint32_t const uMsiAddrLo = PDMPciDevGetDWord(pPciDev, IOMMU_PCI_OFF_MSI_ADDR_LO);
|
---|
3105 | uReg = RT_MAKE_U64(uMsiCapHdr, uMsiAddrLo);
|
---|
3106 | break;
|
---|
3107 | }
|
---|
3108 | case IOMMU_MMIO_OFF_MSI_ADDR_LO:
|
---|
3109 | {
|
---|
3110 | uReg = PDMPciDevGetDWord(pPciDev, IOMMU_PCI_OFF_MSI_ADDR_LO);
|
---|
3111 | break;
|
---|
3112 | }
|
---|
3113 | case IOMMU_MMIO_OFF_MSI_ADDR_HI:
|
---|
3114 | {
|
---|
3115 | uint32_t const uMsiAddrHi = PDMPciDevGetDWord(pPciDev, IOMMU_PCI_OFF_MSI_ADDR_HI);
|
---|
3116 | uint32_t const uMsiData = PDMPciDevGetDWord(pPciDev, IOMMU_PCI_OFF_MSI_DATA);
|
---|
3117 | uReg = RT_MAKE_U64(uMsiAddrHi, uMsiData);
|
---|
3118 | break;
|
---|
3119 | }
|
---|
3120 | case IOMMU_MMIO_OFF_MSI_DATA:
|
---|
3121 | {
|
---|
3122 | uReg = PDMPciDevGetDWord(pPciDev, IOMMU_PCI_OFF_MSI_DATA);
|
---|
3123 | break;
|
---|
3124 | }
|
---|
3125 | case IOMMU_MMIO_OFF_MSI_MAPPING_CAP_HDR:
|
---|
3126 | {
|
---|
3127 | /*
|
---|
3128 | * The PCI spec. lists MSI Mapping Capability 08H as related to HyperTransport capability.
|
---|
3129 | * The AMD IOMMU spec. fails to mention it explicitly and lists values for this register as
|
---|
3130 | * though HyperTransport is supported. We don't support HyperTransport, we thus just return
|
---|
3131 | * 0 for this register.
|
---|
3132 | */
|
---|
3133 | uReg = RT_MAKE_U64(0, pThis->PerfOptCtrl.u32);
|
---|
3134 | break;
|
---|
3135 | }
|
---|
3136 |
|
---|
3137 | case IOMMU_MMIO_OFF_PERF_OPT_CTRL: uReg = pThis->PerfOptCtrl.u32; break;
|
---|
3138 |
|
---|
3139 | case IOMMU_MMIO_OFF_XT_GEN_INTR_CTRL: uReg = pThis->XtGenIntrCtrl.u64; break;
|
---|
3140 | case IOMMU_MMIO_OFF_XT_PPR_INTR_CTRL: uReg = pThis->XtPprIntrCtrl.u64; break;
|
---|
3141 | case IOMMU_MMIO_OFF_XT_GALOG_INT_CTRL: uReg = pThis->XtGALogIntrCtrl.u64; break;
|
---|
3142 |
|
---|
3143 | case IOMMU_MMIO_OFF_MARC_APER_BAR_0: uReg = pThis->aMarcApers[0].Base.u64; break;
|
---|
3144 | case IOMMU_MMIO_OFF_MARC_APER_RELOC_0: uReg = pThis->aMarcApers[0].Reloc.u64; break;
|
---|
3145 | case IOMMU_MMIO_OFF_MARC_APER_LEN_0: uReg = pThis->aMarcApers[0].Length.u64; break;
|
---|
3146 | case IOMMU_MMIO_OFF_MARC_APER_BAR_1: uReg = pThis->aMarcApers[1].Base.u64; break;
|
---|
3147 | case IOMMU_MMIO_OFF_MARC_APER_RELOC_1: uReg = pThis->aMarcApers[1].Reloc.u64; break;
|
---|
3148 | case IOMMU_MMIO_OFF_MARC_APER_LEN_1: uReg = pThis->aMarcApers[1].Length.u64; break;
|
---|
3149 | case IOMMU_MMIO_OFF_MARC_APER_BAR_2: uReg = pThis->aMarcApers[2].Base.u64; break;
|
---|
3150 | case IOMMU_MMIO_OFF_MARC_APER_RELOC_2: uReg = pThis->aMarcApers[2].Reloc.u64; break;
|
---|
3151 | case IOMMU_MMIO_OFF_MARC_APER_LEN_2: uReg = pThis->aMarcApers[2].Length.u64; break;
|
---|
3152 | case IOMMU_MMIO_OFF_MARC_APER_BAR_3: uReg = pThis->aMarcApers[3].Base.u64; break;
|
---|
3153 | case IOMMU_MMIO_OFF_MARC_APER_RELOC_3: uReg = pThis->aMarcApers[3].Reloc.u64; break;
|
---|
3154 | case IOMMU_MMIO_OFF_MARC_APER_LEN_3: uReg = pThis->aMarcApers[3].Length.u64; break;
|
---|
3155 |
|
---|
3156 | case IOMMU_MMIO_OFF_RSVD_REG: uReg = pThis->RsvdReg; break;
|
---|
3157 |
|
---|
3158 | case IOMMU_MMIO_CMD_BUF_HEAD_PTR: uReg = pThis->CmdBufHeadPtr.u64; break;
|
---|
3159 | case IOMMU_MMIO_CMD_BUF_TAIL_PTR: uReg = pThis->CmdBufTailPtr.u64; break;
|
---|
3160 | case IOMMU_MMIO_EVT_LOG_HEAD_PTR: uReg = pThis->EvtLogHeadPtr.u64; break;
|
---|
3161 | case IOMMU_MMIO_EVT_LOG_TAIL_PTR: uReg = pThis->EvtLogTailPtr.u64; break;
|
---|
3162 |
|
---|
3163 | case IOMMU_MMIO_OFF_STATUS: uReg = pThis->Status.u64; break;
|
---|
3164 |
|
---|
3165 | case IOMMU_MMIO_OFF_PPR_LOG_HEAD_PTR: uReg = pThis->PprLogHeadPtr.u64; break;
|
---|
3166 | case IOMMU_MMIO_OFF_PPR_LOG_TAIL_PTR: uReg = pThis->PprLogTailPtr.u64; break;
|
---|
3167 |
|
---|
3168 | case IOMMU_MMIO_OFF_GALOG_HEAD_PTR: uReg = pThis->GALogHeadPtr.u64; break;
|
---|
3169 | case IOMMU_MMIO_OFF_GALOG_TAIL_PTR: uReg = pThis->GALogTailPtr.u64; break;
|
---|
3170 |
|
---|
3171 | case IOMMU_MMIO_OFF_PPR_LOG_B_HEAD_PTR: uReg = pThis->PprLogBHeadPtr.u64; break;
|
---|
3172 | case IOMMU_MMIO_OFF_PPR_LOG_B_TAIL_PTR: uReg = pThis->PprLogBTailPtr.u64; break;
|
---|
3173 |
|
---|
3174 | case IOMMU_MMIO_OFF_EVT_LOG_B_HEAD_PTR: uReg = pThis->EvtLogBHeadPtr.u64; break;
|
---|
3175 | case IOMMU_MMIO_OFF_EVT_LOG_B_TAIL_PTR: uReg = pThis->EvtLogBTailPtr.u64; break;
|
---|
3176 |
|
---|
3177 | case IOMMU_MMIO_OFF_PPR_LOG_AUTO_RESP: uReg = pThis->PprLogAutoResp.u64; break;
|
---|
3178 | case IOMMU_MMIO_OFF_PPR_LOG_OVERFLOW_EARLY: uReg = pThis->PprLogOverflowEarly.u64; break;
|
---|
3179 | case IOMMU_MMIO_OFF_PPR_LOG_B_OVERFLOW_EARLY: uReg = pThis->PprLogBOverflowEarly.u64; break;
|
---|
3180 |
|
---|
3181 | /* Not implemented. */
|
---|
3182 | case IOMMU_MMIO_OFF_SMI_FLT_FIRST:
|
---|
3183 | case IOMMU_MMIO_OFF_SMI_FLT_LAST:
|
---|
3184 | {
|
---|
3185 | Log((IOMMU_LOG_PFX ": Reading unsupported register: SMI filter %u\n", (off - IOMMU_MMIO_OFF_SMI_FLT_FIRST) >> 3));
|
---|
3186 | uReg = 0;
|
---|
3187 | break;
|
---|
3188 | }
|
---|
3189 |
|
---|
3190 | /* Unknown. */
|
---|
3191 | default:
|
---|
3192 | {
|
---|
3193 | Log((IOMMU_LOG_PFX ": Reading unknown register %u (%#x) -> 0\n", off, off));
|
---|
3194 | uReg = 0;
|
---|
3195 | return VINF_IOM_MMIO_UNUSED_00;
|
---|
3196 | }
|
---|
3197 | }
|
---|
3198 |
|
---|
3199 | *puResult = uReg;
|
---|
3200 | return VINF_SUCCESS;
|
---|
3201 | }
|
---|
3202 |
|
---|
3203 |
|
---|
3204 | /**
|
---|
3205 | * Raises the MSI interrupt for the IOMMU device.
|
---|
3206 | *
|
---|
3207 | * @param pDevIns The IOMMU device instance.
|
---|
3208 | */
|
---|
3209 | static void iommuAmdRaiseMsiInterrupt(PPDMDEVINS pDevIns)
|
---|
3210 | {
|
---|
3211 | if (iommuAmdIsMsiEnabled(pDevIns))
|
---|
3212 | PDMDevHlpPCISetIrq(pDevIns, 0, PDM_IRQ_LEVEL_HIGH);
|
---|
3213 | }
|
---|
3214 |
|
---|
3215 | /**
|
---|
3216 | * Clears the MSI interrupt for the IOMMU device.
|
---|
3217 | *
|
---|
3218 | * @param pDevIns The IOMMU device instance.
|
---|
3219 | */
|
---|
3220 | static void iommuAmdClearMsiInterrupt(PPDMDEVINS pDevIns)
|
---|
3221 | {
|
---|
3222 | if (iommuAmdIsMsiEnabled(pDevIns))
|
---|
3223 | PDMDevHlpPCISetIrq(pDevIns, 0, PDM_IRQ_LEVEL_LOW);
|
---|
3224 | }
|
---|
3225 |
|
---|
3226 |
|
---|
3227 | /**
|
---|
3228 | * Writes an entry to the event log in memory.
|
---|
3229 | *
|
---|
3230 | * @returns VBox status code.
|
---|
3231 | * @param pDevIns The IOMMU device instance.
|
---|
3232 | * @param pEvent The event to log.
|
---|
3233 | *
|
---|
3234 | * @thread Any.
|
---|
3235 | */
|
---|
3236 | static int iommuAmdWriteEvtLogEntry(PPDMDEVINS pDevIns, PCEVT_GENERIC_T pEvent)
|
---|
3237 | {
|
---|
3238 | PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
|
---|
3239 | IOMMU_STATUS_T const Status = iommuAmdGetStatus(pThis);
|
---|
3240 |
|
---|
3241 | /* Check if event logging is active and the log has not overflowed. */
|
---|
3242 | if ( Status.n.u1EvtLogRunning
|
---|
3243 | && !Status.n.u1EvtOverflow)
|
---|
3244 | {
|
---|
3245 | uint32_t const cbEvt = sizeof(*pEvent);
|
---|
3246 |
|
---|
3247 | /* Get the offset we need to write the event to in memory (circular buffer offset). */
|
---|
3248 | uint32_t const offEvt = pThis->EvtLogTailPtr.n.off;
|
---|
3249 | Assert(!(offEvt & ~IOMMU_EVT_LOG_TAIL_PTR_VALID_MASK));
|
---|
3250 |
|
---|
3251 | /* Ensure we have space in the event log. */
|
---|
3252 | uint32_t const cMaxEvts = iommuAmdGetBufMaxEntries(pThis->EvtLogBaseAddr.n.u4Len);
|
---|
3253 | uint32_t const cEvts = iommuAmdGetEvtLogEntryCount(pThis);
|
---|
3254 | if (cEvts + 1 < cMaxEvts)
|
---|
3255 | {
|
---|
3256 | /* Write the event log entry to memory. */
|
---|
3257 | RTGCPHYS const GCPhysEvtLog = pThis->EvtLogBaseAddr.n.u40Base << X86_PAGE_4K_SHIFT;
|
---|
3258 | RTGCPHYS const GCPhysEvtLogEntry = GCPhysEvtLog + offEvt;
|
---|
3259 | int rc = PDMDevHlpPCIPhysWrite(pDevIns, GCPhysEvtLogEntry, pEvent, cbEvt);
|
---|
3260 | if (RT_FAILURE(rc))
|
---|
3261 | Log((IOMMU_LOG_PFX ": Failed to write event log entry at %#RGp. rc=%Rrc\n", GCPhysEvtLogEntry, rc));
|
---|
3262 |
|
---|
3263 | /* Increment the event log tail pointer. */
|
---|
3264 | uint32_t const cbEvtLog = iommuAmdGetBufLength(pThis->EvtLogBaseAddr.n.u4Len);
|
---|
3265 | pThis->EvtLogTailPtr.n.off = (offEvt + cbEvt) % cbEvtLog;
|
---|
3266 |
|
---|
3267 | /* Indicate that an event log entry was written. */
|
---|
3268 | ASMAtomicOrU64(&pThis->Status.u64, IOMMU_STATUS_EVT_LOG_INTR);
|
---|
3269 |
|
---|
3270 | /* Check and signal an interrupt if software wants to receive one when an event log entry is written. */
|
---|
3271 | IOMMU_CTRL_T const Ctrl = iommuAmdGetCtrl(pThis);
|
---|
3272 | if (Ctrl.n.u1EvtIntrEn)
|
---|
3273 | iommuAmdRaiseMsiInterrupt(pDevIns);
|
---|
3274 | }
|
---|
3275 | else
|
---|
3276 | {
|
---|
3277 | /* Indicate that the event log has overflowed. */
|
---|
3278 | ASMAtomicOrU64(&pThis->Status.u64, IOMMU_STATUS_EVT_LOG_OVERFLOW);
|
---|
3279 |
|
---|
3280 | /* Check and signal an interrupt if software wants to receive one when the event log has overflowed. */
|
---|
3281 | IOMMU_CTRL_T const Ctrl = iommuAmdGetCtrl(pThis);
|
---|
3282 | if (Ctrl.n.u1EvtIntrEn)
|
---|
3283 | iommuAmdRaiseMsiInterrupt(pDevIns);
|
---|
3284 | }
|
---|
3285 | }
|
---|
3286 | }
|
---|
3287 |
|
---|
3288 |
|
---|
3289 | /**
|
---|
3290 | * Sets an event in the hardware error registers.
|
---|
3291 | *
|
---|
3292 | * @param pDevIns The IOMMU device instance.
|
---|
3293 | * @param pEvent The event.
|
---|
3294 | *
|
---|
3295 | * @thread Any.
|
---|
3296 | */
|
---|
3297 | static void iommuAmdSetHwError(PPDMDEVINS pDevIns, PCEVT_GENERIC_T pEvent)
|
---|
3298 | {
|
---|
3299 | PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
|
---|
3300 | if (pThis->ExtFeat.n.u1HwErrorSup)
|
---|
3301 | {
|
---|
3302 | if (pThis->HwEvtStatus.n.u1Valid)
|
---|
3303 | pThis->HwEvtStatus.n.u1Overflow = 1;
|
---|
3304 | pThis->HwEvtStatus.n.u1Valid = 1;
|
---|
3305 | pThis->HwEvtHi.u64 = RT_MAKE_U64(pEvent->au32[0], pEvent->au32[1]);
|
---|
3306 | pThis->HwEvtLo = RT_MAKE_U64(pEvent->au32[2], pEvent->au32[3]);
|
---|
3307 | Assert(pThis->HwEvtHi.n.u4EvtCode == IOMMU_EVT_DEV_TAB_HW_ERROR);
|
---|
3308 | }
|
---|
3309 | }
|
---|
3310 |
|
---|
3311 |
|
---|
3312 | /**
|
---|
3313 | * Constructs a DEV_TAB_HARDWARE_ERROR event.
|
---|
3314 | *
|
---|
3315 | * @param uDevId The device ID.
|
---|
3316 | * @param GCPhysDevTabEntry The system physical address of the failed device
|
---|
3317 | * table access.
|
---|
3318 | * @param enmOp The operation being performed.
|
---|
3319 | * @param pEvent Where to store the constructed event.
|
---|
3320 | *
|
---|
3321 | * @thread Any.
|
---|
3322 | */
|
---|
3323 | static void iommuAmdMakeDevTabHwErrorEvent(uint16_t uDevId, RTGCPHYS GCPhysDevTabEntry, IOMMUOP enmOp, PEVT_GENERIC_T pEvent)
|
---|
3324 | {
|
---|
3325 | memset(pEvent, 0, sizeof(*pEvent));
|
---|
3326 | AssertCompile(sizeof(EVT_DEV_TAB_HW_ERROR_T) == sizeof(EVT_GENERIC_T));
|
---|
3327 | PEVT_DEV_TAB_HW_ERROR_T pDevTabHwErr = (PEVT_DEV_TAB_HW_ERROR_T)pEvent;
|
---|
3328 | pDevTabHwErr->n.u16DevId = uDevId;
|
---|
3329 | pDevTabHwErr->n.u1Intr = RT_BOOL(enmOp == IOMMUOP_INTR_REQ);
|
---|
3330 | pDevTabHwErr->n.u1ReadWrite = RT_BOOL(enmOp == IOMMUOP_MEM_WRITE);
|
---|
3331 | pDevTabHwErr->n.u1Translation = RT_BOOL(enmOp == IOMMUOP_TRANSLATE_REQ);
|
---|
3332 | pDevTabHwErr->n.u2Type = enmOp == IOMMUOP_CMD ? HWEVTTYPE_DATA_ERROR : HWEVTTYPE_TARGET_ABORT;
|
---|
3333 | pDevTabHwErr->n.u4EvtCode = IOMMU_EVT_DEV_TAB_HW_ERROR;
|
---|
3334 | pDevTabHwErr->n.u64Addr = GCPhysDevTabEntry;
|
---|
3335 | }
|
---|
3336 |
|
---|
3337 |
|
---|
3338 | /**
|
---|
3339 | * Raises a DEV_TAB_HARDWARE_ERROR event.
|
---|
3340 | *
|
---|
3341 | * @param pDevIns The IOMMU device instance.
|
---|
3342 | * @param uDevId The device ID.
|
---|
3343 | * @param GCPhysDevTabEntry The system physical address of the failed device
|
---|
3344 | * table access.
|
---|
3345 | * @param enmOp The operation being performed by the IOMMU.
|
---|
3346 | */
|
---|
3347 | static void iommuAmdRaiseDevTabHwErrorEvent(PPDMDEVINS pDevIns, uint16_t uDevId, RTGCPHYS GCPhysDevTabEntry, IOMMUOP enmOp)
|
---|
3348 | {
|
---|
3349 | EVT_GENERIC_T Event;
|
---|
3350 | iommuAmdMakeDevTabHwErrorEvent(uDevId, GCPhysDevTabEntry, enmOp, &Event);
|
---|
3351 | iommuAmdSetHwError(pDevIns, &Event);
|
---|
3352 | iommuAmdWriteEvtLogEntry(pDevIns, &Event);
|
---|
3353 | if (enmOp != IOMMUOP_CMD)
|
---|
3354 | iommuAmdSetPciTargetAbort(pDevIns);
|
---|
3355 | }
|
---|
3356 |
|
---|
3357 |
|
---|
3358 | /**
|
---|
3359 | * Constructs an ILLEGAL_DEV_TAB_ENTRY event.
|
---|
3360 | *
|
---|
3361 | * @param uDevId The device ID.
|
---|
3362 | * @param uDva The device virtual address.
|
---|
3363 | * @param fRsvdNotZero Whether reserved bits in the device table entry were not
|
---|
3364 | * zero.
|
---|
3365 | * @param enmOp The operation being performed.
|
---|
3366 | * @param pEvent Where to store the constructed event.
|
---|
3367 | */
|
---|
3368 | static void iommuAmdMakeIllegalDevTabEntryEvent(uint16_t uDevId, uint64_t uDva, bool fRsvdNotZero, IOMMUOP enmOp,
|
---|
3369 | PEVT_GENERIC_T pEvent)
|
---|
3370 | {
|
---|
3371 | memset(pEvent, 0, sizeof(*pEvent));
|
---|
3372 | AssertCompile(sizeof(EVT_ILLEGAL_DEV_TAB_ENTRY_T) == sizeof(EVT_GENERIC_T));
|
---|
3373 | PEVT_ILLEGAL_DEV_TAB_ENTRY_T pIllegalDteErr = (PEVT_ILLEGAL_DEV_TAB_ENTRY_T)pEvent;
|
---|
3374 | pIllegalDteErr->n.u16DevId = uDevId;
|
---|
3375 | pIllegalDteErr->n.u1Interrupt = RT_BOOL(enmOp == IOMMUOP_INTR_REQ);
|
---|
3376 | pIllegalDteErr->n.u1ReadWrite = RT_BOOL(enmOp == IOMMUOP_MEM_WRITE);
|
---|
3377 | pIllegalDteErr->n.u1RsvdNotZero = fRsvdNotZero;
|
---|
3378 | pIllegalDteErr->n.u1Translation = RT_BOOL(enmOp == IOMMUOP_TRANSLATE_REQ);
|
---|
3379 | pIllegalDteErr->n.u4EvtCode = IOMMU_EVT_ILLEGAL_DEV_TAB_ENTRY;
|
---|
3380 | pIllegalDteErr->n.u64Addr = uDva & ~UINT64_C(0x3);
|
---|
3381 | /** @todo r=ramshankar: Not sure why the last 2 bits are marked as reserved by the
|
---|
3382 | * IOMMU spec here but not for this field for I/O page fault event. */
|
---|
3383 | Assert(!(uDva & UINT64_C(0x3)));
|
---|
3384 | }
|
---|
3385 |
|
---|
3386 |
|
---|
3387 | /**
|
---|
3388 | * Raises an ILLEGAL_DEV_TAB_ENTRY event.
|
---|
3389 | *
|
---|
3390 | * @param pDevIns The IOMMU instance data.
|
---|
3391 | * @param uDevId The device ID.
|
---|
3392 | * @param uDva The device virtual address.
|
---|
3393 | * @param fRsvdNotZero Whether reserved bits in the device table entry were not
|
---|
3394 | * zero.
|
---|
3395 | * @param enmOp The operation being performed.
|
---|
3396 | */
|
---|
3397 | static void iommuAmdRaiseIllegalDevTabEntryEvent(PPDMDEVINS pDevIns, uint16_t uDevId, uint64_t uDva, bool fRsvdNotZero,
|
---|
3398 | IOMMUOP enmOp)
|
---|
3399 | {
|
---|
3400 | EVT_GENERIC_T Event;
|
---|
3401 | iommuAmdMakeIllegalDevTabEntryEvent(uDevId, uDva, fRsvdNotZero, enmOp, &Event);
|
---|
3402 | iommuAmdWriteEvtLogEntry(pDevIns, &Event);
|
---|
3403 | if (enmOp != IOMMUOP_CMD)
|
---|
3404 | iommuAmdSetPciTargetAbort(pDevIns);
|
---|
3405 | }
|
---|
3406 |
|
---|
3407 |
|
---|
3408 |
|
---|
3409 | /**
|
---|
3410 | * Returns whether the device virtual address is allowed to be excluded from
|
---|
3411 | * translation and permission checks.
|
---|
3412 | *
|
---|
3413 | * @returns @c true if the DVA is excluded, @c false otherwise.
|
---|
3414 | * @param pThis The IOMMU device state.
|
---|
3415 | * @param pDevTabEntry The device table entry.
|
---|
3416 | * @param uDva The device virtual address.
|
---|
3417 | */
|
---|
3418 | static bool iommuAmdIsDvaSubjectToExclRange(PCIOMMU pThis, PCDEV_TAB_ENTRY_T pDevTabEntry, uint64_t uDva)
|
---|
3419 | {
|
---|
3420 | /* Check if the exclusion range is enabled. */
|
---|
3421 | if (pThis->ExclRangeBaseAddr.n.u1ExclEnable)
|
---|
3422 | {
|
---|
3423 | /* Check if the device virtual address falls within the exclusion range. */
|
---|
3424 | uint64_t const uDvaExclFirst = pThis->ExclRangeBaseAddr.n.u40ExclRangeBase << X86_PAGE_4K_SHIFT;
|
---|
3425 | uint64_t const uDvaExclLast = pThis->ExclRangeLimit.n.u52ExclLimit;
|
---|
3426 | if (uDvaExclLast - uDva >= uDvaExclFirst)
|
---|
3427 | {
|
---|
3428 | /* Check if device access to addresses in the exclusion can be forwarded untranslated. */
|
---|
3429 | if ( pThis->ExclRangeBaseAddr.n.u1AllowAll
|
---|
3430 | || pDevTabEntry->n.u1AllowExclusion)
|
---|
3431 | return true;
|
---|
3432 | }
|
---|
3433 | }
|
---|
3434 | return false;
|
---|
3435 | }
|
---|
3436 |
|
---|
3437 |
|
---|
3438 | /**
|
---|
3439 | * Reads a device table entry from guest memory given the device ID.
|
---|
3440 | *
|
---|
3441 | * @returns VBox status code.
|
---|
3442 | * @param pDevIns The IOMMU device instance.
|
---|
3443 | * @param uDevId The device ID.
|
---|
3444 | * @param enmOp The operation being performed by the IOMMU.
|
---|
3445 | * @param pDevTabEntry Where to store the device table entry.
|
---|
3446 | *
|
---|
3447 | * @thread Any.
|
---|
3448 | */
|
---|
3449 | static int iommuAmdReadDevTabEntry(PPDMDEVINS pDevIns, uint16_t uDevId, IOMMUOP enmOp, PDEV_TAB_ENTRY_T pDevTabEntry)
|
---|
3450 | {
|
---|
3451 | PCIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
|
---|
3452 | IOMMU_CTRL_T const Ctrl = iommuAmdGetCtrl(pThis);
|
---|
3453 |
|
---|
3454 | uint8_t const idxSegsEn = Ctrl.n.u3DevTabSegEn;
|
---|
3455 | Assert(idxSegsEn < RT_ELEMENTS(g_auDevTabSegMasks));
|
---|
3456 |
|
---|
3457 | uint8_t const idxSeg = uDevId & g_auDevTabSegMasks[idxSegsEn] >> 13;
|
---|
3458 | Assert(idxSeg < RT_ELEMENTS(pThis->aDevTabBaseAddrs));
|
---|
3459 |
|
---|
3460 | RTGCPHYS const GCPhysDevTab = pThis->aDevTabBaseAddrs[idxSeg].n.u40Base << X86_PAGE_4K_SHIFT;
|
---|
3461 | uint16_t const offDevTabEntry = uDevId & ~g_auDevTabSegMasks[idxSegsEn];
|
---|
3462 | RTGCPHYS const GCPhysDevTabEntry = GCPhysDevTab + offDevTabEntry;
|
---|
3463 |
|
---|
3464 | Assert(!(GCPhysDevTab & X86_PAGE_4K_OFFSET_MASK));
|
---|
3465 | int rc = PDMDevHlpPCIPhysRead(pDevIns, GCPhysDevTabEntry, pDevTabEntry, sizeof(*pDevTabEntry));
|
---|
3466 | if (RT_FAILURE(rc))
|
---|
3467 | {
|
---|
3468 | Log((IOMMU_LOG_PFX ": Failed to read device table entry at %#RGp. rc=%Rrc\n", GCPhysDevTabEntry, rc));
|
---|
3469 | iommuAmdRaiseDevTabHwErrorEvent(pDevIns, uDevId, GCPhysDevTabEntry, enmOp);
|
---|
3470 | }
|
---|
3471 |
|
---|
3472 | return rc;
|
---|
3473 | }
|
---|
3474 |
|
---|
3475 |
|
---|
3476 | /**
|
---|
3477 | * Memory read transaction from a device.
|
---|
3478 | *
|
---|
3479 | * @returns VBox status code.
|
---|
3480 | * @param pDevIns The IOMMU device instance.
|
---|
3481 | * @param uDevId The device ID (bus, device, function).
|
---|
3482 | * @param uDva The device virtual address being read.
|
---|
3483 | * @param cbRead The number of bytes being read.
|
---|
3484 | * @param pGCPhysOut Where to store the translated physical address.
|
---|
3485 | *
|
---|
3486 | * @thread Any.
|
---|
3487 | */
|
---|
3488 | static int iommuAmdDeviceMemRead(PPDMDEVINS pDevIns, uint16_t uDevId, uint64_t uDva, size_t cbRead, PRTGCPHYS pGCPhysOut)
|
---|
3489 | {
|
---|
3490 | RT_NOREF(pDevIns, uDevId, uDva, cbRead, pGCPhysOut);
|
---|
3491 |
|
---|
3492 | Assert(pDevIns);
|
---|
3493 | Assert(pGCPhysOut);
|
---|
3494 |
|
---|
3495 | PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
|
---|
3496 | IOMMUOP const enmOp = IOMMUOP_TRANSLATE_REQ;
|
---|
3497 |
|
---|
3498 | /* Addresses are forwarded without translation when the IOMMU is disabled. */
|
---|
3499 | IOMMU_CTRL_T const Ctrl = iommuAmdGetCtrl(pThis);
|
---|
3500 | if (Ctrl.n.u1IommuEn)
|
---|
3501 | {
|
---|
3502 | /** @todo IOTLB cache lookup. */
|
---|
3503 |
|
---|
3504 | /* Read the device table entry. */
|
---|
3505 | DEV_TAB_ENTRY_T DevTabEntry;
|
---|
3506 | int rc = iommuAmdReadDevTabEntry(pDevIns, uDevId, enmOp, &DevTabEntry);
|
---|
3507 | if (RT_SUCCESS(rc))
|
---|
3508 | {
|
---|
3509 | /* Addresses are forwarded without translation when DTE.V is 0. */
|
---|
3510 | if (DevTabEntry.n.u1Valid)
|
---|
3511 | {
|
---|
3512 | /* Validate bits 127:0 of the device table entry when DTE.V is 1. */
|
---|
3513 | uint64_t const fRsvdQword0 = DevTabEntry.au64[0] & ~IOMMU_DEV_TAB_ENTRY_QWORD_0_VALID_MASK;
|
---|
3514 | uint64_t const fRsvdQword1 = DevTabEntry.au64[1] & ~IOMMU_DEV_TAB_ENTRY_QWORD_1_VALID_MASK;
|
---|
3515 | if ( fRsvdQword0
|
---|
3516 | || fRsvdQword1)
|
---|
3517 | {
|
---|
3518 | Log((IOMMU_LOG_PFX ":DTE invalid reserved bits ([0]=%#RX64 [1]=%#RX64)\n", fRsvdQword0, fRsvdQword1));
|
---|
3519 | iommuAmdRaiseIllegalDevTabEntryEvent(pDevIns, uDevId, uDva, true /* fRsvdNotZero */, enmOp);
|
---|
3520 | return VERR_GENERAL_FAILURE; /** @todo IOMMU: Change this. */
|
---|
3521 | }
|
---|
3522 |
|
---|
3523 | /* Check if the exclusion range is active. */
|
---|
3524 | if (!iommuAmdIsDvaSubjectToExclRange(pThis, &DevTabEntry, uDva))
|
---|
3525 | {
|
---|
3526 | /** @todo IOMMU: Traverse the I/O page table and translate. */
|
---|
3527 | return VERR_NOT_IMPLEMENTED;
|
---|
3528 | }
|
---|
3529 | }
|
---|
3530 | }
|
---|
3531 | else
|
---|
3532 | {
|
---|
3533 | Log((IOMMU_LOG_PFX ":Failed to read device table entry. uDevId=%#x rc=%Rrc\n", uDevId, rc));
|
---|
3534 | return VERR_GENERAL_FAILURE; /** @todo IOMMU: Change this. */
|
---|
3535 | }
|
---|
3536 | }
|
---|
3537 |
|
---|
3538 | *pGCPhysOut = uDva;
|
---|
3539 | return VINF_SUCCESS;
|
---|
3540 | }
|
---|
3541 |
|
---|
3542 |
|
---|
3543 | /**
|
---|
3544 | * Memory write transaction from a device.
|
---|
3545 | *
|
---|
3546 | * @returns VBox status code.
|
---|
3547 | * @param pDevIns The IOMMU device instance.
|
---|
3548 | * @param uDevId The device ID (bus, device, function).
|
---|
3549 | * @param uDva The device virtual address being written.
|
---|
3550 | * @param cbWrite The number of bytes being written.
|
---|
3551 | * @param pGCPhysOut Where to store the translated physical address.
|
---|
3552 | *
|
---|
3553 | * @thread Any.
|
---|
3554 | */
|
---|
3555 | static int iommuAmdDeviceMemWrite(PPDMDEVINS pDevIns, uint16_t uDevId, uint64_t uDva, size_t cbWrite, PRTGCPHYS pGCPhysOut)
|
---|
3556 | {
|
---|
3557 | RT_NOREF(pDevIns, uDevId, uDva, cbWrite, pGCPhysOut);
|
---|
3558 | return VERR_NOT_IMPLEMENTED;
|
---|
3559 | }
|
---|
3560 |
|
---|
3561 |
|
---|
3562 | /**
|
---|
3563 | * @callback_method_impl{FNIOMMMIONEWWRITE}
|
---|
3564 | */
|
---|
3565 | static DECLCALLBACK(VBOXSTRICTRC) iommuAmdMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb)
|
---|
3566 | {
|
---|
3567 | NOREF(pvUser);
|
---|
3568 | Assert(cb == 4 || cb == 8);
|
---|
3569 | Assert(!(off & (cb - 1)));
|
---|
3570 |
|
---|
3571 | uint64_t const uValue = cb == 8 ? *(uint64_t const *)pv : *(uint32_t const *)pv;
|
---|
3572 | return iommuAmdWriteRegister(pDevIns, off, cb, uValue);
|
---|
3573 | }
|
---|
3574 |
|
---|
3575 |
|
---|
3576 | /**
|
---|
3577 | * @callback_method_impl{FNIOMMMIONEWREAD}
|
---|
3578 | */
|
---|
3579 | static DECLCALLBACK(VBOXSTRICTRC) iommuAmdMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb)
|
---|
3580 | {
|
---|
3581 | NOREF(pvUser);
|
---|
3582 | Assert(cb == 4 || cb == 8);
|
---|
3583 | Assert(!(off & (cb - 1)));
|
---|
3584 |
|
---|
3585 | uint64_t uResult;
|
---|
3586 | VBOXSTRICTRC rcStrict = iommuAmdReadRegister(pDevIns, off, &uResult);
|
---|
3587 | if (cb == 8)
|
---|
3588 | *(uint64_t *)pv = uResult;
|
---|
3589 | else
|
---|
3590 | *(uint32_t *)pv = (uint32_t)uResult;
|
---|
3591 |
|
---|
3592 | return rcStrict;
|
---|
3593 | }
|
---|
3594 |
|
---|
3595 |
|
---|
3596 | # ifdef IN_RING3
|
---|
3597 | /**
|
---|
3598 | * @callback_method_impl{FNPCICONFIGREAD}
|
---|
3599 | */
|
---|
3600 | static DECLCALLBACK(VBOXSTRICTRC) iommuAmdR3PciConfigRead(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t uAddress,
|
---|
3601 | unsigned cb, uint32_t *pu32Value)
|
---|
3602 | {
|
---|
3603 | /** @todo IOMMU: PCI config read stat counter. */
|
---|
3604 | VBOXSTRICTRC rcStrict = PDMDevHlpPCIConfigRead(pDevIns, pPciDev, uAddress, cb, pu32Value);
|
---|
3605 | Log3((IOMMU_LOG_PFX ": Reading PCI config register %#x (cb=%u) -> %#x %Rrc\n", uAddress, cb, *pu32Value,
|
---|
3606 | VBOXSTRICTRC_VAL(rcStrict)));
|
---|
3607 | return rcStrict;
|
---|
3608 | }
|
---|
3609 |
|
---|
3610 |
|
---|
3611 | /**
|
---|
3612 | * @callback_method_impl{FNPCICONFIGWRITE}
|
---|
3613 | */
|
---|
3614 | static DECLCALLBACK(VBOXSTRICTRC) iommuAmdR3PciConfigWrite(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t uAddress,
|
---|
3615 | unsigned cb, uint32_t u32Value)
|
---|
3616 | {
|
---|
3617 | PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
|
---|
3618 |
|
---|
3619 | /*
|
---|
3620 | * Discard writes to read-only registers that are specific to the IOMMU.
|
---|
3621 | * Other common PCI registers are handled by the generic code, see devpciR3IsConfigByteWritable().
|
---|
3622 | * See PCI spec. 6.1. "Configuration Space Organization".
|
---|
3623 | */
|
---|
3624 | switch (uAddress)
|
---|
3625 | {
|
---|
3626 | case IOMMU_PCI_OFF_CAP_HDR: /* All bits are read-only. */
|
---|
3627 | case IOMMU_PCI_OFF_RANGE_REG: /* We don't have any devices integrated with the IOMMU. */
|
---|
3628 | case IOMMU_PCI_OFF_MISCINFO_REG_0: /* We don't support MSI-X. */
|
---|
3629 | case IOMMU_PCI_OFF_MISCINFO_REG_1: /* We don't support guest-address translation. */
|
---|
3630 | {
|
---|
3631 | Log((IOMMU_LOG_PFX ": PCI config write (%#RX32) to read-only register %#x -> Ignored\n", u32Value, uAddress));
|
---|
3632 | return VINF_SUCCESS;
|
---|
3633 | }
|
---|
3634 | }
|
---|
3635 |
|
---|
3636 | IOMMU_LOCK_RET(pDevIns, pThis, VERR_IGNORED);
|
---|
3637 |
|
---|
3638 | VBOXSTRICTRC rcStrict;
|
---|
3639 | switch (uAddress)
|
---|
3640 | {
|
---|
3641 | case IOMMU_PCI_OFF_BASE_ADDR_REG_LO:
|
---|
3642 | {
|
---|
3643 | if (pThis->IommuBar.n.u1Enable)
|
---|
3644 | {
|
---|
3645 | rcStrict = VINF_SUCCESS;
|
---|
3646 | Log((IOMMU_LOG_PFX ": Writing Base Address (Lo) when it's already enabled -> Ignored\n"));
|
---|
3647 | break;
|
---|
3648 | }
|
---|
3649 |
|
---|
3650 | pThis->IommuBar.au32[0] = u32Value & IOMMU_BAR_VALID_MASK;
|
---|
3651 | if (pThis->IommuBar.n.u1Enable)
|
---|
3652 | {
|
---|
3653 | Assert(pThis->hMmio == NIL_IOMMMIOHANDLE);
|
---|
3654 | Assert(!pThis->ExtFeat.n.u1PerfCounterSup); /* Base is 16K aligned when performance counters aren't supported. */
|
---|
3655 | RTGCPHYS const GCPhysMmioBase = RT_MAKE_U64(pThis->IommuBar.au32[0] & 0xffffc000, pThis->IommuBar.au32[1]);
|
---|
3656 | rcStrict = PDMDevHlpMmioMap(pDevIns, pThis->hMmio, GCPhysMmioBase);
|
---|
3657 | if (RT_FAILURE(rcStrict))
|
---|
3658 | Log((IOMMU_LOG_PFX ": Failed to map IOMMU MMIO region at %#RGp. rc=%Rrc\n", GCPhysMmioBase, rcStrict));
|
---|
3659 | }
|
---|
3660 | break;
|
---|
3661 | }
|
---|
3662 |
|
---|
3663 | case IOMMU_PCI_OFF_BASE_ADDR_REG_HI:
|
---|
3664 | {
|
---|
3665 | if (!pThis->IommuBar.n.u1Enable)
|
---|
3666 | pThis->IommuBar.au32[1] = u32Value;
|
---|
3667 | else
|
---|
3668 | {
|
---|
3669 | rcStrict = VINF_SUCCESS;
|
---|
3670 | Log((IOMMU_LOG_PFX ": Writing Base Address (Hi) when it's already enabled -> Ignored\n"));
|
---|
3671 | }
|
---|
3672 | break;
|
---|
3673 | }
|
---|
3674 |
|
---|
3675 | case IOMMU_PCI_OFF_MSI_CAP_HDR:
|
---|
3676 | {
|
---|
3677 | u32Value |= RT_BIT(23); /* 64-bit MSI addressess must always be enabled for IOMMU. */
|
---|
3678 | RT_FALL_THRU();
|
---|
3679 | }
|
---|
3680 |
|
---|
3681 | default:
|
---|
3682 | {
|
---|
3683 | rcStrict = PDMDevHlpPCIConfigWrite(pDevIns, pPciDev, uAddress, cb, u32Value);
|
---|
3684 | break;
|
---|
3685 | }
|
---|
3686 | }
|
---|
3687 |
|
---|
3688 | IOMMU_UNLOCK(pDevIns, pThis);
|
---|
3689 |
|
---|
3690 | Log3((IOMMU_LOG_PFX ": PCI config write: %#x -> To %#x (%u) %Rrc\n", u32Value, uAddress, cb, VBOXSTRICTRC_VAL(rcStrict)));
|
---|
3691 | return rcStrict;
|
---|
3692 | }
|
---|
3693 |
|
---|
3694 |
|
---|
3695 | /**
|
---|
3696 | * @callback_method_impl{FNDBGFHANDLERDEV}
|
---|
3697 | */
|
---|
3698 | static DECLCALLBACK(void) iommuAmdR3DbgInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
|
---|
3699 | {
|
---|
3700 | PCIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
|
---|
3701 | PPDMPCIDEV pPciDev = pDevIns->apPciDevs[0];
|
---|
3702 | PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev);
|
---|
3703 |
|
---|
3704 | LogFlow((IOMMU_LOG_PFX ": %s: pThis=%p pszArgs=%s\n", __PRETTY_FUNCTION__, pThis, pszArgs));
|
---|
3705 | bool const fVerbose = !strncmp(pszArgs, RT_STR_TUPLE("verbose")) ? true : false;
|
---|
3706 |
|
---|
3707 | pHlp->pfnPrintf(pHlp, "AMD-IOMMU:\n");
|
---|
3708 | /* Device Table Base Addresses (all segments). */
|
---|
3709 | for (unsigned i = 0; i < RT_ELEMENTS(pThis->aDevTabBaseAddrs); i++)
|
---|
3710 | {
|
---|
3711 | DEV_TAB_BAR_T const DevTabBar = pThis->aDevTabBaseAddrs[i];
|
---|
3712 | pHlp->pfnPrintf(pHlp, " Device Table BAR [%u] = %#RX64\n", i, DevTabBar.u64);
|
---|
3713 | if (fVerbose)
|
---|
3714 | {
|
---|
3715 | pHlp->pfnPrintf(pHlp, " Size = %#x (%u bytes)\n", DevTabBar.n.u9Size,
|
---|
3716 | IOMMU_GET_DEV_TAB_SIZE(DevTabBar.n.u9Size));
|
---|
3717 | pHlp->pfnPrintf(pHlp, " Base address = %#RX64\n", DevTabBar.n.u40Base << X86_PAGE_4K_SHIFT);
|
---|
3718 | }
|
---|
3719 | }
|
---|
3720 | /* Command Buffer Base Address Register. */
|
---|
3721 | {
|
---|
3722 | CMD_BUF_BAR_T const CmdBufBar = pThis->CmdBufBaseAddr;
|
---|
3723 | uint8_t const uEncodedLen = CmdBufBar.n.u4Len;
|
---|
3724 | uint32_t const cEntries = iommuAmdGetBufMaxEntries(uEncodedLen);
|
---|
3725 | uint32_t const cbBuffer = iommuAmdGetBufLength(uEncodedLen);
|
---|
3726 | pHlp->pfnPrintf(pHlp, " Command buffer BAR = %#RX64\n", CmdBufBar.u64);
|
---|
3727 | if (fVerbose)
|
---|
3728 | {
|
---|
3729 | pHlp->pfnPrintf(pHlp, " Base address = %#RX64\n", CmdBufBar.n.u40Base << X86_PAGE_4K_SHIFT);
|
---|
3730 | pHlp->pfnPrintf(pHlp, " Length = %u (%u entries, %u bytes)\n", uEncodedLen,
|
---|
3731 | cEntries, cbBuffer);
|
---|
3732 | }
|
---|
3733 | }
|
---|
3734 | /* Event Log Base Address Register. */
|
---|
3735 | {
|
---|
3736 | EVT_LOG_BAR_T const EvtLogBar = pThis->EvtLogBaseAddr;
|
---|
3737 | uint8_t const uEncodedLen = EvtLogBar.n.u4Len;
|
---|
3738 | uint32_t const cEntries = iommuAmdGetBufMaxEntries(uEncodedLen);
|
---|
3739 | uint32_t const cbBuffer = iommuAmdGetBufLength(uEncodedLen);
|
---|
3740 | pHlp->pfnPrintf(pHlp, " Event log BAR = %#RX64\n", EvtLogBar.u64);
|
---|
3741 | if (fVerbose)
|
---|
3742 | {
|
---|
3743 | pHlp->pfnPrintf(pHlp, " Base address = %#RX64\n", EvtLogBar.n.u40Base << X86_PAGE_4K_SHIFT);
|
---|
3744 | pHlp->pfnPrintf(pHlp, " Length = %u (%u entries, %u bytes)\n", uEncodedLen,
|
---|
3745 | cEntries, cbBuffer);
|
---|
3746 | }
|
---|
3747 | }
|
---|
3748 | /* IOMMU Control Register. */
|
---|
3749 | {
|
---|
3750 | IOMMU_CTRL_T const Ctrl = pThis->Ctrl;
|
---|
3751 | pHlp->pfnPrintf(pHlp, " Control = %#RX64\n", Ctrl.u64);
|
---|
3752 | if (fVerbose)
|
---|
3753 | {
|
---|
3754 | pHlp->pfnPrintf(pHlp, " IOMMU enable = %RTbool\n", Ctrl.n.u1IommuEn);
|
---|
3755 | pHlp->pfnPrintf(pHlp, " HT Tunnel translation enable = %RTbool\n", Ctrl.n.u1HtTunEn);
|
---|
3756 | pHlp->pfnPrintf(pHlp, " Event log enable = %RTbool\n", Ctrl.n.u1EvtLogEn);
|
---|
3757 | pHlp->pfnPrintf(pHlp, " Event log interrupt enable = %RTbool\n", Ctrl.n.u1EvtIntrEn);
|
---|
3758 | pHlp->pfnPrintf(pHlp, " Completion wait interrupt enable = %RTbool\n", Ctrl.n.u1EvtIntrEn);
|
---|
3759 | pHlp->pfnPrintf(pHlp, " Invalidation timeout = %u\n", Ctrl.n.u3InvTimeOut);
|
---|
3760 | pHlp->pfnPrintf(pHlp, " Pass posted write = %RTbool\n", Ctrl.n.u1PassPW);
|
---|
3761 | pHlp->pfnPrintf(pHlp, " Respose Pass posted write = %RTbool\n", Ctrl.n.u1ResPassPW);
|
---|
3762 | pHlp->pfnPrintf(pHlp, " Coherent = %RTbool\n", Ctrl.n.u1Coherent);
|
---|
3763 | pHlp->pfnPrintf(pHlp, " Isochronous = %RTbool\n", Ctrl.n.u1Isoc);
|
---|
3764 | pHlp->pfnPrintf(pHlp, " Command buffer enable = %RTbool\n", Ctrl.n.u1CmdBufEn);
|
---|
3765 | pHlp->pfnPrintf(pHlp, " PPR log enable = %RTbool\n", Ctrl.n.u1PprLogEn);
|
---|
3766 | pHlp->pfnPrintf(pHlp, " PPR interrupt enable = %RTbool\n", Ctrl.n.u1PprIntrEn);
|
---|
3767 | pHlp->pfnPrintf(pHlp, " PPR enable = %RTbool\n", Ctrl.n.u1PprEn);
|
---|
3768 | pHlp->pfnPrintf(pHlp, " Guest translation eanble = %RTbool\n", Ctrl.n.u1GstTranslateEn);
|
---|
3769 | pHlp->pfnPrintf(pHlp, " Guest virtual-APIC enable = %RTbool\n", Ctrl.n.u1GstVirtApicEn);
|
---|
3770 | pHlp->pfnPrintf(pHlp, " CRW = %#x\n", Ctrl.n.u4Crw);
|
---|
3771 | pHlp->pfnPrintf(pHlp, " SMI filter enable = %RTbool\n", Ctrl.n.u1SmiFilterEn);
|
---|
3772 | pHlp->pfnPrintf(pHlp, " Self-writeback disable = %RTbool\n", Ctrl.n.u1SelfWriteBackDis);
|
---|
3773 | pHlp->pfnPrintf(pHlp, " SMI filter log enable = %RTbool\n", Ctrl.n.u1SmiFilterLogEn);
|
---|
3774 | pHlp->pfnPrintf(pHlp, " Guest virtual-APIC mode enable = %#x\n", Ctrl.n.u3GstVirtApicModeEn);
|
---|
3775 | pHlp->pfnPrintf(pHlp, " Guest virtual-APIC GA log enable = %RTbool\n", Ctrl.n.u1GstLogEn);
|
---|
3776 | pHlp->pfnPrintf(pHlp, " Guest virtual-APIC interrupt enable = %RTbool\n", Ctrl.n.u1GstIntrEn);
|
---|
3777 | pHlp->pfnPrintf(pHlp, " Dual PPR log enable = %#x\n", Ctrl.n.u2DualPprLogEn);
|
---|
3778 | pHlp->pfnPrintf(pHlp, " Dual event log enable = %#x\n", Ctrl.n.u2DualEvtLogEn);
|
---|
3779 | pHlp->pfnPrintf(pHlp, " Device table segmentation enable = %#x\n", Ctrl.n.u3DevTabSegEn);
|
---|
3780 | pHlp->pfnPrintf(pHlp, " Privilege abort enable = %#x\n", Ctrl.n.u2PrivAbortEn);
|
---|
3781 | pHlp->pfnPrintf(pHlp, " PPR auto response enable = %RTbool\n", Ctrl.n.u1PprAutoRespEn);
|
---|
3782 | pHlp->pfnPrintf(pHlp, " MARC enable = %RTbool\n", Ctrl.n.u1MarcEn);
|
---|
3783 | pHlp->pfnPrintf(pHlp, " Block StopMark enable = %RTbool\n", Ctrl.n.u1BlockStopMarkEn);
|
---|
3784 | pHlp->pfnPrintf(pHlp, " PPR auto response always-on enable = %RTbool\n", Ctrl.n.u1PprAutoRespAlwaysOnEn);
|
---|
3785 | pHlp->pfnPrintf(pHlp, " Domain IDPNE = %RTbool\n", Ctrl.n.u1DomainIDPNE);
|
---|
3786 | pHlp->pfnPrintf(pHlp, " Enhanced PPR handling = %RTbool\n", Ctrl.n.u1EnhancedPpr);
|
---|
3787 | pHlp->pfnPrintf(pHlp, " Host page table access/dirty bit update = %#x\n", Ctrl.n.u2HstAccDirtyBitUpdate);
|
---|
3788 | pHlp->pfnPrintf(pHlp, " Guest page table dirty bit disable = %RTbool\n", Ctrl.n.u1GstDirtyUpdateDis);
|
---|
3789 | pHlp->pfnPrintf(pHlp, " x2APIC enable = %RTbool\n", Ctrl.n.u1X2ApicEn);
|
---|
3790 | pHlp->pfnPrintf(pHlp, " x2APIC interrupt enable = %RTbool\n", Ctrl.n.u1X2ApicIntrGenEn);
|
---|
3791 | pHlp->pfnPrintf(pHlp, " Guest page table access bit update = %RTbool\n", Ctrl.n.u1GstAccessUpdateDis);
|
---|
3792 | }
|
---|
3793 | }
|
---|
3794 | /* Exclusion Base Address Register. */
|
---|
3795 | {
|
---|
3796 | IOMMU_EXCL_RANGE_BAR_T const ExclRangeBar = pThis->ExclRangeBaseAddr;
|
---|
3797 | pHlp->pfnPrintf(pHlp, " Exclusion BAR = %#RX64\n", ExclRangeBar.u64);
|
---|
3798 | if (fVerbose)
|
---|
3799 | {
|
---|
3800 | pHlp->pfnPrintf(pHlp, " Exclusion enable = %RTbool\n", ExclRangeBar.n.u1ExclEnable);
|
---|
3801 | pHlp->pfnPrintf(pHlp, " Allow all devices = %RTbool\n", ExclRangeBar.n.u1AllowAll);
|
---|
3802 | pHlp->pfnPrintf(pHlp, " Base address = %#RX64\n",
|
---|
3803 | ExclRangeBar.n.u40ExclRangeBase << X86_PAGE_4K_SHIFT);
|
---|
3804 | }
|
---|
3805 | }
|
---|
3806 | /* Exclusion Range Limit Register. */
|
---|
3807 | {
|
---|
3808 | IOMMU_EXCL_RANGE_LIMIT_T const ExclRangeLimit = pThis->ExclRangeLimit;
|
---|
3809 | pHlp->pfnPrintf(pHlp, " Exclusion Range Limit = %#RX64\n", ExclRangeLimit.u64);
|
---|
3810 | if (fVerbose)
|
---|
3811 | pHlp->pfnPrintf(pHlp, " Range limit = %#RX64\n", ExclRangeLimit.n.u52ExclLimit);
|
---|
3812 | }
|
---|
3813 | /* Extended Feature Register. */
|
---|
3814 | {
|
---|
3815 | IOMMU_EXT_FEAT_T ExtFeat = pThis->ExtFeat;
|
---|
3816 | pHlp->pfnPrintf(pHlp, " Extended Feature Register = %#RX64\n", ExtFeat.u64);
|
---|
3817 | pHlp->pfnPrintf(pHlp, " Prefetch support = %RTbool\n", ExtFeat.n.u1PrefetchSup);
|
---|
3818 | if (fVerbose)
|
---|
3819 | {
|
---|
3820 | pHlp->pfnPrintf(pHlp, " PPR support = %RTbool\n", ExtFeat.n.u1PprSup);
|
---|
3821 | pHlp->pfnPrintf(pHlp, " x2APIC support = %RTbool\n", ExtFeat.n.u1X2ApicSup);
|
---|
3822 | pHlp->pfnPrintf(pHlp, " NX and privilege level support = %RTbool\n", ExtFeat.n.u1NoExecuteSup);
|
---|
3823 | pHlp->pfnPrintf(pHlp, " Guest translation support = %RTbool\n", ExtFeat.n.u1GstTranslateSup);
|
---|
3824 | pHlp->pfnPrintf(pHlp, " Invalidate-All command support = %RTbool\n", ExtFeat.n.u1InvAllSup);
|
---|
3825 | pHlp->pfnPrintf(pHlp, " Guest virtual-APIC support = %RTbool\n", ExtFeat.n.u1GstVirtApicSup);
|
---|
3826 | pHlp->pfnPrintf(pHlp, " Hardware error register support = %RTbool\n", ExtFeat.n.u1HwErrorSup);
|
---|
3827 | pHlp->pfnPrintf(pHlp, " Performance counters support = %RTbool\n", ExtFeat.n.u1PerfCounterSup);
|
---|
3828 | pHlp->pfnPrintf(pHlp, " Host address translation size = %#x\n", ExtFeat.n.u2HostAddrTranslateSize);
|
---|
3829 | pHlp->pfnPrintf(pHlp, " Guest address translation size = %#x\n", ExtFeat.n.u2GstAddrTranslateSize);
|
---|
3830 | pHlp->pfnPrintf(pHlp, " Guest CR3 root table level support = %#x\n", ExtFeat.n.u2GstCr3RootTblLevel);
|
---|
3831 | pHlp->pfnPrintf(pHlp, " SMI filter register support = %#x\n", ExtFeat.n.u2SmiFilterSup);
|
---|
3832 | pHlp->pfnPrintf(pHlp, " SMI filter register count = %#x\n", ExtFeat.n.u3SmiFilterCount);
|
---|
3833 | pHlp->pfnPrintf(pHlp, " Guest virtual-APIC modes support = %#x\n", ExtFeat.n.u3GstVirtApicModeSup);
|
---|
3834 | pHlp->pfnPrintf(pHlp, " Dual PPR log support = %#x\n", ExtFeat.n.u2DualPprLogSup);
|
---|
3835 | pHlp->pfnPrintf(pHlp, " Dual event log support = %#x\n", ExtFeat.n.u2DualEvtLogSup);
|
---|
3836 | pHlp->pfnPrintf(pHlp, " Maximum PASID = %#x\n", ExtFeat.n.u5MaxPasidSup);
|
---|
3837 | pHlp->pfnPrintf(pHlp, " User/supervisor page protection support = %RTbool\n", ExtFeat.n.u1UserSupervisorSup);
|
---|
3838 | pHlp->pfnPrintf(pHlp, " Device table segments supported = %#x (%u)\n", ExtFeat.n.u2DevTabSegSup,
|
---|
3839 | g_acDevTabSegs[ExtFeat.n.u2DevTabSegSup]);
|
---|
3840 | pHlp->pfnPrintf(pHlp, " PPR log overflow early warning support = %RTbool\n", ExtFeat.n.u1PprLogOverflowWarn);
|
---|
3841 | pHlp->pfnPrintf(pHlp, " PPR auto response support = %RTbool\n", ExtFeat.n.u1PprAutoRespSup);
|
---|
3842 | pHlp->pfnPrintf(pHlp, " MARC support = %#x\n", ExtFeat.n.u2MarcSup);
|
---|
3843 | pHlp->pfnPrintf(pHlp, " Block StopMark message support = %RTbool\n", ExtFeat.n.u1BlockStopMarkSup);
|
---|
3844 | pHlp->pfnPrintf(pHlp, " Performance optimization support = %RTbool\n", ExtFeat.n.u1PerfOptSup);
|
---|
3845 | pHlp->pfnPrintf(pHlp, " MSI capability MMIO access support = %RTbool\n", ExtFeat.n.u1MsiCapMmioSup);
|
---|
3846 | pHlp->pfnPrintf(pHlp, " Guest I/O protection support = %RTbool\n", ExtFeat.n.u1GstIoSup);
|
---|
3847 | pHlp->pfnPrintf(pHlp, " Host access support = %RTbool\n", ExtFeat.n.u1HostAccessSup);
|
---|
3848 | pHlp->pfnPrintf(pHlp, " Enhanced PPR handling support = %RTbool\n", ExtFeat.n.u1EnhancedPprSup);
|
---|
3849 | pHlp->pfnPrintf(pHlp, " Attribute forward supported = %RTbool\n", ExtFeat.n.u1AttrForwardSup);
|
---|
3850 | pHlp->pfnPrintf(pHlp, " Host dirty support = %RTbool\n", ExtFeat.n.u1HostDirtySup);
|
---|
3851 | pHlp->pfnPrintf(pHlp, " Invalidate IOTLB type support = %RTbool\n", ExtFeat.n.u1InvIoTlbTypeSup);
|
---|
3852 | pHlp->pfnPrintf(pHlp, " Guest page table access bit hw disable = %RTbool\n", ExtFeat.n.u1GstUpdateDisSup);
|
---|
3853 | pHlp->pfnPrintf(pHlp, " Force physical dest for remapped intr. = %RTbool\n", ExtFeat.n.u1ForcePhysDstSup);
|
---|
3854 | }
|
---|
3855 | }
|
---|
3856 | /* PPR Log Base Address Register. */
|
---|
3857 | {
|
---|
3858 | PPR_LOG_BAR_T PprLogBar = pThis->PprLogBaseAddr;
|
---|
3859 | uint8_t const uEncodedLen = PprLogBar.n.u4Len;
|
---|
3860 | uint32_t const cEntries = iommuAmdGetBufMaxEntries(uEncodedLen);
|
---|
3861 | uint32_t const cbBuffer = iommuAmdGetBufLength(uEncodedLen);
|
---|
3862 | pHlp->pfnPrintf(pHlp, " PPR Log BAR = %#RX64\n", PprLogBar.u64);
|
---|
3863 | if (fVerbose)
|
---|
3864 | {
|
---|
3865 | pHlp->pfnPrintf(pHlp, " Base address = %#RX64\n", PprLogBar.n.u40Base << X86_PAGE_4K_SHIFT);
|
---|
3866 | pHlp->pfnPrintf(pHlp, " Length = %u (%u entries, %u bytes)\n", uEncodedLen,
|
---|
3867 | cEntries, cbBuffer);
|
---|
3868 | }
|
---|
3869 | }
|
---|
3870 | /* Hardware Event (Hi) Register. */
|
---|
3871 | {
|
---|
3872 | IOMMU_HW_EVT_HI_T HwEvtHi = pThis->HwEvtHi;
|
---|
3873 | pHlp->pfnPrintf(pHlp, " Hardware Event (Hi) = %#RX64\n", HwEvtHi.u64);
|
---|
3874 | if (fVerbose)
|
---|
3875 | {
|
---|
3876 | pHlp->pfnPrintf(pHlp, " First operand = %#RX64\n", HwEvtHi.n.u60FirstOperand);
|
---|
3877 | pHlp->pfnPrintf(pHlp, " Event code = %#RX8\n", HwEvtHi.n.u4EvtCode);
|
---|
3878 | }
|
---|
3879 | }
|
---|
3880 | /* Hardware Event (Lo) Register. */
|
---|
3881 | pHlp->pfnPrintf(pHlp, " Hardware Event (Lo) = %#RX64\n", pThis->HwEvtLo);
|
---|
3882 | /* Hardware Event Status. */
|
---|
3883 | {
|
---|
3884 | IOMMU_HW_EVT_STATUS_T HwEvtStatus = pThis->HwEvtStatus;
|
---|
3885 | pHlp->pfnPrintf(pHlp, " Hardware Event Status = %#RX64\n", HwEvtStatus.u64);
|
---|
3886 | if (fVerbose)
|
---|
3887 | {
|
---|
3888 | pHlp->pfnPrintf(pHlp, " Valid = %RTbool\n", HwEvtStatus.n.u1Valid);
|
---|
3889 | pHlp->pfnPrintf(pHlp, " Overflow = %RTbool\n", HwEvtStatus.n.u1Overflow);
|
---|
3890 | }
|
---|
3891 | }
|
---|
3892 | /* Guest Virtual-APIC Log Base Address Register. */
|
---|
3893 | {
|
---|
3894 | GALOG_BAR_T const GALogBar = pThis->GALogBaseAddr;
|
---|
3895 | uint8_t const uEncodedLen = GALogBar.n.u4Len;
|
---|
3896 | uint32_t const cEntries = iommuAmdGetBufMaxEntries(uEncodedLen);
|
---|
3897 | uint32_t const cbBuffer = iommuAmdGetBufLength(uEncodedLen);
|
---|
3898 | pHlp->pfnPrintf(pHlp, " Guest Log BAR = %#RX64\n", GALogBar.u64);
|
---|
3899 | if (fVerbose)
|
---|
3900 | {
|
---|
3901 | pHlp->pfnPrintf(pHlp, " Base address = %RTbool\n", GALogBar.n.u40Base << X86_PAGE_4K_SHIFT);
|
---|
3902 | pHlp->pfnPrintf(pHlp, " Length = %u (%u entries, %u bytes)\n", uEncodedLen,
|
---|
3903 | cEntries, cbBuffer);
|
---|
3904 | }
|
---|
3905 | }
|
---|
3906 | /* Guest Virtual-APIC Log Tail Address Register. */
|
---|
3907 | {
|
---|
3908 | GALOG_TAIL_ADDR_T GALogTail = pThis->GALogTailAddr;
|
---|
3909 | pHlp->pfnPrintf(pHlp, " Guest Log Tail Address = %#RX64\n", GALogTail.u64);
|
---|
3910 | if (fVerbose)
|
---|
3911 | pHlp->pfnPrintf(pHlp, " Tail address = %#RX64\n", GALogTail.n.u40GALogTailAddr);
|
---|
3912 | }
|
---|
3913 | /* PPR Log B Base Address Register. */
|
---|
3914 | {
|
---|
3915 | PPR_LOG_B_BAR_T PprLogBBar = pThis->PprLogBBaseAddr;
|
---|
3916 | uint8_t const uEncodedLen = PprLogBBar.n.u4Len;
|
---|
3917 | uint32_t const cEntries = iommuAmdGetBufMaxEntries(uEncodedLen);
|
---|
3918 | uint32_t const cbBuffer = iommuAmdGetBufLength(uEncodedLen);
|
---|
3919 | pHlp->pfnPrintf(pHlp, " PPR Log B BAR = %#RX64\n", PprLogBBar.u64);
|
---|
3920 | if (fVerbose)
|
---|
3921 | {
|
---|
3922 | pHlp->pfnPrintf(pHlp, " Base address = %#RX64\n", PprLogBBar.n.u40Base << X86_PAGE_4K_SHIFT);
|
---|
3923 | pHlp->pfnPrintf(pHlp, " Length = %u (%u entries, %u bytes)\n", uEncodedLen,
|
---|
3924 | cEntries, cbBuffer);
|
---|
3925 | }
|
---|
3926 | }
|
---|
3927 | /* Event Log B Base Address Register. */
|
---|
3928 | {
|
---|
3929 | EVT_LOG_B_BAR_T EvtLogBBar = pThis->EvtLogBBaseAddr;
|
---|
3930 | uint8_t const uEncodedLen = EvtLogBBar.n.u4Len;
|
---|
3931 | uint32_t const cEntries = iommuAmdGetBufMaxEntries(uEncodedLen);
|
---|
3932 | uint32_t const cbBuffer = iommuAmdGetBufLength(uEncodedLen);
|
---|
3933 | pHlp->pfnPrintf(pHlp, " Event Log B BAR = %#RX64\n", EvtLogBBar.u64);
|
---|
3934 | if (fVerbose)
|
---|
3935 | {
|
---|
3936 | pHlp->pfnPrintf(pHlp, " Base address = %#RX64\n", EvtLogBBar.n.u40Base << X86_PAGE_4K_SHIFT);
|
---|
3937 | pHlp->pfnPrintf(pHlp, " Length = %u (%u entries, %u bytes)\n", uEncodedLen,
|
---|
3938 | cEntries, cbBuffer);
|
---|
3939 | }
|
---|
3940 | }
|
---|
3941 | /* Device-Specific Feature Extension Register. */
|
---|
3942 | {
|
---|
3943 | DEV_SPECIFIC_FEAT_T const DevSpecificFeat = pThis->DevSpecificFeat;
|
---|
3944 | pHlp->pfnPrintf(pHlp, " Device-specific Feature = %#RX64\n", DevSpecificFeat.u64);
|
---|
3945 | if (fVerbose)
|
---|
3946 | {
|
---|
3947 | pHlp->pfnPrintf(pHlp, " Feature = %#RX32\n", DevSpecificFeat.n.u24DevSpecFeat);
|
---|
3948 | pHlp->pfnPrintf(pHlp, " Minor revision ID = %#x\n", DevSpecificFeat.n.u4RevMinor);
|
---|
3949 | pHlp->pfnPrintf(pHlp, " Major revision ID = %#x\n", DevSpecificFeat.n.u4RevMajor);
|
---|
3950 | }
|
---|
3951 | }
|
---|
3952 | /* Device-Specific Control Extension Register. */
|
---|
3953 | {
|
---|
3954 | DEV_SPECIFIC_CTRL_T const DevSpecificCtrl = pThis->DevSpecificCtrl;
|
---|
3955 | pHlp->pfnPrintf(pHlp, " Device-specific Control = %#RX64\n", DevSpecificCtrl.u64);
|
---|
3956 | if (fVerbose)
|
---|
3957 | {
|
---|
3958 | pHlp->pfnPrintf(pHlp, " Control = %#RX32\n", DevSpecificCtrl.n.u24DevSpecCtrl);
|
---|
3959 | pHlp->pfnPrintf(pHlp, " Minor revision ID = %#x\n", DevSpecificCtrl.n.u4RevMinor);
|
---|
3960 | pHlp->pfnPrintf(pHlp, " Major revision ID = %#x\n", DevSpecificCtrl.n.u4RevMajor);
|
---|
3961 | }
|
---|
3962 | }
|
---|
3963 | /* Device-Specific Status Extension Register. */
|
---|
3964 | {
|
---|
3965 | DEV_SPECIFIC_STATUS_T const DevSpecificStatus = pThis->DevSpecificStatus;
|
---|
3966 | pHlp->pfnPrintf(pHlp, " Device-specific Control = %#RX64\n", DevSpecificStatus.u64);
|
---|
3967 | if (fVerbose)
|
---|
3968 | {
|
---|
3969 | pHlp->pfnPrintf(pHlp, " Status = %#RX32\n", DevSpecificStatus.n.u24DevSpecStatus);
|
---|
3970 | pHlp->pfnPrintf(pHlp, " Minor revision ID = %#x\n", DevSpecificStatus.n.u4RevMinor);
|
---|
3971 | pHlp->pfnPrintf(pHlp, " Major revision ID = %#x\n", DevSpecificStatus.n.u4RevMajor);
|
---|
3972 | }
|
---|
3973 | }
|
---|
3974 | /* MSI Miscellaneous Information Register (Lo and Hi). */
|
---|
3975 | {
|
---|
3976 | MSI_MISC_INFO_T const MsiMiscInfo = pThis->MsiMiscInfo;
|
---|
3977 | pHlp->pfnPrintf(pHlp, " MSI Misc. Info. Register = %#RX64\n", MsiMiscInfo.u64);
|
---|
3978 | if (fVerbose)
|
---|
3979 | {
|
---|
3980 | pHlp->pfnPrintf(pHlp, " Event Log MSI number = %#x\n", MsiMiscInfo.n.u5MsiNumEvtLog);
|
---|
3981 | pHlp->pfnPrintf(pHlp, " Guest Virtual-Address Size = %#x\n", MsiMiscInfo.n.u3GstVirtAddrSize);
|
---|
3982 | pHlp->pfnPrintf(pHlp, " Physical Address Size = %#x\n", MsiMiscInfo.n.u7PhysAddrSize);
|
---|
3983 | pHlp->pfnPrintf(pHlp, " Virtual-Address Size = %#x\n", MsiMiscInfo.n.u7VirtAddrSize);
|
---|
3984 | pHlp->pfnPrintf(pHlp, " HT Transport ATS Range Reserved = %RTbool\n", MsiMiscInfo.n.u1HtAtsResv);
|
---|
3985 | pHlp->pfnPrintf(pHlp, " PPR MSI number = %#x\n", MsiMiscInfo.n.u5MsiNumPpr);
|
---|
3986 | pHlp->pfnPrintf(pHlp, " GA Log MSI number = %#x\n", MsiMiscInfo.n.u5MsiNumGa);
|
---|
3987 | }
|
---|
3988 | }
|
---|
3989 | /* MSI Capability Header. */
|
---|
3990 | {
|
---|
3991 | MSI_CAP_HDR_T MsiCapHdr;
|
---|
3992 | MsiCapHdr.u32 = PDMPciDevGetDWord(pPciDev, IOMMU_PCI_OFF_MSI_CAP_HDR);
|
---|
3993 | pHlp->pfnPrintf(pHlp, " MSI Capability Header = %#RX32\n", MsiCapHdr.u32);
|
---|
3994 | if (fVerbose)
|
---|
3995 | {
|
---|
3996 | pHlp->pfnPrintf(pHlp, " Capability ID = %#x\n", MsiCapHdr.n.u8MsiCapId);
|
---|
3997 | pHlp->pfnPrintf(pHlp, " Capability Ptr (PCI config offset) = %#x\n", MsiCapHdr.n.u8MsiCapPtr);
|
---|
3998 | pHlp->pfnPrintf(pHlp, " Enable = %RTbool\n", MsiCapHdr.n.u1MsiEnable);
|
---|
3999 | pHlp->pfnPrintf(pHlp, " Multi-message capability = %#x\n", MsiCapHdr.n.u3MsiMultiMessCap);
|
---|
4000 | pHlp->pfnPrintf(pHlp, " Multi-message enable = %#x\n", MsiCapHdr.n.u3MsiMultiMessEn);
|
---|
4001 | }
|
---|
4002 | }
|
---|
4003 | /* MSI Address Register (Lo and Hi). */
|
---|
4004 | {
|
---|
4005 | uint32_t const uMsiAddrLo = PDMPciDevGetDWord(pPciDev, IOMMU_PCI_OFF_MSI_ADDR_LO);
|
---|
4006 | uint32_t const uMsiAddrHi = PDMPciDevGetDWord(pPciDev, IOMMU_PCI_OFF_MSI_ADDR_HI);
|
---|
4007 | MSI_ADDR_T MsiAddr;
|
---|
4008 | MsiAddr.u64 = RT_MAKE_U64(uMsiAddrLo, uMsiAddrHi);
|
---|
4009 | pHlp->pfnPrintf(pHlp, " MSI Address = %#RX64\n", MsiAddr.u64);
|
---|
4010 | if (fVerbose)
|
---|
4011 | pHlp->pfnPrintf(pHlp, " Address = %#RX64\n", MsiAddr.n.u62MsiAddr);
|
---|
4012 | }
|
---|
4013 | /* MSI Data. */
|
---|
4014 | {
|
---|
4015 | MSI_DATA_T MsiData;
|
---|
4016 | MsiData.u32 = PDMPciDevGetDWord(pPciDev, IOMMU_PCI_OFF_MSI_DATA);
|
---|
4017 | pHlp->pfnPrintf(pHlp, " MSI Data = %#RX32\n", MsiData.u32);
|
---|
4018 | if (fVerbose)
|
---|
4019 | pHlp->pfnPrintf(pHlp, " Data = %#x\n", MsiData.n.u16MsiData);
|
---|
4020 | }
|
---|
4021 | /* MSI Mapping Capability Header (HyperTransport, reporting all 0s currently). */
|
---|
4022 | {
|
---|
4023 | MSI_MAP_CAP_HDR_T MsiMapCapHdr;
|
---|
4024 | MsiMapCapHdr.u32 = 0;
|
---|
4025 | pHlp->pfnPrintf(pHlp, " MSI Mapping Capability Header = %#RX32\n", MsiMapCapHdr.u32);
|
---|
4026 | if (fVerbose)
|
---|
4027 | {
|
---|
4028 | pHlp->pfnPrintf(pHlp, " Capability ID = %#x\n", MsiMapCapHdr.n.u8MsiMapCapId);
|
---|
4029 | pHlp->pfnPrintf(pHlp, " Map enable = %RTbool\n", MsiMapCapHdr.n.u1MsiMapEn);
|
---|
4030 | pHlp->pfnPrintf(pHlp, " Map fixed = %RTbool\n", MsiMapCapHdr.n.u1MsiMapFixed);
|
---|
4031 | pHlp->pfnPrintf(pHlp, " Map capability type = %#x\n", MsiMapCapHdr.n.u5MapCapType);
|
---|
4032 | }
|
---|
4033 | }
|
---|
4034 | /* Performance Optimization Control Register. */
|
---|
4035 | {
|
---|
4036 | IOMMU_PERF_OPT_CTRL_T const PerfOptCtrl = pThis->PerfOptCtrl;
|
---|
4037 | pHlp->pfnPrintf(pHlp, " Performance Optimization Control = %#RX32\n", PerfOptCtrl.u32);
|
---|
4038 | if (fVerbose)
|
---|
4039 | pHlp->pfnPrintf(pHlp, " Enable = %RTbool\n", PerfOptCtrl.n.u1PerfOptEn);
|
---|
4040 | }
|
---|
4041 | /* XT (x2APIC) General Interrupt Control Register. */
|
---|
4042 | {
|
---|
4043 | IOMMU_XT_GEN_INTR_CTRL_T const XtGenIntrCtrl = pThis->XtGenIntrCtrl;
|
---|
4044 | pHlp->pfnPrintf(pHlp, " XT General Interrupt Control = %#RX64\n", XtGenIntrCtrl.u64);
|
---|
4045 | if (fVerbose)
|
---|
4046 | {
|
---|
4047 | pHlp->pfnPrintf(pHlp, " Interrupt destination mode = %s\n",
|
---|
4048 | !XtGenIntrCtrl.n.u1X2ApicIntrDstMode ? "physical" : "logical");
|
---|
4049 | pHlp->pfnPrintf(pHlp, " Interrupt destination = %#RX64\n",
|
---|
4050 | RT_MAKE_U64(XtGenIntrCtrl.n.u24X2ApicIntrDstLo, XtGenIntrCtrl.n.u7X2ApicIntrDstHi));
|
---|
4051 | pHlp->pfnPrintf(pHlp, " Interrupt vector = %#x\n", XtGenIntrCtrl.n.u8X2ApicIntrVector);
|
---|
4052 | pHlp->pfnPrintf(pHlp, " Interrupt delivery mode = %#x\n",
|
---|
4053 | !XtGenIntrCtrl.n.u8X2ApicIntrVector ? "fixed" : "arbitrated");
|
---|
4054 | }
|
---|
4055 | }
|
---|
4056 | /* XT (x2APIC) PPR Interrupt Control Register. */
|
---|
4057 | {
|
---|
4058 | IOMMU_XT_PPR_INTR_CTRL_T const XtPprIntrCtrl = pThis->XtPprIntrCtrl;
|
---|
4059 | pHlp->pfnPrintf(pHlp, " XT PPR Interrupt Control = %#RX64\n", XtPprIntrCtrl.u64);
|
---|
4060 | if (fVerbose)
|
---|
4061 | {
|
---|
4062 | pHlp->pfnPrintf(pHlp, " Interrupt destination mode = %s\n",
|
---|
4063 | !XtPprIntrCtrl.n.u1X2ApicIntrDstMode ? "physical" : "logical");
|
---|
4064 | pHlp->pfnPrintf(pHlp, " Interrupt destination = %#RX64\n",
|
---|
4065 | RT_MAKE_U64(XtPprIntrCtrl.n.u24X2ApicIntrDstLo, XtPprIntrCtrl.n.u7X2ApicIntrDstHi));
|
---|
4066 | pHlp->pfnPrintf(pHlp, " Interrupt vector = %#x\n", XtPprIntrCtrl.n.u8X2ApicIntrVector);
|
---|
4067 | pHlp->pfnPrintf(pHlp, " Interrupt delivery mode = %#x\n",
|
---|
4068 | !XtPprIntrCtrl.n.u8X2ApicIntrVector ? "fixed" : "arbitrated");
|
---|
4069 | }
|
---|
4070 | }
|
---|
4071 | /* XT (X2APIC) GA Log Interrupt Control Register. */
|
---|
4072 | {
|
---|
4073 | IOMMU_XT_GALOG_INTR_CTRL_T const XtGALogIntrCtrl = pThis->XtGALogIntrCtrl;
|
---|
4074 | pHlp->pfnPrintf(pHlp, " XT PPR Interrupt Control = %#RX64\n", XtGALogIntrCtrl.u64);
|
---|
4075 | if (fVerbose)
|
---|
4076 | {
|
---|
4077 | pHlp->pfnPrintf(pHlp, " Interrupt destination mode = %s\n",
|
---|
4078 | !XtGALogIntrCtrl.n.u1X2ApicIntrDstMode ? "physical" : "logical");
|
---|
4079 | pHlp->pfnPrintf(pHlp, " Interrupt destination = %#RX64\n",
|
---|
4080 | RT_MAKE_U64(XtGALogIntrCtrl.n.u24X2ApicIntrDstLo, XtGALogIntrCtrl.n.u7X2ApicIntrDstHi));
|
---|
4081 | pHlp->pfnPrintf(pHlp, " Interrupt vector = %#x\n", XtGALogIntrCtrl.n.u8X2ApicIntrVector);
|
---|
4082 | pHlp->pfnPrintf(pHlp, " Interrupt delivery mode = %#x\n",
|
---|
4083 | !XtGALogIntrCtrl.n.u8X2ApicIntrVector ? "fixed" : "arbitrated");
|
---|
4084 | }
|
---|
4085 | }
|
---|
4086 | /* MARC Registers. */
|
---|
4087 | {
|
---|
4088 | for (unsigned i = 0; i < RT_ELEMENTS(pThis->aMarcApers); i++)
|
---|
4089 | {
|
---|
4090 | pHlp->pfnPrintf(pHlp, " MARC Aperature %u:\n", i);
|
---|
4091 | MARC_APER_BAR_T const MarcAperBar = pThis->aMarcApers[i].Base;
|
---|
4092 | pHlp->pfnPrintf(pHlp, " Base = %#RX64\n", MarcAperBar.n.u40MarcBaseAddr << X86_PAGE_4K_SHIFT);
|
---|
4093 |
|
---|
4094 | MARC_APER_RELOC_T const MarcAperReloc = pThis->aMarcApers[i].Reloc;
|
---|
4095 | pHlp->pfnPrintf(pHlp, " Reloc = %#RX64 (addr: %#RX64, read-only: %RTbool, enable: %RTbool)\n",
|
---|
4096 | MarcAperReloc.u64, MarcAperReloc.n.u40MarcRelocAddr << X86_PAGE_4K_SHIFT,
|
---|
4097 | MarcAperReloc.n.u1ReadOnly, MarcAperReloc.n.u1RelocEn);
|
---|
4098 |
|
---|
4099 | MARC_APER_LEN_T const MarcAperLen = pThis->aMarcApers[i].Length;
|
---|
4100 | pHlp->pfnPrintf(pHlp, " Length = %u pages\n", MarcAperLen.n.u40MarcLength);
|
---|
4101 | }
|
---|
4102 | }
|
---|
4103 | /* Reserved Register. */
|
---|
4104 | pHlp->pfnPrintf(pHlp, " Reserved Register = %#RX64\n", pThis->RsvdReg);
|
---|
4105 | /* Command Buffer Head Pointer Register. */
|
---|
4106 | {
|
---|
4107 | CMD_BUF_HEAD_PTR_T const CmdBufHeadPtr = pThis->CmdBufHeadPtr;
|
---|
4108 | pHlp->pfnPrintf(pHlp, " Command Buffer Head Pointer = %#RX64\n", CmdBufHeadPtr.u64);
|
---|
4109 | pHlp->pfnPrintf(pHlp, " Pointer = %#x\n", CmdBufHeadPtr.n.off);
|
---|
4110 | }
|
---|
4111 | /* Command Buffer Tail Pointer Register. */
|
---|
4112 | {
|
---|
4113 | CMD_BUF_HEAD_PTR_T const CmdBufTailPtr = pThis->CmdBufTailPtr;
|
---|
4114 | pHlp->pfnPrintf(pHlp, " Command Buffer Tail Pointer = %#RX64\n", CmdBufTailPtr.u64);
|
---|
4115 | pHlp->pfnPrintf(pHlp, " Pointer = %#x\n", CmdBufTailPtr.n.off);
|
---|
4116 | }
|
---|
4117 | /* Event Log Head Pointer Register. */
|
---|
4118 | {
|
---|
4119 | EVT_LOG_HEAD_PTR_T const EvtLogHeadPtr = pThis->EvtLogHeadPtr;
|
---|
4120 | pHlp->pfnPrintf(pHlp, " Event Log Head Pointer = %#RX64\n", EvtLogHeadPtr.u64);
|
---|
4121 | pHlp->pfnPrintf(pHlp, " Pointer = %#x\n", EvtLogHeadPtr.n.off);
|
---|
4122 | }
|
---|
4123 | /* Event Log Tail Pointer Register. */
|
---|
4124 | {
|
---|
4125 | EVT_LOG_TAIL_PTR_T const EvtLogTailPtr = pThis->EvtLogTailPtr;
|
---|
4126 | pHlp->pfnPrintf(pHlp, " Event Log Head Pointer = %#RX64\n", EvtLogTailPtr.u64);
|
---|
4127 | pHlp->pfnPrintf(pHlp, " Pointer = %#x\n", EvtLogTailPtr.n.off);
|
---|
4128 | }
|
---|
4129 | /* Status Register. */
|
---|
4130 | {
|
---|
4131 | IOMMU_STATUS_T const Status = pThis->Status;
|
---|
4132 | pHlp->pfnPrintf(pHlp, " Status Register = %#RX64\n", Status.u64);
|
---|
4133 | if (fVerbose)
|
---|
4134 | {
|
---|
4135 | pHlp->pfnPrintf(pHlp, " Event log overflow = %RTbool\n", Status.n.u1EvtOverflow);
|
---|
4136 | pHlp->pfnPrintf(pHlp, " Event log interrupt = %RTbool\n", Status.n.u1EvtLogIntr);
|
---|
4137 | pHlp->pfnPrintf(pHlp, " Completion wait interrupt = %RTbool\n", Status.n.u1CompWaitIntr);
|
---|
4138 | pHlp->pfnPrintf(pHlp, " Event log running = %RTbool\n", Status.n.u1EvtLogRunning);
|
---|
4139 | pHlp->pfnPrintf(pHlp, " Command buffer running = %RTbool\n", Status.n.u1CmdBufRunning);
|
---|
4140 | pHlp->pfnPrintf(pHlp, " PPR overflow = %RTbool\n", Status.n.u1PprOverflow);
|
---|
4141 | pHlp->pfnPrintf(pHlp, " PPR interrupt = %RTbool\n", Status.n.u1PprIntr);
|
---|
4142 | pHlp->pfnPrintf(pHlp, " PPR log running = %RTbool\n", Status.n.u1PprLogRunning);
|
---|
4143 | pHlp->pfnPrintf(pHlp, " Guest log running = %RTbool\n", Status.n.u1GstLogRunning);
|
---|
4144 | pHlp->pfnPrintf(pHlp, " Guest log interrupt = %RTbool\n", Status.n.u1GstLogIntr);
|
---|
4145 | pHlp->pfnPrintf(pHlp, " PPR log B overflow = %RTbool\n", Status.n.u1PprOverflowB);
|
---|
4146 | pHlp->pfnPrintf(pHlp, " PPR log active = %RTbool\n", Status.n.u1PprLogActive);
|
---|
4147 | pHlp->pfnPrintf(pHlp, " Event log B overflow = %RTbool\n", Status.n.u1EvtOverflowB);
|
---|
4148 | pHlp->pfnPrintf(pHlp, " Event log active = %RTbool\n", Status.n.u1EvtLogActive);
|
---|
4149 | pHlp->pfnPrintf(pHlp, " PPR log B overflow early warning = %RTbool\n", Status.n.u1PprOverflowEarlyB);
|
---|
4150 | pHlp->pfnPrintf(pHlp, " PPR log overflow early warning = %RTbool\n", Status.n.u1PprOverflowEarly);
|
---|
4151 | }
|
---|
4152 | }
|
---|
4153 | /* PPR Log Head Pointer. */
|
---|
4154 | {
|
---|
4155 | PPR_LOG_HEAD_PTR_T const PprLogHeadPtr = pThis->PprLogHeadPtr;
|
---|
4156 | pHlp->pfnPrintf(pHlp, " PPR Log Head Pointer = %#RX64\n", PprLogHeadPtr.u64);
|
---|
4157 | pHlp->pfnPrintf(pHlp, " Pointer = %#x\n", PprLogHeadPtr.n.off);
|
---|
4158 | }
|
---|
4159 | /* PPR Log Tail Pointer. */
|
---|
4160 | {
|
---|
4161 | PPR_LOG_TAIL_PTR_T const PprLogTailPtr = pThis->PprLogTailPtr;
|
---|
4162 | pHlp->pfnPrintf(pHlp, " PPR Log Tail Pointer = %#RX64\n", PprLogTailPtr.u64);
|
---|
4163 | pHlp->pfnPrintf(pHlp, " Pointer = %#x\n", PprLogTailPtr.n.off);
|
---|
4164 | }
|
---|
4165 | /* Guest Virtual-APIC Log Head Pointer. */
|
---|
4166 | {
|
---|
4167 | GALOG_HEAD_PTR_T const GALogHeadPtr = pThis->GALogHeadPtr;
|
---|
4168 | pHlp->pfnPrintf(pHlp, " Guest Virtual-APIC Log Head Pointer = %#RX64\n", GALogHeadPtr.u64);
|
---|
4169 | pHlp->pfnPrintf(pHlp, " Pointer = %#x\n", GALogHeadPtr.n.u12GALogPtr);
|
---|
4170 | }
|
---|
4171 | /* Guest Virtual-APIC Log Tail Pointer. */
|
---|
4172 | {
|
---|
4173 | GALOG_HEAD_PTR_T const GALogTailPtr = pThis->GALogTailPtr;
|
---|
4174 | pHlp->pfnPrintf(pHlp, " Guest Virtual-APIC Log Tail Pointer = %#RX64\n", GALogTailPtr.u64);
|
---|
4175 | pHlp->pfnPrintf(pHlp, " Pointer = %#x\n", GALogTailPtr.n.u12GALogPtr);
|
---|
4176 | }
|
---|
4177 | /* PPR Log B Head Pointer. */
|
---|
4178 | {
|
---|
4179 | PPR_LOG_B_HEAD_PTR_T const PprLogBHeadPtr = pThis->PprLogBHeadPtr;
|
---|
4180 | pHlp->pfnPrintf(pHlp, " PPR Log B Head Pointer = %#RX64\n", PprLogBHeadPtr.u64);
|
---|
4181 | pHlp->pfnPrintf(pHlp, " Pointer = %#x\n", PprLogBHeadPtr.n.off);
|
---|
4182 | }
|
---|
4183 | /* PPR Log B Tail Pointer. */
|
---|
4184 | {
|
---|
4185 | PPR_LOG_B_TAIL_PTR_T const PprLogBTailPtr = pThis->PprLogBTailPtr;
|
---|
4186 | pHlp->pfnPrintf(pHlp, " PPR Log B Tail Pointer = %#RX64\n", PprLogBTailPtr.u64);
|
---|
4187 | pHlp->pfnPrintf(pHlp, " Pointer = %#x\n", PprLogBTailPtr.n.off);
|
---|
4188 | }
|
---|
4189 | /* Event Log B Head Pointer. */
|
---|
4190 | {
|
---|
4191 | EVT_LOG_B_HEAD_PTR_T const EvtLogBHeadPtr = pThis->EvtLogBHeadPtr;
|
---|
4192 | pHlp->pfnPrintf(pHlp, " Event Log B Head Pointer = %#RX64\n", EvtLogBHeadPtr.u64);
|
---|
4193 | pHlp->pfnPrintf(pHlp, " Pointer = %#x\n", EvtLogBHeadPtr.n.off);
|
---|
4194 | }
|
---|
4195 | /* Event Log B Tail Pointer. */
|
---|
4196 | {
|
---|
4197 | EVT_LOG_B_TAIL_PTR_T const EvtLogBTailPtr = pThis->EvtLogBTailPtr;
|
---|
4198 | pHlp->pfnPrintf(pHlp, " Event Log B Tail Pointer = %#RX64\n", EvtLogBTailPtr.u64);
|
---|
4199 | pHlp->pfnPrintf(pHlp, " Pointer = %#x\n", EvtLogBTailPtr.n.off);
|
---|
4200 | }
|
---|
4201 | /* PPR Log Auto Response Register. */
|
---|
4202 | {
|
---|
4203 | PPR_LOG_AUTO_RESP_T const PprLogAutoResp = pThis->PprLogAutoResp;
|
---|
4204 | pHlp->pfnPrintf(pHlp, " PPR Log Auto Response Register = %#RX64\n", PprLogAutoResp.u64);
|
---|
4205 | if (fVerbose)
|
---|
4206 | {
|
---|
4207 | pHlp->pfnPrintf(pHlp, " Code = %#x\n", PprLogAutoResp.n.u4AutoRespCode);
|
---|
4208 | pHlp->pfnPrintf(pHlp, " Mask Gen. = %RTbool\n", PprLogAutoResp.n.u1AutoRespMaskGen);
|
---|
4209 | }
|
---|
4210 | }
|
---|
4211 | /* PPR Log Overflow Early Warning Indicator Register. */
|
---|
4212 | {
|
---|
4213 | PPR_LOG_OVERFLOW_EARLY_T const PprLogOverflowEarly = pThis->PprLogOverflowEarly;
|
---|
4214 | pHlp->pfnPrintf(pHlp, " PPR Log overflow early warning = %#RX64\n", PprLogOverflowEarly.u64);
|
---|
4215 | if (fVerbose)
|
---|
4216 | {
|
---|
4217 | pHlp->pfnPrintf(pHlp, " Threshold = %#x\n", PprLogOverflowEarly.n.u15Threshold);
|
---|
4218 | pHlp->pfnPrintf(pHlp, " Interrupt enable = %RTbool\n", PprLogOverflowEarly.n.u1IntrEn);
|
---|
4219 | pHlp->pfnPrintf(pHlp, " Enable = %RTbool\n", PprLogOverflowEarly.n.u1Enable);
|
---|
4220 | }
|
---|
4221 | }
|
---|
4222 | /* PPR Log Overflow Early Warning Indicator Register. */
|
---|
4223 | {
|
---|
4224 | PPR_LOG_OVERFLOW_EARLY_T const PprLogBOverflowEarly = pThis->PprLogBOverflowEarly;
|
---|
4225 | pHlp->pfnPrintf(pHlp, " PPR Log B overflow early warning = %#RX64\n", PprLogBOverflowEarly.u64);
|
---|
4226 | if (fVerbose)
|
---|
4227 | {
|
---|
4228 | pHlp->pfnPrintf(pHlp, " Threshold = %#x\n", PprLogBOverflowEarly.n.u15Threshold);
|
---|
4229 | pHlp->pfnPrintf(pHlp, " Interrupt enable = %RTbool\n", PprLogBOverflowEarly.n.u1IntrEn);
|
---|
4230 | pHlp->pfnPrintf(pHlp, " Enable = %RTbool\n", PprLogBOverflowEarly.n.u1Enable);
|
---|
4231 | }
|
---|
4232 | }
|
---|
4233 | }
|
---|
4234 |
|
---|
4235 |
|
---|
4236 | /**
|
---|
4237 | * @callback_method_impl{FNSSMDEVSAVEEXEC}
|
---|
4238 | */
|
---|
4239 | static DECLCALLBACK(int) iommuAmdR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
|
---|
4240 | {
|
---|
4241 | /** @todo IOMMU: Save state. */
|
---|
4242 | RT_NOREF2(pDevIns, pSSM);
|
---|
4243 | return VERR_NOT_IMPLEMENTED;
|
---|
4244 | }
|
---|
4245 |
|
---|
4246 |
|
---|
4247 | /**
|
---|
4248 | * @callback_method_impl{FNSSMDEVLOADEXEC}
|
---|
4249 | */
|
---|
4250 | static DECLCALLBACK(int) iommuAmdR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
|
---|
4251 | {
|
---|
4252 | /** @todo IOMMU: Load state. */
|
---|
4253 | RT_NOREF4(pDevIns, pSSM, uVersion, uPass);
|
---|
4254 | return VERR_NOT_IMPLEMENTED;
|
---|
4255 | }
|
---|
4256 |
|
---|
4257 |
|
---|
4258 | /**
|
---|
4259 | * @interface_method_impl{PDMDEVREG,pfnReset}
|
---|
4260 | */
|
---|
4261 | static DECLCALLBACK(void) iommuAmdR3Reset(PPDMDEVINS pDevIns)
|
---|
4262 | {
|
---|
4263 | /*
|
---|
4264 | * Resets read-write portion of the IOMMU state.
|
---|
4265 | *
|
---|
4266 | * State data not initialized here is expected to be initialized during
|
---|
4267 | * device construction and remain read-only through the lifetime of the VM.
|
---|
4268 | */
|
---|
4269 | PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
|
---|
4270 | PPDMPCIDEV pPciDev = pDevIns->apPciDevs[0];
|
---|
4271 | PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev);
|
---|
4272 |
|
---|
4273 | memset(&pThis->aDevTabBaseAddrs[0], 0, sizeof(pThis->aDevTabBaseAddrs));
|
---|
4274 |
|
---|
4275 | pThis->CmdBufBaseAddr.u64 = 0;
|
---|
4276 | pThis->CmdBufBaseAddr.n.u4Len = 8;
|
---|
4277 |
|
---|
4278 | pThis->EvtLogBaseAddr.u64 = 0;
|
---|
4279 | pThis->EvtLogBaseAddr.n.u4Len = 8;
|
---|
4280 |
|
---|
4281 | pThis->Ctrl.u64 = 0;
|
---|
4282 |
|
---|
4283 | pThis->ExclRangeBaseAddr.u64 = 0;
|
---|
4284 | pThis->ExclRangeLimit.u64 = 0;
|
---|
4285 |
|
---|
4286 | pThis->PprLogBaseAddr.u64 = 0;
|
---|
4287 | pThis->PprLogBaseAddr.n.u4Len = 8;
|
---|
4288 |
|
---|
4289 | pThis->HwEvtHi.u64 = 0;
|
---|
4290 | pThis->HwEvtLo = 0;
|
---|
4291 | pThis->HwEvtStatus.u64 = 0;
|
---|
4292 |
|
---|
4293 | pThis->GALogBaseAddr.u64 = 0;
|
---|
4294 | pThis->GALogBaseAddr.n.u4Len = 8;
|
---|
4295 | pThis->GALogTailAddr.u64 = 0;
|
---|
4296 |
|
---|
4297 | pThis->PprLogBBaseAddr.u64 = 0;
|
---|
4298 | pThis->PprLogBBaseAddr.n.u4Len = 8;
|
---|
4299 |
|
---|
4300 | pThis->EvtLogBBaseAddr.u64 = 0;
|
---|
4301 | pThis->EvtLogBBaseAddr.n.u4Len = 8;
|
---|
4302 |
|
---|
4303 | pThis->DevSpecificFeat.u64 = 0;
|
---|
4304 | pThis->DevSpecificCtrl.u64 = 0;
|
---|
4305 | pThis->DevSpecificStatus.u64 = 0;
|
---|
4306 |
|
---|
4307 | pThis->MsiMiscInfo.u64 = 0;
|
---|
4308 | pThis->PerfOptCtrl.u32 = 0;
|
---|
4309 |
|
---|
4310 | pThis->XtGenIntrCtrl.u64 = 0;
|
---|
4311 | pThis->XtPprIntrCtrl.u64 = 0;
|
---|
4312 | pThis->XtGALogIntrCtrl.u64 = 0;
|
---|
4313 |
|
---|
4314 | memset(&pThis->aMarcApers[0], 0, sizeof(pThis->aMarcApers));
|
---|
4315 |
|
---|
4316 | pThis->CmdBufHeadPtr.u64 = 0;
|
---|
4317 | pThis->CmdBufTailPtr.u64 = 0;
|
---|
4318 | pThis->EvtLogHeadPtr.u64 = 0;
|
---|
4319 | pThis->EvtLogTailPtr.u64 = 0;
|
---|
4320 |
|
---|
4321 | pThis->Status.u64 = 0;
|
---|
4322 |
|
---|
4323 | pThis->PprLogHeadPtr.u64 = 0;
|
---|
4324 | pThis->PprLogTailPtr.u64 = 0;
|
---|
4325 |
|
---|
4326 | pThis->GALogHeadPtr.u64 = 0;
|
---|
4327 | pThis->GALogTailPtr.u64 = 0;
|
---|
4328 |
|
---|
4329 | pThis->PprLogBHeadPtr.u64 = 0;
|
---|
4330 | pThis->PprLogBTailPtr.u64 = 0;
|
---|
4331 |
|
---|
4332 | pThis->EvtLogBHeadPtr.u64 = 0;
|
---|
4333 | pThis->EvtLogBTailPtr.u64 = 0;
|
---|
4334 |
|
---|
4335 | pThis->PprLogAutoResp.u64 = 0;
|
---|
4336 | pThis->PprLogOverflowEarly.u64 = 0;
|
---|
4337 | pThis->PprLogBOverflowEarly.u64 = 0;
|
---|
4338 |
|
---|
4339 | PDMPciDevSetDWord(pPciDev, IOMMU_PCI_OFF_BASE_ADDR_REG_LO, 0);
|
---|
4340 | PDMPciDevSetDWord(pPciDev, IOMMU_PCI_OFF_BASE_ADDR_REG_HI, 0);
|
---|
4341 | }
|
---|
4342 |
|
---|
4343 |
|
---|
4344 | /**
|
---|
4345 | * @interface_method_impl{PDMDEVREG,pfnDestruct}
|
---|
4346 | */
|
---|
4347 | static DECLCALLBACK(int) iommuAmdR3Destruct(PPDMDEVINS pDevIns)
|
---|
4348 | {
|
---|
4349 | PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns);
|
---|
4350 | PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
|
---|
4351 | LogFlowFunc(("\n"));
|
---|
4352 |
|
---|
4353 | /* Close the command thread semaphore. */
|
---|
4354 | if (pThis->hEvtCmdThread != NIL_SUPSEMEVENT)
|
---|
4355 | {
|
---|
4356 | PDMDevHlpSUPSemEventClose(pDevIns, pThis->hEvtCmdThread);
|
---|
4357 | pThis->hEvtCmdThread = NIL_SUPSEMEVENT;
|
---|
4358 | }
|
---|
4359 | return VINF_SUCCESS;
|
---|
4360 | }
|
---|
4361 |
|
---|
4362 |
|
---|
4363 | /**
|
---|
4364 | * @interface_method_impl{PDMDEVREG,pfnConstruct}
|
---|
4365 | */
|
---|
4366 | static DECLCALLBACK(int) iommuAmdR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
|
---|
4367 | {
|
---|
4368 | NOREF(iInstance);
|
---|
4369 |
|
---|
4370 | PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
|
---|
4371 | PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
|
---|
4372 | PIOMMUCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PIOMMUCC);
|
---|
4373 | PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3;
|
---|
4374 | int rc;
|
---|
4375 | LogFlowFunc(("\n"));
|
---|
4376 |
|
---|
4377 | pThisCC->pDevInsR3 = pDevIns;
|
---|
4378 |
|
---|
4379 | /*
|
---|
4380 | * Validate and read the configuration.
|
---|
4381 | */
|
---|
4382 | PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "Device|Function", "");
|
---|
4383 |
|
---|
4384 | uint8_t uPciDevice;
|
---|
4385 | rc = pHlp->pfnCFGMQueryU8Def(pCfg, "Device", &uPciDevice, 0);
|
---|
4386 | if (RT_FAILURE(rc))
|
---|
4387 | return PDMDEV_SET_ERROR(pDevIns, rc, N_("IOMMU: Failed to query \"Device\""));
|
---|
4388 |
|
---|
4389 | uint8_t uPciFunction;
|
---|
4390 | rc = pHlp->pfnCFGMQueryU8Def(pCfg, "Function", &uPciFunction, 2);
|
---|
4391 | if (RT_FAILURE(rc))
|
---|
4392 | return PDMDEV_SET_ERROR(pDevIns, rc, N_("IOMMU: Failed to query \"Function\""));
|
---|
4393 |
|
---|
4394 | /*
|
---|
4395 | * Register the IOMMU with PDM.
|
---|
4396 | */
|
---|
4397 | PDMIOMMUREGR3 IommuReg;
|
---|
4398 | RT_ZERO(IommuReg);
|
---|
4399 | IommuReg.u32Version = PDM_IOMMUREGCC_VERSION;
|
---|
4400 | IommuReg.pfnMemRead = iommuAmdDeviceMemRead;
|
---|
4401 | IommuReg.pfnMemWrite = iommuAmdDeviceMemWrite;
|
---|
4402 | IommuReg.u32TheEnd = PDM_IOMMUREGCC_VERSION;
|
---|
4403 | rc = PDMDevHlpIommuRegister(pDevIns, &IommuReg, &pThisCC->CTX_SUFF(pIommuHlp), &pThis->idxIommu);
|
---|
4404 | if (RT_FAILURE(rc))
|
---|
4405 | return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to register ourselves as an IOMMU device"));
|
---|
4406 | if (pThisCC->CTX_SUFF(pIommuHlp)->u32Version != PDM_IOMMUHLPR3_VERSION)
|
---|
4407 | return PDMDevHlpVMSetError(pDevIns, VERR_VERSION_MISMATCH, RT_SRC_POS,
|
---|
4408 | N_("IOMMU helper version mismatch; got %#x expected %#x"),
|
---|
4409 | pThisCC->CTX_SUFF(pIommuHlp)->u32Version, PDM_IOMMUHLPR3_VERSION);
|
---|
4410 | if (pThisCC->CTX_SUFF(pIommuHlp)->u32TheEnd != PDM_IOMMUHLPR3_VERSION)
|
---|
4411 | return PDMDevHlpVMSetError(pDevIns, VERR_VERSION_MISMATCH, RT_SRC_POS,
|
---|
4412 | N_("IOMMU helper end-version mismatch; got %#x expected %#x"),
|
---|
4413 | pThisCC->CTX_SUFF(pIommuHlp)->u32TheEnd, PDM_IOMMUHLPR3_VERSION);
|
---|
4414 |
|
---|
4415 | /*
|
---|
4416 | * Initialize read-only PCI configuration space.
|
---|
4417 | */
|
---|
4418 | PPDMPCIDEV pPciDev = pDevIns->apPciDevs[0];
|
---|
4419 | PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev);
|
---|
4420 |
|
---|
4421 | /* Header. */
|
---|
4422 | PDMPciDevSetVendorId(pPciDev, IOMMU_PCI_VENDOR_ID); /* AMD */
|
---|
4423 | PDMPciDevSetDeviceId(pPciDev, IOMMU_PCI_DEVICE_ID); /* VirtualBox IOMMU device */
|
---|
4424 | PDMPciDevSetCommand(pPciDev, 0); /* Command */
|
---|
4425 | PDMPciDevSetStatus(pPciDev, VBOX_PCI_STATUS_CAP_LIST); /* Status - CapList supported */
|
---|
4426 | PDMPciDevSetRevisionId(pPciDev, IOMMU_PCI_REVISION_ID); /* VirtualBox specific device implementation revision */
|
---|
4427 | PDMPciDevSetClassBase(pPciDev, 0x08); /* System Base Peripheral */
|
---|
4428 | PDMPciDevSetClassSub(pPciDev, 0x06); /* IOMMU */
|
---|
4429 | PDMPciDevSetClassProg(pPciDev, 0x00); /* IOMMU Programming interface */
|
---|
4430 | PDMPciDevSetHeaderType(pPciDev, 0x00); /* Single function, type 0. */
|
---|
4431 | PDMPciDevSetSubSystemId(pPciDev, IOMMU_PCI_DEVICE_ID); /* AMD */
|
---|
4432 | PDMPciDevSetSubSystemVendorId(pPciDev, IOMMU_PCI_VENDOR_ID); /* VirtualBox IOMMU device */
|
---|
4433 | PDMPciDevSetCapabilityList(pPciDev, IOMMU_PCI_OFF_CAP_HDR); /* Offset into capability registers. */
|
---|
4434 | PDMPciDevSetInterruptPin(pPciDev, 0x01); /* INTA#. */
|
---|
4435 | PDMPciDevSetInterruptLine(pPciDev, 0x00); /* For software compatibility; no effect on hardware. */
|
---|
4436 |
|
---|
4437 | /* Capability Header. */
|
---|
4438 | PDMPciDevSetDWord(pPciDev, IOMMU_PCI_OFF_CAP_HDR,
|
---|
4439 | RT_BF_MAKE(IOMMU_BF_CAPHDR_CAP_ID, 0xf) /* RO - Secure Device capability block */
|
---|
4440 | | RT_BF_MAKE(IOMMU_BF_CAPHDR_CAP_PTR, IOMMU_PCI_OFF_MSI_CAP_HDR) /* RO - Offset to next capability */
|
---|
4441 | | RT_BF_MAKE(IOMMU_BF_CAPHDR_CAP_TYPE, 0x3) /* RO - IOMMU capability block */
|
---|
4442 | | RT_BF_MAKE(IOMMU_BF_CAPHDR_CAP_REV, 0x1) /* RO - IOMMU interface revision */
|
---|
4443 | | RT_BF_MAKE(IOMMU_BF_CAPHDR_IOTLB_SUP, 0x0) /* RO - Remote IOTLB support */
|
---|
4444 | | RT_BF_MAKE(IOMMU_BF_CAPHDR_HT_TUNNEL, 0x0) /* RO - HyperTransport Tunnel support */
|
---|
4445 | | RT_BF_MAKE(IOMMU_BF_CAPHDR_NP_CACHE, 0x0) /* RO - Cache NP page table entries */
|
---|
4446 | | RT_BF_MAKE(IOMMU_BF_CAPHDR_EFR_SUP, 0x1) /* RO - Extended Feature Register support */
|
---|
4447 | | RT_BF_MAKE(IOMMU_BF_CAPHDR_CAP_EXT, 0x1)); /* RO - Misc. Information Register support */
|
---|
4448 |
|
---|
4449 | /* Base Address Low Register. */
|
---|
4450 | PDMPciDevSetDWord(pPciDev, IOMMU_PCI_OFF_BASE_ADDR_REG_LO, 0x0); /* RW - Base address (Lo) and enable bit. */
|
---|
4451 |
|
---|
4452 | /* Base Address High Register. */
|
---|
4453 | PDMPciDevSetDWord(pPciDev, IOMMU_PCI_OFF_BASE_ADDR_REG_HI, 0x0); /* RW - Base address (Hi) */
|
---|
4454 |
|
---|
4455 | /* IOMMU Range Register. */
|
---|
4456 | PDMPciDevSetDWord(pPciDev, IOMMU_PCI_OFF_RANGE_REG, 0x0); /* RW - Range register (implemented as RO by us). */
|
---|
4457 |
|
---|
4458 | /* Misc. Information Register 0. */
|
---|
4459 | PDMPciDevSetDWord(pPciDev, IOMMU_PCI_OFF_MISCINFO_REG_0,
|
---|
4460 | RT_BF_MAKE(IOMMU_BF_MISCINFO_0_MSI_NUM, 0x0) /* RO - MSI number */
|
---|
4461 | | RT_BF_MAKE(IOMMU_BF_MISCINFO_0_GVA_SIZE, 0x2) /* RO - Guest Virt. Addr size (2=48 bits) */
|
---|
4462 | | RT_BF_MAKE(IOMMU_BF_MISCINFO_0_PA_SIZE, 0x30) /* RO - Physical Addr size (48 bits) */
|
---|
4463 | | RT_BF_MAKE(IOMMU_BF_MISCINFO_0_VA_SIZE, 0x40) /* RO - Virt. Addr size (64 bits) */
|
---|
4464 | | RT_BF_MAKE(IOMMU_BF_MISCINFO_0_HT_ATS_RESV, 0x0) /* RW - HT ATS reserved */
|
---|
4465 | | RT_BF_MAKE(IOMMU_BF_MISCINFO_0_MSI_NUM_PPR, 0x0)); /* RW - PPR interrupt number */
|
---|
4466 |
|
---|
4467 | /* Misc. Information Register 1. */
|
---|
4468 | PDMPciDevSetDWord(pPciDev, IOMMU_PCI_OFF_MISCINFO_REG_0, 0);
|
---|
4469 |
|
---|
4470 | /* MSI Capability Header register. */
|
---|
4471 | PDMMSIREG MsiReg;
|
---|
4472 | RT_ZERO(MsiReg);
|
---|
4473 | MsiReg.cMsiVectors = 1;
|
---|
4474 | MsiReg.iMsiCapOffset = IOMMU_PCI_OFF_MSI_CAP_HDR;
|
---|
4475 | MsiReg.iMsiNextOffset = 0; /* IOMMU_PCI_OFF_MSI_MAP_CAP_HDR */
|
---|
4476 | MsiReg.fMsi64bit = 1; /* 64-bit addressing support is mandatory; See AMD spec. 2.8 "IOMMU Interrupt Support". */
|
---|
4477 | rc = PDMDevHlpPCIRegisterMsi(pDevIns, &MsiReg);
|
---|
4478 | AssertRCReturn(rc, rc);
|
---|
4479 |
|
---|
4480 | /* MSI Address (Lo, Hi) and MSI data are read-write PCI config registers handled by our generic PCI config space code. */
|
---|
4481 | #if 0
|
---|
4482 | /* MSI Address Lo. */
|
---|
4483 | PDMPciDevSetDWord(pPciDev, IOMMU_PCI_OFF_MSI_ADDR_LO, 0); /* RW - MSI message address (Lo). */
|
---|
4484 | /* MSI Address Hi. */
|
---|
4485 | PDMPciDevSetDWord(pPciDev, IOMMU_PCI_OFF_MSI_ADDR_HI, 0); /* RW - MSI message address (Hi). */
|
---|
4486 | /* MSI Data. */
|
---|
4487 | PDMPciDevSetDWord(pPciDev, IOMMU_PCI_OFF_MSI_DATA, 0); /* RW - MSI data. */
|
---|
4488 | #endif
|
---|
4489 |
|
---|
4490 | #if 0
|
---|
4491 | /** @todo IOMMU: I don't know if we need to support this, enable later if
|
---|
4492 | * required. */
|
---|
4493 | /* MSI Mapping Capability Header register. */
|
---|
4494 | PDMPciDevSetDWord(pPciDev, IOMMU_PCI_OFF_MSI_MAP_CAP_HDR,
|
---|
4495 | RT_BF_MAKE(IOMMU_BF_MSI_MAP_CAPHDR_CAP_ID, 0x8) /* RO - Capability ID */
|
---|
4496 | | RT_BF_MAKE(IOMMU_BF_MSI_MAP_CAPHDR_CAP_PTR, 0x0) /* RO - Offset to next capability (NULL) */
|
---|
4497 | | RT_BF_MAKE(IOMMU_BF_MSI_MAP_CAPHDR_EN, 0x1) /* RO - MSI mapping capability enable */
|
---|
4498 | | RT_BF_MAKE(IOMMU_BF_MSI_MAP_CAPHDR_FIXED, 0x1) /* RO - MSI mapping range is fixed */
|
---|
4499 | | RT_BF_MAKE(IOMMU_BF_MSI_MAP_CAPHDR_CAP_TYPE, 0x15)); /* RO - MSI mapping capability */
|
---|
4500 | /* When implementing don't forget to copy this to its MMIO shadow register (MsiMapCapHdr) in iommuAmdR3Init. */
|
---|
4501 | #endif
|
---|
4502 |
|
---|
4503 | /*
|
---|
4504 | * Register the PCI function with PDM.
|
---|
4505 | */
|
---|
4506 | rc = PDMDevHlpPCIRegisterEx(pDevIns, pPciDev, 0 /* fFlags */, uPciDevice, uPciFunction, "amd-iommu");
|
---|
4507 | AssertLogRelRCReturn(rc, rc);
|
---|
4508 |
|
---|
4509 | /*
|
---|
4510 | * Intercept PCI config. space accesses.
|
---|
4511 | */
|
---|
4512 | rc = PDMDevHlpPCIInterceptConfigAccesses(pDevIns, pPciDev, iommuAmdR3PciConfigRead, iommuAmdR3PciConfigWrite);
|
---|
4513 | AssertLogRelRCReturn(rc, rc);
|
---|
4514 |
|
---|
4515 | /*
|
---|
4516 | * Create the MMIO region.
|
---|
4517 | * Mapping of the region is done when software configures it via PCI config space.
|
---|
4518 | */
|
---|
4519 | rc = PDMDevHlpMmioCreate(pDevIns, IOMMU_MMIO_REGION_SIZE, pPciDev, 0 /* iPciRegion */, iommuAmdMmioWrite, iommuAmdMmioRead,
|
---|
4520 | NULL /* pvUser */, IOMMMIO_FLAGS_READ_DWORD_QWORD | IOMMMIO_FLAGS_WRITE_DWORD_QWORD_ZEROED,
|
---|
4521 | "AMD-IOMMU", &pThis->hMmio);
|
---|
4522 | AssertLogRelRCReturn(rc, rc);
|
---|
4523 |
|
---|
4524 | /*
|
---|
4525 | * Register saved state.
|
---|
4526 | */
|
---|
4527 | rc = PDMDevHlpSSMRegisterEx(pDevIns, IOMMU_SAVED_STATE_VERSION, sizeof(IOMMU), NULL,
|
---|
4528 | NULL, NULL, NULL,
|
---|
4529 | NULL, iommuAmdR3SaveExec, NULL,
|
---|
4530 | NULL, iommuAmdR3LoadExec, NULL);
|
---|
4531 | AssertLogRelRCReturn(rc, rc);
|
---|
4532 |
|
---|
4533 | /*
|
---|
4534 | * Register debugger info item.
|
---|
4535 | */
|
---|
4536 | rc = PDMDevHlpDBGFInfoRegister(pDevIns, "iommu", "Display IOMMU state.", iommuAmdR3DbgInfo);
|
---|
4537 | AssertLogRelRCReturn(rc, rc);
|
---|
4538 |
|
---|
4539 | /*
|
---|
4540 | * Create the command thread and its event semaphore.
|
---|
4541 | */
|
---|
4542 | rc = PDMDevHlpThreadCreate(pDevIns, &pThisCC->pCmdThread, pThis, iommuAmdR3CmdThread, iommuAmdR3CmdThreadWakeUp,
|
---|
4543 | 0 /* cbStack */, RTTHREADTYPE_IO, "AMD-IOMMU");
|
---|
4544 | AssertLogRelRCReturn(rc, rc);
|
---|
4545 |
|
---|
4546 | rc = PDMDevHlpSUPSemEventCreate(pDevIns, &pThis->hEvtCmdThread);
|
---|
4547 | AssertLogRelRCReturn(rc, rc);
|
---|
4548 |
|
---|
4549 | /*
|
---|
4550 | * Initialize read-only registers.
|
---|
4551 | */
|
---|
4552 | /** @todo Don't remove the =0 assignment for now. It's just there so it's easier
|
---|
4553 | * for me to see existing features that we might want to implement. Do it
|
---|
4554 | * later. */
|
---|
4555 | pThis->ExtFeat.u64 = 0;
|
---|
4556 | pThis->ExtFeat.n.u1PrefetchSup = 0;
|
---|
4557 | pThis->ExtFeat.n.u1PprSup = 0;
|
---|
4558 | pThis->ExtFeat.n.u1X2ApicSup = 0;
|
---|
4559 | pThis->ExtFeat.n.u1NoExecuteSup = 0;
|
---|
4560 | pThis->ExtFeat.n.u1GstTranslateSup = 0;
|
---|
4561 | pThis->ExtFeat.n.u1InvAllSup = 0;
|
---|
4562 | pThis->ExtFeat.n.u1GstVirtApicSup = 0;
|
---|
4563 | pThis->ExtFeat.n.u1HwErrorSup = 1;
|
---|
4564 | pThis->ExtFeat.n.u1PerfCounterSup = 0;
|
---|
4565 | pThis->ExtFeat.n.u2HostAddrTranslateSize = IOMMU_MAX_HOST_PT_LEVEL;
|
---|
4566 | pThis->ExtFeat.n.u2GstAddrTranslateSize = 0; /* Requires GstTranslateSup. */
|
---|
4567 | pThis->ExtFeat.n.u2GstCr3RootTblLevel = 0; /* Requires GstTranslateSup. */
|
---|
4568 | pThis->ExtFeat.n.u2SmiFilterSup = 0;
|
---|
4569 | pThis->ExtFeat.n.u3SmiFilterCount = 0;
|
---|
4570 | pThis->ExtFeat.n.u3GstVirtApicModeSup = 0; /* Requires GstVirtApicSup */
|
---|
4571 | pThis->ExtFeat.n.u2DualPprLogSup = 0;
|
---|
4572 | pThis->ExtFeat.n.u2DualEvtLogSup = 0;
|
---|
4573 | pThis->ExtFeat.n.u5MaxPasidSup = 0; /* Requires GstTranslateSup. */
|
---|
4574 | pThis->ExtFeat.n.u1UserSupervisorSup = 0;
|
---|
4575 | AssertCompile(IOMMU_MAX_DEV_TAB_SEGMENTS <= 3);
|
---|
4576 | pThis->ExtFeat.n.u2DevTabSegSup = IOMMU_MAX_DEV_TAB_SEGMENTS;
|
---|
4577 | pThis->ExtFeat.n.u1PprLogOverflowWarn = 0;
|
---|
4578 | pThis->ExtFeat.n.u1PprAutoRespSup = 0;
|
---|
4579 | pThis->ExtFeat.n.u2MarcSup = 0;
|
---|
4580 | pThis->ExtFeat.n.u1BlockStopMarkSup = 0;
|
---|
4581 | pThis->ExtFeat.n.u1PerfOptSup = 0;
|
---|
4582 | pThis->ExtFeat.n.u1MsiCapMmioSup = 1;
|
---|
4583 | pThis->ExtFeat.n.u1GstIoSup = 0;
|
---|
4584 | pThis->ExtFeat.n.u1HostAccessSup = 0;
|
---|
4585 | pThis->ExtFeat.n.u1EnhancedPprSup = 0;
|
---|
4586 | pThis->ExtFeat.n.u1AttrForwardSup = 0;
|
---|
4587 | pThis->ExtFeat.n.u1HostDirtySup = 0;
|
---|
4588 | pThis->ExtFeat.n.u1InvIoTlbTypeSup = 0;
|
---|
4589 | pThis->ExtFeat.n.u1GstUpdateDisSup = 0;
|
---|
4590 | pThis->ExtFeat.n.u1ForcePhysDstSup = 0;
|
---|
4591 |
|
---|
4592 | pThis->RsvdReg = 0;
|
---|
4593 |
|
---|
4594 | /*
|
---|
4595 | * Initialize parts of the IOMMU state as it would during reset.
|
---|
4596 | * Must be called -after- initializing PCI config. space registers.
|
---|
4597 | */
|
---|
4598 | iommuAmdR3Reset(pDevIns);
|
---|
4599 |
|
---|
4600 | return VINF_SUCCESS;
|
---|
4601 | }
|
---|
4602 |
|
---|
4603 | # else /* !IN_RING3 */
|
---|
4604 |
|
---|
4605 | /**
|
---|
4606 | * @callback_method_impl{PDMDEVREGR0,pfnConstruct}
|
---|
4607 | */
|
---|
4608 | static DECLCALLBACK(int) iommuAmdRZConstruct(PPDMDEVINS pDevIns)
|
---|
4609 | {
|
---|
4610 | PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
|
---|
4611 | PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
|
---|
4612 | PIOMMUCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PIOMMUCC);
|
---|
4613 |
|
---|
4614 | pThisCC->CTX_SUFF(pDevIns) = pDevIns;
|
---|
4615 |
|
---|
4616 | /* Set up the MMIO RZ handlers. */
|
---|
4617 | int rc = PDMDevHlpMmioSetUpContext(pDevIns, pThis->hMmio, iommuAmdMmioWrite, iommuAmdMmioRead, NULL /* pvUser */);
|
---|
4618 | AssertRCReturn(rc, rc);
|
---|
4619 |
|
---|
4620 | /* Set up the IOMMU RZ callbacks. */
|
---|
4621 | PDMIOMMUREGCC IommuReg;
|
---|
4622 | RT_ZERO(IommuReg);
|
---|
4623 | IommuReg.u32Version = PDM_IOMMUREGCC_VERSION;
|
---|
4624 | IommuReg.idxIommu = pThis->idxIommu;
|
---|
4625 | IommuReg.pfnMemRead = iommuAmdDeviceMemRead;
|
---|
4626 | IommuReg.pfnMemWrite = iommuAmdDeviceMemWrite;
|
---|
4627 | IommuReg.u32TheEnd = PDM_IOMMUREGCC_VERSION;
|
---|
4628 | rc = PDMDevHlpIommuSetUpContext(pDevIns, &IommuReg, &pThisCC->CTX_SUFF(pIommuHlp));
|
---|
4629 | AssertRCReturn(rc, rc);
|
---|
4630 |
|
---|
4631 | return VINF_SUCCESS;
|
---|
4632 | }
|
---|
4633 |
|
---|
4634 | # endif /* !IN_RING3 */
|
---|
4635 |
|
---|
4636 | /**
|
---|
4637 | * The device registration structure.
|
---|
4638 | */
|
---|
4639 | const PDMDEVREG g_DeviceIommuAmd =
|
---|
4640 | {
|
---|
4641 | /* .u32Version = */ PDM_DEVREG_VERSION,
|
---|
4642 | /* .uReserved0 = */ 0,
|
---|
4643 | /* .szName = */ "iommu-amd",
|
---|
4644 | /* .fFlags = */ PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RZ | PDM_DEVREG_FLAGS_NEW_STYLE,
|
---|
4645 | /* .fClass = */ PDM_DEVREG_CLASS_BUS_ISA, /* Instantiate after PDM_DEVREG_CLASS_BUS_PCI */
|
---|
4646 | /* .cMaxInstances = */ ~0U,
|
---|
4647 | /* .uSharedVersion = */ 42,
|
---|
4648 | /* .cbInstanceShared = */ sizeof(IOMMU),
|
---|
4649 | /* .cbInstanceCC = */ sizeof(IOMMUCC),
|
---|
4650 | /* .cbInstanceRC = */ sizeof(IOMMURC),
|
---|
4651 | /* .cMaxPciDevices = */ 1,
|
---|
4652 | /* .cMaxMsixVectors = */ 0,
|
---|
4653 | /* .pszDescription = */ "IOMMU (AMD)",
|
---|
4654 | #if defined(IN_RING3)
|
---|
4655 | /* .pszRCMod = */ "VBoxDDRC.rc",
|
---|
4656 | /* .pszR0Mod = */ "VBoxDDR0.r0",
|
---|
4657 | /* .pfnConstruct = */ iommuAmdR3Construct,
|
---|
4658 | /* .pfnDestruct = */ iommuAmdR3Destruct,
|
---|
4659 | /* .pfnRelocate = */ NULL,
|
---|
4660 | /* .pfnMemSetup = */ NULL,
|
---|
4661 | /* .pfnPowerOn = */ NULL,
|
---|
4662 | /* .pfnReset = */ iommuAmdR3Reset,
|
---|
4663 | /* .pfnSuspend = */ NULL,
|
---|
4664 | /* .pfnResume = */ NULL,
|
---|
4665 | /* .pfnAttach = */ NULL,
|
---|
4666 | /* .pfnDetach = */ NULL,
|
---|
4667 | /* .pfnQueryInterface = */ NULL,
|
---|
4668 | /* .pfnInitComplete = */ NULL,
|
---|
4669 | /* .pfnPowerOff = */ NULL,
|
---|
4670 | /* .pfnSoftReset = */ NULL,
|
---|
4671 | /* .pfnReserved0 = */ NULL,
|
---|
4672 | /* .pfnReserved1 = */ NULL,
|
---|
4673 | /* .pfnReserved2 = */ NULL,
|
---|
4674 | /* .pfnReserved3 = */ NULL,
|
---|
4675 | /* .pfnReserved4 = */ NULL,
|
---|
4676 | /* .pfnReserved5 = */ NULL,
|
---|
4677 | /* .pfnReserved6 = */ NULL,
|
---|
4678 | /* .pfnReserved7 = */ NULL,
|
---|
4679 | #elif defined(IN_RING0)
|
---|
4680 | /* .pfnEarlyConstruct = */ NULL,
|
---|
4681 | /* .pfnConstruct = */ iommuAmdRZConstruct,
|
---|
4682 | /* .pfnDestruct = */ NULL,
|
---|
4683 | /* .pfnFinalDestruct = */ NULL,
|
---|
4684 | /* .pfnRequest = */ NULL,
|
---|
4685 | /* .pfnReserved0 = */ NULL,
|
---|
4686 | /* .pfnReserved1 = */ NULL,
|
---|
4687 | /* .pfnReserved2 = */ NULL,
|
---|
4688 | /* .pfnReserved3 = */ NULL,
|
---|
4689 | /* .pfnReserved4 = */ NULL,
|
---|
4690 | /* .pfnReserved5 = */ NULL,
|
---|
4691 | /* .pfnReserved6 = */ NULL,
|
---|
4692 | /* .pfnReserved7 = */ NULL,
|
---|
4693 | #elif defined(IN_RC)
|
---|
4694 | /* .pfnConstruct = */ iommuAmdRZConstruct,
|
---|
4695 | /* .pfnReserved0 = */ NULL,
|
---|
4696 | /* .pfnReserved1 = */ NULL,
|
---|
4697 | /* .pfnReserved2 = */ NULL,
|
---|
4698 | /* .pfnReserved3 = */ NULL,
|
---|
4699 | /* .pfnReserved4 = */ NULL,
|
---|
4700 | /* .pfnReserved5 = */ NULL,
|
---|
4701 | /* .pfnReserved6 = */ NULL,
|
---|
4702 | /* .pfnReserved7 = */ NULL,
|
---|
4703 | #else
|
---|
4704 | # error "Not in IN_RING3, IN_RING0 or IN_RC!"
|
---|
4705 | #endif
|
---|
4706 | /* .u32VersionEnd = */ PDM_DEVREG_VERSION
|
---|
4707 | };
|
---|
4708 |
|
---|
4709 | #endif /* !VBOX_DEVICE_STRUCT_TESTCASE */
|
---|
4710 |
|
---|