From nobody Sat Nov 15 17:58:28 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1748597988; cv=none; d=zohomail.com; s=zohoarc; b=mSf4MR/Wf4N4MB8fNzMl8Tmkmp7KDiEjXF+IyL5EuJy0szjtJ7w4wXTc43plAXHZRYR0Z/49Kz6/CuF9uwUh/WljS2k4HTFLxsBEcWlYHDmhvTKLCBa9EsgYnV5ekkULlHJPdYURJl7Ov0WFEpuI93jz4BJJvA6PBXMEIljgWSs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748597988; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DSCqBLhc7v2EKcCvZZKc3CRIHZ2ieepaCMxYuFih0Pk=; b=AhsfbCgzJLqziN/OpQ9YIokdA9AAIoUxtQwGDb2xWkIb0OS0L/4P77xcSo8NH/cTvsTjrRx/E29Xl8jZgi87uo98qbStFEovLyb8HPnBwSeb3yhW0B6mr5dU4XmfqArgaKRfiH3Fa+HVNJ6PxWIiRBm5oyMpjtWS5YrXPtIt7UU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748597988340536.87545127; Fri, 30 May 2025 02:39:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uKwCl-00082V-W1; Fri, 30 May 2025 05:39:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uKwCk-00081K-5b for qemu-devel@nongnu.org; Fri, 30 May 2025 05:39:10 -0400 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uKwCi-0006Dk-4e for qemu-devel@nongnu.org; Fri, 30 May 2025 05:39:09 -0400 Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2025 02:39:06 -0700 Received: from spr-s2600bt.bj.intel.com ([10.240.192.127]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2025 02:39:03 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1748597948; x=1780133948; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SElgsoPszIDEZ4XPOU35hS5vzpCzyvcoUOKPEYnhdlY=; b=CAUzNBzX/GMnsoM5Eay6NvAdX0pdQi4upuwtSe4Fa5LEvW5OwiuRQbFl GD/oA7oXcX6OEo5o2v07TWvLvrNXhLXeCukj5afv+uJHVWhylVvfsZ4UA /ExPn0ToMJAMJM1J7NIu2MOh3Sh2J6GnZeJKyDmwdt4gIKJB80H9keiSC IkjYOaMsNh53Qios7eS4SyR5YnlxW4dGSvLAUP7WpVxE6FYssTKNk2w0G idZv0XLTtYCmY8xHLfkugYgPHjooW2MFTu1Xx025e4HqBYmLPeBMYxtkB zPq8Q7B5aN613B28HdCWsbWwQdRp45swpSqgg4E03nRZHNxGK690uJNVA A==; X-CSE-ConnectionGUID: Pg0rn/yNS86/vqkxqBYDAQ== X-CSE-MsgGUID: ab9SCwV4S82ziODWeL9rQA== X-IronPort-AV: E=McAfee;i="6700,10204,11448"; a="60942050" X-IronPort-AV: E=Sophos;i="6.16,195,1744095600"; d="scan'208";a="60942050" X-CSE-ConnectionGUID: GXEzVrNkTuSDVfMR/VQefw== X-CSE-MsgGUID: yze+de7GTS+/6kxkVHd1PA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,195,1744095600"; d="scan'208";a="143788733" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, mst@redhat.com, jasowang@redhat.com, peterx@redhat.com, ddutile@redhat.com, jgg@nvidia.com, nicolinc@nvidia.com, shameerali.kolothum.thodi@huawei.com, joao.m.martins@oracle.com, clement.mathieu--drif@eviden.com, kevin.tian@intel.com, yi.l.liu@intel.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH v2 1/4] backends/iommufd: Add a helper to invalidate user-managed HWPT Date: Fri, 30 May 2025 17:35:09 +0800 Message-Id: <20250530093512.3959484-2-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250530093512.3959484-1-zhenzhong.duan@intel.com> References: <20250530093512.3959484-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.11; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -72 X-Spam_score: -7.3 X-Spam_bar: ------- X-Spam_report: (-7.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.902, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1748597990277116600 Content-Type: text/plain; charset="utf-8" This helper passes cache invalidation request from guest to invalidate stage-1 page table cache in host hardware. Signed-off-by: Nicolin Chen Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Eric Auger --- include/system/iommufd.h | 4 ++++ backends/iommufd.c | 36 ++++++++++++++++++++++++++++++++++++ backends/trace-events | 1 + 3 files changed, 41 insertions(+) diff --git a/include/system/iommufd.h b/include/system/iommufd.h index cbab75bfbf..83ab8e1e4c 100644 --- a/include/system/iommufd.h +++ b/include/system/iommufd.h @@ -61,6 +61,10 @@ bool iommufd_backend_get_dirty_bitmap(IOMMUFDBackend *be= , uint32_t hwpt_id, uint64_t iova, ram_addr_t size, uint64_t page_size, uint64_t *data, Error **errp); +bool iommufd_backend_invalidate_cache(IOMMUFDBackend *be, uint32_t id, + uint32_t data_type, uint32_t entry_l= en, + uint32_t *entry_num, void *data, + Error **errp); =20 #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD TYPE_HOST_IOMMU_DEVICE "-iommufd" #endif diff --git a/backends/iommufd.c b/backends/iommufd.c index b73f75cd0b..8bcdb60fe7 100644 --- a/backends/iommufd.c +++ b/backends/iommufd.c @@ -311,6 +311,42 @@ bool iommufd_backend_get_device_info(IOMMUFDBackend *b= e, uint32_t devid, return true; } =20 +bool iommufd_backend_invalidate_cache(IOMMUFDBackend *be, uint32_t id, + uint32_t data_type, uint32_t entry_l= en, + uint32_t *entry_num, void *data, + Error **errp) +{ + int ret, fd =3D be->fd; + uint32_t total_entries =3D *entry_num; + struct iommu_hwpt_invalidate cache =3D { + .size =3D sizeof(cache), + .hwpt_id =3D id, + .data_type =3D data_type, + .entry_len =3D entry_len, + .entry_num =3D total_entries, + .data_uptr =3D (uintptr_t)data, + }; + + ret =3D ioctl(fd, IOMMU_HWPT_INVALIDATE, &cache); + trace_iommufd_backend_invalidate_cache(fd, id, data_type, entry_len, + total_entries, cache.entry_num, + (uintptr_t)data, ret ? errno : = 0); + *entry_num =3D cache.entry_num; + + if (ret) { + error_setg_errno(errp, errno, "IOMMU_HWPT_INVALIDATE failed:" + " total %d entries, processed %d entries", + total_entries, cache.entry_num); + } else if (total_entries !=3D cache.entry_num) { + error_setg(errp, "IOMMU_HWPT_INVALIDATE succeed but with unprocess= ed" + " entries: total %d entries, processed %d entries= ." + " Kernel BUG?!", total_entries, cache.entry_num); + return false; + } + + return !ret; +} + static int hiod_iommufd_get_cap(HostIOMMUDevice *hiod, int cap, Error **er= rp) { HostIOMMUDeviceCaps *caps =3D &hiod->caps; diff --git a/backends/trace-events b/backends/trace-events index 40811a3162..7278214ea5 100644 --- a/backends/trace-events +++ b/backends/trace-events @@ -18,3 +18,4 @@ iommufd_backend_alloc_hwpt(int iommufd, uint32_t dev_id, = uint32_t pt_id, uint32_ iommufd_backend_free_id(int iommufd, uint32_t id, int ret) " iommufd=3D%d = id=3D%d (%d)" iommufd_backend_set_dirty(int iommufd, uint32_t hwpt_id, bool start, int r= et) " iommufd=3D%d hwpt=3D%u enable=3D%d (%d)" iommufd_backend_get_dirty_bitmap(int iommufd, uint32_t hwpt_id, uint64_t i= ova, uint64_t size, uint64_t page_size, int ret) " iommufd=3D%d hwpt=3D%u i= ova=3D0x%"PRIx64" size=3D0x%"PRIx64" page_size=3D0x%"PRIx64" (%d)" +iommufd_backend_invalidate_cache(int iommufd, uint32_t id, uint32_t data_t= ype, uint32_t entry_len, uint32_t entry_num, uint32_t done_num, uint64_t da= ta_ptr, int ret) " iommufd=3D%d id=3D%u data_type=3D%u entry_len=3D%u entry= _num=3D%u done_num=3D%u data_ptr=3D0x%"PRIx64" (%d)" --=20 2.34.1 From nobody Sat Nov 15 17:58:28 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1748597988; cv=none; d=zohomail.com; s=zohoarc; b=cu8enilzcxQQzWyGg8G61gtHbmzxtI1QQhKl6Yu+n+Y9rhDsNgThKb+1y58+qLEWZH7fb3lnr6jsj575eyvd+xwpy4sfLNUCbva6S7InIxDTe/gSXqXGElijxRnuvKUosEf0saNDr5FaQpsjDW2eLpcZzjueC1pWZYsGe7RFzqE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748597988; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kVPpO99NJ8Wr8DbZHTG41NNAKa3xM40Y8Uy7l8WCHMU=; b=NnzNPBe5YGax+N1KtlsjeF/OXbq6Q9KzlPMu/Si6S+Jpx/dhVtG2aoVH237Y8iNE+rSEK8VoX4yVj7KcqlhMrwb3XdiAXTmPkLAK4UCLI9JsOXr1s/E8NEIIZ7gCyZryZBrSkUlHt9Z/1Qd2kj2T2aXW41tAMj9xzy5hi6yhxqE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 174859798804475.58727379539346; Fri, 30 May 2025 02:39:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uKwCq-00083t-Ia; Fri, 30 May 2025 05:39:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uKwCn-00083H-Pl for qemu-devel@nongnu.org; Fri, 30 May 2025 05:39:14 -0400 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uKwCm-0006E7-1x for qemu-devel@nongnu.org; Fri, 30 May 2025 05:39:13 -0400 Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2025 02:39:11 -0700 Received: from spr-s2600bt.bj.intel.com ([10.240.192.127]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2025 02:39:07 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1748597952; x=1780133952; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=I+1Tmy4s6r2K7hGPZ7z3W7e3Gy3Luj1bV6KKdzf1un8=; b=QFkeKhUji6Nk/kS2sPQeS/mi6M+D/9CtWT/mhjGxGDIrInZCTa31ajlS fjFB4Y5exarD55CLHb/My75zNxqvWyCZ6F3+xQWLTVVeyaaQBbLRecid2 4bZCmpXZ9Pvh4i80tiYIbdKMCYDcUQirz1awmfer00Gbx855EA6uBi8Ie RonjKebN3CeiMbtpURz3xWs0rp/C3cAlrSdSm+mB1OhGlXcR7h/zpY0bD OtLv76bzkgiAU4+VLT8dizJRYX9/XLZEyZeTM898JBYxUI4EUJCKCBAYr yVjmfu3OTKWXMA40Ovx3roh0s58TVrrG3SQ2vQIIgxCOKCJpk25xuNAQC Q==; X-CSE-ConnectionGUID: rc8h/FowRj66M9Dq4u+bEA== X-CSE-MsgGUID: N0rBFxwKQaefnUt1vzk0ww== X-IronPort-AV: E=McAfee;i="6700,10204,11448"; a="60942056" X-IronPort-AV: E=Sophos;i="6.16,195,1744095600"; d="scan'208";a="60942056" X-CSE-ConnectionGUID: DLehRV9ETs+nuFMOFybJ5Q== X-CSE-MsgGUID: Ka5sLRyuQoePsq3aZlAvwA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,195,1744095600"; d="scan'208";a="143788737" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, mst@redhat.com, jasowang@redhat.com, peterx@redhat.com, ddutile@redhat.com, jgg@nvidia.com, nicolinc@nvidia.com, shameerali.kolothum.thodi@huawei.com, joao.m.martins@oracle.com, clement.mathieu--drif@eviden.com, kevin.tian@intel.com, yi.l.liu@intel.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH v2 2/4] vfio/iommufd: Add properties and handlers to TYPE_HOST_IOMMU_DEVICE_IOMMUFD Date: Fri, 30 May 2025 17:35:10 +0800 Message-Id: <20250530093512.3959484-3-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250530093512.3959484-1-zhenzhong.duan@intel.com> References: <20250530093512.3959484-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.11; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -72 X-Spam_score: -7.3 X-Spam_bar: ------- X-Spam_report: (-7.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.902, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1748597990325116600 Enhance HostIOMMUDeviceIOMMUFD object with 3 new members, specific to the iommufd BE + 2 new class functions. IOMMUFD BE includes IOMMUFD handle, devid and hwpt_id. IOMMUFD handle and devid are used to allocate/free ioas and hwpt. hwpt_id is used to re-attach IOMMUFD backed device to its default VFIO sub-system created hwpt, i.e., when vIOMMU is disabled by guest. These properties are initialized in hiod::realize() after attachment. 2 new class functions are [at|de]tach_hwpt(). They are used to attach/detach hwpt. VFIO and VDPA can have different implementions, so implementation will be in sub-class instead of HostIOMMUDeviceIOMMUFD, e.g., in HostIOMMUDeviceIOMMUFDVFIO. Add two wrappers host_iommu_device_iommufd_[at|de]tach_hwpt to wrap the two functions. Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Eric Auger --- include/system/iommufd.h | 50 ++++++++++++++++++++++++++++++++++++++++ backends/iommufd.c | 22 ++++++++++++++++++ hw/vfio/iommufd.c | 6 +++++ 3 files changed, 78 insertions(+) diff --git a/include/system/iommufd.h b/include/system/iommufd.h index 83ab8e1e4c..283861b924 100644 --- a/include/system/iommufd.h +++ b/include/system/iommufd.h @@ -67,4 +67,54 @@ bool iommufd_backend_invalidate_cache(IOMMUFDBackend *be= , uint32_t id, Error **errp); =20 #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD TYPE_HOST_IOMMU_DEVICE "-iommufd" +OBJECT_DECLARE_TYPE(HostIOMMUDeviceIOMMUFD, HostIOMMUDeviceIOMMUFDClass, + HOST_IOMMU_DEVICE_IOMMUFD) + +/* Overload of the host IOMMU device for the iommufd backend */ +struct HostIOMMUDeviceIOMMUFD { + HostIOMMUDevice parent_obj; + + IOMMUFDBackend *iommufd; + uint32_t devid; + uint32_t hwpt_id; +}; + +struct HostIOMMUDeviceIOMMUFDClass { + HostIOMMUDeviceClass parent_class; + + /** + * @attach_hwpt: attach host IOMMU device to IOMMUFD hardware page tab= le. + * VFIO and VDPA device can have different implementation. + * + * Mandatory callback. + * + * @idev: host IOMMU device backed by IOMMUFD backend. + * + * @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); + /** + * @detach_hwpt: detach host IOMMU device from IOMMUFD hardware page t= able. + * VFIO and VDPA device can have different implementation. + * + * Mandatory callback. + * + * @idev: host IOMMU device backed by IOMMUFD backend. + * + * @errp: pass an Error out when attachment fails. + * + * Returns: true on success, false on failure. + */ + bool (*detach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, 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, + Error **errp); #endif diff --git a/backends/iommufd.c b/backends/iommufd.c index 8bcdb60fe7..c2c47abf7e 100644 --- a/backends/iommufd.c +++ b/backends/iommufd.c @@ -347,6 +347,26 @@ bool iommufd_backend_invalidate_cache(IOMMUFDBackend *= be, uint32_t id, return !ret; } =20 +bool host_iommu_device_iommufd_attach_hwpt(HostIOMMUDeviceIOMMUFD *idev, + uint32_t hwpt_id, Error **errp) +{ + HostIOMMUDeviceIOMMUFDClass *idevc =3D + HOST_IOMMU_DEVICE_IOMMUFD_GET_CLASS(idev); + + g_assert(idevc->attach_hwpt); + return idevc->attach_hwpt(idev, hwpt_id, errp); +} + +bool host_iommu_device_iommufd_detach_hwpt(HostIOMMUDeviceIOMMUFD *idev, + Error **errp) +{ + HostIOMMUDeviceIOMMUFDClass *idevc =3D + HOST_IOMMU_DEVICE_IOMMUFD_GET_CLASS(idev); + + g_assert(idevc->detach_hwpt); + return idevc->detach_hwpt(idev, errp); +} + static int hiod_iommufd_get_cap(HostIOMMUDevice *hiod, int cap, Error **er= rp) { HostIOMMUDeviceCaps *caps =3D &hiod->caps; @@ -385,6 +405,8 @@ static const TypeInfo types[] =3D { }, { .name =3D TYPE_HOST_IOMMU_DEVICE_IOMMUFD, .parent =3D TYPE_HOST_IOMMU_DEVICE, + .instance_size =3D sizeof(HostIOMMUDeviceIOMMUFD), + .class_size =3D sizeof(HostIOMMUDeviceIOMMUFDClass), .class_init =3D hiod_iommufd_class_init, .abstract =3D true, } diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index af1c7ab10a..5fde2b633a 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -814,6 +814,7 @@ static bool hiod_iommufd_vfio_realize(HostIOMMUDevice *= hiod, void *opaque, Error **errp) { VFIODevice *vdev =3D opaque; + HostIOMMUDeviceIOMMUFD *idev; HostIOMMUDeviceCaps *caps =3D &hiod->caps; enum iommu_hw_info_type type; union { @@ -833,6 +834,11 @@ static bool hiod_iommufd_vfio_realize(HostIOMMUDevice = *hiod, void *opaque, caps->type =3D type; caps->hw_caps =3D hw_caps; =20 + idev =3D HOST_IOMMU_DEVICE_IOMMUFD(hiod); + idev->iommufd =3D vdev->iommufd; + idev->devid =3D vdev->devid; + idev->hwpt_id =3D vdev->hwpt->hwpt_id; + return true; } =20 --=20 2.34.1 From nobody Sat Nov 15 17:58:28 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1748597988; cv=none; d=zohomail.com; s=zohoarc; b=Nhn05QRpGd5+BH3mkUM7V4KvNE0BcpB8UFbQxZxtyfYix1diwNw/hfA1Zzm+WMq92IgUHtFiqIE2WyArhYGAfqxqkIA8KrvM3DFNzSBT86mna6jf/yOUpq0HX3iTIX7CBW/2g9SSFcOwARgT8BhL813enasrDz2xzKUqfwI4gTM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748597988; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aQEH7mOTEmZHBSKm+YG3/cjK9hxI7U17cpEwuPxizHk=; b=RjobSFkflbSWuzhpL6vNLRe5q3AF7j8hw4AfbWDAGiPlZaHYi8zrBm6gkJAgLHPb8LPH3uQizF6pJMNpdwK1MaqdqsWHgFFNWBdvB3/WZhOse8q0i/SGsB9fmOsBmwGVZcoecBUrZDV/fmr2R8hklpZv+TmfwyMR0QcvnDDK1fc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 174859798797291.56869838267824; Fri, 30 May 2025 02:39:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uKwCs-00084J-Mw; Fri, 30 May 2025 05:39:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uKwCr-000843-8b for qemu-devel@nongnu.org; Fri, 30 May 2025 05:39:17 -0400 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uKwCp-0006E7-NO for qemu-devel@nongnu.org; Fri, 30 May 2025 05:39:17 -0400 Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2025 02:39:15 -0700 Received: from spr-s2600bt.bj.intel.com ([10.240.192.127]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2025 02:39:11 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1748597956; x=1780133956; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MEpUcenrqAs0CR5CwtYmoOmXE3rdczwvGggcsjxEn8A=; b=U3l4qLGjjyvmfBs4br0YakcDmmfRnVRMo/L78Xl4BM9aA1E+CZ3iH3p8 fYj7R7Kk2T28AWZQzfAWmAv1O7crdN1PBHYvGRz8twbHCQyl0tQ1fsPLv WccF3OCnretenAO1sNLhwGEo1BM9koB2xs6bBx4xbH7hb/l6yINU55njM HSiYOUiW2eZYNodz/LLSdicnk+IPJKPt7a6Y8CkJPY94DmrjNk7fswQI8 4jHbzZv/cG4mhJkassRs4IVZERq17ZUGiMWtev9hi2MFC9+Y1WC6/IAQg DH2kXBLHn/P30/MDS3ryy3QeE4Hj5m5Cri83d4pIXrEIc3iQUqAfvFGpf Q==; X-CSE-ConnectionGUID: uhu3XPlGRK6tflpY7TI7Ig== X-CSE-MsgGUID: QZpJ+w4zTJyNKjbsKa+d+g== X-IronPort-AV: E=McAfee;i="6700,10204,11448"; a="60942064" X-IronPort-AV: E=Sophos;i="6.16,195,1744095600"; d="scan'208";a="60942064" X-CSE-ConnectionGUID: hw/H8Z29T7uKDAu3qkYvyw== X-CSE-MsgGUID: sQP9XL7FRSCH5Om7xUyU5A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,195,1744095600"; d="scan'208";a="143788743" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, mst@redhat.com, jasowang@redhat.com, peterx@redhat.com, ddutile@redhat.com, jgg@nvidia.com, nicolinc@nvidia.com, shameerali.kolothum.thodi@huawei.com, joao.m.martins@oracle.com, clement.mathieu--drif@eviden.com, kevin.tian@intel.com, yi.l.liu@intel.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH v2 3/4] vfio/iommufd: Implement [at|de]tach_hwpt handlers Date: Fri, 30 May 2025 17:35:11 +0800 Message-Id: <20250530093512.3959484-4-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250530093512.3959484-1-zhenzhong.duan@intel.com> References: <20250530093512.3959484-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.11; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -72 X-Spam_score: -7.3 X-Spam_bar: ------- X-Spam_report: (-7.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.902, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1748597990195116600 Implement [at|de]tach_hwpt handlers in VFIO subsystem. vIOMMU utilizes them to attach to or detach from hwpt on host side. Signed-off-by: Yi Liu Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Eric Auger Reviewed-by: Nicolin Chen --- hw/vfio/iommufd.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 5fde2b633a..d661737c17 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -810,6 +810,24 @@ static void vfio_iommu_iommufd_class_init(ObjectClass = *klass, const void *data) vioc->query_dirty_bitmap =3D iommufd_query_dirty_bitmap; }; =20 +static bool +host_iommu_device_iommufd_vfio_attach_hwpt(HostIOMMUDeviceIOMMUFD *idev, + uint32_t hwpt_id, Error **errp) +{ + VFIODevice *vbasedev =3D HOST_IOMMU_DEVICE(idev)->agent; + + return !iommufd_cdev_attach_ioas_hwpt(vbasedev, hwpt_id, errp); +} + +static bool +host_iommu_device_iommufd_vfio_detach_hwpt(HostIOMMUDeviceIOMMUFD *idev, + Error **errp) +{ + VFIODevice *vbasedev =3D HOST_IOMMU_DEVICE(idev)->agent; + + return iommufd_cdev_detach_ioas_hwpt(vbasedev, errp); +} + static bool hiod_iommufd_vfio_realize(HostIOMMUDevice *hiod, void *opaque, Error **errp) { @@ -864,10 +882,14 @@ hiod_iommufd_vfio_get_page_size_mask(HostIOMMUDevice = *hiod) static void hiod_iommufd_vfio_class_init(ObjectClass *oc, const void *data) { HostIOMMUDeviceClass *hiodc =3D HOST_IOMMU_DEVICE_CLASS(oc); + HostIOMMUDeviceIOMMUFDClass *idevc =3D HOST_IOMMU_DEVICE_IOMMUFD_CLASS= (oc); =20 hiodc->realize =3D hiod_iommufd_vfio_realize; hiodc->get_iova_ranges =3D hiod_iommufd_vfio_get_iova_ranges; hiodc->get_page_size_mask =3D hiod_iommufd_vfio_get_page_size_mask; + + idevc->attach_hwpt =3D host_iommu_device_iommufd_vfio_attach_hwpt; + idevc->detach_hwpt =3D host_iommu_device_iommufd_vfio_detach_hwpt; }; =20 static const TypeInfo types[] =3D { --=20 2.34.1 From nobody Sat Nov 15 17:58:28 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1748598002; cv=none; d=zohomail.com; s=zohoarc; b=f8ry2okEzvxQqTEyasZloNUNG3TIbHPtls+3ht8ZcrIyKlM8RH3nlT//z6MNn1eTU9fCj6frYoD7czT8spDb2Z13cwUStRt75pg9gnbgoXTwSFxY0pxD4Q74E72ZovhR+R2E7zaQ5GSPrfW1mPLFKZiV0jC3dwxfKDCcjGSxXWY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748598002; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wcOO/Kr9ZeRwh9K9k6WHFj4t28GUMqzvij1uHUxUdNA=; b=I98msKdnXOsRV+zrulEexvyM2lW6FaU2ADLLvM5U4Xh1bI3AgxeTadeH2Tu0Yy+SHToAkQGLCGlCJeuUytL8E669SKwZy9cRs+F+z80NtHaH5sm5kTxnuAddDk/tqzFgQgJrwQN4zoIiPhfDVBO7vv28AtgrDTIPawOgAiNua/g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748598002499875.8167051563273; Fri, 30 May 2025 02:40:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uKwCx-00085B-7V; Fri, 30 May 2025 05:39:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uKwCv-00084f-Qd for qemu-devel@nongnu.org; Fri, 30 May 2025 05:39:21 -0400 Received: from mgamail.intel.com ([198.175.65.11]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uKwCu-0006E7-2k for qemu-devel@nongnu.org; Fri, 30 May 2025 05:39:21 -0400 Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2025 02:39:19 -0700 Received: from spr-s2600bt.bj.intel.com ([10.240.192.127]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2025 02:39:16 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1748597960; x=1780133960; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=i1XoNd1NYjkM5RhjY0iY2ZkYYbdxMuGBjOnPOr0yyKQ=; b=gDYOGahA6QCmb6exYTbLtkdshRQtOSg9BTP8l182lmV39wWms6g9eOhr 0YvXCbQACuyi3z9M8hcmhEghDUqUbZ1G1J3A3HcMUdSTzx9BAjW0GQzn0 +JppyXfMTAp2xhFFA46ZDhEui7QVU7JLopIiTo1UshIE0kSAzlneIuBr9 AQ4dXMXq/5jWuDXz17y+HN9sbzBaCONQKuBue9incqXwmpeig7odtMXIz 18NTNLHav+WBtIaQufR2+mPibSReKOr5PUCV3B/m7oY5RHoQ4lwWhMLRp ipWxd20uSi4iH542OL8mI381MAI9GGUtR/7q6hI66v5SGK0tfk85XX781 A==; X-CSE-ConnectionGUID: Dh4xVlafSoCymUcyIP+zmQ== X-CSE-MsgGUID: YuRDJKXkSkSGpY2ubEtVsg== X-IronPort-AV: E=McAfee;i="6700,10204,11448"; a="60942072" X-IronPort-AV: E=Sophos;i="6.16,195,1744095600"; d="scan'208";a="60942072" X-CSE-ConnectionGUID: DXiuxMP2RoOx0mGK2eu8zw== X-CSE-MsgGUID: cDSMXtxzQt6imgTPhdifdQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,195,1744095600"; d="scan'208";a="143788753" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, mst@redhat.com, jasowang@redhat.com, peterx@redhat.com, ddutile@redhat.com, jgg@nvidia.com, nicolinc@nvidia.com, shameerali.kolothum.thodi@huawei.com, joao.m.martins@oracle.com, clement.mathieu--drif@eviden.com, kevin.tian@intel.com, yi.l.liu@intel.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH v2 4/4] vfio/iommufd: Save vendor specific device info Date: Fri, 30 May 2025 17:35:12 +0800 Message-Id: <20250530093512.3959484-5-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250530093512.3959484-1-zhenzhong.duan@intel.com> References: <20250530093512.3959484-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.11; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -72 X-Spam_score: -7.3 X-Spam_bar: ------- X-Spam_report: (-7.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.902, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1748598004047116600 Content-Type: text/plain; charset="utf-8" Some device information returned by ioctl(IOMMU_GET_HW_INFO) are vendor specific. Save them as raw data in a union supporting different vendors, then vendor IOMMU can query the raw data with its fixed format for capability directly. Because IOMMU_GET_HW_INFO is only supported in linux, so declare those capability related structures with CONFIG_LINUX. Suggested-by: Eric Auger Suggested-by: Nicolin Chen Signed-off-by: Zhenzhong Duan Reviewed-by: Eric Auger Reviewed-by: Nicolin Chen --- include/system/host_iommu_device.h | 11 +++++++++++ hw/vfio/iommufd.c | 8 +++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/system/host_iommu_device.h b/include/system/host_iommu= _device.h index 809cced4ba..10fccc10be 100644 --- a/include/system/host_iommu_device.h +++ b/include/system/host_iommu_device.h @@ -14,6 +14,13 @@ =20 #include "qom/object.h" #include "qapi/error.h" +#ifdef CONFIG_LINUX +#include "linux/iommufd.h" + +typedef union VendorCaps { + struct iommu_hw_info_vtd vtd; + struct iommu_hw_info_arm_smmuv3 smmuv3; +} VendorCaps; =20 /** * struct HostIOMMUDeviceCaps - Define host IOMMU device capabilities. @@ -26,7 +33,9 @@ typedef struct HostIOMMUDeviceCaps { uint32_t type; uint64_t hw_caps; + VendorCaps vendor_caps; } HostIOMMUDeviceCaps; +#endif =20 #define TYPE_HOST_IOMMU_DEVICE "host-iommu-device" OBJECT_DECLARE_TYPE(HostIOMMUDevice, HostIOMMUDeviceClass, HOST_IOMMU_DEVI= CE) @@ -38,7 +47,9 @@ struct HostIOMMUDevice { void *agent; /* pointer to agent device, ie. VFIO or VDPA device */ PCIBus *aliased_bus; int aliased_devfn; +#ifdef CONFIG_LINUX HostIOMMUDeviceCaps caps; +#endif }; =20 /** diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index d661737c17..fbf47cab09 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -834,16 +834,14 @@ static bool hiod_iommufd_vfio_realize(HostIOMMUDevice= *hiod, void *opaque, VFIODevice *vdev =3D opaque; HostIOMMUDeviceIOMMUFD *idev; HostIOMMUDeviceCaps *caps =3D &hiod->caps; + VendorCaps *vendor_caps =3D &caps->vendor_caps; enum iommu_hw_info_type type; - union { - struct iommu_hw_info_vtd vtd; - } data; uint64_t hw_caps; =20 hiod->agent =3D opaque; =20 - if (!iommufd_backend_get_device_info(vdev->iommufd, vdev->devid, - &type, &data, sizeof(data), + if (!iommufd_backend_get_device_info(vdev->iommufd, vdev->devid, &type, + vendor_caps, sizeof(*vendor_caps), &hw_caps, errp)) { return false; } --=20 2.34.1