Re: [PATCH V2 03/11] iommufd: Allow binding to a noiommu device
From: Jacob Pan
Date: Tue Mar 24 2026 - 15:28:54 EST
Hi Mostafa,
On Sun, 22 Mar 2026 09:54:15 +0000
Mostafa Saleh <smostafa@xxxxxxxxxx> wrote:
> From: Mostafa Saleh <smostafa@xxxxxxxxxx>
> To: Jacob Pan <jacob.pan@xxxxxxxxxxxxxxxxxxx>
> Cc: linux-kernel@xxxxxxxxxxxxxxx, "iommu@xxxxxxxxxxxxxxx"
> <iommu@xxxxxxxxxxxxxxx>, Jason Gunthorpe <jgg@xxxxxxxxxx>, Alex
> Williamson <alex@xxxxxxxxxxx>, Joerg Roedel <joro@xxxxxxxxxx>, David
> Matlack <dmatlack@xxxxxxxxxx>, Robin Murphy <robin.murphy@xxxxxxx>,
> Nicolin Chen <nicolinc@xxxxxxxxxx>, "Tian, Kevin"
> <kevin.tian@xxxxxxxxx>, Yi Liu <yi.l.liu@xxxxxxxxx>,
> skhawaja@xxxxxxxxxx, pasha.tatashin@xxxxxxxxxx, Will Deacon
> <will@xxxxxxxxxx>, Baolu Lu <baolu.lu@xxxxxxxxxxxxxxx> Subject: Re:
> [PATCH V2 03/11] iommufd: Allow binding to a noiommu device Date:
> Sun, 22 Mar 2026 09:54:15 +0000
>
> On Thu, Mar 12, 2026 at 08:56:29AM -0700, Jacob Pan wrote:
> > From: Jason Gunthorpe <jgg@xxxxxxxxxx>
> >
> > Allow iommufd to bind devices without an IOMMU (noiommu mode) by
> > creating a dummy IOMMU group for such devices and skipping hwpt
> > operations.
> >
> > This enables noiommu devices to operate through the same iommufd
> > API as IOMMU- capable devices.
> >
> > Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
> > Signed-off-by: Jacob Pan <jacob.pan@xxxxxxxxxxxxxxxxxxx>
> > ---
> > drivers/iommu/iommufd/device.c | 113
> > ++++++++++++++++++++++----------- 1 file changed, 76 insertions(+),
> > 37 deletions(-)
> >
> > diff --git a/drivers/iommu/iommufd/device.c
> > b/drivers/iommu/iommufd/device.c index 54d73016468f..c38d3efa3d6f
> > 100644 --- a/drivers/iommu/iommufd/device.c
> > +++ b/drivers/iommu/iommufd/device.c
> > @@ -23,6 +23,11 @@ struct iommufd_attach {
> > struct xarray device_array;
> > };
> >
> > +static bool is_vfio_noiommu(struct iommufd_device *idev)
> > +{
> > + return !device_iommu_mapped(idev->dev) ||
> > !idev->dev->iommu;
>
> Do this need to check for CONFIG_VFIO_NOIOMMU and maybe the module
> param enable_unsafe_noiommu_mode similar to the legacy implemenation?
>
Checking for CONFIG_VFIO_NOIOMMU is not needed since all the conditions
are not restricted by CONFIG_VFIO_NOIOMMU. I felt it is cleaner this
way by not tying iommufd private code with vfio.
I guess we could do something like below but not necessary IMHO.
--- a/drivers/iommu/iommufd/device.c
+++ b/drivers/iommu/iommufd/device.c
@@ -23,11 +23,6 @@ struct iommufd_attach {
struct xarray device_array;
};
-static bool is_vfio_noiommu(struct iommufd_device *idev)
-{
- return !device_iommu_mapped(idev->dev) || !idev->dev->iommu;
-}
-
static void iommufd_group_release(struct kref *kref)
{
struct iommufd_group *igroup =
diff --git a/drivers/iommu/iommufd/iommufd_private.h
b/drivers/iommu/iommufd/iommufd_private.h index
3302c6a1f99e..cba5550e3f2b 100644 ---
a/drivers/iommu/iommufd/iommufd_private.h +++
b/drivers/iommu/iommufd/iommufd_private.h @@ -711,6 +711,18 @@
iommufd_get_vdevice(struct iommufd_ctx *ictx, u32 id) struct
iommufd_vdevice, obj); }
+#ifdef CONFIG_VFIO_NOIOMMU
+static inline bool is_vfio_noiommu(struct iommufd_device *idev)
+{
+ return !device_iommu_mapped(idev->dev) || !idev->dev->iommu;
+}
+#else
+static inline bool is_vfio_noiommu(struct iommufd_device *idev)
+{
+ return false;
+}
+#endif
+