History

vfio: Remove vfio_external_group_match_file()

vfio_group_fops_open() ensures there is only ever one struct file open for any struct vfio_group at any time: /* Do we need multiple instances of the group open? Seems not. */ opened = atomic_cmpxchg(&group->opened, 0, 1); if (opened) { vfio_group_put(group); return -EBUSY; Therefor the struct file * can be used directly to search the list of VFIO groups that KVM keeps instead of using the vfio_external_group_match_file() callback to try to figure out if the passed in FD matches the list or not. Delete vfio_external_group_match_file().

Jason Gunthorpe committed 4 years ago

Commit c38ff5b1 parent 50d63b53 files · +1 −29Browse files

Unified · Split

3 files
  1. drivers/vfio/vfio.c +0 −9
  2. include/linux/vfio.h +0 −2
  3. virt/kvm/vfio.c +1 −18
drivers/vfio/vfio.c+0−9
@@ -1685,15 +1685,6 @@ void vfio_group_put_external_user(struct vfio_group *group) · 1684 unmodified lines
16851685 }
16861686 EXPORT_SYMBOL_GPL(vfio_group_put_external_user);
16871687
1688−bool vfio_external_group_match_file(struct vfio_group *test_group,
1689− struct file *filep)
1690−{
1691− struct vfio_group *group = filep->private_data;
1692−
1693− return (filep->f_op == &vfio_group_fops) && (group == test_group);
1694−}
1695−EXPORT_SYMBOL_GPL(vfio_external_group_match_file);
1696−
16971688 /**
16981689 * vfio_file_iommu_group - Return the struct iommu_group for the vfio group file
16991690 * @file: VFIO group file
include/linux/vfio.h+0−2
@@ -138,8 +138,6 @@ int vfio_mig_get_next_state(struct vfio_device *device, · 137 unmodified lines
138138 */
139139 extern struct vfio_group *vfio_group_get_external_user(struct file *filep);
140140 extern void vfio_group_put_external_user(struct vfio_group *group);
141−extern bool vfio_external_group_match_file(struct vfio_group *group,
142− struct file *filep);
143141 extern struct iommu_group *vfio_file_iommu_group(struct file *file);
144142 extern long vfio_external_check_extension(struct vfio_group *group,
145143 unsigned long arg);
virt/kvm/vfio.c+1−18
@@ -49,22 +49,6 @@ static struct vfio_group *kvm_vfio_group_get_external_user(struct file *filep) · 48 unmodified lines
4949 return vfio_group;
5050 }
5151
52−static bool kvm_vfio_external_group_match_file(struct vfio_group *group,
53− struct file *filep)
54−{
55− bool ret, (*fn)(struct vfio_group *, struct file *);
56−
57− fn = symbol_get(vfio_external_group_match_file);
58− if (!fn)
59− return false;
60−
61− ret = fn(group, filep);
62−
63− symbol_put(vfio_external_group_match_file);
64−
65− return ret;
66−}
67−
6852 static void kvm_vfio_group_put_external_user(struct vfio_group *vfio_group)
6953 {
7054 void (*fn)(struct vfio_group *);
@@ -239,8 +223,7 @@ static int kvm_vfio_group_del(struct kvm_device *dev, unsigned int fd) · 168 unmodified lines
239223 mutex_lock(&kv->lock);
240224
241225 list_for_each_entry(kvg, &kv->group_list, node) {
242− if (!kvm_vfio_external_group_match_file(kvg->vfio_group,
243− f.file))
226+ if (kvg->file != f.file)
244227 continue;
245228
246229 list_del(&kvg->node);