mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
vfio/virtio: Convert to the get_region_info op
Remove virtiovf_vfio_pci_core_ioctl() and change the signature of virtiovf_pci_ioctl_get_region_info(). 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/3-v2-2a9e24d62f1b+e10a-vfio_get_region_info_op_jgg@nvidia.com Signed-off-by: Alex Williamson <alex@shazbot.org>
This commit is contained in:
committed by
Alex Williamson
parent
e238f147d5
commit
c044eefa47
@@ -109,10 +109,8 @@ void virtiovf_migration_reset_done(struct pci_dev *pdev);
|
|||||||
|
|
||||||
#ifdef CONFIG_VIRTIO_VFIO_PCI_ADMIN_LEGACY
|
#ifdef CONFIG_VIRTIO_VFIO_PCI_ADMIN_LEGACY
|
||||||
int virtiovf_open_legacy_io(struct virtiovf_pci_core_device *virtvdev);
|
int virtiovf_open_legacy_io(struct virtiovf_pci_core_device *virtvdev);
|
||||||
long virtiovf_vfio_pci_core_ioctl(struct vfio_device *core_vdev,
|
|
||||||
unsigned int cmd, unsigned long arg);
|
|
||||||
int virtiovf_pci_ioctl_get_region_info(struct vfio_device *core_vdev,
|
int virtiovf_pci_ioctl_get_region_info(struct vfio_device *core_vdev,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct vfio_region_info __user *arg);
|
||||||
ssize_t virtiovf_pci_core_write(struct vfio_device *core_vdev,
|
ssize_t virtiovf_pci_core_write(struct vfio_device *core_vdev,
|
||||||
const char __user *buf, size_t count,
|
const char __user *buf, size_t count,
|
||||||
loff_t *ppos);
|
loff_t *ppos);
|
||||||
|
|||||||
@@ -281,15 +281,14 @@ ssize_t virtiovf_pci_core_write(struct vfio_device *core_vdev, const char __user
|
|||||||
}
|
}
|
||||||
|
|
||||||
int virtiovf_pci_ioctl_get_region_info(struct vfio_device *core_vdev,
|
int virtiovf_pci_ioctl_get_region_info(struct vfio_device *core_vdev,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct vfio_region_info __user *arg)
|
||||||
{
|
{
|
||||||
struct virtiovf_pci_core_device *virtvdev = container_of(
|
struct virtiovf_pci_core_device *virtvdev = container_of(
|
||||||
core_vdev, struct virtiovf_pci_core_device, core_device.vdev);
|
core_vdev, struct virtiovf_pci_core_device, core_device.vdev);
|
||||||
unsigned long minsz = offsetofend(struct vfio_region_info, offset);
|
unsigned long minsz = offsetofend(struct vfio_region_info, offset);
|
||||||
void __user *uarg = (void __user *)arg;
|
|
||||||
struct vfio_region_info info = {};
|
struct vfio_region_info info = {};
|
||||||
|
|
||||||
if (copy_from_user(&info, uarg, minsz))
|
if (copy_from_user(&info, arg, minsz))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
if (info.argsz < minsz)
|
if (info.argsz < minsz)
|
||||||
@@ -301,20 +300,9 @@ int virtiovf_pci_ioctl_get_region_info(struct vfio_device *core_vdev,
|
|||||||
info.size = virtvdev->bar0_virtual_buf_size;
|
info.size = virtvdev->bar0_virtual_buf_size;
|
||||||
info.flags = VFIO_REGION_INFO_FLAG_READ |
|
info.flags = VFIO_REGION_INFO_FLAG_READ |
|
||||||
VFIO_REGION_INFO_FLAG_WRITE;
|
VFIO_REGION_INFO_FLAG_WRITE;
|
||||||
return copy_to_user(uarg, &info, minsz) ? -EFAULT : 0;
|
return copy_to_user(arg, &info, minsz) ? -EFAULT : 0;
|
||||||
default:
|
default:
|
||||||
return vfio_pci_core_ioctl(core_vdev, cmd, arg);
|
return vfio_pci_ioctl_get_region_info(core_vdev, arg);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
long virtiovf_vfio_pci_core_ioctl(struct vfio_device *core_vdev, unsigned int cmd,
|
|
||||||
unsigned long arg)
|
|
||||||
{
|
|
||||||
switch (cmd) {
|
|
||||||
case VFIO_DEVICE_GET_REGION_INFO:
|
|
||||||
return virtiovf_pci_ioctl_get_region_info(core_vdev, cmd, arg);
|
|
||||||
default:
|
|
||||||
return vfio_pci_core_ioctl(core_vdev, cmd, arg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,8 @@ static const struct vfio_device_ops virtiovf_vfio_pci_tran_lm_ops = {
|
|||||||
.release = virtiovf_pci_core_release_dev,
|
.release = virtiovf_pci_core_release_dev,
|
||||||
.open_device = virtiovf_pci_open_device,
|
.open_device = virtiovf_pci_open_device,
|
||||||
.close_device = virtiovf_pci_close_device,
|
.close_device = virtiovf_pci_close_device,
|
||||||
.ioctl = virtiovf_vfio_pci_core_ioctl,
|
.ioctl = vfio_pci_core_ioctl,
|
||||||
|
.get_region_info = virtiovf_pci_ioctl_get_region_info,
|
||||||
.device_feature = vfio_pci_core_ioctl_feature,
|
.device_feature = vfio_pci_core_ioctl_feature,
|
||||||
.read = virtiovf_pci_core_read,
|
.read = virtiovf_pci_core_read,
|
||||||
.write = virtiovf_pci_core_write,
|
.write = virtiovf_pci_core_write,
|
||||||
|
|||||||
Reference in New Issue
Block a user