[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <17342260-0795-9636-8408-0ca0d6c50403@linux.intel.com>
Date: Mon, 24 Apr 2023 10:44:08 +0800
From: Baolu Lu <baolu.lu@...ux.intel.com>
To: Nicolin Chen <nicolinc@...dia.com>, jgg@...dia.com,
kevin.tian@...el.com
Cc: baolu.lu@...ux.intel.com, robin.murphy@....com,
eric.auger@...hat.com, yi.l.liu@...el.com, will@...nel.org,
joro@...tes.org, shameerali.kolothum.thodi@...wei.com,
jean-philippe@...aro.org, linux-arm-kernel@...ts.infradead.org,
iommu@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH RFC v3 2/4] iommufd: Add IOMMUFD_CMD_DEVICE_SET_DATA and
IOMMUFD_CMD_DEVICE_UNSET_DATA
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@...dia.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
Powered by blists - more mailing lists