[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <SJ0PR11MB6744B5CAC867EE643958078D92BDA@SJ0PR11MB6744.namprd11.prod.outlook.com>
Date: Mon, 27 Nov 2023 06:50:36 +0000
From: "Duan, Zhenzhong" <zhenzhong.duan@...el.com>
To: "Liu, Yi L" <yi.l.liu@...el.com>,
"joro@...tes.org" <joro@...tes.org>,
"alex.williamson@...hat.com" <alex.williamson@...hat.com>,
"jgg@...dia.com" <jgg@...dia.com>,
"Tian, Kevin" <kevin.tian@...el.com>,
"robin.murphy@....com" <robin.murphy@....com>,
"baolu.lu@...ux.intel.com" <baolu.lu@...ux.intel.com>
CC: "cohuck@...hat.com" <cohuck@...hat.com>,
"eric.auger@...hat.com" <eric.auger@...hat.com>,
"nicolinc@...dia.com" <nicolinc@...dia.com>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"mjrosato@...ux.ibm.com" <mjrosato@...ux.ibm.com>,
"chao.p.peng@...ux.intel.com" <chao.p.peng@...ux.intel.com>,
"yi.y.sun@...ux.intel.com" <yi.y.sun@...ux.intel.com>,
"peterx@...hat.com" <peterx@...hat.com>,
"jasowang@...hat.com" <jasowang@...hat.com>,
"shameerali.kolothum.thodi@...wei.com"
<shameerali.kolothum.thodi@...wei.com>,
"lulu@...hat.com" <lulu@...hat.com>,
"suravee.suthikulpanit@....com" <suravee.suthikulpanit@....com>,
"iommu@...ts.linux.dev" <iommu@...ts.linux.dev>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-kselftest@...r.kernel.org" <linux-kselftest@...r.kernel.org>,
"joao.m.martins@...cle.com" <joao.m.martins@...cle.com>,
"Zeng, Xin" <xin.zeng@...el.com>,
"Zhao, Yan Y" <yan.y.zhao@...el.com>
Subject: RE: [PATCH 2/3] vfio: Add VFIO_DEVICE_PASID_[AT|DE]TACH_IOMMUFD_PT
>-----Original Message-----
>From: Liu, Yi L <yi.l.liu@...el.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@...el.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
Powered by blists - more mailing lists