Messages in this thread | | | Date | Mon, 24 Apr 2023 10:44:08 +0800 | Subject | Re: [PATCH RFC v3 2/4] iommufd: Add IOMMUFD_CMD_DEVICE_SET_DATA and IOMMUFD_CMD_DEVICE_UNSET_DATA | From | Baolu Lu <> |
| |
On 4/23/23 3:40 PM, Nicolin Chen wrote: > Add a new pair of ioctls to allow user space to set and unset its iommu- > specific device data for a passthrough device that's behind the iommu. > > On platforms with SMMUv3, this new uAPIs will be used to forward a user > space virtual Stream ID of a passthrough device to link to its physical > Stream ID and log into a lookup table, in order for the host kernel to > later run sanity on ATC invalidation requests from the user space, with > ATC_INV commands that have SID fields (virtual Stream IDs). > > Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> > --- > drivers/iommu/iommufd/device.c | 81 +++++++++++++++++++++++++ > drivers/iommu/iommufd/iommufd_private.h | 3 + > drivers/iommu/iommufd/main.c | 4 ++ > include/uapi/linux/iommufd.h | 32 ++++++++++ > 4 files changed, 120 insertions(+) > > diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c > index c649a3403797..9480cd36a8bd 100644 > --- a/drivers/iommu/iommufd/device.c > +++ b/drivers/iommu/iommufd/device.c > @@ -136,6 +136,8 @@ void iommufd_device_destroy(struct iommufd_object *obj) > struct iommufd_device *idev = > container_of(obj, struct iommufd_device, obj); > > + if (WARN_ON(idev->has_user_data)) > + dev_iommu_ops(idev->dev)->unset_dev_user_data(idev->dev);
Do you really need this WARN_ON()? The user space application can easily trigger this kernel WARN() by setting the user data and forgetting to unset it.
Best regards, baolu
| |