Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

vfio: Provide a get_region_info op

Instead of hooking the general ioctl op, have the core code directly
decode VFIO_DEVICE_GET_REGION_INFO and call an op just for it.

This is intended to allow mechanical changes to the drivers to pull their
VFIO_DEVICE_GET_REGION_INFO int oa function. Later patches will improve
the function signature to consolidate more code.

Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/1-v2-2a9e24d62f1b+e10a-vfio_get_region_info_op_jgg@nvidia.com
Signed-off-by: Alex Williamson <alex@shazbot.org>

authored by

Jason Gunthorpe and committed by
Alex Williamson
113557b0 0ed3a30f

+17 -3
+6 -3
drivers/vfio/pci/vfio_pci_core.c
··· 996 996 return copy_to_user(arg, &info, minsz) ? -EFAULT : 0; 997 997 } 998 998 999 - static int vfio_pci_ioctl_get_region_info(struct vfio_pci_core_device *vdev, 1000 - struct vfio_region_info __user *arg) 999 + int vfio_pci_ioctl_get_region_info(struct vfio_device *core_vdev, 1000 + struct vfio_region_info __user *arg) 1001 1001 { 1002 + struct vfio_pci_core_device *vdev = 1003 + container_of(core_vdev, struct vfio_pci_core_device, vdev); 1002 1004 unsigned long minsz = offsetofend(struct vfio_region_info, offset); 1003 1005 struct pci_dev *pdev = vdev->pdev; 1004 1006 struct vfio_region_info info; ··· 1134 1132 1135 1133 return copy_to_user(arg, &info, minsz) ? -EFAULT : 0; 1136 1134 } 1135 + EXPORT_SYMBOL_GPL(vfio_pci_ioctl_get_region_info); 1137 1136 1138 1137 static int vfio_pci_ioctl_get_irq_info(struct vfio_pci_core_device *vdev, 1139 1138 struct vfio_irq_info __user *arg) ··· 1461 1458 case VFIO_DEVICE_GET_PCI_HOT_RESET_INFO: 1462 1459 return vfio_pci_ioctl_get_pci_hot_reset_info(vdev, uarg); 1463 1460 case VFIO_DEVICE_GET_REGION_INFO: 1464 - return vfio_pci_ioctl_get_region_info(vdev, uarg); 1461 + return vfio_pci_ioctl_get_region_info(core_vdev, uarg); 1465 1462 case VFIO_DEVICE_IOEVENTFD: 1466 1463 return vfio_pci_ioctl_ioeventfd(vdev, uarg); 1467 1464 case VFIO_DEVICE_PCI_HOT_RESET:
+7
drivers/vfio/vfio_main.c
··· 1296 1296 ret = vfio_ioctl_device_feature(device, uptr); 1297 1297 break; 1298 1298 1299 + case VFIO_DEVICE_GET_REGION_INFO: 1300 + if (!device->ops->get_region_info) 1301 + goto ioctl_fallback; 1302 + ret = device->ops->get_region_info(device, uptr); 1303 + break; 1304 + 1299 1305 default: 1306 + ioctl_fallback: 1300 1307 if (unlikely(!device->ops->ioctl)) 1301 1308 ret = -EINVAL; 1302 1309 else
+2
include/linux/vfio.h
··· 132 132 size_t count, loff_t *size); 133 133 long (*ioctl)(struct vfio_device *vdev, unsigned int cmd, 134 134 unsigned long arg); 135 + int (*get_region_info)(struct vfio_device *vdev, 136 + struct vfio_region_info __user *arg); 135 137 int (*mmap)(struct vfio_device *vdev, struct vm_area_struct *vma); 136 138 void (*request)(struct vfio_device *vdev, unsigned int count); 137 139 int (*match)(struct vfio_device *vdev, char *buf);
+2
include/linux/vfio_pci_core.h
··· 115 115 unsigned long arg); 116 116 int vfio_pci_core_ioctl_feature(struct vfio_device *device, u32 flags, 117 117 void __user *arg, size_t argsz); 118 + int vfio_pci_ioctl_get_region_info(struct vfio_device *core_vdev, 119 + struct vfio_region_info __user *arg); 118 120 ssize_t vfio_pci_core_read(struct vfio_device *core_vdev, char __user *buf, 119 121 size_t count, loff_t *ppos); 120 122 ssize_t vfio_pci_core_write(struct vfio_device *core_vdev, const char __user *buf,