summaryrefslogtreecommitdiff
path: root/drivers/vfio/vfio.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-09-24 18:57:01 +0300
committerAlex Williamson <alex.williamson@redhat.com>2021-09-30 21:46:44 +0300
commitc3c0fa9d94f7078b6664d29d79484d071a144f2e (patch)
tree30e9089670973348a96dc8968eef50d73e51fa69 /drivers/vfio/vfio.c
parentfda49d97f2c4faf0b42e8796d3e6c868d992f3af (diff)
downloadlinux-c3c0fa9d94f7078b6664d29d79484d071a144f2e.tar.xz
vfio: clean up the check for mediated device in vfio_iommu_type1
Pass the group flags to ->attach_group and remove the messy check for the bus type. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Link: https://lore.kernel.org/r/20210924155705.4258-12-hch@lst.de Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'drivers/vfio/vfio.c')
-rw-r--r--drivers/vfio/vfio.c32
1 files changed, 5 insertions, 27 deletions
diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
index 6589e296ef34..08b27b64f0f9 100644
--- a/drivers/vfio/vfio.c
+++ b/drivers/vfio/vfio.c
@@ -68,30 +68,6 @@ struct vfio_unbound_dev {
struct list_head unbound_next;
};
-enum vfio_group_type {
- /*
- * Physical device with IOMMU backing.
- */
- VFIO_IOMMU,
-
- /*
- * Virtual device without IOMMU backing. The VFIO core fakes up an
- * iommu_group as the iommu_group sysfs interface is part of the
- * userspace ABI. The user of these devices must not be able to
- * directly trigger unmediated DMA.
- */
- VFIO_EMULATED_IOMMU,
-
- /*
- * Physical device without IOMMU backing. The VFIO core fakes up an
- * iommu_group as the iommu_group sysfs interface is part of the
- * userspace ABI. Users can trigger unmediated DMA by the device,
- * usage is highly dangerous, requires an explicit opt-in and will
- * taint the kernel.
- */
- VFIO_NO_IOMMU,
-};
-
struct vfio_group {
struct kref kref;
int minor;
@@ -219,7 +195,7 @@ static long vfio_noiommu_ioctl(void *iommu_data,
}
static int vfio_noiommu_attach_group(void *iommu_data,
- struct iommu_group *iommu_group)
+ struct iommu_group *iommu_group, enum vfio_group_type type)
{
return 0;
}
@@ -1129,7 +1105,8 @@ static int __vfio_container_attach_groups(struct vfio_container *container,
int ret = -ENODEV;
list_for_each_entry(group, &container->group_list, container_next) {
- ret = driver->ops->attach_group(data, group->iommu_group);
+ ret = driver->ops->attach_group(data, group->iommu_group,
+ group->type);
if (ret)
goto unwind;
}
@@ -1387,7 +1364,8 @@ static int vfio_group_set_container(struct vfio_group *group, int container_fd)
driver = container->iommu_driver;
if (driver) {
ret = driver->ops->attach_group(container->iommu_data,
- group->iommu_group);
+ group->iommu_group,
+ group->type);
if (ret)
goto unlock_out;
}