[PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to support pasid

Zhenzhong Duan posted 14 patches 1 week ago
Maintainers: Yi Liu <yi.l.liu@intel.com>, Eric Auger <eric.auger@redhat.com>, Zhenzhong Duan <zhenzhong.duan@intel.com>, Peter Maydell <peter.maydell@linaro.org>, "Michael S. Tsirkin" <mst@redhat.com>, Jason Wang <jasowang@redhat.com>, "Clément Mathieu--Drif" <clement.mathieu--drif@bull.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Alex Williamson <alex@shazbot.org>, "Cédric Le Goater" <clg@redhat.com>
[PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to support pasid
Posted by Zhenzhong Duan 1 week ago
Same for the two wrappers and their call sites.

Suggested-by: Shameer Kolothum Thodi <skolothumtho@nvidia.com>
Suggested-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Yi Liu <yi.l.liu@intel.com>
---
 include/system/iommufd.h    | 16 +++++++++++-----
 backends/iommufd.c          |  9 +++++----
 hw/arm/smmuv3-accel.c       | 12 ++++++++----
 hw/i386/intel_iommu_accel.c |  8 +++++---
 hw/vfio/iommufd.c           | 10 +++++-----
 5 files changed, 34 insertions(+), 21 deletions(-)

diff --git a/include/system/iommufd.h b/include/system/iommufd.h
index 7062944fe6..45a9e87cb0 100644
--- a/include/system/iommufd.h
+++ b/include/system/iommufd.h
@@ -138,14 +138,16 @@ struct HostIOMMUDeviceIOMMUFDClass {
      *
      * @idev: host IOMMU device backed by IOMMUFD backend.
      *
+     * @pasid: target pasid of attach.
+     *
      * @hwpt_id: ID of IOMMUFD hardware page table.
      *
      * @errp: pass an Error out when attachment fails.
      *
      * Returns: true on success, false on failure.
      */
-    bool (*attach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, uint32_t hwpt_id,
-                        Error **errp);
+    bool (*attach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, uint32_t pasid,
+                        uint32_t hwpt_id, Error **errp);
     /**
      * @detach_hwpt: detach host IOMMU device from IOMMUFD hardware page table.
      * VFIO and VDPA device can have different implementation.
@@ -154,15 +156,19 @@ struct HostIOMMUDeviceIOMMUFDClass {
      *
      * @idev: host IOMMU device backed by IOMMUFD backend.
      *
+     * @pasid: target pasid of detach.
+     *
      * @errp: pass an Error out when attachment fails.
      *
      * Returns: true on success, false on failure.
      */
-    bool (*detach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, Error **errp);
+    bool (*detach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, uint32_t pasid,
+                        Error **errp);
 };
 
 bool host_iommu_device_iommufd_attach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
-                                           uint32_t hwpt_id, Error **errp);
-bool host_iommu_device_iommufd_detach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
+                                           uint32_t pasid, uint32_t hwpt_id,
                                            Error **errp);
+bool host_iommu_device_iommufd_detach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
+                                           uint32_t pasid, Error **errp);
 #endif
diff --git a/backends/iommufd.c b/backends/iommufd.c
index e1fee16acf..ab612e4874 100644
--- a/backends/iommufd.c
+++ b/backends/iommufd.c
@@ -539,23 +539,24 @@ bool iommufd_backend_alloc_veventq(IOMMUFDBackend *be, uint32_t viommu_id,
 }
 
 bool host_iommu_device_iommufd_attach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
-                                           uint32_t hwpt_id, Error **errp)
+                                           uint32_t pasid, uint32_t hwpt_id,
+                                           Error **errp)
 {
     HostIOMMUDeviceIOMMUFDClass *idevc =
         HOST_IOMMU_DEVICE_IOMMUFD_GET_CLASS(idev);
 
     g_assert(idevc->attach_hwpt);
-    return idevc->attach_hwpt(idev, hwpt_id, errp);
+    return idevc->attach_hwpt(idev, pasid, hwpt_id, errp);
 }
 
 bool host_iommu_device_iommufd_detach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
-                                           Error **errp)
+                                           uint32_t pasid, Error **errp)
 {
     HostIOMMUDeviceIOMMUFDClass *idevc =
         HOST_IOMMU_DEVICE_IOMMUFD_GET_CLASS(idev);
 
     g_assert(idevc->detach_hwpt);
-    return idevc->detach_hwpt(idev, errp);
+    return idevc->detach_hwpt(idev, pasid, errp);
 }
 
 static int hiod_iommufd_get_cap(HostIOMMUDevice *hiod, int cap, Error **errp)
diff --git a/hw/arm/smmuv3-accel.c b/hw/arm/smmuv3-accel.c
index 65c2f44880..0af6b3296d 100644
--- a/hw/arm/smmuv3-accel.c
+++ b/hw/arm/smmuv3-accel.c
@@ -300,7 +300,8 @@ bool smmuv3_accel_install_ste(SMMUv3State *s, SMMUDevice *sdev, int sid,
         return false;
     }
 
-    if (!host_iommu_device_iommufd_attach_hwpt(idev, hwpt_id, errp)) {
+    if (!host_iommu_device_iommufd_attach_hwpt(idev, IOMMU_NO_PASID, hwpt_id,
+                                               errp)) {
         if (s1_hwpt) {
             iommufd_backend_free_id(idev->iommufd, s1_hwpt->hwpt_id);
             g_free(s1_hwpt);
@@ -575,7 +576,8 @@ smmuv3_accel_alloc_viommu(SMMUv3State *s, HostIOMMUDeviceIOMMUFD *idev,
 
     /* Attach a HWPT based on SMMUv3 GBPA.ABORT value */
     hwpt_id = smmuv3_accel_gbpa_hwpt(s, accel);
-    if (!host_iommu_device_iommufd_attach_hwpt(idev, hwpt_id, errp)) {
+    if (!host_iommu_device_iommufd_attach_hwpt(idev, IOMMU_NO_PASID, hwpt_id,
+                                               errp)) {
         goto free_veventq;
     }
     return true;
@@ -665,7 +667,8 @@ static void smmuv3_accel_unset_iommu_device(PCIBus *bus, void *opaque,
     idev = accel_dev->idev;
     accel = accel_dev->s_accel;
     /* Re-attach the default s2 hwpt id */
-    if (!host_iommu_device_iommufd_attach_hwpt(idev, idev->hwpt_id, NULL)) {
+    if (!host_iommu_device_iommufd_attach_hwpt(idev, IOMMU_NO_PASID,
+                                               idev->hwpt_id, NULL)) {
         error_report("Unable to attach the default HW pagetable: idev devid "
                      "0x%x", idev->devid);
     }
@@ -879,7 +882,8 @@ bool smmuv3_accel_attach_gbpa_hwpt(SMMUv3State *s, Error **errp)
 
     hwpt_id = smmuv3_accel_gbpa_hwpt(s, accel);
     QLIST_FOREACH(accel_dev, &accel->device_list, next) {
-        if (!host_iommu_device_iommufd_attach_hwpt(accel_dev->idev, hwpt_id,
+        if (!host_iommu_device_iommufd_attach_hwpt(accel_dev->idev,
+                                                   IOMMU_NO_PASID, hwpt_id,
                                                    &local_err)) {
             error_append_hint(&local_err, "Failed to attach GBPA hwpt %u for "
                               "idev devid %u", hwpt_id, accel_dev->idev->devid);
diff --git a/hw/i386/intel_iommu_accel.c b/hw/i386/intel_iommu_accel.c
index 67d54849f2..45c08c8f6f 100644
--- a/hw/i386/intel_iommu_accel.c
+++ b/hw/i386/intel_iommu_accel.c
@@ -121,7 +121,8 @@ static bool vtd_device_attach_iommufd(VTDHostIOMMUDevice *vtd_hiod,
         }
     }
 
-    ret = host_iommu_device_iommufd_attach_hwpt(idev, hwpt_id, errp);
+    ret = host_iommu_device_iommufd_attach_hwpt(idev, IOMMU_NO_PASID, hwpt_id,
+                                                errp);
     trace_vtd_device_attach_hwpt(idev->devid, vtd_as->pasid, hwpt_id, ret);
     if (ret) {
         /* Destroy old fs_hwpt if it's a replacement */
@@ -145,7 +146,7 @@ static bool vtd_device_detach_iommufd(VTDHostIOMMUDevice *vtd_hiod,
     bool ret;
 
     if (s->dmar_enabled && s->root_scalable) {
-        ret = host_iommu_device_iommufd_detach_hwpt(idev, errp);
+        ret = host_iommu_device_iommufd_detach_hwpt(idev, IOMMU_NO_PASID, errp);
         trace_vtd_device_detach_hwpt(idev->devid, pasid, ret);
     } else {
         /*
@@ -153,7 +154,8 @@ static bool vtd_device_detach_iommufd(VTDHostIOMMUDevice *vtd_hiod,
          * we fallback to the default HWPT which contains shadow page table.
          * So guest DMA could still work.
          */
-        ret = host_iommu_device_iommufd_attach_hwpt(idev, idev->hwpt_id, errp);
+        ret = host_iommu_device_iommufd_attach_hwpt(idev, IOMMU_NO_PASID,
+                                                    idev->hwpt_id, errp);
         trace_vtd_device_reattach_def_hwpt(idev->devid, pasid, idev->hwpt_id,
                                            ret);
     }
diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
index 93f1e61a8c..e822039858 100644
--- a/hw/vfio/iommufd.c
+++ b/hw/vfio/iommufd.c
@@ -927,21 +927,21 @@ static void vfio_iommu_iommufd_class_init(ObjectClass *klass, const void *data)
 
 static bool
 host_iommu_device_iommufd_vfio_attach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
-                                           uint32_t hwpt_id, Error **errp)
+                                           uint32_t pasid, uint32_t hwpt_id,
+                                           Error **errp)
 {
     VFIODevice *vbasedev = HOST_IOMMU_DEVICE(idev)->agent;
 
-    return !iommufd_cdev_pasid_attach_ioas_hwpt(vbasedev, IOMMU_NO_PASID,
-                                                hwpt_id, errp);
+    return !iommufd_cdev_pasid_attach_ioas_hwpt(vbasedev, pasid, hwpt_id, errp);
 }
 
 static bool
 host_iommu_device_iommufd_vfio_detach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
-                                           Error **errp)
+                                           uint32_t pasid, Error **errp)
 {
     VFIODevice *vbasedev = HOST_IOMMU_DEVICE(idev)->agent;
 
-    return iommufd_cdev_pasid_detach_ioas_hwpt(vbasedev, IOMMU_NO_PASID, errp);
+    return iommufd_cdev_pasid_detach_ioas_hwpt(vbasedev, pasid, errp);
 }
 
 static bool hiod_iommufd_vfio_realize(HostIOMMUDevice *hiod, void *opaque,
-- 
2.47.3
Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to support pasid
Posted by Cédric Le Goater 3 days, 9 hours ago
Zhenzhong

On 3/26/26 10:11, Zhenzhong Duan wrote:
> Same for the two wrappers and their call sites.
> 
> Suggested-by: Shameer Kolothum Thodi <skolothumtho@nvidia.com>
> Suggested-by: Nicolin Chen <nicolinc@nvidia.com>
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
> Reviewed-by: Yi Liu <yi.l.liu@intel.com>
> ---
>   include/system/iommufd.h    | 16 +++++++++++-----
>   backends/iommufd.c          |  9 +++++----
>   hw/arm/smmuv3-accel.c       | 12 ++++++++----
>   hw/i386/intel_iommu_accel.c |  8 +++++---
>   hw/vfio/iommufd.c           | 10 +++++-----
>   5 files changed, 34 insertions(+), 21 deletions(-)
> 
> diff --git a/include/system/iommufd.h b/include/system/iommufd.h
> index 7062944fe6..45a9e87cb0 100644
> --- a/include/system/iommufd.h
> +++ b/include/system/iommufd.h
> @@ -138,14 +138,16 @@ struct HostIOMMUDeviceIOMMUFDClass {
>        *
>        * @idev: host IOMMU device backed by IOMMUFD backend.
>        *
> +     * @pasid: target pasid of attach.
> +     *
>        * @hwpt_id: ID of IOMMUFD hardware page table.
>        *
>        * @errp: pass an Error out when attachment fails.
>        *
>        * Returns: true on success, false on failure.
>        */
> -    bool (*attach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, uint32_t hwpt_id,
> -                        Error **errp);
> +    bool (*attach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, uint32_t pasid,
> +                        uint32_t hwpt_id, Error **errp);
>       /**
>        * @detach_hwpt: detach host IOMMU device from IOMMUFD hardware page table.
>        * VFIO and VDPA device can have different implementation.
> @@ -154,15 +156,19 @@ struct HostIOMMUDeviceIOMMUFDClass {
>        *
>        * @idev: host IOMMU device backed by IOMMUFD backend.
>        *
> +     * @pasid: target pasid of detach.
> +     *
>        * @errp: pass an Error out when attachment fails.
>        *
>        * Returns: true on success, false on failure.
>        */
> -    bool (*detach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, Error **errp);
> +    bool (*detach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, uint32_t pasid,
> +                        Error **errp);
>   };
>   
>   bool host_iommu_device_iommufd_attach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
> -                                           uint32_t hwpt_id, Error **errp);
> -bool host_iommu_device_iommufd_detach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
> +                                           uint32_t pasid, uint32_t hwpt_id,
>                                              Error **errp);
> +bool host_iommu_device_iommufd_detach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
> +                                           uint32_t pasid, Error **errp);
>   #endif
> diff --git a/backends/iommufd.c b/backends/iommufd.c
> index e1fee16acf..ab612e4874 100644
> --- a/backends/iommufd.c
> +++ b/backends/iommufd.c
> @@ -539,23 +539,24 @@ bool iommufd_backend_alloc_veventq(IOMMUFDBackend *be, uint32_t viommu_id,
>   }
>   
>   bool host_iommu_device_iommufd_attach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
> -                                           uint32_t hwpt_id, Error **errp)
> +                                           uint32_t pasid, uint32_t hwpt_id,
> +                                           Error **errp)
>   {
>       HostIOMMUDeviceIOMMUFDClass *idevc =
>           HOST_IOMMU_DEVICE_IOMMUFD_GET_CLASS(idev);


For consistency with the rest of the code, I would rename all the
idev and idevc variables, to hiod and hiodc.

Thanks,

C.



>   
>       g_assert(idevc->attach_hwpt);
> -    return idevc->attach_hwpt(idev, hwpt_id, errp);
> +    return idevc->attach_hwpt(idev, pasid, hwpt_id, errp);
>   }
>   
>   bool host_iommu_device_iommufd_detach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
> -                                           Error **errp)
> +                                           uint32_t pasid, Error **errp)
>   {
>       HostIOMMUDeviceIOMMUFDClass *idevc =
>           HOST_IOMMU_DEVICE_IOMMUFD_GET_CLASS(idev);
>   
>       g_assert(idevc->detach_hwpt);
> -    return idevc->detach_hwpt(idev, errp);
> +    return idevc->detach_hwpt(idev, pasid, errp);
>   }
>   
>   static int hiod_iommufd_get_cap(HostIOMMUDevice *hiod, int cap, Error **errp)
> diff --git a/hw/arm/smmuv3-accel.c b/hw/arm/smmuv3-accel.c
> index 65c2f44880..0af6b3296d 100644
> --- a/hw/arm/smmuv3-accel.c
> +++ b/hw/arm/smmuv3-accel.c
> @@ -300,7 +300,8 @@ bool smmuv3_accel_install_ste(SMMUv3State *s, SMMUDevice *sdev, int sid,
>           return false;
>       }
>   
> -    if (!host_iommu_device_iommufd_attach_hwpt(idev, hwpt_id, errp)) {
> +    if (!host_iommu_device_iommufd_attach_hwpt(idev, IOMMU_NO_PASID, hwpt_id,
> +                                               errp)) {
>           if (s1_hwpt) {
>               iommufd_backend_free_id(idev->iommufd, s1_hwpt->hwpt_id);
>               g_free(s1_hwpt);
> @@ -575,7 +576,8 @@ smmuv3_accel_alloc_viommu(SMMUv3State *s, HostIOMMUDeviceIOMMUFD *idev,
>   
>       /* Attach a HWPT based on SMMUv3 GBPA.ABORT value */
>       hwpt_id = smmuv3_accel_gbpa_hwpt(s, accel);
> -    if (!host_iommu_device_iommufd_attach_hwpt(idev, hwpt_id, errp)) {
> +    if (!host_iommu_device_iommufd_attach_hwpt(idev, IOMMU_NO_PASID, hwpt_id,
> +                                               errp)) {
>           goto free_veventq;
>       }
>       return true;
> @@ -665,7 +667,8 @@ static void smmuv3_accel_unset_iommu_device(PCIBus *bus, void *opaque,
>       idev = accel_dev->idev;
>       accel = accel_dev->s_accel;
>       /* Re-attach the default s2 hwpt id */
> -    if (!host_iommu_device_iommufd_attach_hwpt(idev, idev->hwpt_id, NULL)) {
> +    if (!host_iommu_device_iommufd_attach_hwpt(idev, IOMMU_NO_PASID,
> +                                               idev->hwpt_id, NULL)) {
>           error_report("Unable to attach the default HW pagetable: idev devid "
>                        "0x%x", idev->devid);
>       }
> @@ -879,7 +882,8 @@ bool smmuv3_accel_attach_gbpa_hwpt(SMMUv3State *s, Error **errp)
>   
>       hwpt_id = smmuv3_accel_gbpa_hwpt(s, accel);
>       QLIST_FOREACH(accel_dev, &accel->device_list, next) {
> -        if (!host_iommu_device_iommufd_attach_hwpt(accel_dev->idev, hwpt_id,
> +        if (!host_iommu_device_iommufd_attach_hwpt(accel_dev->idev,
> +                                                   IOMMU_NO_PASID, hwpt_id,
>                                                      &local_err)) {
>               error_append_hint(&local_err, "Failed to attach GBPA hwpt %u for "
>                                 "idev devid %u", hwpt_id, accel_dev->idev->devid);
> diff --git a/hw/i386/intel_iommu_accel.c b/hw/i386/intel_iommu_accel.c
> index 67d54849f2..45c08c8f6f 100644
> --- a/hw/i386/intel_iommu_accel.c
> +++ b/hw/i386/intel_iommu_accel.c
> @@ -121,7 +121,8 @@ static bool vtd_device_attach_iommufd(VTDHostIOMMUDevice *vtd_hiod,
>           }
>       }
>   
> -    ret = host_iommu_device_iommufd_attach_hwpt(idev, hwpt_id, errp);
> +    ret = host_iommu_device_iommufd_attach_hwpt(idev, IOMMU_NO_PASID, hwpt_id,
> +                                                errp);
>       trace_vtd_device_attach_hwpt(idev->devid, vtd_as->pasid, hwpt_id, ret);
>       if (ret) {
>           /* Destroy old fs_hwpt if it's a replacement */
> @@ -145,7 +146,7 @@ static bool vtd_device_detach_iommufd(VTDHostIOMMUDevice *vtd_hiod,
>       bool ret;
>   
>       if (s->dmar_enabled && s->root_scalable) {
> -        ret = host_iommu_device_iommufd_detach_hwpt(idev, errp);
> +        ret = host_iommu_device_iommufd_detach_hwpt(idev, IOMMU_NO_PASID, errp);
>           trace_vtd_device_detach_hwpt(idev->devid, pasid, ret);
>       } else {
>           /*
> @@ -153,7 +154,8 @@ static bool vtd_device_detach_iommufd(VTDHostIOMMUDevice *vtd_hiod,
>            * we fallback to the default HWPT which contains shadow page table.
>            * So guest DMA could still work.
>            */
> -        ret = host_iommu_device_iommufd_attach_hwpt(idev, idev->hwpt_id, errp);
> +        ret = host_iommu_device_iommufd_attach_hwpt(idev, IOMMU_NO_PASID,
> +                                                    idev->hwpt_id, errp);
>           trace_vtd_device_reattach_def_hwpt(idev->devid, pasid, idev->hwpt_id,
>                                              ret);
>       }
> diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
> index 93f1e61a8c..e822039858 100644
> --- a/hw/vfio/iommufd.c
> +++ b/hw/vfio/iommufd.c
> @@ -927,21 +927,21 @@ static void vfio_iommu_iommufd_class_init(ObjectClass *klass, const void *data)
>   
>   static bool
>   host_iommu_device_iommufd_vfio_attach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
> -                                           uint32_t hwpt_id, Error **errp)
> +                                           uint32_t pasid, uint32_t hwpt_id,
> +                                           Error **errp)
>   {
>       VFIODevice *vbasedev = HOST_IOMMU_DEVICE(idev)->agent;
>   
> -    return !iommufd_cdev_pasid_attach_ioas_hwpt(vbasedev, IOMMU_NO_PASID,
> -                                                hwpt_id, errp);
> +    return !iommufd_cdev_pasid_attach_ioas_hwpt(vbasedev, pasid, hwpt_id, errp);
>   }
>   
>   static bool
>   host_iommu_device_iommufd_vfio_detach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
> -                                           Error **errp)
> +                                           uint32_t pasid, Error **errp)
>   {
>       VFIODevice *vbasedev = HOST_IOMMU_DEVICE(idev)->agent;
>   
> -    return iommufd_cdev_pasid_detach_ioas_hwpt(vbasedev, IOMMU_NO_PASID, errp);
> +    return iommufd_cdev_pasid_detach_ioas_hwpt(vbasedev, pasid, errp);
>   }
>   
>   static bool hiod_iommufd_vfio_realize(HostIOMMUDevice *hiod, void *opaque,
RE: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to support pasid
Posted by Duan, Zhenzhong 2 days, 16 hours ago
Hi 

>-----Original Message-----
>From: Cédric Le Goater <clg@redhat.com>
>Sent: Monday, March 30, 2026 8:43 PM
>To: Duan, Zhenzhong <zhenzhong.duan@intel.com>; qemu-devel@nongnu.org
>Cc: alex@shazbot.org; eric.auger@redhat.com; mst@redhat.com;
>jasowang@redhat.com; jgg@nvidia.com; nicolinc@nvidia.com;
>skolothumtho@nvidia.com; joao.m.martins@oracle.com; clement.mathieu--
>drif@bull.com; Tian, Kevin <kevin.tian@intel.com>; Liu, Yi L <yi.l.liu@intel.com>;
>Hao, Xudong <xudong.hao@intel.com>; qemu-arm@nongnu.org
>Subject: Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to
>support pasid
>
>Zhenzhong
>
>On 3/26/26 10:11, Zhenzhong Duan wrote:
>> Same for the two wrappers and their call sites.
>>
>> Suggested-by: Shameer Kolothum Thodi <skolothumtho@nvidia.com>
>> Suggested-by: Nicolin Chen <nicolinc@nvidia.com>
>> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
>> Reviewed-by: Yi Liu <yi.l.liu@intel.com>
>> ---
>>   include/system/iommufd.h    | 16 +++++++++++-----
>>   backends/iommufd.c          |  9 +++++----
>>   hw/arm/smmuv3-accel.c       | 12 ++++++++----
>>   hw/i386/intel_iommu_accel.c |  8 +++++---
>>   hw/vfio/iommufd.c           | 10 +++++-----
>>   5 files changed, 34 insertions(+), 21 deletions(-)
>>
>> diff --git a/include/system/iommufd.h b/include/system/iommufd.h
>> index 7062944fe6..45a9e87cb0 100644
>> --- a/include/system/iommufd.h
>> +++ b/include/system/iommufd.h
>> @@ -138,14 +138,16 @@ struct HostIOMMUDeviceIOMMUFDClass {
>>        *
>>        * @idev: host IOMMU device backed by IOMMUFD backend.
>>        *
>> +     * @pasid: target pasid of attach.
>> +     *
>>        * @hwpt_id: ID of IOMMUFD hardware page table.
>>        *
>>        * @errp: pass an Error out when attachment fails.
>>        *
>>        * Returns: true on success, false on failure.
>>        */
>> -    bool (*attach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, uint32_t hwpt_id,
>> -                        Error **errp);
>> +    bool (*attach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, uint32_t pasid,
>> +                        uint32_t hwpt_id, Error **errp);
>>       /**
>>        * @detach_hwpt: detach host IOMMU device from IOMMUFD hardware
>page table.
>>        * VFIO and VDPA device can have different implementation.
>> @@ -154,15 +156,19 @@ struct HostIOMMUDeviceIOMMUFDClass {
>>        *
>>        * @idev: host IOMMU device backed by IOMMUFD backend.
>>        *
>> +     * @pasid: target pasid of detach.
>> +     *
>>        * @errp: pass an Error out when attachment fails.
>>        *
>>        * Returns: true on success, false on failure.
>>        */
>> -    bool (*detach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, Error **errp);
>> +    bool (*detach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, uint32_t pasid,
>> +                        Error **errp);
>>   };
>>
>>   bool
>host_iommu_device_iommufd_attach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
>> -                                           uint32_t hwpt_id, Error **errp);
>> -bool
>host_iommu_device_iommufd_detach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
>> +                                           uint32_t pasid, uint32_t hwpt_id,
>>                                              Error **errp);
>> +bool
>host_iommu_device_iommufd_detach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
>> +                                           uint32_t pasid, Error **errp);
>>   #endif
>> diff --git a/backends/iommufd.c b/backends/iommufd.c
>> index e1fee16acf..ab612e4874 100644
>> --- a/backends/iommufd.c
>> +++ b/backends/iommufd.c
>> @@ -539,23 +539,24 @@ bool
>iommufd_backend_alloc_veventq(IOMMUFDBackend *be, uint32_t viommu_id,
>>   }
>>
>>   bool
>host_iommu_device_iommufd_attach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
>> -                                           uint32_t hwpt_id, Error **errp)
>> +                                           uint32_t pasid, uint32_t hwpt_id,
>> +                                           Error **errp)
>>   {
>>       HostIOMMUDeviceIOMMUFDClass *idevc =
>>           HOST_IOMMU_DEVICE_IOMMUFD_GET_CLASS(idev);
>
>
>For consistency with the rest of the code, I would rename all the
>idev and idevc variables, to hiod and hiodc.

We have used hiod and hiodc for the base HostIOMMUDevice type:

HostIOMMUDevice *hiod;
HostIOMMUDeviceClass *hiodc;

To avoid conflict, what about hiodi and hiodic for HostIOMMUDeviceIOMMUFD type?

Thanks
Zhenzhong
Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to support pasid
Posted by Cédric Le Goater 2 days, 14 hours ago
On 3/31/26 07:31, Duan, Zhenzhong wrote:
> Hi
> 
>> -----Original Message-----
>> From: Cédric Le Goater <clg@redhat.com>
>> Sent: Monday, March 30, 2026 8:43 PM
>> To: Duan, Zhenzhong <zhenzhong.duan@intel.com>; qemu-devel@nongnu.org
>> Cc: alex@shazbot.org; eric.auger@redhat.com; mst@redhat.com;
>> jasowang@redhat.com; jgg@nvidia.com; nicolinc@nvidia.com;
>> skolothumtho@nvidia.com; joao.m.martins@oracle.com; clement.mathieu--
>> drif@bull.com; Tian, Kevin <kevin.tian@intel.com>; Liu, Yi L <yi.l.liu@intel.com>;
>> Hao, Xudong <xudong.hao@intel.com>; qemu-arm@nongnu.org
>> Subject: Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to
>> support pasid
>>
>> Zhenzhong
>>
>> On 3/26/26 10:11, Zhenzhong Duan wrote:
>>> Same for the two wrappers and their call sites.
>>>
>>> Suggested-by: Shameer Kolothum Thodi <skolothumtho@nvidia.com>
>>> Suggested-by: Nicolin Chen <nicolinc@nvidia.com>
>>> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
>>> Reviewed-by: Yi Liu <yi.l.liu@intel.com>
>>> ---
>>>    include/system/iommufd.h    | 16 +++++++++++-----
>>>    backends/iommufd.c          |  9 +++++----
>>>    hw/arm/smmuv3-accel.c       | 12 ++++++++----
>>>    hw/i386/intel_iommu_accel.c |  8 +++++---
>>>    hw/vfio/iommufd.c           | 10 +++++-----
>>>    5 files changed, 34 insertions(+), 21 deletions(-)
>>>
>>> diff --git a/include/system/iommufd.h b/include/system/iommufd.h
>>> index 7062944fe6..45a9e87cb0 100644
>>> --- a/include/system/iommufd.h
>>> +++ b/include/system/iommufd.h
>>> @@ -138,14 +138,16 @@ struct HostIOMMUDeviceIOMMUFDClass {
>>>         *
>>>         * @idev: host IOMMU device backed by IOMMUFD backend.
>>>         *
>>> +     * @pasid: target pasid of attach.
>>> +     *
>>>         * @hwpt_id: ID of IOMMUFD hardware page table.
>>>         *
>>>         * @errp: pass an Error out when attachment fails.
>>>         *
>>>         * Returns: true on success, false on failure.
>>>         */
>>> -    bool (*attach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, uint32_t hwpt_id,
>>> -                        Error **errp);
>>> +    bool (*attach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, uint32_t pasid,
>>> +                        uint32_t hwpt_id, Error **errp);
>>>        /**
>>>         * @detach_hwpt: detach host IOMMU device from IOMMUFD hardware
>> page table.
>>>         * VFIO and VDPA device can have different implementation.
>>> @@ -154,15 +156,19 @@ struct HostIOMMUDeviceIOMMUFDClass {
>>>         *
>>>         * @idev: host IOMMU device backed by IOMMUFD backend.
>>>         *
>>> +     * @pasid: target pasid of detach.
>>> +     *
>>>         * @errp: pass an Error out when attachment fails.
>>>         *
>>>         * Returns: true on success, false on failure.
>>>         */
>>> -    bool (*detach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, Error **errp);
>>> +    bool (*detach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, uint32_t pasid,
>>> +                        Error **errp);
>>>    };
>>>
>>>    bool
>> host_iommu_device_iommufd_attach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
>>> -                                           uint32_t hwpt_id, Error **errp);
>>> -bool
>> host_iommu_device_iommufd_detach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
>>> +                                           uint32_t pasid, uint32_t hwpt_id,
>>>                                               Error **errp);
>>> +bool
>> host_iommu_device_iommufd_detach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
>>> +                                           uint32_t pasid, Error **errp);
>>>    #endif
>>> diff --git a/backends/iommufd.c b/backends/iommufd.c
>>> index e1fee16acf..ab612e4874 100644
>>> --- a/backends/iommufd.c
>>> +++ b/backends/iommufd.c
>>> @@ -539,23 +539,24 @@ bool
>> iommufd_backend_alloc_veventq(IOMMUFDBackend *be, uint32_t viommu_id,
>>>    }
>>>
>>>    bool
>> host_iommu_device_iommufd_attach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
>>> -                                           uint32_t hwpt_id, Error **errp)
>>> +                                           uint32_t pasid, uint32_t hwpt_id,
>>> +                                           Error **errp)
>>>    {
>>>        HostIOMMUDeviceIOMMUFDClass *idevc =
>>>            HOST_IOMMU_DEVICE_IOMMUFD_GET_CLASS(idev);
>>
>>
>> For consistency with the rest of the code, I would rename all the
>> idev and idevc variables, to hiod and hiodc.
> 
> We have used hiod and hiodc for the base HostIOMMUDevice type:
> 
> HostIOMMUDevice *hiod;
> HostIOMMUDeviceClass *hiodc;
> 
> To avoid conflict, what about hiodi and hiodic for HostIOMMUDeviceIOMMUFD type?
> 
fine with me.

Thanks,

C.


Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to support pasid
Posted by Yi Liu 6 days, 17 hours ago
On 3/26/26 17:11, Zhenzhong Duan wrote:

> diff --git a/hw/i386/intel_iommu_accel.c b/hw/i386/intel_iommu_accel.c
> index 67d54849f2..45c08c8f6f 100644
> --- a/hw/i386/intel_iommu_accel.c
> +++ b/hw/i386/intel_iommu_accel.c
> @@ -121,7 +121,8 @@ static bool vtd_device_attach_iommufd(VTDHostIOMMUDevice *vtd_hiod,
>           }
>       }
>   
> -    ret = host_iommu_device_iommufd_attach_hwpt(idev, hwpt_id, errp);
> +    ret = host_iommu_device_iommufd_attach_hwpt(idev, IOMMU_NO_PASID, hwpt_id,
> +                                                errp);
>       trace_vtd_device_attach_hwpt(idev->devid, vtd_as->pasid, hwpt_id, ret);

The trace looks to use the wrong pasid. could you make it use
IOMMU_NO_PASID as well? Same to the below chunks.

>       if (ret) {
>           /* Destroy old fs_hwpt if it's a replacement */
> @@ -145,7 +146,7 @@ static bool vtd_device_detach_iommufd(VTDHostIOMMUDevice *vtd_hiod,
>       bool ret;
>   
>       if (s->dmar_enabled && s->root_scalable) {
> -        ret = host_iommu_device_iommufd_detach_hwpt(idev, errp);
> +        ret = host_iommu_device_iommufd_detach_hwpt(idev, IOMMU_NO_PASID, errp);
>           trace_vtd_device_detach_hwpt(idev->devid, pasid, ret);
>       } else {
>           /*
> @@ -153,7 +154,8 @@ static bool vtd_device_detach_iommufd(VTDHostIOMMUDevice *vtd_hiod,
>            * we fallback to the default HWPT which contains shadow page table.
>            * So guest DMA could still work.
>            */
> -        ret = host_iommu_device_iommufd_attach_hwpt(idev, idev->hwpt_id, errp);
> +        ret = host_iommu_device_iommufd_attach_hwpt(idev, IOMMU_NO_PASID,
> +                                                    idev->hwpt_id, errp);
>           trace_vtd_device_reattach_def_hwpt(idev->devid, pasid, idev->hwpt_id,
>                                              ret);

Regards,
Yi Liu
RE: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to support pasid
Posted by Duan, Zhenzhong 6 days, 15 hours ago

>-----Original Message-----
>From: Liu, Yi L <yi.l.liu@intel.com>
>Subject: Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to
>support pasid
>
>On 3/26/26 17:11, Zhenzhong Duan wrote:
>
>> diff --git a/hw/i386/intel_iommu_accel.c b/hw/i386/intel_iommu_accel.c
>> index 67d54849f2..45c08c8f6f 100644
>> --- a/hw/i386/intel_iommu_accel.c
>> +++ b/hw/i386/intel_iommu_accel.c
>> @@ -121,7 +121,8 @@ static bool
>vtd_device_attach_iommufd(VTDHostIOMMUDevice *vtd_hiod,
>>           }
>>       }
>>
>> -    ret = host_iommu_device_iommufd_attach_hwpt(idev, hwpt_id, errp);
>> +    ret = host_iommu_device_iommufd_attach_hwpt(idev, IOMMU_NO_PASID,
>hwpt_id,
>> +                                                errp);
>>       trace_vtd_device_attach_hwpt(idev->devid, vtd_as->pasid, hwpt_id, ret);
>
>The trace looks to use the wrong pasid. could you make it use
>IOMMU_NO_PASID as well? Same to the below chunks.

OK, will do. In fact vtd_as->pasid always equals to IOMMU_NO_PASID here because we don't support pasid yet.

Thanks
Zhenzhong

>
>>       if (ret) {
>>           /* Destroy old fs_hwpt if it's a replacement */
>> @@ -145,7 +146,7 @@ static bool
>vtd_device_detach_iommufd(VTDHostIOMMUDevice *vtd_hiod,
>>       bool ret;
>>
>>       if (s->dmar_enabled && s->root_scalable) {
>> -        ret = host_iommu_device_iommufd_detach_hwpt(idev, errp);
>> +        ret = host_iommu_device_iommufd_detach_hwpt(idev,
>IOMMU_NO_PASID, errp);
>>           trace_vtd_device_detach_hwpt(idev->devid, pasid, ret);
>>       } else {
>>           /*
>> @@ -153,7 +154,8 @@ static bool
>vtd_device_detach_iommufd(VTDHostIOMMUDevice *vtd_hiod,
>>            * we fallback to the default HWPT which contains shadow page table.
>>            * So guest DMA could still work.
>>            */
>> -        ret = host_iommu_device_iommufd_attach_hwpt(idev, idev->hwpt_id,
>errp);
>> +        ret = host_iommu_device_iommufd_attach_hwpt(idev,
>IOMMU_NO_PASID,
>> +                                                    idev->hwpt_id, errp);
>>           trace_vtd_device_reattach_def_hwpt(idev->devid, pasid, idev->hwpt_id,
>>                                              ret);
>
>Regards,
>Yi Liu
Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to support pasid
Posted by Nicolin Chen 6 days, 23 hours ago
On Thu, Mar 26, 2026 at 05:11:16AM -0400, Zhenzhong Duan wrote:
> @@ -138,14 +138,16 @@ struct HostIOMMUDeviceIOMMUFDClass {
>       *
>       * @idev: host IOMMU device backed by IOMMUFD backend.

Not commenting against this patch, but I just found the "host IOMMU
device" and the "HostIOMMUDeviceIOMMUFD" a bit ambiguous. It's not
an "IOMMU device" right? Perhaps somebody can help me understand :)

> +     * @pasid: target pasid of attach.
> +     *

How about "target pasid of the device to be attached"?

The uAPI docs has the narrative "pasid of this device", which makes
it clearer. 

>       * @hwpt_id: ID of IOMMUFD hardware page table.
>       *
>       * @errp: pass an Error out when attachment fails.
>       *
>       * Returns: true on success, false on failure.
>       */
> -    bool (*attach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, uint32_t hwpt_id,
> -                        Error **errp);
> +    bool (*attach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, uint32_t pasid,
> +                        uint32_t hwpt_id, Error **errp);
>      /**
>       * @detach_hwpt: detach host IOMMU device from IOMMUFD hardware page table.
>       * VFIO and VDPA device can have different implementation.
> @@ -154,15 +156,19 @@ struct HostIOMMUDeviceIOMMUFDClass {
>       *
>       * @idev: host IOMMU device backed by IOMMUFD backend.
>       *
> +     * @pasid: target pasid of detach.

Ditto

Otherwise,

Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>
RE: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to support pasid
Posted by Duan, Zhenzhong 6 days, 19 hours ago

>-----Original Message-----
>From: Nicolin Chen <nicolinc@nvidia.com>
>Subject: Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to
>support pasid
>
>On Thu, Mar 26, 2026 at 05:11:16AM -0400, Zhenzhong Duan wrote:
>> @@ -138,14 +138,16 @@ struct HostIOMMUDeviceIOMMUFDClass {
>>       *
>>       * @idev: host IOMMU device backed by IOMMUFD backend.
>
>Not commenting against this patch, but I just found the "host IOMMU
>device" and the "HostIOMMUDeviceIOMMUFD" a bit ambiguous. It's not
>an "IOMMU device" right? Perhaps somebody can help me understand :)

A host device under host IOMMU?

>
>> +     * @pasid: target pasid of attach.
>> +     *
>
>How about "target pasid of the device to be attached"?

Looks fine, will do.

Thanks
Zhenzhong

>
>The uAPI docs has the narrative "pasid of this device", which makes
>it clearer.
>
>>       * @hwpt_id: ID of IOMMUFD hardware page table.
>>       *
>>       * @errp: pass an Error out when attachment fails.
>>       *
>>       * Returns: true on success, false on failure.
>>       */
>> -    bool (*attach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, uint32_t hwpt_id,
>> -                        Error **errp);
>> +    bool (*attach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, uint32_t pasid,
>> +                        uint32_t hwpt_id, Error **errp);
>>      /**
>>       * @detach_hwpt: detach host IOMMU device from IOMMUFD hardware
>page table.
>>       * VFIO and VDPA device can have different implementation.
>> @@ -154,15 +156,19 @@ struct HostIOMMUDeviceIOMMUFDClass {
>>       *
>>       * @idev: host IOMMU device backed by IOMMUFD backend.
>>       *
>> +     * @pasid: target pasid of detach.
>
>Ditto
>
>Otherwise,
>
>Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>
Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to support pasid
Posted by Nicolin Chen 6 days, 18 hours ago
On Fri, Mar 27, 2026 at 02:32:57AM +0000, Duan, Zhenzhong wrote:
> >-----Original Message-----
> >From: Nicolin Chen <nicolinc@nvidia.com>
> >Subject: Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to
> >support pasid
> >
> >On Thu, Mar 26, 2026 at 05:11:16AM -0400, Zhenzhong Duan wrote:
> >> @@ -138,14 +138,16 @@ struct HostIOMMUDeviceIOMMUFDClass {
> >>       *
> >>       * @idev: host IOMMU device backed by IOMMUFD backend.
> >
> >Not commenting against this patch, but I just found the "host IOMMU
> >device" and the "HostIOMMUDeviceIOMMUFD" a bit ambiguous. It's not
> >an "IOMMU device" right? Perhaps somebody can help me understand :)
> 
> A host device under host IOMMU?

"host device" would make sense, not "host IOMMU device", right?

Nicolin
RE: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to support pasid
Posted by Duan, Zhenzhong 6 days, 15 hours ago

>-----Original Message-----
>From: Nicolin Chen <nicolinc@nvidia.com>
>Subject: Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to
>support pasid
>
>On Fri, Mar 27, 2026 at 02:32:57AM +0000, Duan, Zhenzhong wrote:
>> >-----Original Message-----
>> >From: Nicolin Chen <nicolinc@nvidia.com>
>> >Subject: Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks
>to
>> >support pasid
>> >
>> >On Thu, Mar 26, 2026 at 05:11:16AM -0400, Zhenzhong Duan wrote:
>> >> @@ -138,14 +138,16 @@ struct HostIOMMUDeviceIOMMUFDClass {
>> >>       *
>> >>       * @idev: host IOMMU device backed by IOMMUFD backend.
>> >
>> >Not commenting against this patch, but I just found the "host IOMMU
>> >device" and the "HostIOMMUDeviceIOMMUFD" a bit ambiguous. It's not
>> >an "IOMMU device" right? Perhaps somebody can help me understand :)
>>
>> A host device under host IOMMU?
>
>"host device" would make sense, not "host IOMMU device", right?

We want to emphasize that it's a "host device" backed by "host IOMMU",
"host device" is not enough, I think.

Thanks
Zhenzhong
Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to support pasid
Posted by Cédric Le Goater 6 days, 12 hours ago
On 3/27/26 07:44, Duan, Zhenzhong wrote:
> 
> 
>> -----Original Message-----
>> From: Nicolin Chen <nicolinc@nvidia.com>
>> Subject: Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to
>> support pasid
>>
>> On Fri, Mar 27, 2026 at 02:32:57AM +0000, Duan, Zhenzhong wrote:
>>>> -----Original Message-----
>>>> From: Nicolin Chen <nicolinc@nvidia.com>
>>>> Subject: Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks
>> to
>>>> support pasid
>>>>
>>>> On Thu, Mar 26, 2026 at 05:11:16AM -0400, Zhenzhong Duan wrote:
>>>>> @@ -138,14 +138,16 @@ struct HostIOMMUDeviceIOMMUFDClass {
>>>>>        *
>>>>>        * @idev: host IOMMU device backed by IOMMUFD backend.
>>>>
>>>> Not commenting against this patch, but I just found the "host IOMMU
>>>> device" and the "HostIOMMUDeviceIOMMUFD" a bit ambiguous. It's not
>>>> an "IOMMU device" right? Perhaps somebody can help me understand :)
>>>
>>> A host device under host IOMMU?
>>
>> "host device" would make sense, not "host IOMMU device", right?
> 
> We want to emphasize that it's a "host device" backed by "host IOMMU",
> "host device" is not enough, I think.
Yes. These are related to the Host IOMMU device backends :

   - VFIO IOMMU Type1, a.k.a legacy backend
   - IOMMUFD,

There are other implementations. VFIO IOMMU Type1 is versioned and
a ppc flavor exists.

Thanks,

C.
Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to support pasid
Posted by Nicolin Chen via qemu development 6 days, 1 hour ago
On Fri, Mar 27, 2026 at 10:34:01AM +0100, Cédric Le Goater wrote:
> On 3/27/26 07:44, Duan, Zhenzhong wrote:
> > 
> > 
> > > -----Original Message-----
> > > From: Nicolin Chen <nicolinc@nvidia.com>
> > > Subject: Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to
> > > support pasid
> > > 
> > > On Fri, Mar 27, 2026 at 02:32:57AM +0000, Duan, Zhenzhong wrote:
> > > > > -----Original Message-----
> > > > > From: Nicolin Chen <nicolinc@nvidia.com>
> > > > > Subject: Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks
> > > to
> > > > > support pasid
> > > > > 
> > > > > On Thu, Mar 26, 2026 at 05:11:16AM -0400, Zhenzhong Duan wrote:
> > > > > > @@ -138,14 +138,16 @@ struct HostIOMMUDeviceIOMMUFDClass {
> > > > > >        *
> > > > > >        * @idev: host IOMMU device backed by IOMMUFD backend.
> > > > > 
> > > > > Not commenting against this patch, but I just found the "host IOMMU
> > > > > device" and the "HostIOMMUDeviceIOMMUFD" a bit ambiguous. It's not
> > > > > an "IOMMU device" right? Perhaps somebody can help me understand :)
> > > > 
> > > > A host device under host IOMMU?
> > > 
> > > "host device" would make sense, not "host IOMMU device", right?
> > 
> > We want to emphasize that it's a "host device" backed by "host IOMMU",
> > "host device" is not enough, I think.
> Yes. These are related to the Host IOMMU device backends :
> 
>   - VFIO IOMMU Type1, a.k.a legacy backend
>   - IOMMUFD,
> 
> There are other implementations. VFIO IOMMU Type1 is versioned and
> a ppc flavor exists.

But the @idev here is a passthrough device (VFIO/PCI)?

"IOMMU device" would be SMMU, VT-d...

Especially we are adding @pasid parameter. Relating it to SMMU or
VT-d sounds weird.

Nicolin
Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to support pasid
Posted by Cédric Le Goater 3 days, 10 hours ago
On 3/27/26 21:52, Nicolin Chen wrote:
> On Fri, Mar 27, 2026 at 10:34:01AM +0100, Cédric Le Goater wrote:
>> On 3/27/26 07:44, Duan, Zhenzhong wrote:
>>>
>>>
>>>> -----Original Message-----
>>>> From: Nicolin Chen <nicolinc@nvidia.com>
>>>> Subject: Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to
>>>> support pasid
>>>>
>>>> On Fri, Mar 27, 2026 at 02:32:57AM +0000, Duan, Zhenzhong wrote:
>>>>>> -----Original Message-----
>>>>>> From: Nicolin Chen <nicolinc@nvidia.com>
>>>>>> Subject: Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks
>>>> to
>>>>>> support pasid
>>>>>>
>>>>>> On Thu, Mar 26, 2026 at 05:11:16AM -0400, Zhenzhong Duan wrote:
>>>>>>> @@ -138,14 +138,16 @@ struct HostIOMMUDeviceIOMMUFDClass {
>>>>>>>         *
>>>>>>>         * @idev: host IOMMU device backed by IOMMUFD backend.
>>>>>>
>>>>>> Not commenting against this patch, but I just found the "host IOMMU
>>>>>> device" and the "HostIOMMUDeviceIOMMUFD" a bit ambiguous. It's not
>>>>>> an "IOMMU device" right? Perhaps somebody can help me understand :)
>>>>>
>>>>> A host device under host IOMMU?
>>>>
>>>> "host device" would make sense, not "host IOMMU device", right?
>>>
>>> We want to emphasize that it's a "host device" backed by "host IOMMU",
>>> "host device" is not enough, I think.
>> Yes. These are related to the Host IOMMU device backends :
>>
>>    - VFIO IOMMU Type1, a.k.a legacy backend
>>    - IOMMUFD,
>>
>> There are other implementations. VFIO IOMMU Type1 is versioned and
>> a ppc flavor exists.
> 
> But the @idev here is a passthrough device (VFIO/PCI)?
> 
> "IOMMU device" would be SMMU, VT-d...

The 'idev' above is for a 'host IOMMU device backed by IOMMUFD backend'
AFAICT.

  
> Especially we are adding @pasid parameter. Relating it to SMMU or
> VT-d sounds weird.
host IOMMU device variables are usually named 'hiod' and the class 'hiodc'.

Thanks,

C.




Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to support pasid
Posted by Yi Liu 3 days, 13 hours ago
Hi Cédric, Zhenzhong,

On 3/28/26 04:52, Nicolin Chen wrote:
> On Fri, Mar 27, 2026 at 10:34:01AM +0100, Cédric Le Goater wrote:
>> On 3/27/26 07:44, Duan, Zhenzhong wrote:
>>>
>>>
>>>> -----Original Message-----
>>>> From: Nicolin Chen <nicolinc@nvidia.com>
>>>> Subject: Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks to
>>>> support pasid
>>>>
>>>> On Fri, Mar 27, 2026 at 02:32:57AM +0000, Duan, Zhenzhong wrote:
>>>>>> -----Original Message-----
>>>>>> From: Nicolin Chen <nicolinc@nvidia.com>
>>>>>> Subject: Re: [PATCH v2 02/14] iommufd: Extend attach/detach_hwpt callbacks
>>>> to
>>>>>> support pasid
>>>>>>
>>>>>> On Thu, Mar 26, 2026 at 05:11:16AM -0400, Zhenzhong Duan wrote:
>>>>>>> @@ -138,14 +138,16 @@ struct HostIOMMUDeviceIOMMUFDClass {
>>>>>>>         *
>>>>>>>         * @idev: host IOMMU device backed by IOMMUFD backend.
>>>>>>
>>>>>> Not commenting against this patch, but I just found the "host IOMMU
>>>>>> device" and the "HostIOMMUDeviceIOMMUFD" a bit ambiguous. It's not
>>>>>> an "IOMMU device" right? Perhaps somebody can help me understand :)
>>>>>
>>>>> A host device under host IOMMU?
>>>>
>>>> "host device" would make sense, not "host IOMMU device", right?
>>>
>>> We want to emphasize that it's a "host device" backed by "host IOMMU",
>>> "host device" is not enough, I think.
>> Yes. These are related to the Host IOMMU device backends :
>>
>>    - VFIO IOMMU Type1, a.k.a legacy backend
>>    - IOMMUFD,
>>
>> There are other implementations. VFIO IOMMU Type1 is versioned and
>> a ppc flavor exists.
> 
> But the @idev here is a passthrough device (VFIO/PCI)?
> 
> "IOMMU device" would be SMMU, VT-d...
> 
> Especially we are adding @pasid parameter. Relating it to SMMU or
> VT-d sounds weird.

how about "@idev: the iommufd-backed assigned device to xxx"? This
object is quite similar to the iommufd_device object of the kernel side,
kernel refers iommufd_device parameters as device.

1046 /**
1047  * iommufd_device_detach - Disconnect a device/device to an 
iommu_domain
1048  * @idev: device to detach
1049  * @pasid: pasid to detach