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/mtty: Provide a get_region_info op

Move it out of mtty_ioctl() and re-indent it.

Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Pranjal Shrivastava <praan@google.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/6-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
07877552 f3fddb71

+29 -24
+29 -24
samples/vfio-mdev/mtty.c
··· 1785 1785 return 0; 1786 1786 } 1787 1787 1788 + static int mtty_ioctl_get_region_info(struct vfio_device *vdev, 1789 + struct vfio_region_info __user *arg) 1790 + { 1791 + struct mdev_state *mdev_state = 1792 + container_of(vdev, struct mdev_state, vdev); 1793 + struct vfio_region_info info; 1794 + void *cap_type = NULL; 1795 + u16 cap_type_id = 0; 1796 + unsigned long minsz; 1797 + int ret; 1798 + 1799 + minsz = offsetofend(struct vfio_region_info, offset); 1800 + 1801 + if (copy_from_user(&info, arg, minsz)) 1802 + return -EFAULT; 1803 + 1804 + if (info.argsz < minsz) 1805 + return -EINVAL; 1806 + 1807 + ret = mtty_get_region_info(mdev_state, &info, &cap_type_id, &cap_type); 1808 + if (ret) 1809 + return ret; 1810 + 1811 + if (copy_to_user(arg, &info, minsz)) 1812 + return -EFAULT; 1813 + return 0; 1814 + } 1815 + 1788 1816 static long mtty_ioctl(struct vfio_device *vdev, unsigned int cmd, 1789 1817 unsigned long arg) 1790 1818 { ··· 1839 1811 return ret; 1840 1812 1841 1813 memcpy(&mdev_state->dev_info, &info, sizeof(info)); 1842 - 1843 - if (copy_to_user((void __user *)arg, &info, minsz)) 1844 - return -EFAULT; 1845 - 1846 - return 0; 1847 - } 1848 - case VFIO_DEVICE_GET_REGION_INFO: 1849 - { 1850 - struct vfio_region_info info; 1851 - u16 cap_type_id = 0; 1852 - void *cap_type = NULL; 1853 - 1854 - minsz = offsetofend(struct vfio_region_info, offset); 1855 - 1856 - if (copy_from_user(&info, (void __user *)arg, minsz)) 1857 - return -EFAULT; 1858 - 1859 - if (info.argsz < minsz) 1860 - return -EINVAL; 1861 - 1862 - ret = mtty_get_region_info(mdev_state, &info, &cap_type_id, 1863 - &cap_type); 1864 - if (ret) 1865 - return ret; 1866 1814 1867 1815 if (copy_to_user((void __user *)arg, &info, minsz)) 1868 1816 return -EFAULT; ··· 1953 1949 .read = mtty_read, 1954 1950 .write = mtty_write, 1955 1951 .ioctl = mtty_ioctl, 1952 + .get_region_info = mtty_ioctl_get_region_info, 1956 1953 .bind_iommufd = vfio_iommufd_emulated_bind, 1957 1954 .unbind_iommufd = vfio_iommufd_emulated_unbind, 1958 1955 .attach_ioas = vfio_iommufd_emulated_attach_ioas,