Blame SOURCES/0002-bus-pci-use-IOVAs-check-when-setting-IOVA-mode.patch

343f6f
From 9372cd814782d3ffdf2464b64fc6aa67a0bf117c Mon Sep 17 00:00:00 2001
343f6f
From: Alejandro Lucero <alejandro.lucero@netronome.com>
343f6f
Date: Tue, 10 Jul 2018 18:25:49 +0100
343f6f
Subject: [2/5] bus/pci: use IOVAs check when setting IOVA mode
343f6f
343f6f
Although VT-d emulation currently only supports 39 bits, it could
343f6f
be iovas being within that supported range. This patch allows
343f6f
IOVA mode in such a case.
343f6f
343f6f
Indeed, memory initialization code can be modified for using lower
343f6f
virtual addresses than those used by the kernel for 64 bits processes
343f6f
by default, and therefore memsegs iovas can use 39 bits or less for
343f6f
most system. And this is likely 100% true for VMs.
343f6f
343f6f
Applicable to v17.11.3 only.
343f6f
343f6f
Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
343f6f
---
343f6f
 drivers/bus/pci/linux/pci.c | 15 +++++++++++----
343f6f
 1 file changed, 11 insertions(+), 4 deletions(-)
343f6f
343f6f
diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
343f6f
index 74deef3..c81ed50 100644
343f6f
--- a/drivers/bus/pci/linux/pci.c
343f6f
+++ b/drivers/bus/pci/linux/pci.c
343f6f
@@ -43,6 +43,7 @@
343f6f
 #include <rte_devargs.h>
343f6f
 #include <rte_memcpy.h>
343f6f
 #include <rte_vfio.h>
343f6f
+#include <rte_memory.h>
343f6f
 
343f6f
 #include "eal_private.h"
343f6f
 #include "eal_filesystem.h"
343f6f
@@ -613,10 +614,12 @@ pci_one_device_iommu_support_va(struct rte_pci_device *dev)
343f6f
 	fclose(fp);
343f6f
 
343f6f
 	mgaw = ((vtd_cap_reg & VTD_CAP_MGAW_MASK) >> VTD_CAP_MGAW_SHIFT) + 1;
343f6f
-	if (mgaw < X86_VA_WIDTH)
343f6f
+
343f6f
+	if (!rte_eal_check_dma_mask(mgaw))
343f6f
+		return true;
343f6f
+	else
343f6f
 		return false;
343f6f
 
343f6f
-	return true;
343f6f
 }
343f6f
 #elif defined(RTE_ARCH_PPC_64)
343f6f
 static bool
343f6f
@@ -640,13 +643,17 @@ pci_devices_iommu_support_va(void)
343f6f
 {
343f6f
 	struct rte_pci_device *dev = NULL;
343f6f
 	struct rte_pci_driver *drv = NULL;
343f6f
+	int iommu_dma_mask_check_done = 0;
343f6f
 
343f6f
 	FOREACH_DRIVER_ON_PCIBUS(drv) {
343f6f
 		FOREACH_DEVICE_ON_PCIBUS(dev) {
343f6f
 			if (!rte_pci_match(drv, dev))
343f6f
 				continue;
343f6f
-			if (!pci_one_device_iommu_support_va(dev))
343f6f
-				return false;
343f6f
+			if (!iommu_dma_mask_check_done) {
343f6f
+				if (!pci_one_device_iommu_support_va(dev))
343f6f
+					return false;
343f6f
+				iommu_dma_mask_check_done  = 1;
343f6f
+			}
343f6f
 		}
343f6f
 	}
343f6f
 	return true;
343f6f
-- 
343f6f
1.8.3.1
343f6f