lkml.org 
[lkml]   [2023]   [Nov]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH 2/3] vfio: Add VFIO_DEVICE_PASID_[AT|DE]TACH_IOMMUFD_PT
Date


>-----Original Message-----
>From: Liu, Yi L <yi.l.liu@intel.com>
>Sent: Monday, November 27, 2023 2:39 PM
>Subject: [PATCH 2/3] vfio: Add
>VFIO_DEVICE_PASID_[AT|DE]TACH_IOMMUFD_PT
>
>This adds ioctls for the userspace to attach a given pasid of a vfio
>device to/from an IOAS/HWPT.
>
>Signed-off-by: Yi Liu <yi.l.liu@intel.com>
>---
> drivers/vfio/device_cdev.c | 45 +++++++++++++++++++++++++++++++
> drivers/vfio/vfio.h | 4 +++
> drivers/vfio/vfio_main.c | 8 ++++++
> include/uapi/linux/vfio.h | 55 ++++++++++++++++++++++++++++++++++++++
> 4 files changed, 112 insertions(+)
>
>diff --git a/drivers/vfio/device_cdev.c b/drivers/vfio/device_cdev.c
>index e75da0a70d1f..c2ac7ed44537 100644
>--- a/drivers/vfio/device_cdev.c
>+++ b/drivers/vfio/device_cdev.c
>@@ -210,6 +210,51 @@ int vfio_df_ioctl_detach_pt(struct vfio_device_file *df,
> return 0;
> }
>
>+int vfio_df_ioctl_pasid_attach_pt(struct vfio_device_file *df,
>+ struct vfio_device_pasid_attach_iommufd_pt
>__user *arg)
>+{
>+ struct vfio_device *device = df->device;
>+ struct vfio_device_pasid_attach_iommufd_pt attach;
>+ unsigned long minsz;
>+ int ret;
>+
>+ minsz = offsetofend(struct vfio_device_pasid_attach_iommufd_pt, pt_id);
>+
>+ if (copy_from_user(&attach, arg, minsz))
>+ return -EFAULT;
>+
>+ if (attach.argsz < minsz || attach.flags)
>+ return -EINVAL;
>+
>+ mutex_lock(&device->dev_set->lock);
>+ ret = device->ops->pasid_attach_ioas(device, attach.pasid,
>&attach.pt_id);
>+ mutex_unlock(&device->dev_set->lock);
>+
>+ return ret;
>+}
>+
>+int vfio_df_ioctl_pasid_detach_pt(struct vfio_device_file *df,
>+ struct vfio_device_pasid_detach_iommufd_pt
>__user *arg)
>+{
>+ struct vfio_device *device = df->device;
>+ struct vfio_device_pasid_detach_iommufd_pt detach;
>+ unsigned long minsz;
>+
>+ minsz = offsetofend(struct vfio_device_pasid_detach_iommufd_pt, flags);

Pasid isn't copied, should use pasid here?

Thanks
Zhenzhong

\
 
 \ /
  Last update: 2023-11-27 07:51    [W:4.143 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site