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

Move it out of mbochs_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/8-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
8339fccd cf16acc0

+31 -25
+31 -25
samples/vfio-mdev/mbochs.c
··· 1185 1185 return dma_buf_fd(dmabuf->buf, 0); 1186 1186 } 1187 1187 1188 + static int mbochs_ioctl_get_region_info(struct vfio_device *vdev, 1189 + struct vfio_region_info __user *arg) 1190 + { 1191 + struct mdev_state *mdev_state = 1192 + container_of(vdev, struct mdev_state, vdev); 1193 + struct vfio_region_info_ext info; 1194 + unsigned long minsz, outsz; 1195 + int ret; 1196 + 1197 + minsz = offsetofend(typeof(info), base.offset); 1198 + 1199 + if (copy_from_user(&info, arg, minsz)) 1200 + return -EFAULT; 1201 + 1202 + outsz = info.base.argsz; 1203 + if (outsz < minsz) 1204 + return -EINVAL; 1205 + if (outsz > sizeof(info)) 1206 + return -EINVAL; 1207 + 1208 + ret = mbochs_get_region_info(mdev_state, &info); 1209 + if (ret) 1210 + return ret; 1211 + 1212 + if (copy_to_user(arg, &info, outsz)) 1213 + return -EFAULT; 1214 + return 0; 1215 + } 1216 + 1188 1217 static long mbochs_ioctl(struct vfio_device *vdev, unsigned int cmd, 1189 1218 unsigned long arg) 1190 1219 { 1191 1220 struct mdev_state *mdev_state = 1192 1221 container_of(vdev, struct mdev_state, vdev); 1193 1222 int ret = 0; 1194 - unsigned long minsz, outsz; 1223 + unsigned long minsz; 1195 1224 1196 1225 switch (cmd) { 1197 1226 case VFIO_DEVICE_GET_INFO: ··· 1240 1211 return ret; 1241 1212 1242 1213 if (copy_to_user((void __user *)arg, &info, minsz)) 1243 - return -EFAULT; 1244 - 1245 - return 0; 1246 - } 1247 - case VFIO_DEVICE_GET_REGION_INFO: 1248 - { 1249 - struct vfio_region_info_ext info; 1250 - 1251 - minsz = offsetofend(typeof(info), base.offset); 1252 - 1253 - if (copy_from_user(&info, (void __user *)arg, minsz)) 1254 - return -EFAULT; 1255 - 1256 - outsz = info.base.argsz; 1257 - if (outsz < minsz) 1258 - return -EINVAL; 1259 - if (outsz > sizeof(info)) 1260 - return -EINVAL; 1261 - 1262 - ret = mbochs_get_region_info(mdev_state, &info); 1263 - if (ret) 1264 - return ret; 1265 - 1266 - if (copy_to_user((void __user *)arg, &info, outsz)) 1267 1214 return -EFAULT; 1268 1215 1269 1216 return 0; ··· 1381 1376 .read = mbochs_read, 1382 1377 .write = mbochs_write, 1383 1378 .ioctl = mbochs_ioctl, 1379 + .get_region_info = mbochs_ioctl_get_region_info, 1384 1380 .mmap = mbochs_mmap, 1385 1381 .bind_iommufd = vfio_iommufd_emulated_bind, 1386 1382 .unbind_iommufd = vfio_iommufd_emulated_unbind,