The current IOVA allocator allocates within the [0x10000, 1ULL << 39] window, without paying attention to the host IOVA reserved regions. This prevents NVMe passthtrough from working on ARM as the fixed IOVAs rapidly grow up to the MSI reserved region [0x8000000, 0x8100000] causing some VFIO MAP DMA failures. This series collects the usable IOVA regions using VFIO GET_INFO (this requires the host to support VFIO_IOMMU_TYPE1_INFO_CAP_IOVA_RANGE) and rework the fixed and temporary IOVA allocators to avoid those latter. Also the min/max IOVAs now can be dynamically determined.
Unfortunately the usable host IOVA ranges reported by the kernel currently do not take into account the dma_mask of devices within the group. This needs to be fixed, otherwise this series might try to allocate temporary IOVAs within the range supported by the IOMMU but beyond the allowed dma_mask. I got the case where the SMMU supports up to 48 bits but the dma_mask only is 42bits. This kernel dependency plus the testing limited to one peculiar ARM platform explains the RFC state. Best Regards Eric This series can be found at: https://github.com/eauger/qemu/tree/nvme_rfc This was tested on ARM only. Eric Auger (3): util/vfio-helpers: Collect IOVA reserved regions util/vfio-helpers: Dynamically compute the min/max IOVA util/vfio-helpers: Rework the IOVA allocator to avoid IOVA reserved regions util/vfio-helpers.c | 162 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 143 insertions(+), 19 deletions(-) -- 2.21.3