Skip to content

hw/riscv/riscv-iommu: Correct MSI fault records and test trap handling

Zephyr Li qemu-devel qemu-riscv 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3hw/riscv/riscv-iommu: Preserve IOVA in MSI fault recordshw/riscv/riscv-iommu.c tests/qtest/iommu-riscv-test.c+189 -241 reply
2/3hw/riscv/riscv-iommu: Fix MSI fault PV reporting for process ID zerohw/riscv/riscv-iommu.c tests/qtest/iommu-riscv-test.c+33 -51 reply
3/3hw/riscv/riscv-iommu: Add unit tests for MSI trap handlingMAINTAINERS hw/riscv/riscv-iommu-trap.c.inc hw/riscv/riscv-iommu.c +2 more+338 -601 reply

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchDaniel Henrique Barboza
1/3R-b
2/3R-b
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/3] hw/riscv/riscv-iommu: Correct MSI fault records and test trap handling

This series corrects MSI fault records in the RISC-V IOMMU and adds regression coverage for the trap callback.

Patch 1 preserves the original IOVA through MSI interception, recovers the GPA for MSI lookup, and keeps internal recovery walks out of the modeled HPM events. It includes four firmware-independent MSI qtests.

Patch 2 separately aligns MSI fault PV reporting with QEMU's existing PDTV policy. Its PD8/DPE regression selects default process zero and checks PV, PID, and the original IOVA. Complete per-request PID-validity metadata handling is outside this change.

Patch 3 shares the private callback with nine deterministic unit tests for recovery faults and ordinary-DMA fallback, without adding a public API or runtime test hooks. The context stub uses a distinct release reference so cleanup checks cannot confuse it with the context.

Patch 1 can be applied on its own. Patch 2 builds on patch 1; neither requires patch 3. The refactoring and unit tests in patch 3 can be reviewed separately if the private implementation fragment or test structure needs further discussion.

The series is based on QEMU master at e9fa1f66f0d4. Validation covers RISC-V IOMMU qtests, MSI trap unit tests, the MSI regression probe, and an x86_64-softmmu-only unit-test build with -Werror.

The initial local series was also built and tested after each individual patch.

Issue: https://gitlab.com/qemu-project/qemu/-/work_items/3562

Zephyr Li (3):
hw/riscv/riscv-iommu: Preserve IOVA in MSI fault records hw/riscv/riscv-iommu: Fix MSI fault PV reporting for process ID zero hw/riscv/riscv-iommu: Add unit tests for MSI trap handling

 MAINTAINERS                        |   1 +
 hw/riscv/riscv-iommu-trap.c.inc    |  69 ++++++++
 hw/riscv/riscv-iommu.c             |  61 +++----
 tests/qtest/iommu-riscv-test.c     | 181 ++++++++++++++++++--
 tests/unit/meson.build             |   1 +
 tests/unit/test-riscv-iommu-trap.c | 266 +++++++++++++++++++++++++++++
 6 files changed, 525 insertions(+), 54 deletions(-)
 create mode 100644 hw/riscv/riscv-iommu-trap.c.inc
 create mode 100644 tests/unit/test-riscv-iommu-trap.c
Signature · 1 line
2.43.0