On 2022/11/29 21:27, Jason Gunthorpe wrote:
On Tue, Nov 29, 2022 at 02:04:01AM +0000, Tian, Kevin wrote:
From: Liu, Yi L <yi.l.liu@xxxxxxxxx>
Sent: Monday, November 28, 2022 5:17 PM
+static int vfio_device_set_group(struct vfio_device *device,
+ enum vfio_group_type type)
{
- int ret;
+ struct vfio_group *group;
+
+ if (type == VFIO_IOMMU)
+ group = vfio_group_find_or_alloc(device->dev);
+ else
+ group = vfio_noiommu_group_alloc(device->dev, type);
Do we need a WARN_ON(type == VFIO_NO_IOMMU)?
do you mean a heads-up to user? if so, there is already a warn in
vfio_group_find_or_alloc() and vfio_group_ioctl_get_device_fd()
I meant that VFIO_NO_IOMMU is not expected as a passed in type.
It's implicitly handled by vfio_group_find_or_alloc() which calls
vfio_noiommu_group_alloc() plus kernel taint.
The code is simple enough to check the two callers, I don't know if we
need a WARN_ON - and it isn't actually wrong to call
vfio_noiommu_group_alloc() for a VFIO_NO_IOMMU..
this function also works if the VFIO_NO_IOMMU is passed in. But no such
usage in the code yet. :-)
--
Regards,
Yi Liu