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

Move it out of mdpy_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/7-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
cf16acc0 07877552

+29 -24
+29 -24
samples/vfio-mdev/mdpy.c
··· 512 512 return 0; 513 513 } 514 514 515 + static int mdpy_ioctl_get_region_info(struct vfio_device *vdev, 516 + struct vfio_region_info __user *arg) 517 + { 518 + struct mdev_state *mdev_state = 519 + container_of(vdev, struct mdev_state, vdev); 520 + struct vfio_region_info info; 521 + void *cap_type = NULL; 522 + u16 cap_type_id = 0; 523 + unsigned long minsz; 524 + int ret; 525 + 526 + minsz = offsetofend(struct vfio_region_info, offset); 527 + 528 + if (copy_from_user(&info, arg, minsz)) 529 + return -EFAULT; 530 + 531 + if (info.argsz < minsz) 532 + return -EINVAL; 533 + 534 + ret = mdpy_get_region_info(mdev_state, &info, &cap_type_id, &cap_type); 535 + if (ret) 536 + return ret; 537 + 538 + if (copy_to_user(arg, &info, minsz)) 539 + return -EFAULT; 540 + return 0; 541 + } 542 + 515 543 static long mdpy_ioctl(struct vfio_device *vdev, unsigned int cmd, 516 544 unsigned long arg) 517 545 { ··· 566 538 return ret; 567 539 568 540 memcpy(&mdev_state->dev_info, &info, sizeof(info)); 569 - 570 - if (copy_to_user((void __user *)arg, &info, minsz)) 571 - return -EFAULT; 572 - 573 - return 0; 574 - } 575 - case VFIO_DEVICE_GET_REGION_INFO: 576 - { 577 - struct vfio_region_info info; 578 - u16 cap_type_id = 0; 579 - void *cap_type = NULL; 580 - 581 - minsz = offsetofend(struct vfio_region_info, offset); 582 - 583 - if (copy_from_user(&info, (void __user *)arg, minsz)) 584 - return -EFAULT; 585 - 586 - if (info.argsz < minsz) 587 - return -EINVAL; 588 - 589 - ret = mdpy_get_region_info(mdev_state, &info, &cap_type_id, 590 - &cap_type); 591 - if (ret) 592 - return ret; 593 541 594 542 if (copy_to_user((void __user *)arg, &info, minsz)) 595 543 return -EFAULT; ··· 669 665 .read = mdpy_read, 670 666 .write = mdpy_write, 671 667 .ioctl = mdpy_ioctl, 668 + .get_region_info = mdpy_ioctl_get_region_info, 672 669 .mmap = mdpy_mmap, 673 670 .bind_iommufd = vfio_iommufd_emulated_bind, 674 671 .unbind_iommufd = vfio_iommufd_emulated_unbind,