From 5e5acd3dbfb86ef1d52e7fe88806a6cedeb7b6eb Mon Sep 17 00:00:00 2001 From: Nikos Dragazis Date: Wed, 6 Feb 2019 03:25:15 +0200 Subject: [PATCH] setup.sh: use vfio kernel driver in case of vfio no-IOMMU mode The current state for the setup script is that the vfio kernel driver will be preferred against the uio_pci_generic driver only if an IOMMU is present in the system. This is checked by looking for any IOMMU groups in sysfs. In case of vfio no-IOMMU driver, there are no IOMMU groups when loading the vfio modules. The IOMMU groups are created when the PCI devices get bound to the vfio-pci driver. Thus, even though the vfio driver is loaded, the setup script will prefer to use the uio_pci_generic kernel driver. This patch changes this behavior. In order to support vfio no-IOMMU mode, the setup script will be checking if the vfio module is loaded with parameter "enable_unsafe_noiommu_mode". In other case, it will be falling back to the uio_pci_generic driver. Change-Id: I1e8317bc4e3d6af4ba8a9e0c51175c9f4190f47b Signed-off-by: Nikos Dragazis Reviewed-on: https://review.gerrithub.io/c/441062 Reviewed-by: Darek Stojaczyk Reviewed-by: Jim Harris Tested-by: SPDK CI Jenkins --- scripts/setup.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/setup.sh b/scripts/setup.sh index 280ef299f..6be3e4c0a 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -170,8 +170,12 @@ function configure_linux_pci { if [ -z "${DRIVER_OVERRIDE}" ]; then driver_name=vfio-pci if [ -z "$(ls /sys/kernel/iommu_groups)" ]; then - # No IOMMU. Use uio. - driver_name=uio_pci_generic + # No IOMMU. If no-IOMMU mode vfio is not present, then use uio. + if ! [ -e /sys/module/vfio/parameters/enable_unsafe_noiommu_mode ] || + ! [ "$(cat /sys/module/vfio/parameters/enable_unsafe_noiommu_mode)" == "Y" ] + then + driver_name=uio_pci_generic + fi fi else driver_name="${DRIVER_OVERRIDE}"