hw/riscv/riscv-iommu.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/hw/riscv/riscv-iommu.c b/hw/riscv/riscv-iommu.c
index e9a0775d6e..f5d53a36b2 100644
--- a/hw/riscv/riscv-iommu.c
+++ b/hw/riscv/riscv-iommu.c
@@ -2436,6 +2436,14 @@ void riscv_iommu_pci_setup_iommu(RISCVIOMMUState *iommu,
PCIBus *bus,
QLIST_INSERT_AFTER(last, iommu, iommus);
} else if (!bus->iommu_ops && !bus->iommu_opaque) {
pci_setup_iommu(bus, &riscv_iommu_ops, iommu);
+ } else if (bus->iommu_ops && bus->iommu_ops->set_memory_region) {
+ /*
+ * TODO:
+ * All memory transactions of this bus will be directed to this AS.
+ * We need to distinguish the source device dynamically.
+ */
+ AddressSpace *as = riscv_iommu_space(iommu, 0);
+ pci_setup_iommu_downstream_mem(bus, as->root);
} else {
error_setg(errp, "can't register secondary IOMMU for PCI bus #%d",
pci_bus_num(bus));