Re: [PATCH V4 01/10] iommufd: Support a HWPT without an iommu driver for noiommu
From: Jacob Pan
Date: Fri Apr 17 2026 - 18:00:01 EST
Hi Kevin,
On Thu, 16 Apr 2026 07:25:57 +0000
"Tian, Kevin" <kevin.tian@xxxxxxxxx> wrote:
> > From: Jacob Pan <jacob.pan@xxxxxxxxxxxxxxxxxxx>
> > Sent: Wednesday, April 15, 2026 5:14 AM
> >
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/*
> > + * Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES
> > + */
>
> the years are not latest...
will fix.
> > +
> > +static struct iommu_domain *
> > +noiommu_alloc_paging_flags(struct device *dev, u32 flags,
> > + const struct iommu_user_data *user_data)
> > +{
> > + struct pt_iommu_amdv1_cfg cfg = {};
> > + struct noiommu_domain *dom;
> > + int rc;
> > +
> > + if (flags || user_data)
> > + return ERR_PTR(-EOPNOTSUPP);
> > +
> > + cfg.common.hw_max_vasz_lg2 = 64;
> > + cfg.common.hw_max_oasz_lg2 = 52;
> > + cfg.starting_level = 2;
> > + cfg.common.features =
> > + (BIT(PT_FEAT_DYNAMIC_TOP) |
> > BIT(PT_FEAT_AMDV1_ENCRYPT_TABLES) |
> > + BIT(PT_FEAT_AMDV1_FORCE_COHERENCE));
>
> PT_FEAT_AMDV1_ENCRYPT_TABLES is useless here.
Technically yes but we need this flag to match forced features since we
are sharing with the real AMDv1. Otherwise, this will fail with
EOPNOTSUPP.
static int pt_init_common(struct pt_common *common)
{
...
/* Requested features must match features compiled into this
format */
if ((common->features & ~(unsigned int)PT_SUPPORTED_FEATURES) ||
(!IS_ENABLED(CONFIG_DEBUG_GENERIC_PT) &&
(common->features & PT_FORCE_ENABLED_FEATURES) !=
PT_FORCE_ENABLED_FEATURES))
return -EOPNOTSUPP;
where in iommu_amdv1.c:
#define PT_FORCE_ENABLED_FEATURES
\ (BIT(PT_FEAT_DYNAMIC_TOP) | BIT(PT_FEAT_AMDV1_ENCRYPT_TABLES) | \
BIT(PT_FEAT_AMDV1_FORCE_COHERENCE))
> > +/*
> > + * AMDV1 is used as a dummy page table for no-IOMMU mode, similar
> > to the
> > + * iommufd selftest mock page table.
> > + * Unlike legacy VFIO no-IOMMU mode, where no container level APIs
> > are
> > + * supported, this allows IOAS and hwpt objects to exist without
> > hardware
> > + * IOMMU support. IOVAs are used only for IOVA-to-PA lookups not
> > for
> > + * hardware translation in DMA.
>
> it's confusing between above "legacy VFIO no-IOMMU mode" and following
> "legacy VFIO group-container based noiommu mode".
>
will make them consistent.
> > + *
> > + * This is only used with iommufd and cdev-based interfaces and
> > does not
> > + * apply to legacy VFIO group-container based noiommu mode.
> > + */
> > +static const struct iommu_domain_ops noiommu_amdv1_ops = {
> > + IOMMU_PT_DOMAIN_OPS(amdv1),
> > + .free = noiommu_domain_free,
> > +};
> > +
> > +const struct iommu_ops iommufd_noiommu_ops = {
> > + .domain_alloc_paging_flags = noiommu_alloc_paging_flags,
> > +};
> > diff --git a/drivers/iommu/iommufd/iommufd_private.h
> > b/drivers/iommu/iommufd/iommufd_private.h
> > index 6ac1965199e9..2682b5baa6e9 100644
> > --- a/drivers/iommu/iommufd/iommufd_private.h
> > +++ b/drivers/iommu/iommufd/iommufd_private.h
> > @@ -464,6 +464,8 @@ static inline void
> > iommufd_hw_pagetable_put(struct iommufd_ctx *ictx,
> > refcount_dec(&hwpt->obj.users);
> > }
> >
> > +extern const struct iommu_ops iommufd_noiommu_ops;
> > +
> > struct iommufd_attach;
> >
> > struct iommufd_group {
> > --
> > 2.34.1