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
1685}1685}
1686EXPORT_SYMBOL_GPL(vfio_group_put_external_user);1686EXPORT_SYMBOL_GPL(vfio_group_put_external_user);
1687 1687
1688bool 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}
1695EXPORT_SYMBOL_GPL(vfio_external_group_match_file);
1696
1697/**1688/**
1698 * vfio_file_iommu_group - Return the struct iommu_group for the vfio group file1689 * vfio_file_iommu_group - Return the struct iommu_group for the vfio group file
1699 * @file: VFIO group file1690 * @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
138 */138 */
139extern struct vfio_group *vfio_group_get_external_user(struct file *filep);139extern struct vfio_group *vfio_group_get_external_user(struct file *filep);
140extern void vfio_group_put_external_user(struct vfio_group *group);140extern void vfio_group_put_external_user(struct vfio_group *group);
141extern bool vfio_external_group_match_file(struct vfio_group *group,
142 struct file *filep);
143extern struct iommu_group *vfio_file_iommu_group(struct file *file);141extern struct iommu_group *vfio_file_iommu_group(struct file *file);
144extern long vfio_external_check_extension(struct vfio_group *group,142extern long vfio_external_check_extension(struct vfio_group *group,
145 unsigned long arg);143 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
49 return vfio_group;49 return vfio_group;
50}50}
51 51
52static 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
68static void kvm_vfio_group_put_external_user(struct vfio_group *vfio_group)52static void kvm_vfio_group_put_external_user(struct vfio_group *vfio_group)
69{53{
70 void (*fn)(struct vfio_group *);54 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
239 mutex_lock(&kv->lock);223 mutex_lock(&kv->lock);
240 224
241 list_for_each_entry(kvg, &kv->group_list, node) {225 list_for_each_entry(kvg, &kv->group_list, node) {
242 if (!kvm_vfio_external_group_match_file(kvg->vfio_group,226 if (kvg->file != f.file)
243 f.file))
244 continue;227 continue;
245 228
246 list_del(&kvg->node);229 list_del(&kvg->node);