{"id":2196473,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2196473/?format=json","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.0/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260214034135.220413-2-zhenzhong.duan@intel.com>","date":"2026-02-14T03:41:21","name":"[RFCv2,01/13] vfio/iommufd: Extend attach/detach_hwpt callback implementations with pasid","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"5ab2e9595abf77f388171cdbf6ada6d21a66b0d9","submitter":{"id":81636,"url":"http://patchwork.ozlabs.org/api/1.0/people/81636/?format=json","name":"Duan, Zhenzhong","email":"zhenzhong.duan@intel.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260214034135.220413-2-zhenzhong.duan@intel.com/mbox/","series":[{"id":492156,"url":"http://patchwork.ozlabs.org/api/1.0/series/492156/?format=json","date":"2026-02-14T03:41:20","name":"intel_iommu: Enable PASID support for passthrough device","version":1,"mbox":"http://patchwork.ozlabs.org/series/492156/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2196473/checks/","tags":{},"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256\n header.s=Intel header.b=IZ7xBK7+;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fCZcG4Bxgz1xxT\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 14 Feb 2026 14:42:38 +1100 (AEDT)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1vr6Xb-00056n-Ue; Fri, 13 Feb 2026 22:41:55 -0500","from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <zhenzhong.duan@intel.com>)\n id 1vr6Xa-00056J-Cj\n for qemu-devel@nongnu.org; Fri, 13 Feb 2026 22:41:54 -0500","from mgamail.intel.com ([198.175.65.12])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <zhenzhong.duan@intel.com>)\n id 1vr6XY-0008AH-8x\n for qemu-devel@nongnu.org; Fri, 13 Feb 2026 22:41:54 -0500","from orviesa009.jf.intel.com ([10.64.159.149])\n by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 13 Feb 2026 19:41:51 -0800","from unknown (HELO gnr-sp-2s-612.sh.intel.com) ([10.112.230.229])\n by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 13 Feb 2026 19:41:47 -0800"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1771040512; x=1802576512;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=18dtOvGTWDZahCxxiczFaosuF0dbwCjkXGH5XXISKsQ=;\n b=IZ7xBK7+we/QF8IvmRtnbVsDkflwA0osNsGOuYPwVUEARoUcyDMrssRE\n NuENxXhdMs2p4NCtrnxsnh2wjEWlupmH4mC40ZBxMxMRohtJWVZtUUw6S\n ySaak3p6YsoKEOKm5n+7/WdFDH+WjLcTSVxXFqcfKPtToa5ZkZy3trwHA\n r0C7+qfFaGDz6mvD3JdPyrMWIFK9pLslBVRoABbFsTEhbUZOi4wjOaKl3\n RNkQNRevRAWpoPdtbfOSGNjbAhVCnrOS2jAvfGU5dj/TinKXo5YXRPnAS\n W8tAV1qf8+1Mxq+Qd46S3iPLzp19VdXr08ZaUpwIcv/EW1k/l7zNPLQwo Q==;","X-CSE-ConnectionGUID":["c/EkYuRQRcqSUpTG4glPzg==","wy3507OaTueyWkDZPFUwSA=="],"X-CSE-MsgGUID":["1ko8ENYITHm2s3dkKfa+QQ==","NUQxvHhMRse7D/5s7L1NDg=="],"X-IronPort-AV":["E=McAfee;i=\"6800,10657,11700\"; a=\"83666795\"","E=Sophos;i=\"6.21,289,1763452800\"; d=\"scan'208\";a=\"83666795\"","E=Sophos;i=\"6.21,289,1763452800\"; d=\"scan'208\";a=\"212932925\""],"X-ExtLoop1":"1","From":"Zhenzhong Duan <zhenzhong.duan@intel.com>","To":"qemu-devel@nongnu.org","Cc":"alex@shazbot.org, clg@redhat.com, eric.auger@redhat.com, mst@redhat.com,\n jasowang@redhat.com, jgg@nvidia.com, nicolinc@nvidia.com,\n skolothumtho@nvidia.com, joao.m.martins@oracle.com,\n clement.mathieu--drif@eviden.com, kevin.tian@intel.com, yi.l.liu@intel.com,\n xudong.hao@intel.com, Zhenzhong Duan <zhenzhong.duan@intel.com>","Subject":"[RFCv2 PATCH 01/13] vfio/iommufd: Extend attach/detach_hwpt callback\n implementations with pasid","Date":"Fri, 13 Feb 2026 22:41:21 -0500","Message-ID":"<20260214034135.220413-2-zhenzhong.duan@intel.com>","X-Mailer":"git-send-email 2.47.3","In-Reply-To":"<20260214034135.220413-1-zhenzhong.duan@intel.com>","References":"<20260214034135.220413-1-zhenzhong.duan@intel.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=198.175.65.12;\n envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com","X-Spam_score_int":"-43","X-Spam_score":"-4.4","X-Spam_bar":"----","X-Spam_report":"(-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001,\n RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=ham autolearn_force=no","X-Spam_action":"no action","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"For attachment with pasid, pasid together with flag VFIO_DEVICE_ATTACH_PASID\nshould be passed in.\n\nDefine IOMMU_NO_PASID to represent device attachment without pasid same as\nin kernel.\n\nThe implementation is similar for detachment.\n\nSuggested-by: Shameer Kolothum Thodi <skolothumtho@nvidia.com>\nSuggested-by: Nicolin Chen <nicolinc@nvidia.com>\nSigned-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>\n---\n include/hw/core/iommu.h |  2 ++\n hw/vfio/iommufd.c       | 44 +++++++++++++++++++++++++----------------\n hw/vfio/trace-events    |  4 ++--\n 3 files changed, 31 insertions(+), 19 deletions(-)","diff":"diff --git a/include/hw/core/iommu.h b/include/hw/core/iommu.h\nindex 86af315c15..bfcd511013 100644\n--- a/include/hw/core/iommu.h\n+++ b/include/hw/core/iommu.h\n@@ -28,4 +28,6 @@ enum host_iommu_quirks {\n     HOST_IOMMU_QUIRK_NESTING_PARENT_BYPASS_RO = BIT_ULL(0),\n };\n \n+#define IOMMU_NO_PASID 0\n+\n #endif /* HW_IOMMU_H */\ndiff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c\nindex 131612eb83..b4c5e81b1d 100644\n--- a/hw/vfio/iommufd.c\n+++ b/hw/vfio/iommufd.c\n@@ -21,6 +21,7 @@\n #include \"qapi/error.h\"\n #include \"system/iommufd.h\"\n #include \"hw/core/qdev.h\"\n+#include \"hw/core/iommu.h\"\n #include \"hw/vfio/vfio-cpr.h\"\n #include \"system/reset.h\"\n #include \"qemu/cutils.h\"\n@@ -302,43 +303,48 @@ out:\n     return ret;\n }\n \n-static int iommufd_cdev_attach_ioas_hwpt(VFIODevice *vbasedev, uint32_t id,\n-                                         Error **errp)\n+static int iommufd_cdev_pasid_attach_ioas_hwpt(VFIODevice *vbasedev,\n+                                               uint32_t pasid, uint32_t id,\n+                                               Error **errp)\n {\n     int iommufd = vbasedev->iommufd->fd;\n     struct vfio_device_attach_iommufd_pt attach_data = {\n         .argsz = sizeof(attach_data),\n-        .flags = 0,\n+        .flags = pasid == IOMMU_NO_PASID ? 0 : VFIO_DEVICE_ATTACH_PASID,\n+        .pasid = pasid,\n         .pt_id = id,\n     };\n \n     /* Attach device to an IOAS or hwpt within iommufd */\n     if (ioctl(vbasedev->fd, VFIO_DEVICE_ATTACH_IOMMUFD_PT, &attach_data)) {\n         error_setg_errno(errp, errno,\n-                         \"[iommufd=%d] error attach %s (%d) to id=%d\",\n-                         iommufd, vbasedev->name, vbasedev->fd, id);\n+                         \"[iommufd=%d] error attach %s (%d) pasid %d to id=%d\",\n+                         iommufd, vbasedev->name, vbasedev->fd, pasid, id);\n         return -errno;\n     }\n \n-    trace_iommufd_cdev_attach_ioas_hwpt(iommufd, vbasedev->name,\n-                                        vbasedev->fd, id);\n+    trace_iommufd_cdev_pasid_attach_ioas_hwpt(iommufd, vbasedev->name,\n+                                              vbasedev->fd, pasid, id);\n     return 0;\n }\n \n-static bool iommufd_cdev_detach_ioas_hwpt(VFIODevice *vbasedev, Error **errp)\n+static bool iommufd_cdev_pasid_detach_ioas_hwpt(VFIODevice *vbasedev,\n+                                                uint32_t pasid, Error **errp)\n {\n     int iommufd = vbasedev->iommufd->fd;\n     struct vfio_device_detach_iommufd_pt detach_data = {\n         .argsz = sizeof(detach_data),\n-        .flags = 0,\n+        .flags = pasid == IOMMU_NO_PASID ? 0 : VFIO_DEVICE_DETACH_PASID,\n+        .pasid = pasid,\n     };\n \n     if (ioctl(vbasedev->fd, VFIO_DEVICE_DETACH_IOMMUFD_PT, &detach_data)) {\n-        error_setg_errno(errp, errno, \"detach %s failed\", vbasedev->name);\n+        error_setg_errno(errp, errno, \"detach %s pasid %d failed\",\n+                         vbasedev->name, pasid);\n         return false;\n     }\n \n-    trace_iommufd_cdev_detach_ioas_hwpt(iommufd, vbasedev->name);\n+    trace_iommufd_cdev_pasid_detach_ioas_hwpt(iommufd, vbasedev->name, pasid);\n     return true;\n }\n \n@@ -359,7 +365,8 @@ static bool iommufd_cdev_autodomains_get(VFIODevice *vbasedev,\n     /* Try to find a domain */\n     QLIST_FOREACH(hwpt, &container->hwpt_list, next) {\n         if (!cpr_is_incoming()) {\n-            ret = iommufd_cdev_attach_ioas_hwpt(vbasedev, hwpt->hwpt_id, errp);\n+            ret = iommufd_cdev_pasid_attach_ioas_hwpt(vbasedev, IOMMU_NO_PASID,\n+                                                      hwpt->hwpt_id, errp);\n         } else if (vbasedev->cpr.hwpt_id == hwpt->hwpt_id) {\n             ret = 0;\n         } else {\n@@ -432,7 +439,8 @@ static bool iommufd_cdev_autodomains_get(VFIODevice *vbasedev,\n         return false;\n     }\n \n-    ret = iommufd_cdev_attach_ioas_hwpt(vbasedev, hwpt_id, errp);\n+    ret = iommufd_cdev_pasid_attach_ioas_hwpt(vbasedev, IOMMU_NO_PASID, hwpt_id,\n+                                              errp);\n     if (ret) {\n         iommufd_backend_free_id(container->be, hwpt_id);\n         return false;\n@@ -485,7 +493,8 @@ static bool iommufd_cdev_attach_container(VFIODevice *vbasedev,\n \n     /* If CPR, we are already attached to ioas_id. */\n     return cpr_is_incoming() ||\n-           !iommufd_cdev_attach_ioas_hwpt(vbasedev, container->ioas_id, errp);\n+           !iommufd_cdev_pasid_attach_ioas_hwpt(vbasedev, IOMMU_NO_PASID,\n+                                                container->ioas_id, errp);\n }\n \n static void iommufd_cdev_detach_container(VFIODevice *vbasedev,\n@@ -493,7 +502,7 @@ static void iommufd_cdev_detach_container(VFIODevice *vbasedev,\n {\n     Error *err = NULL;\n \n-    if (!iommufd_cdev_detach_ioas_hwpt(vbasedev, &err)) {\n+    if (!iommufd_cdev_pasid_detach_ioas_hwpt(vbasedev, IOMMU_NO_PASID, &err)) {\n         error_report_err(err);\n     }\n \n@@ -919,7 +928,8 @@ host_iommu_device_iommufd_vfio_attach_hwpt(HostIOMMUDeviceIOMMUFD *idev,\n {\n     VFIODevice *vbasedev = HOST_IOMMU_DEVICE(idev)->agent;\n \n-    return !iommufd_cdev_attach_ioas_hwpt(vbasedev, hwpt_id, errp);\n+    return !iommufd_cdev_pasid_attach_ioas_hwpt(vbasedev, IOMMU_NO_PASID,\n+                                                hwpt_id, errp);\n }\n \n static bool\n@@ -928,7 +938,7 @@ host_iommu_device_iommufd_vfio_detach_hwpt(HostIOMMUDeviceIOMMUFD *idev,\n {\n     VFIODevice *vbasedev = HOST_IOMMU_DEVICE(idev)->agent;\n \n-    return iommufd_cdev_detach_ioas_hwpt(vbasedev, errp);\n+    return iommufd_cdev_pasid_detach_ioas_hwpt(vbasedev, IOMMU_NO_PASID, errp);\n }\n \n static bool hiod_iommufd_vfio_realize(HostIOMMUDevice *hiod, void *opaque,\ndiff --git a/hw/vfio/trace-events b/hw/vfio/trace-events\nindex 846e3625c5..764a3e4855 100644\n--- a/hw/vfio/trace-events\n+++ b/hw/vfio/trace-events\n@@ -182,8 +182,8 @@ vfio_vmstate_change_prepare(const char *name, int running, const char *reason, c\n \n iommufd_cdev_connect_and_bind(int iommufd, const char *name, int devfd, int devid) \" [iommufd=%d] Successfully bound device %s (fd=%d): output devid=%d\"\n iommufd_cdev_getfd(const char *dev, int devfd) \" %s (fd=%d)\"\n-iommufd_cdev_attach_ioas_hwpt(int iommufd, const char *name, int devfd, int id) \" [iommufd=%d] Successfully attached device %s (%d) to id=%d\"\n-iommufd_cdev_detach_ioas_hwpt(int iommufd, const char *name) \" [iommufd=%d] Successfully detached %s\"\n+iommufd_cdev_pasid_attach_ioas_hwpt(int iommufd, const char *name, int devfd, uint32_t pasid, int id) \" [iommufd=%d] Successfully attached device %s (%d) pasid %d to id=%d\"\n+iommufd_cdev_pasid_detach_ioas_hwpt(int iommufd, const char *name, uint32_t pasid) \" [iommufd=%d] Successfully detached %s pasid %d\"\n iommufd_cdev_fail_attach_existing_container(const char *msg) \" %s\"\n iommufd_cdev_alloc_ioas(int iommufd, int ioas_id) \" [iommufd=%d] new IOMMUFD container with ioasid=%d\"\n iommufd_cdev_device_info(char *name, int devfd, int num_irqs, int num_regions, int flags) \" %s (%d) num_irqs=%d num_regions=%d flags=%d\"\n","prefixes":["RFCv2","01/13"]}