From: Eric Auger Date: Fri, 14 Jun 2024 09:52:54 +0000 (+0200) Subject: HostIOMMUDevice: Store the aliased bus and devfn X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=a95264191f10173e27b175ebc4a487520a523d62;p=qemu.git HostIOMMUDevice: Store the aliased bus and devfn Store the aliased bus and devfn in the HostIOMMUDevice. This will be useful to handle info that are iommu group specific and not device specific (such as reserved iova ranges). Signed-off-by: Eric Auger Reviewed-by: Zhenzhong Duan Reviewed-by: Michael S. Tsirkin --- diff --git a/hw/pci/pci.c b/hw/pci/pci.c index c8a8aab306..50b86d5790 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2745,11 +2745,15 @@ AddressSpace *pci_device_iommu_address_space(PCIDevice *dev) bool pci_device_set_iommu_device(PCIDevice *dev, HostIOMMUDevice *hiod, Error **errp) { - PCIBus *iommu_bus; + PCIBus *iommu_bus, *aliased_bus; + int aliased_devfn; /* set_iommu_device requires device's direct BDF instead of aliased BDF */ - pci_device_get_iommu_bus_devfn(dev, &iommu_bus, NULL, NULL); + pci_device_get_iommu_bus_devfn(dev, &iommu_bus, + &aliased_bus, &aliased_devfn); if (iommu_bus && iommu_bus->iommu_ops->set_iommu_device) { + hiod->aliased_bus = aliased_bus; + hiod->aliased_devfn = aliased_devfn; return iommu_bus->iommu_ops->set_iommu_device(pci_get_bus(dev), iommu_bus->iommu_opaque, dev->devfn, hiod, errp); diff --git a/include/sysemu/host_iommu_device.h b/include/sysemu/host_iommu_device.h index 40e0fa13ef..ee6c813c8b 100644 --- a/include/sysemu/host_iommu_device.h +++ b/include/sysemu/host_iommu_device.h @@ -35,6 +35,8 @@ struct HostIOMMUDevice { char *name; void *agent; /* pointer to agent device, ie. VFIO or VDPA device */ + PCIBus *aliased_bus; + int aliased_devfn; HostIOMMUDeviceCaps caps; };