RE: [PATCH V4 01/10] iommufd: Support a HWPT without an iommu driver for noiommu

From: Tian, Kevin

Date: Thu Apr 16 2026 - 03:30:12 EST


> 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...

> +
> +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.

> +/*
> + * 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".

> + *
> + * 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