vfio: Support VFIO_NOIOMMU with iommufd
authorJason Gunthorpe <jgg@nvidia.com>
Wed, 18 Jan 2023 17:50:28 +0000 (13:50 -0400)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 3 Feb 2023 19:45:23 +0000 (15:45 -0400)
commitc9a397cee9f5c93a7f48e18038b14057044db6ba
tree8b7e0c201d5e50562c6fc0c553da53fd37dfd980
parentb7bfaa761d760e72a969d116517eaa12e404c262
vfio: Support VFIO_NOIOMMU with iommufd

Add a small amount of emulation to vfio_compat to accept the SET_IOMMU to
VFIO_NOIOMMU_IOMMU and have vfio just ignore iommufd if it is working on a
no-iommu enabled device.

Move the enable_unsafe_noiommu_mode module out of container.c into
vfio_main.c so that it is always available even if VFIO_CONTAINER=n.

This passes Alex's mini-test:

https://github.com/awilliam/tests/blob/master/vfio-noiommu-pci-device-open.c

Link: https://lore.kernel.org/r/0-v3-480cd64a16f7+1ad0-iommufd_noiommu_jgg@nvidia.com
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/iommu/iommufd/Kconfig
drivers/iommu/iommufd/iommufd_private.h
drivers/iommu/iommufd/vfio_compat.c
drivers/vfio/Kconfig
drivers/vfio/container.c
drivers/vfio/group.c
drivers/vfio/iommufd.c
drivers/vfio/vfio.h
drivers/vfio/vfio_main.c
include/linux/iommufd.h