]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
iommufd: Allow allocating PASID-compatible domain
authorYi Liu <yi.l.liu@intel.com>
Fri, 21 Mar 2025 17:19:36 +0000 (10:19 -0700)
committerJason Gunthorpe <jgg@nvidia.com>
Tue, 25 Mar 2025 13:18:31 +0000 (10:18 -0300)
The underlying infrastructure has supported the PASID attach and related
enforcement per the requirement of the IOMMU_HWPT_ALLOC_PASID flag. This
extends iommufd to support PASID compatible domain requested by userspace.

Link: https://patch.msgid.link/r/20250321171940.7213-15-yi.l.liu@intel.com
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
Tested-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/iommu/iommufd/hw_pagetable.c
include/uapi/linux/iommufd.h

index 3724533a23c966921b33aa5c63982847a5fb527e..487779470261a75f201e1c826cfcb8151f5ec9e3 100644 (file)
@@ -112,7 +112,8 @@ iommufd_hwpt_paging_alloc(struct iommufd_ctx *ictx, struct iommufd_ioas *ioas,
 {
        const u32 valid_flags = IOMMU_HWPT_ALLOC_NEST_PARENT |
                                IOMMU_HWPT_ALLOC_DIRTY_TRACKING |
-                               IOMMU_HWPT_FAULT_ID_VALID;
+                               IOMMU_HWPT_FAULT_ID_VALID |
+                               IOMMU_HWPT_ALLOC_PASID;
        const struct iommu_ops *ops = dev_iommu_ops(idev->dev);
        struct iommufd_hwpt_paging *hwpt_paging;
        struct iommufd_hw_pagetable *hwpt;
@@ -233,7 +234,7 @@ iommufd_hwpt_nested_alloc(struct iommufd_ctx *ictx,
        struct iommufd_hw_pagetable *hwpt;
        int rc;
 
-       if ((flags & ~IOMMU_HWPT_FAULT_ID_VALID) ||
+       if ((flags & ~(IOMMU_HWPT_FAULT_ID_VALID | IOMMU_HWPT_ALLOC_PASID)) ||
            !user_data->len || !ops->domain_alloc_nested)
                return ERR_PTR(-EOPNOTSUPP);
        if (parent->auto_domain || !parent->nest_parent ||
@@ -290,7 +291,7 @@ iommufd_viommu_alloc_hwpt_nested(struct iommufd_viommu *viommu, u32 flags,
        struct iommufd_hw_pagetable *hwpt;
        int rc;
 
-       if (flags & ~IOMMU_HWPT_FAULT_ID_VALID)
+       if (flags & ~(IOMMU_HWPT_FAULT_ID_VALID | IOMMU_HWPT_ALLOC_PASID))
                return ERR_PTR(-EOPNOTSUPP);
        if (!user_data->len)
                return ERR_PTR(-EOPNOTSUPP);
index 8719d4f5d6183a5ab4937aa82136da6fbcd2988c..6901804ec736ad4d553a43fefd675d9b6983224f 100644 (file)
@@ -393,6 +393,9 @@ struct iommu_vfio_ioas {
  *                          Any domain attached to the non-PASID part of the
  *                          device must also be flagged, otherwise attaching a
  *                          PASID will blocked.
+ *                          For the user that wants to attach PASID, ioas is
+ *                          not recommended for both the non-PASID part
+ *                          and PASID part of the device.
  *                          If IOMMU does not support PASID it will return
  *                          error (-EOPNOTSUPP).
  */