* [PATCH v3 1/5] amd_iommu: Do not create duplicate MSI capability
2026-10-30 0:38 [PATCH v3 0/5] amd_iommu: Bugfix and Cleanup for IO Page Fault Alejandro Jimenez
@ 2026-10-30 0:38 ` Alejandro Jimenez
2026-10-30 0:38 ` [PATCH v3 2/5] amd_iommu: Use full BDF when reporting page faults Alejandro Jimenez
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Alejandro Jimenez @ 2026-10-30 0:38 UTC (permalink / raw)
To: mst, dongli.zhang
Cc: qemu-devel, sarunkod, pbonzini, richard.henderson, joe.jin,
alejandro.j.jimenez
From: Dongli Zhang <dongli.zhang@oracle.com>
amdvi_pci_realize() manually adds an MSI capability before calling
msi_init(). msi_init() creates the MSI capability itself, so the device
can expose duplicate MSI capabilities to the guest.
Drop the manual MSI capability and let msi_init() create the single MSI
capability used by QEMU.
Otherwise, there are duplicate MSI capabilities in guest VM lspci.
[root@vm ~]# lspci -vvv -s 00:02.0
00:02.0 IOMMU: Advanced Micro Devices, Inc. [AMD] Family 15h (Models 10h-1fh) I/O Memory Management Unit
Subsystem: Red Hat, Inc. Device 1100
Control: I/O+ Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Interrupt: pin ? routed to IRQ 24
Capabilities: [60] MSI: Enable+ Count=1/1 Maskable- 64bit+
Address: 00000000fee02000 Data: 0021
Capabilities: [5c] HyperTransport: Slave or Primary Interface
Command: BaseUnitID=0 UnitCnt=0 MastHost- DefDir-
Link Control 0: CFlE- CST+ CFE- <LkFail- Init- EOC- TXO- <CRCErr=c
Link Config 0: MLWI=16bit MLWO=8bit LWI=8bit LWO=8bit
Link Control 1: CFlE- CST- CFE- <LkFail- Init- EOC- TXO- <CRCErr=0
Link Config 1: MLWI=8bit MLWO=[6] LWI=[6] LWO=N/C
Revision ID: 0.00
Capabilities: [58] MSI: Enable- Count=1/1 Maskable- 64bit-
Address: 00005808 Data: 5c05
Capabilities: [40] Secure device <?>
Fixes: d29a09ca6842 ("hw/i386: Introduce AMD IOMMU")
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Reviewed-by: Sairaj Kodilkar <sarunkod@amd.com>
Reviewed-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
---
hw/i386/amd_iommu.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
index 2d5c7b5cdf..fa590c9223 100644
--- a/hw/i386/amd_iommu.c
+++ b/hw/i386/amd_iommu.c
@@ -2576,11 +2576,6 @@ static void amdvi_pci_realize(PCIDevice *pdev, Error **errp)
}
s->capab_offset = ret;
- ret = pci_add_capability(pdev, PCI_CAP_ID_MSI, 0,
- AMDVI_CAPAB_REG_SIZE, errp);
- if (ret < 0) {
- return;
- }
ret = pci_add_capability(pdev, PCI_CAP_ID_HT, 0,
AMDVI_CAPAB_REG_SIZE, errp);
if (ret < 0) {
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v3 2/5] amd_iommu: Use full BDF when reporting page faults
2026-10-30 0:38 [PATCH v3 0/5] amd_iommu: Bugfix and Cleanup for IO Page Fault Alejandro Jimenez
2026-10-30 0:38 ` [PATCH v3 1/5] amd_iommu: Do not create duplicate MSI capability Alejandro Jimenez
@ 2026-10-30 0:38 ` Alejandro Jimenez
2026-10-30 0:38 ` [PATCH v3 3/5] amd_iommu: Define MMIO register masks Alejandro Jimenez
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Alejandro Jimenez @ 2026-10-30 0:38 UTC (permalink / raw)
To: mst, dongli.zhang
Cc: qemu-devel, sarunkod, pbonzini, richard.henderson, joe.jin,
alejandro.j.jimenez
From: Dongli Zhang <dongli.zhang@oracle.com>
AMDVIAddressSpace->devfn only contains the PCI device/function number.
AMD-Vi event log entries require the full DeviceID, including the PCI
bus number.
When reporting IO page faults for devices behind a pcie-root-port, QEMU
logs the fault against the wrong requester. For example, a fault from
01:00.0 is reported as 00:00.0 because only devfn is passed to
amdvi_page_fault().
[root@vm ~]# lspci
... ...
01:00.0 Ethernet controller: Red Hat, Inc. Virtio 1.0 network device (rev 01)
[ 58.154050] pci 0000:00:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0000 address=0xc0000000 flags=0x000a]
[ 58.156968] pci 0000:00:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0000 address=0xc0000000 flags=0x000a]
Use the full BDF consistently for AMD-Vi address spaces and pass it to
page fault and page-table access error reporting.
Fixes: d29a09ca6842 ("hw/i386: Introduce AMD IOMMU")
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Reviewed-by: Sairaj Kodilkar <sarunkod@amd.com>
Reviewed-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
---
hw/i386/amd_iommu.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
index fa590c9223..f52a922c69 100644
--- a/hw/i386/amd_iommu.c
+++ b/hw/i386/amd_iommu.c
@@ -66,6 +66,16 @@ typedef struct AMDVIIOTLBEntry {
uint64_t page_mask; /* physical page size */
} AMDVIIOTLBEntry;
+static uint16_t amdvi_get_devid(PCIBus *bus, uint8_t devfn)
+{
+ return PCI_BUILD_BDF(pci_bus_num(bus), devfn);
+}
+
+static uint16_t amdvi_get_as_devid(AMDVIAddressSpace *as)
+{
+ return amdvi_get_devid(as->bus, as->devfn);
+}
+
/*
* These 'fault' reasons have an overloaded meaning since they are not only
* intended for describing reasons that generate an IO_PAGE_FAULT as per the AMD
@@ -460,7 +470,7 @@ static gboolean amdvi_find_as_by_devid(gpointer key, gpointer value,
const AMDVIAsKey *as = key;
const uint16_t *devidp = user_data;
- return *devidp == PCI_BUILD_BDF(pci_bus_num(as->bus), as->devfn);
+ return *devidp == amdvi_get_devid(as->bus, as->devfn);
}
static AMDVIAddressSpace *amdvi_get_as_by_devid(AMDVIState *s, uint16_t devid)
@@ -665,7 +675,7 @@ static inline uint64_t amdvi_get_pte_entry(AMDVIState *s, uint64_t pte_addr,
static int amdvi_as_to_dte(AMDVIAddressSpace *as, uint64_t *dte)
{
- uint16_t devid = PCI_BUILD_BDF(pci_bus_num(as->bus), as->devfn);
+ uint16_t devid = amdvi_get_as_devid(as);
AMDVIState *s = as->iommu_state;
if (!amdvi_get_dte(s, devid, dte)) {
@@ -764,6 +774,7 @@ static int fetch_pte(AMDVIAddressSpace *as, hwaddr address, uint64_t dte,
uint8_t pt_level, next_pt_level;
IOMMUAccessFlags perms;
int ret;
+ uint16_t devid = amdvi_get_as_devid(as);
*page_size = 0;
@@ -781,7 +792,7 @@ static int fetch_pte(AMDVIAddressSpace *as, hwaddr address, uint64_t dte,
* Pointer and indexing the top level table using the IOVA from the request.
*/
pte_addr = NEXT_PTE_ADDR(dte, pt_level, address);
- *pte = amdvi_get_pte_entry(as->iommu_state, pte_addr, as->devfn);
+ *pte = amdvi_get_pte_entry(as->iommu_state, pte_addr, devid);
if (*pte == (uint64_t)-1) {
/*
@@ -837,7 +848,7 @@ static int fetch_pte(AMDVIAddressSpace *as, hwaddr address, uint64_t dte,
*page_size = PTE_LEVEL_PAGE_SIZE(pt_level);
pte_addr = NEXT_PTE_ADDR(*pte, pt_level, address);
- *pte = amdvi_get_pte_entry(as->iommu_state, pte_addr, as->devfn);
+ *pte = amdvi_get_pte_entry(as->iommu_state, pte_addr, devid);
if (*pte == (uint64_t)-1) {
/* Failure to read PTE. Page walk skips a page_size chunk */
@@ -1898,6 +1909,7 @@ static void amdvi_page_walk(AMDVIAddressSpace *as, uint64_t *dte,
uint8_t mode;
uint64_t pte;
int fetch_ret;
+ uint16_t devid = amdvi_get_as_devid(as);
/* make sure the DTE has TV = 1 */
if (!(dte[0] & AMDVI_DEV_TRANSLATION_VALID)) {
@@ -1931,7 +1943,7 @@ static void amdvi_page_walk(AMDVIAddressSpace *as, uint64_t *dte,
if (fetch_ret < 0 || !IOMMU_PTE_PRESENT(pte) ||
perms != (perms & amdvi_get_perms(pte))) {
- amdvi_page_fault(as->iommu_state, as->devfn, addr, perms);
+ amdvi_page_fault(as->iommu_state, devid, addr, perms);
trace_amdvi_page_fault(addr);
return;
}
@@ -1958,7 +1970,7 @@ static void amdvi_do_translate(AMDVIAddressSpace *as, hwaddr addr,
bool is_write, IOMMUTLBEntry *ret)
{
AMDVIState *s = as->iommu_state;
- uint16_t devid = PCI_BUILD_BDF(pci_bus_num(as->bus), as->devfn);
+ uint16_t devid = amdvi_get_as_devid(as);
AMDVIIOTLBEntry *iotlb_entry = amdvi_iotlb_lookup(s, addr, devid);
uint64_t entry[4];
int dte_ret;
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v3 3/5] amd_iommu: Define MMIO register masks
2026-10-30 0:38 [PATCH v3 0/5] amd_iommu: Bugfix and Cleanup for IO Page Fault Alejandro Jimenez
2026-10-30 0:38 ` [PATCH v3 1/5] amd_iommu: Do not create duplicate MSI capability Alejandro Jimenez
2026-10-30 0:38 ` [PATCH v3 2/5] amd_iommu: Use full BDF when reporting page faults Alejandro Jimenez
@ 2026-10-30 0:38 ` Alejandro Jimenez
2026-10-30 0:38 ` [PATCH v3 4/5] amd_iommu: Make extended feature register read-only Alejandro Jimenez
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Alejandro Jimenez @ 2026-10-30 0:38 UTC (permalink / raw)
To: mst, dongli.zhang
Cc: qemu-devel, sarunkod, pbonzini, richard.henderson, joe.jin,
alejandro.j.jimenez
From: Dongli Zhang <dongli.zhang@oracle.com>
The MMIO read-only and write-1-to-clear masks used by amdvi_init() are
currently hardcoded. The hardcoded values look ambiguous.
Define named masks for the AMD-Vi MMIO registers to make the code easier
to read and understand.
No functional change is intended.
Suggested-by: Sairaj Kodilkar <sarunkod@amd.com>
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Reviewed-by: Sairaj Kodilkar <sarunkod@amd.com>
Reviewed-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
[ajz: apply Sairaj's naming requests, update all code references]
Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
---
hw/i386/amd_iommu.c | 18 ++++++++++--------
hw/i386/amd_iommu.h | 24 ++++++++++++++++++++----
2 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
index f52a922c69..a7f735f691 100644
--- a/hw/i386/amd_iommu.c
+++ b/hw/i386/amd_iommu.c
@@ -294,7 +294,7 @@ static void amdvi_log_event(AMDVIState *s, uint64_t *evt)
/* event logging not enabled */
if (!s->evtlog_enabled || amdvi_test_mask(s, AMDVI_MMIO_STATUS,
- AMDVI_MMIO_STATUS_EVT_OVF)) {
+ AMDVI_MMIO_STATUS_EVTLOG_OVF)) {
return;
}
@@ -304,7 +304,8 @@ static void amdvi_log_event(AMDVIState *s, uint64_t *evt)
if (evtlog_tail_next == s->evtlog_head) {
/* generate overflow interrupt */
if (s->evtlog_intr) {
- amdvi_assign_orq(s, AMDVI_MMIO_STATUS, AMDVI_MMIO_STATUS_EVT_OVF);
+ amdvi_assign_orq(s, AMDVI_MMIO_STATUS,
+ AMDVI_MMIO_STATUS_EVTLOG_OVF);
amdvi_generate_msi_interrupt(s);
}
return;
@@ -325,7 +326,7 @@ static void amdvi_log_event(AMDVIState *s, uint64_t *evt)
amdvi_writeq_raw(s, AMDVI_MMIO_EVENT_TAIL, s->evtlog_tail);
if (s->evtlog_intr) {
- amdvi_assign_orq(s, AMDVI_MMIO_STATUS, AMDVI_MMIO_STATUS_EVENT_INT);
+ amdvi_assign_orq(s, AMDVI_MMIO_STATUS, AMDVI_MMIO_STATUS_EVTLOG_INT);
amdvi_generate_msi_interrupt(s);
}
}
@@ -1694,9 +1695,9 @@ static void amdvi_handle_control_write(AMDVIState *s)
amdvi_assign_andq(s, AMDVI_MMIO_STATUS, ~AMDVI_MMIO_STATUS_CMDBUF_RUN);
}
if (s->evtlog_enabled) {
- amdvi_assign_orq(s, AMDVI_MMIO_STATUS, AMDVI_MMIO_STATUS_EVT_RUN);
+ amdvi_assign_orq(s, AMDVI_MMIO_STATUS, AMDVI_MMIO_STATUS_EVTLOG_RUN);
} else {
- amdvi_assign_andq(s, AMDVI_MMIO_STATUS, ~AMDVI_MMIO_STATUS_EVT_RUN);
+ amdvi_assign_andq(s, AMDVI_MMIO_STATUS, ~AMDVI_MMIO_STATUS_EVTLOG_RUN);
}
trace_amdvi_control_status(control);
@@ -1751,7 +1752,7 @@ static inline void amdvi_handle_evtbase_write(AMDVIState *s)
{
uint64_t val = amdvi_readq(s, AMDVI_MMIO_EVENT_BASE);
- if (amdvi_readq(s, AMDVI_MMIO_STATUS) & AMDVI_MMIO_STATUS_EVENT_INT)
+ if (amdvi_readq(s, AMDVI_MMIO_STATUS) & AMDVI_MMIO_STATUS_EVTLOG_INT)
/* Do not reset if eventlog interrupt bit is set*/
return;
@@ -2572,8 +2573,9 @@ static void amdvi_init(AMDVIState *s)
memset(s->mmior, 0, AMDVI_MMIO_SIZE);
amdvi_set_quad(s, AMDVI_MMIO_EXT_FEATURES,
amdvi_extended_feature_register(s),
- 0xffffffffffffffef, 0);
- amdvi_set_quad(s, AMDVI_MMIO_STATUS, 0, 0x98, 0x67);
+ AMDVI_MMIO_EXT_FEATURE_RO_MASK, 0);
+ amdvi_set_quad(s, AMDVI_MMIO_STATUS, 0, AMDVI_MMIO_STATUS_RO_MASK,
+ AMDVI_MMIO_STATUS_W1C_MASK);
}
static void amdvi_pci_realize(PCIDevice *pdev, Error **errp)
diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h
index 948d8611b1..00842fd487 100644
--- a/hw/i386/amd_iommu.h
+++ b/hw/i386/amd_iommu.h
@@ -107,11 +107,25 @@
#define AMDVI_MMIO_CONTROL_INTCAPXTEN (1ULL << 51)
/* MMIO status register bits */
-#define AMDVI_MMIO_STATUS_CMDBUF_RUN (1 << 4)
-#define AMDVI_MMIO_STATUS_EVT_RUN (1 << 3)
+#define AMDVI_MMIO_STATUS_EVTLOG_OVF (1 << 0)
+#define AMDVI_MMIO_STATUS_EVTLOG_INT (1 << 1)
#define AMDVI_MMIO_STATUS_COMP_INT (1 << 2)
-#define AMDVI_MMIO_STATUS_EVENT_INT (1 << 1)
-#define AMDVI_MMIO_STATUS_EVT_OVF (1 << 0)
+#define AMDVI_MMIO_STATUS_EVTLOG_RUN (1 << 3)
+#define AMDVI_MMIO_STATUS_CMDBUF_RUN (1 << 4)
+#define AMDVI_MMIO_STATUS_PPRLOG_OVF (1 << 5)
+#define AMDVI_MMIO_STATUS_PPRLOG_INT (1 << 6)
+#define AMDVI_MMIO_STATUS_PPRLOG_RUN (1 << 7)
+#define AMDVI_MMIO_STATUS_GALOG_RUN (1 << 8)
+#define AMDVI_MMIO_STATUS_GALOG_OVF (1 << 9)
+#define AMDVI_MMIO_STATUS_GALOG_INT (1 << 10)
+
+#define AMDVI_MMIO_STATUS_RO_MASK \
+ (AMDVI_MMIO_STATUS_EVTLOG_RUN | AMDVI_MMIO_STATUS_CMDBUF_RUN | \
+ AMDVI_MMIO_STATUS_PPRLOG_RUN)
+#define AMDVI_MMIO_STATUS_W1C_MASK \
+ (AMDVI_MMIO_STATUS_EVTLOG_OVF | AMDVI_MMIO_STATUS_EVTLOG_INT | \
+ AMDVI_MMIO_STATUS_COMP_INT | AMDVI_MMIO_STATUS_PPRLOG_OVF | \
+ AMDVI_MMIO_STATUS_PPRLOG_INT)
#define AMDVI_CMDBUF_ID_BYTE 0x07
#define AMDVI_CMDBUF_ID_RSHIFT 4
@@ -230,6 +244,8 @@
(AMDVI_FEATURE_PREFETCH | AMDVI_FEATURE_IA | AMDVI_FEATURE_GT | \
AMDVI_GATS_MODE | AMDVI_HATS_MODE | AMDVI_FEATURE_GA)
+#define AMDVI_MMIO_EXT_FEATURE_RO_MASK 0xffffffffffffffefULL
+
/* capabilities header */
#define AMDVI_CAPAB_FEATURES (AMDVI_CAPAB_FLAT_EXT | \
AMDVI_CAPAB_FLAG_NPCACHE | AMDVI_CAPAB_FLAG_IOTLBSUP \
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v3 4/5] amd_iommu: Make extended feature register read-only
2026-10-30 0:38 [PATCH v3 0/5] amd_iommu: Bugfix and Cleanup for IO Page Fault Alejandro Jimenez
` (2 preceding siblings ...)
2026-10-30 0:38 ` [PATCH v3 3/5] amd_iommu: Define MMIO register masks Alejandro Jimenez
@ 2026-10-30 0:38 ` Alejandro Jimenez
2026-10-30 0:38 ` [PATCH v3 5/5] amd_iommu: Do not latch unsupported GA log status bits Alejandro Jimenez
2026-11-19 15:55 ` [PATCH v3 0/5] amd_iommu: Bugfix and Cleanup for IO Page Fault Alejandro Jimenez
5 siblings, 0 replies; 8+ messages in thread
From: Alejandro Jimenez @ 2026-10-30 0:38 UTC (permalink / raw)
To: mst, dongli.zhang
Cc: qemu-devel, sarunkod, pbonzini, richard.henderson, joe.jin,
alejandro.j.jimenez
From: Dongli Zhang <dongli.zhang@oracle.com>
AMDVI_MMIO_EXT_FEATURES is populated from QEMU's advertised AMD-Vi
extended feature set during reset. Guest writes to this register do not
enable or disable any corresponding QEMU emulation behavior.
Make the register fully read-only so the visible feature bits remain
controlled by QEMU.
According to the AMD IOMMU SDM, bits 25:24 (DualPprLogSup),
29:28 (DualEventLogSup), and 37 (USSup) are not specified as RO.
This commit modifies only bit 4 (GTSup), while leaving the rest as they
are.
Suggested-by: Sairaj Kodilkar <sarunkod@amd.com>
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Reviewed-by: Sairaj Kodilkar <sarunkod@amd.com>
Reviewed-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
[ajz: Remove guest modification claim. AMDVI_MMIO_EXT_FEATURES writes are
not handled in amdvi_mmio_write(), so a guest cannot modify the register]
Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
---
hw/i386/amd_iommu.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h
index 00842fd487..b0a721bc00 100644
--- a/hw/i386/amd_iommu.h
+++ b/hw/i386/amd_iommu.h
@@ -244,7 +244,7 @@
(AMDVI_FEATURE_PREFETCH | AMDVI_FEATURE_IA | AMDVI_FEATURE_GT | \
AMDVI_GATS_MODE | AMDVI_HATS_MODE | AMDVI_FEATURE_GA)
-#define AMDVI_MMIO_EXT_FEATURE_RO_MASK 0xffffffffffffffefULL
+#define AMDVI_MMIO_EXT_FEATURE_RO_MASK (~0ULL)
/* capabilities header */
#define AMDVI_CAPAB_FEATURES (AMDVI_CAPAB_FLAT_EXT | \
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v3 5/5] amd_iommu: Do not latch unsupported GA log status bits
2026-10-30 0:38 [PATCH v3 0/5] amd_iommu: Bugfix and Cleanup for IO Page Fault Alejandro Jimenez
` (3 preceding siblings ...)
2026-10-30 0:38 ` [PATCH v3 4/5] amd_iommu: Make extended feature register read-only Alejandro Jimenez
@ 2026-10-30 0:38 ` Alejandro Jimenez
2026-11-19 15:55 ` [PATCH v3 0/5] amd_iommu: Bugfix and Cleanup for IO Page Fault Alejandro Jimenez
5 siblings, 0 replies; 8+ messages in thread
From: Alejandro Jimenez @ 2026-10-30 0:38 UTC (permalink / raw)
To: mst, dongli.zhang
Cc: qemu-devel, sarunkod, pbonzini, richard.henderson, joe.jin,
alejandro.j.jimenez
From: Dongli Zhang <dongli.zhang@oracle.com>
When QEMU records an AMD-Vi event-log entry for an IO page fault, it
sets the event interrupt status bit and injects the event interrupt.
Linux kernel prior to commit 2379f3485239 ("iommu/amd: Refactor IOMMU
interrupt handling logic for Event, PPR, and GA logs") clears the status
register with a combined mask AMD_IOMMU_INT_MASK when handling any IOMMU
interrupt. That mask includes the
GA log interrupt (MMIO_STATUS_GALOG_INT_MASK) and
overflow (MMIO_STATUS_GALOG_OVERFLOW_MASK) bits, even when the interrupt
being handled is only an event-log interrupt.
QEMU does not produce GA log entries or set GA log status. However, the
emulated status register still accepts guest writes to the GA log status
bits as normal writes. As a result, a guest status clear write that
includes those bits can latch a spurious GA log overflow. The guest then
observes GA log status that QEMU did not generate and repeatedly
restarts the GA log.
The below guest dmesg logs are from v6.4 Linux kernel.
[ 57.818224] virtio-pci 0000:01:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0000 address=0xc0000000 flags=0x0009]
[ 57.821130] virtio-pci 0000:01:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0000 address=0xc0000000 flags=0x0009]
[ 57.824003] AMD-Vi: IOMMU GA Log overflow
[ 57.825099] AMD-Vi: IOMMU GA Log restarting
[ 57.826338] AMD-Vi: IOMMU GA Log overflow
[ 57.827425] AMD-Vi: IOMMU GA Log restarting
[ 57.828657] AMD-Vi: IOMMU GA Log overflow
[ 57.829758] AMD-Vi: IOMMU GA Log restarting
[ 57.830986] AMD-Vi: IOMMU GA Log overflow
[ 57.832063] AMD-Vi: IOMMU GA Log restarting
Mainline Linux commit 2379f3485239 ("iommu/amd: Refactor IOMMU interrupt
handling logic for Event, PPR, and GA logs") avoids triggering this by
chance by clearing only the status bits for the log being handled. However,
older guests still use the combined clear mask.
Add the GA log interrupt and overflow bits to the AMDVI_MMIO_STATUS
w1cmask so guest writes cannot create unsupported GA log status.
Add AMDVI_MMIO_STATUS_GALOG_RUN to AMDVI_MMIO_STATUS_RO_MASK. This
does not implement GA log production. It only prevents guest status clear
writes from creating GA log status that QEMU did not generate to emulate
IO page fault for guest Linux kernel.
Fixes: 12499b23315b ("x86_iommu/amd: Enable Guest virtual APIC support")
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Reviewed-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
[ajz: Add GALOG_RUN to the read-only mask per Sairaj's request]
Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
---
hw/i386/amd_iommu.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h
index b0a721bc00..3d2ee9faf5 100644
--- a/hw/i386/amd_iommu.h
+++ b/hw/i386/amd_iommu.h
@@ -121,11 +121,12 @@
#define AMDVI_MMIO_STATUS_RO_MASK \
(AMDVI_MMIO_STATUS_EVTLOG_RUN | AMDVI_MMIO_STATUS_CMDBUF_RUN | \
- AMDVI_MMIO_STATUS_PPRLOG_RUN)
+ AMDVI_MMIO_STATUS_PPRLOG_RUN | AMDVI_MMIO_STATUS_GALOG_RUN)
#define AMDVI_MMIO_STATUS_W1C_MASK \
(AMDVI_MMIO_STATUS_EVTLOG_OVF | AMDVI_MMIO_STATUS_EVTLOG_INT | \
AMDVI_MMIO_STATUS_COMP_INT | AMDVI_MMIO_STATUS_PPRLOG_OVF | \
- AMDVI_MMIO_STATUS_PPRLOG_INT)
+ AMDVI_MMIO_STATUS_PPRLOG_INT | AMDVI_MMIO_STATUS_GALOG_OVF | \
+ AMDVI_MMIO_STATUS_GALOG_INT)
#define AMDVI_CMDBUF_ID_BYTE 0x07
#define AMDVI_CMDBUF_ID_RSHIFT 4
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH v3 0/5] amd_iommu: Bugfix and Cleanup for IO Page Fault
2026-10-30 0:38 [PATCH v3 0/5] amd_iommu: Bugfix and Cleanup for IO Page Fault Alejandro Jimenez
` (4 preceding siblings ...)
2026-10-30 0:38 ` [PATCH v3 5/5] amd_iommu: Do not latch unsupported GA log status bits Alejandro Jimenez
@ 2026-11-19 15:55 ` Alejandro Jimenez
2026-11-19 16:30 ` Michael S. Tsirkin
5 siblings, 1 reply; 8+ messages in thread
From: Alejandro Jimenez @ 2026-11-19 15:55 UTC (permalink / raw)
To: mst, dongli.zhang
Cc: qemu-devel, sarunkod, pbonzini, richard.henderson, joe.jin
Hi Michael,
Following up on this series, since it contains bug fixes and it has not
been included in the recent pull requests. Do you have any concerns that we
need to address?
Thank you,
Alejandro
On 10/29/26 8:38 PM, Alejandro Jimenez wrote:
> Hi Michael,
>
> I am re-sending Dongli's series after reviewing and addressing the comments from
> his earlier v2 submission:
> v2: https://lore.kernel.org/qemu-devel/20260724223216.108667-1-dongli.zhang@oracle.com/
>
> The series has been rebased on top of:
> b574eaf640f0 ("Merge tag 'for_upstream' of https://git.kernel.org/pub/scm/virt/kvm/mst/qemu into staging")
>
> Please queue it for your next pull request, whenever it is convenient.
>
> Also available at:
> https://github.com/aljimenezb/qemu/commits/amdvi-dongli-fixes-2026/
>
> Changes since v2:
> - Rebased onto b574eaf640f0.
> - Patch 3: Applied suffix LOG for consistent EVTLOG/PPRLOG/GALOG naming, updated
> the existing macros and all their call sites. I preferred the use of LOG since
> GA by itself is generally used to refer to Guest Virtual APIC support in the docs.
> - Patch 4: Minor change in commit message, code unchanged from v2.
> - Patch 5: added GALOG_RUN to the RO mask [Sairaj].
> - Added Reviewed-by and Signed-off trailers as appropriate.
>
> Thank you Dongli and Sairaj for your work on these fixes. Please let me know if
> I missed any of your proposed changes.
>
> Thank you.
> Alejandro
>
> Dongli Zhang (5):
> amd_iommu: Do not create duplicate MSI capability
> amd_iommu: Use full BDF when reporting page faults
> amd_iommu: Define MMIO register masks
> amd_iommu: Make extended feature register read-only
> amd_iommu: Do not latch unsupported GA log status bits
>
> hw/i386/amd_iommu.c | 47 +++++++++++++++++++++++++++------------------
> hw/i386/amd_iommu.h | 25 ++++++++++++++++++++----
> 2 files changed, 49 insertions(+), 23 deletions(-)
>
>
> base-commit: b574eaf640f02c4edf28cbee6417378f0d79cda0
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v3 0/5] amd_iommu: Bugfix and Cleanup for IO Page Fault
2026-11-19 15:55 ` [PATCH v3 0/5] amd_iommu: Bugfix and Cleanup for IO Page Fault Alejandro Jimenez
@ 2026-11-19 16:30 ` Michael S. Tsirkin
0 siblings, 0 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2026-11-19 16:30 UTC (permalink / raw)
To: Alejandro Jimenez
Cc: dongli.zhang, qemu-devel, sarunkod, pbonzini, richard.henderson,
joe.jin
On Thu, Nov 19, 2026 at 10:55:08AM -0500, Alejandro Jimenez wrote:
> Hi Michael,
>
> Following up on this series, since it contains bug fixes and it has not
> been included in the recent pull requests. Do you have any concerns that we
> need to address?
>
> Thank you,
> Alejandro
Nope. sorry lost it in one of rebases. will add in the next pull.
> On 10/29/26 8:38 PM, Alejandro Jimenez wrote:
> > Hi Michael,
> >
> > I am re-sending Dongli's series after reviewing and addressing the comments from
> > his earlier v2 submission:
> > v2: https://lore.kernel.org/qemu-devel/20260724223216.108667-1-dongli.zhang@oracle.com/
> >
> > The series has been rebased on top of:
> > b574eaf640f0 ("Merge tag 'for_upstream' of https://git.kernel.org/pub/scm/virt/kvm/mst/qemu into staging")
> >
> > Please queue it for your next pull request, whenever it is convenient.
> >
> > Also available at:
> > https://github.com/aljimenezb/qemu/commits/amdvi-dongli-fixes-2026/
> >
> > Changes since v2:
> > - Rebased onto b574eaf640f0.
> > - Patch 3: Applied suffix LOG for consistent EVTLOG/PPRLOG/GALOG naming, updated
> > the existing macros and all their call sites. I preferred the use of LOG since
> > GA by itself is generally used to refer to Guest Virtual APIC support in the docs.
> > - Patch 4: Minor change in commit message, code unchanged from v2.
> > - Patch 5: added GALOG_RUN to the RO mask [Sairaj].
> > - Added Reviewed-by and Signed-off trailers as appropriate.
> >
> > Thank you Dongli and Sairaj for your work on these fixes. Please let me know if
> > I missed any of your proposed changes.
> >
> > Thank you.
> > Alejandro
> >
> > Dongli Zhang (5):
> > amd_iommu: Do not create duplicate MSI capability
> > amd_iommu: Use full BDF when reporting page faults
> > amd_iommu: Define MMIO register masks
> > amd_iommu: Make extended feature register read-only
> > amd_iommu: Do not latch unsupported GA log status bits
> >
> > hw/i386/amd_iommu.c | 47 +++++++++++++++++++++++++++------------------
> > hw/i386/amd_iommu.h | 25 ++++++++++++++++++++----
> > 2 files changed, 49 insertions(+), 23 deletions(-)
> >
> >
> > base-commit: b574eaf640f02c4edf28cbee6417378f0d79cda0
^ permalink raw reply [flat|nested] 8+ messages in thread