In case the IOMMU translates MSI, MSI IOVA will need to be transparently
allocated by the kernel in unused GPA space. Let's initialize a DMA domain
where some slots will be reserved "unmanaged" slots and rest is left
available for IOVA allocation.

Signed-off-by: Eric Auger <[email protected]>
---
 drivers/vfio/vfio_iommu_type1.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 2ba1942..ad08fd0 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -36,6 +36,7 @@
 #include <linux/uaccess.h>
 #include <linux/vfio.h>
 #include <linux/workqueue.h>
+#include <linux/dma-iommu.h>
 
 #define DRIVER_VERSION  "0.2"
 #define DRIVER_AUTHOR   "Alex Williamson <[email protected]>"
@@ -829,6 +830,11 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
 
        vfio_test_domain_fgsp(domain);
 
+       /* sets the IOVA window */
+       if (iommu_capable(bus, IOMMU_CAP_TRANSLATE_MSI) &&
+           iommu_get_dma_msi_region_cookie(domain->domain, 0, ULONG_MAX))
+               goto out_detach;
+
        /* replay mappings on new domains */
        ret = vfio_iommu_replay(iommu, domain);
        if (ret)
-- 
1.9.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to