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


On 2023/11/27 14:50, Duan, Zhenzhong wrote:
>
>
>> -----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?

good catch! will fix it.

--
Regards,
Yi Liu

\
 
 \ /
  Last update: 2023-11-28 04:05    [W:0.085 / U:1.216 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site