On 05/06/2023 17:57, Peter Xu wrote: > On Tue, May 30, 2023 at 06:59:25PM +0100, Joao Martins wrote: >> Much like pci_device_iommu_address_space() fetches the IOMMU AS, add a >> pci_device_iommu_memory_region() which lets it return an the IOMMU MR >> associated with it. The IOMMU MR is returned correctly for vIOMMUs using >> pci_setup_iommu_info(). Note that today most vIOMMUs create the address >> space and IOMMU MR at the same time, it's just mainly that there's API >> to make the latter available. > > Have you looked into other archs outside x86? IIRC on some other arch one > address space can have >1 IOMMU memory regions.. at least with such AS and > MR layering it seems always possible? Thanks, >
I looked at all callers of pci_setup_iommu() restricting to those that actually track an IOMMUMemoryRegion when they create a address space... as this is where pci_device_iommu_memory_region() is applicable. From looking at those[*], I see always a 1:1 association between the AS and the IOMMU-MR in their initialization when iommu_fn is called. Unless I missed something... Is there an arch you were thinking specifically? [I am not sure we can track today an 1:N AS->IOMMU association today in Qemu] [*] alpha, arm smmu, ppc, s390, virtio, and some pci bridges (pnv_phb3 and pnv_phb4) Joao