diff mbox

[RFC,08/11] vfio/type1: Sets the IOVA window in case MSI IOVA need to be allocated

Message ID 1475009318-2617-9-git-send-email-eric.auger@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Eric Auger Sept. 27, 2016, 8:48 p.m. UTC
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 <eric.auger@redhat.com>
---
 drivers/vfio/vfio_iommu_type1.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox

Patch

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 <alex.williamson@redhat.com>"
@@ -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)