diff mbox series

[v3,04/15] intel-iommu: Switch to pci_setup_iommu_info()

Message ID 20230530175937.24202-5-joao.m.martins@oracle.com (mailing list archive)
State New, archived
Headers show
Series vfio: VFIO migration support with vIOMMU | expand

Commit Message

Joao Martins May 30, 2023, 5:59 p.m. UTC
Use the PCI IOMMU setup function that allows returning the
IOMMUMemoryRegion in addition to the AddressSpace. To faciliate
conversion use the new to_pci_as()/pci_as_to_as() helpers.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
---
 hw/i386/intel_iommu.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 94d52f4205d2..c344d49fe290 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -4021,7 +4021,7 @@  static void vtd_reset(DeviceState *dev)
     vtd_address_space_refresh_all(s);
 }
 
-static AddressSpace *vtd_host_dma_iommu(PCIBus *bus, void *opaque, int devfn)
+static PCIAddressSpace vtd_host_dma_iommu(PCIBus *bus, void *opaque, int devfn)
 {
     IntelIOMMUState *s = opaque;
     VTDAddressSpace *vtd_as;
@@ -4029,7 +4029,7 @@  static AddressSpace *vtd_host_dma_iommu(PCIBus *bus, void *opaque, int devfn)
     assert(0 <= devfn && devfn < PCI_DEVFN_MAX);
 
     vtd_as = vtd_find_add_as(s, bus, devfn, PCI_NO_PASID);
-    return &vtd_as->as;
+    return to_pci_as(&vtd_as->as, &vtd_as->iommu);
 }
 
 static bool vtd_decide_config(IntelIOMMUState *s, Error **errp)
@@ -4155,9 +4155,10 @@  static void vtd_realize(DeviceState *dev, Error **errp)
                                       g_free, g_free);
     vtd_init(s);
     sysbus_mmio_map(SYS_BUS_DEVICE(s), 0, Q35_HOST_BRIDGE_IOMMU_ADDR);
-    pci_setup_iommu(bus, vtd_host_dma_iommu, dev);
+    pci_setup_iommu_info(bus, vtd_host_dma_iommu, dev);
     /* Pseudo address space under root PCI bus. */
-    x86ms->ioapic_as = vtd_host_dma_iommu(bus, s, Q35_PSEUDO_DEVFN_IOAPIC);
+    x86ms->ioapic_as = pci_as_to_as(vtd_host_dma_iommu(bus,
+                                                s, Q35_PSEUDO_DEVFN_IOAPIC));
     qemu_add_machine_init_done_notifier(&vtd_machine_done_notify);
 }