From nobody Sun Nov 16 01:08:07 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=1744366933; cv=none; d=zohomail.com; s=zohoarc; b=KpdIZT9XTnfH8gMubnts+camArU9vYnqcvXCe4ewWHTkA7Ur+B7n7ofqXN8HwVLoxsCvS3/vnhD114ruVYZNktKD03C+ly8QWdSAaTmbb802a6Wk5FJrPSSCrM1zyiY/kVLMemV5H3CstcbC6yRtCsyEsve3Sy07if2wxw+VYBo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744366933; 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=X+3CqS3gIthWpYWCIzVcGOgCXBOTU2giUvpXcz231U4=; b=W99TM1dOAsX8STe/YHBX64vOsSvDJGsrebU5We2sgtY+qj2+/Y0D7+OmdpNKnMzIENajKUsoxVjSppjHWw2vGdWMJyaoeKfrtkouNj/vJkAcOyPGYc7SvAUKJEnvtLRy//i8nfibvqz7rSzyUmxg+WQVSErmMjDUIvvs+4Fjy3s= 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 1744366933769270.4037996804972; Fri, 11 Apr 2025 03:22:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u3BVq-0002qv-IK; Fri, 11 Apr 2025 06:21:30 -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 1u3BVe-0002bX-0e for qemu-devel@nongnu.org; Fri, 11 Apr 2025 06:21:18 -0400 Received: from mgamail.intel.com ([198.175.65.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u3BVT-0005O8-Nx for qemu-devel@nongnu.org; Fri, 11 Apr 2025 06:21:11 -0400 Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2025 03:20:48 -0700 Received: from spr-s2600bt.bj.intel.com ([10.240.192.127]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2025 03:20:47 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744366867; x=1775902867; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HDSjhWoNRiRif3N3R0QiTa26vrCzPQDa4qlgutcJNyQ=; b=Q51r4nunu81ybHsElx2jIXb98WCN7EIMUyG2Pzxb34btKYXuYJDtHGJI ArYQhgQ1NbaSmO3a0pvjsvKbpr/h+yLxYiDIEdt1MXV3BBDzyZCxGRtNe 9MderpwozUuabmgbPj6s9V9MzYWB9+HSfXuM2uD8uq0TUPdsq2M8VGZGr f954SZkTi/McFHkSWytp6YlHtNwUN3vwJpr/i7KvAmKYoqPc1ypX/bJtE jar8DAwucEWuYwI1pOxPsfFiaXiggQSh/oDI7nmv5aVPC0ZlIs3NJ90dz AH+vFdqAfJQ5QTyJgtV9P2hw2xxeglaHohtI7j1k3tf7HQ3OmYlWvDIIr w==; X-CSE-ConnectionGUID: zyO75PytTuqzTPKOy1+L9g== X-CSE-MsgGUID: BtSLvZ8BSaOsoR37dok+gg== X-IronPort-AV: E=McAfee;i="6700,10204,11400"; a="49566779" X-IronPort-AV: E=Sophos;i="6.15,205,1739865600"; d="scan'208";a="49566779" X-CSE-ConnectionGUID: rLx+R/RrSjyBmrwGrbDKDg== X-CSE-MsgGUID: b+/cmEqZSj6QjggpoAxlEA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,205,1739865600"; d="scan'208";a="133917410" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, nicolinc@nvidia.com, joao.m.martins@oracle.com, chao.p.peng@intel.com, Zhenzhong Duan , Yi Liu Subject: [PATCH 1/5] vfio/iommufd: Save host iommu capabilities in VFIODevice.caps Date: Fri, 11 Apr 2025 18:17:03 +0800 Message-Id: <20250411101707.3460429-2-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250411101707.3460429-1-zhenzhong.duan@intel.com> References: <20250411101707.3460429-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.15; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -49 X-Spam_score: -5.0 X-Spam_bar: ----- X-Spam_report: (-5.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.593, 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1744366934878019000 The saved caps copy can be used to check dirty tracking capability. The capabilities is gotten through IOMMUFD interface, so define a new structure HostIOMMUDeviceIOMMUFDCaps which contains vendor caps raw data in "include/system/iommufd.h". This is a prepare work for moving .realize() after .attach_device(). Suggested-by: C=C3=A9dric Le Goater Suggested-by: Eric Auger Suggested-by: Nicolin Chen Signed-off-by: Zhenzhong Duan --- include/hw/vfio/vfio-device.h | 1 + include/system/iommufd.h | 22 ++++++++++++++++++++++ hw/vfio/iommufd.c | 10 +++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/include/hw/vfio/vfio-device.h b/include/hw/vfio/vfio-device.h index 66797b4c92..09a7af891a 100644 --- a/include/hw/vfio/vfio-device.h +++ b/include/hw/vfio/vfio-device.h @@ -77,6 +77,7 @@ typedef struct VFIODevice { bool dirty_tracking; /* Protected by BQL */ bool iommu_dirty_tracking; HostIOMMUDevice *hiod; + HostIOMMUDeviceIOMMUFDCaps caps; int devid; IOMMUFDBackend *iommufd; VFIOIOASHwpt *hwpt; diff --git a/include/system/iommufd.h b/include/system/iommufd.h index cbab75bfbf..0f337585c9 100644 --- a/include/system/iommufd.h +++ b/include/system/iommufd.h @@ -18,6 +18,9 @@ #include "exec/hwaddr.h" #include "exec/cpu-common.h" #include "system/host_iommu_device.h" +#ifdef CONFIG_LINUX +#include +#endif =20 #define TYPE_IOMMUFD_BACKEND "iommufd" OBJECT_DECLARE_TYPE(IOMMUFDBackend, IOMMUFDBackendClass, IOMMUFD_BACKEND) @@ -63,4 +66,23 @@ bool iommufd_backend_get_dirty_bitmap(IOMMUFDBackend *be= , uint32_t hwpt_id, Error **errp); =20 #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD TYPE_HOST_IOMMU_DEVICE "-iommufd" + +typedef union VendorCaps { + struct iommu_hw_info_vtd vtd; + struct iommu_hw_info_arm_smmuv3 smmuv3; +} VendorCaps; + +/** + * struct HostIOMMUDeviceIOMMUFDCaps - Define host IOMMU device capabiliti= es. + * + * @type: host platform IOMMU type. + * + * @hw_caps: host platform IOMMU capabilities (e.g. on IOMMUFD this repres= ents + * the @out_capabilities value returned from IOMMU_GET_HW_INFO i= octl) + */ +typedef struct HostIOMMUDeviceIOMMUFDCaps { + uint32_t type; + uint64_t hw_caps; + VendorCaps vendor_caps; +} HostIOMMUDeviceIOMMUFDCaps; #endif diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 48db105422..530cde6740 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -324,7 +324,7 @@ static bool iommufd_cdev_autodomains_get(VFIODevice *vb= asedev, * vfio_migration_realize() may decide to use VF dirty tracking * instead. */ - if (vbasedev->hiod->caps.hw_caps & IOMMU_HW_CAP_DIRTY_TRACKING) { + if (vbasedev->caps.hw_caps & IOMMU_HW_CAP_DIRTY_TRACKING) { flags =3D IOMMU_HWPT_ALLOC_DIRTY_TRACKING; } =20 @@ -475,6 +475,7 @@ static bool iommufd_cdev_attach(const char *name, VFIOD= evice *vbasedev, int ret, devfd; uint32_t ioas_id; Error *err =3D NULL; + HostIOMMUDeviceIOMMUFDCaps *caps =3D &vbasedev->caps; const VFIOIOMMUClass *iommufd_vioc =3D VFIO_IOMMU_CLASS(object_class_by_name(TYPE_VFIO_IOMMU_IOMMUFD)); =20 @@ -505,6 +506,13 @@ static bool iommufd_cdev_attach(const char *name, VFIO= Device *vbasedev, goto err_alloc_ioas; } =20 + if (!iommufd_backend_get_device_info(vbasedev->iommufd, vbasedev->devi= d, + &caps->type, &caps->vendor_caps, + sizeof(VendorCaps), &caps->hw_cap= s, + errp)) { + goto err_alloc_ioas; + } + /* try to attach to an existing container in this space */ QLIST_FOREACH(bcontainer, &space->containers, next) { container =3D container_of(bcontainer, VFIOIOMMUFDContainer, bcont= ainer); --=20 2.34.1 From nobody Sun Nov 16 01:08:07 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=1744366914; cv=none; d=zohomail.com; s=zohoarc; b=UCIKjPXlNN1kOiJUn4UpfPD1LL70g8M44A9y3PW7ZVN4Oh0AFyITFwd0gFqqOBhQG1GGmcrSfyw4GbxpdxI41xDVWuoE7rweM6RbAigEhBeqc5/BHjN1JF1f9Lvd3gAT1BXXjtyxijFpi1Sg+vsoe76bVHFV1pgI8cDNGHm5YZA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744366914; 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=1rhhcPblm1YK6AIJnQ5KKFxepRz1hzfjjaJdzuqaAyg=; b=ZOC6eHnQ7fcb4eta+oQOMOn1d//yf0nM0I46OzYGeRxs4fFKTjTg8V4UjWhGWv6LCdjVB+9ZVZMWTJeXLSZb1JL3o4Ac41/SZ8qXWROeMZ81h7M2OjQIAwUQiHd+Rb7r32Aiwc/tgLxS15+BYWAHmiyH/y78M7Beus1yIj1Pndg= 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 1744366914669731.5715043747495; Fri, 11 Apr 2025 03:21:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u3BVn-0002jb-UT; Fri, 11 Apr 2025 06:21:28 -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 1u3BVe-0002bb-1I for qemu-devel@nongnu.org; Fri, 11 Apr 2025 06:21:18 -0400 Received: from mgamail.intel.com ([198.175.65.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u3BVT-0005Op-4m for qemu-devel@nongnu.org; Fri, 11 Apr 2025 06:21:11 -0400 Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2025 03:20:51 -0700 Received: from spr-s2600bt.bj.intel.com ([10.240.192.127]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2025 03:20:49 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744366867; x=1775902867; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZALbs/dbjCI0xMs0gD6081Unyv17rpEdGJH3ZlKWYPs=; b=jYpnrTeqNf8NM6udXhDg55MNnwR9V3il5GQfpAHB5vXl/6+hgNgYNppf TtgaHMdHboTNBVzSlJOBikh2UhuKwFy9GgwqyjHHGLvETw5ry98HIClCC wzILOOCl5kcCrbrH5y0vt/nyK2MHP37V8ZYR0Z8zvnsGrlyPk6meGAWIL 2QCEK/FpflxONN75JkkWNVAwKK1Hs1hCLgahOHNqBFu+WV35Zyp3JJiHf xNNkmTYPOLc8Jd+iGIHc1UXr8Svt51IW7wHZxT/viQavjYsJOTGSdpklD 3BkonD0cqEbSUxJLDitGTVOXtTZRyCdJ60Kg3th/YyHzWrmsn48F+Ov0W Q==; X-CSE-ConnectionGUID: euIePaKvQfie1XeE6Wo85Q== X-CSE-MsgGUID: f6psmTnOSoqhANMdPfNhwQ== X-IronPort-AV: E=McAfee;i="6700,10204,11400"; a="49566790" X-IronPort-AV: E=Sophos;i="6.15,205,1739865600"; d="scan'208";a="49566790" X-CSE-ConnectionGUID: F4JueCLbR1uihvjZ7OCpRg== X-CSE-MsgGUID: ax4RPBrBRte8OW+i6C7t/Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,205,1739865600"; d="scan'208";a="133917413" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, nicolinc@nvidia.com, joao.m.martins@oracle.com, chao.p.peng@intel.com, Zhenzhong Duan , Donald Dutile Subject: [PATCH 2/5] vfio: Move realize() after attach_device() Date: Fri, 11 Apr 2025 18:17:04 +0800 Message-Id: <20250411101707.3460429-3-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250411101707.3460429-1-zhenzhong.duan@intel.com> References: <20250411101707.3460429-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.15; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -49 X-Spam_score: -5.0 X-Spam_bar: ----- X-Spam_report: (-5.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.593, 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1744366916438019000 Previously device attaching depends on realize() getting host iommu capabilities to check dirty tracking support. Now we save a caps copy in VFIODevice and check that copy for dirty tracking support, there is no dependency any more, move realize() call after attach_device() call in vfio_device_attach(). Drop vfio_device_hiod_realize() which looks redundant now. Suggested-by: C=C3=A9dric Le Goater Suggested-by: Donald Dutile Signed-off-by: Zhenzhong Duan Reviewed-by: Donald Dutile --- include/hw/vfio/vfio-device.h | 1 - hw/vfio/container.c | 4 ---- hw/vfio/device.c | 28 +++++++++++----------------- hw/vfio/iommufd.c | 4 ---- 4 files changed, 11 insertions(+), 26 deletions(-) diff --git a/include/hw/vfio/vfio-device.h b/include/hw/vfio/vfio-device.h index 09a7af891a..14559733c6 100644 --- a/include/hw/vfio/vfio-device.h +++ b/include/hw/vfio/vfio-device.h @@ -124,7 +124,6 @@ bool vfio_device_irq_set_signaling(VFIODevice *vbasedev= , int index, int subindex =20 void vfio_device_reset_handler(void *opaque); bool vfio_device_is_mdev(VFIODevice *vbasedev); -bool vfio_device_hiod_realize(VFIODevice *vbasedev, Error **errp); bool vfio_device_attach(char *name, VFIODevice *vbasedev, AddressSpace *as, Error **errp); void vfio_device_detach(VFIODevice *vbasedev); diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 23a3373470..676e88cef4 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -883,10 +883,6 @@ static bool vfio_legacy_attach_device(const char *name= , VFIODevice *vbasedev, =20 trace_vfio_device_attach(vbasedev->name, groupid); =20 - if (!vfio_device_hiod_realize(vbasedev, errp)) { - return false; - } - group =3D vfio_group_get(groupid, as, errp); if (!group) { return false; diff --git a/hw/vfio/device.c b/hw/vfio/device.c index 4de6948cf4..6154d3f443 100644 --- a/hw/vfio/device.c +++ b/hw/vfio/device.c @@ -347,17 +347,6 @@ bool vfio_device_is_mdev(VFIODevice *vbasedev) return subsys && (strcmp(subsys, "/sys/bus/mdev") =3D=3D 0); } =20 -bool vfio_device_hiod_realize(VFIODevice *vbasedev, Error **errp) -{ - HostIOMMUDevice *hiod =3D vbasedev->hiod; - - if (!hiod) { - return true; - } - - return HOST_IOMMU_DEVICE_GET_CLASS(hiod)->realize(hiod, vbasedev, errp= ); -} - VFIODevice *vfio_get_vfio_device(Object *obj) { if (object_dynamic_cast(obj, TYPE_VFIO_PCI)) { @@ -372,6 +361,7 @@ bool vfio_device_attach(char *name, VFIODevice *vbasede= v, { const VFIOIOMMUClass *ops =3D VFIO_IOMMU_CLASS(object_class_by_name(TYPE_VFIO_IOMMU_LEGACY)); + HostIOMMUDeviceClass *hiodc; HostIOMMUDevice *hiod =3D NULL; =20 if (vbasedev->iommufd) { @@ -380,16 +370,20 @@ bool vfio_device_attach(char *name, VFIODevice *vbase= dev, =20 assert(ops); =20 + if (!ops->attach_device(name, vbasedev, as, errp)) { + return false; + } =20 if (!vbasedev->mdev) { hiod =3D HOST_IOMMU_DEVICE(object_new(ops->hiod_typename)); - vbasedev->hiod =3D hiod; - } + hiodc =3D HOST_IOMMU_DEVICE_GET_CLASS(hiod); =20 - if (!ops->attach_device(name, vbasedev, as, errp)) { - object_unref(hiod); - vbasedev->hiod =3D NULL; - return false; + if (!hiodc->realize(hiod, vbasedev, errp)) { + object_unref(hiod); + ops->detach_device(vbasedev); + return false; + } + vbasedev->hiod =3D hiod; } =20 return true; diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 530cde6740..e05b472e35 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -502,10 +502,6 @@ static bool iommufd_cdev_attach(const char *name, VFIO= Device *vbasedev, * FD to be connected and having a devid to be able to successfully ca= ll * iommufd_backend_get_device_info(). */ - if (!vfio_device_hiod_realize(vbasedev, errp)) { - goto err_alloc_ioas; - } - if (!iommufd_backend_get_device_info(vbasedev->iommufd, vbasedev->devi= d, &caps->type, &caps->vendor_caps, sizeof(VendorCaps), &caps->hw_cap= s, --=20 2.34.1 From nobody Sun Nov 16 01:08:07 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=1744366899; cv=none; d=zohomail.com; s=zohoarc; b=DFNcsg9qUcSg+lE3S0c10/b/2jaX8bDq+iSpE6ORHQ6RrAYPKAuaVItm3fJvOxtQR4ykHSH34fyxleYPO/SXakuAeE8idB2dX+A9A0zcXVgXfGN0QlIVxhgngIIT1amPlwb/P+AqM6T+ExBRr8O8vEZcAF+MgF9oHzrnKzpoHDo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744366899; 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=Am0H1qD07jOx0tThaTj09aCmjk9xY+aSucsYPnRh/SI=; b=ddr6lnn6z0SVPX1dEFJy3GQmK2nYigp4+RlQRLkihtfzq00rjee8MWGNgdKlLTEwveVkJWV6bhXbQNtov8SShBIgEer1LyI5K0lzt6vrNfaj+umiVfxCehT4gAqKq21sotcl/kqPSCCA9aqGVXu1QvkY6L2v6YfXgb6Axhus3H4= 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 1744366899211147.0957231442851; Fri, 11 Apr 2025 03:21:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u3BVo-0002nM-W6; Fri, 11 Apr 2025 06:21:29 -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 1u3BVh-0002fE-J8 for qemu-devel@nongnu.org; Fri, 11 Apr 2025 06:21:21 -0400 Received: from mgamail.intel.com ([198.175.65.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u3BVe-0005Op-F7 for qemu-devel@nongnu.org; Fri, 11 Apr 2025 06:21:20 -0400 Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2025 03:20:53 -0700 Received: from spr-s2600bt.bj.intel.com ([10.240.192.127]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2025 03:20:52 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744366878; x=1775902878; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pognV82UVdHK8qT+B92vH8V1D8/ilicX35LTb3dliZA=; b=Th5rqfua5bRnQ/FBbJYbgvGX/TOFJfyzempPvvOLGLW9AESL9P3bZXx/ mQ87WwGsgiIpMGuelX8CUVZIji9EDUw5mwPp+Rl7jj22yFyZa+G6nxI0d 3L5E1FwHatRahL/FdTW1bGvgu0lR13Q1LA2alDfHEqQJ1XnXoAns1jRLF NuELsHc8wWDTbTQ4EbSvWpsjyZKmiFjDeH/sDR+lyVHoJXz1TKWUpNNAk dJfJ8caPHmotu2ZrNJVGFz0cH3qTbPyZv1Gg09hf5VGWmNQ5L5GD8vhRJ 7BmzUV0lu7Vnai5IOUJGQQpcw+HMlTsETsutqNMWvY/6RH7GBaJR90H3i A==; X-CSE-ConnectionGUID: fwWKyU7jQ/O3SWT2EmUygg== X-CSE-MsgGUID: oqFqfiSmScGYBklweoJqbQ== X-IronPort-AV: E=McAfee;i="6700,10204,11400"; a="49566798" X-IronPort-AV: E=Sophos;i="6.15,205,1739865600"; d="scan'208";a="49566798" X-CSE-ConnectionGUID: SdcHZi/MQeOse6DGf1o+4A== X-CSE-MsgGUID: rC2gTDqzRQe+XxHFcn7dmw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,205,1739865600"; d="scan'208";a="133917417" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, nicolinc@nvidia.com, joao.m.martins@oracle.com, chao.p.peng@intel.com, Zhenzhong Duan , Yi Liu Subject: [PATCH 3/5] vfio/iommufd: Implement .get_cap() in TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO sub-class Date: Fri, 11 Apr 2025 18:17:05 +0800 Message-Id: <20250411101707.3460429-4-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250411101707.3460429-1-zhenzhong.duan@intel.com> References: <20250411101707.3460429-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.15; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -49 X-Spam_score: -5.0 X-Spam_bar: ----- X-Spam_report: (-5.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.593, 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1744366900362019000 Content-Type: text/plain; charset="utf-8" Now we have saved a copy of host iommu capabilities in VFIODevice, implemen= ted hiod_iommufd_vfio_get_cap() by querying the caps copy in sub-class. This overrides .get_cap() implementation hiod_iommufd_vfio_get_cap() in TYPE_HOST_IOMMU_DEVICE_IOMMUFD parent class. Vendor caps are checked for a specific capability, e.g., for vtd, checking code will be in hiod_iommufd_get_vtd_cap(). This also fixes an issue that calling vfio_device_get_aw_bits() in TYPE_HOST_IOMMU_DEVICE_IOMMUFD parent class .get_cap(). Signed-off-by: Zhenzhong Duan --- include/system/iommufd.h | 4 ++++ backends/iommufd.c | 40 ++++++++++++++++++++++++++++++++++++++++ hw/vfio/iommufd.c | 16 ++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/include/system/iommufd.h b/include/system/iommufd.h index 0f337585c9..baba5ec1d8 100644 --- a/include/system/iommufd.h +++ b/include/system/iommufd.h @@ -85,4 +85,8 @@ typedef struct HostIOMMUDeviceIOMMUFDCaps { uint64_t hw_caps; VendorCaps vendor_caps; } HostIOMMUDeviceIOMMUFDCaps; + +int hiod_iommufd_get_common_cap(HostIOMMUDevice *hiod, + HostIOMMUDeviceIOMMUFDCaps *caps, + int cap, Error **errp); #endif diff --git a/backends/iommufd.c b/backends/iommufd.c index 9587e4d99b..54fa3174d0 100644 --- a/backends/iommufd.c +++ b/backends/iommufd.c @@ -355,3 +355,43 @@ static const TypeInfo types[] =3D { }; =20 DEFINE_TYPES(types) + +static int hiod_iommufd_get_vtd_cap(HostIOMMUDevice *hiod, + struct iommu_hw_info_vtd *vtd, + int cap, Error **errp) +{ + /* TODO: Check vtd->cap_reg/ecap_reg for capability */ + error_setg(errp, "%s: unsupported capability %x", hiod->name, cap); + return -EINVAL; +} + +static int hiod_iommufd_get_vendor_cap(HostIOMMUDevice *hiod, + HostIOMMUDeviceIOMMUFDCaps *caps, + int cap, Error **errp) +{ + enum iommu_hw_info_type type =3D caps->type; + + switch (type) { + case IOMMU_HW_INFO_TYPE_INTEL_VTD: + return hiod_iommufd_get_vtd_cap(hiod, &caps->vendor_caps.vtd, + cap, errp); + case IOMMU_HW_INFO_TYPE_ARM_SMMUV3: + case IOMMU_HW_INFO_TYPE_NONE: + break; + } + + error_setg(errp, "%s: unsupported capability type %x", hiod->name, typ= e); + return -EINVAL; +} + +int hiod_iommufd_get_common_cap(HostIOMMUDevice *hiod, + HostIOMMUDeviceIOMMUFDCaps *caps, + int cap, Error **errp) +{ + switch (cap) { + case HOST_IOMMU_DEVICE_CAP_IOMMU_TYPE: + return caps->type; + default: + return hiod_iommufd_get_vendor_cap(hiod, caps, cap, errp); + } +} diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index e05b472e35..e7ca92f81f 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -833,6 +833,21 @@ static bool hiod_iommufd_vfio_realize(HostIOMMUDevice = *hiod, void *opaque, return true; } =20 +static int hiod_iommufd_vfio_get_cap(HostIOMMUDevice *hiod, int cap, + Error **errp) +{ + VFIODevice *vdev =3D hiod->agent; + HostIOMMUDeviceIOMMUFDCaps *caps =3D &vdev->caps; + + /* VFIO has its own way to get aw_bits which may be different from VDP= A */ + switch (cap) { + case HOST_IOMMU_DEVICE_CAP_AW_BITS: + return vfio_device_get_aw_bits(hiod->agent); + default: + return hiod_iommufd_get_common_cap(hiod, caps, cap, errp); + } +} + static GList * hiod_iommufd_vfio_get_iova_ranges(HostIOMMUDevice *hiod) { @@ -857,6 +872,7 @@ static void hiod_iommufd_vfio_class_init(ObjectClass *o= c, void *data) HostIOMMUDeviceClass *hiodc =3D HOST_IOMMU_DEVICE_CLASS(oc); =20 hiodc->realize =3D hiod_iommufd_vfio_realize; + hiodc->get_cap =3D hiod_iommufd_vfio_get_cap; hiodc->get_iova_ranges =3D hiod_iommufd_vfio_get_iova_ranges; hiodc->get_page_size_mask =3D hiod_iommufd_vfio_get_page_size_mask; }; --=20 2.34.1 From nobody Sun Nov 16 01:08:07 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=1744366950; cv=none; d=zohomail.com; s=zohoarc; b=HtXJdnywsLHbPInfyXG/uJJXJF/9w+y2l8MRed4zuaXYUfxXc8rIVVhZQCzqd39V7Hgqh8OsgKCws+muO9L7L2nFJylA3R2Au3qMtDk4KhMkJbdDGIPfl7mXYzz6Q43ybhCeWnNgWOOJTiSIk1Eu55Yw4Ut6fzoqDS2zIipiC3g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744366950; 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=slq6Timt78DsQUBEUcT6yHHPSlWS+oAs0zUhOiR0XMk=; b=j5B5rBSXOJ+TXYs1hqSNuTfp5mABhCy012v7zR+C7ntA015bOXD1qIhO/Szd6aEqe22gjiALT28j0zLlC24Q+tNSziPpDITxvLr8dv/XSCNXTFOgEkpHhyQmHMFInUedPqco1aaaz6GOfVB1/a2F+YD3OcQDaTTiAWaHg0uVcg4= 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 1744366950626546.2076985262918; Fri, 11 Apr 2025 03:22:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u3BVs-0002v0-6z; Fri, 11 Apr 2025 06:21:32 -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 1u3BVh-0002fG-KN for qemu-devel@nongnu.org; Fri, 11 Apr 2025 06:21:21 -0400 Received: from mgamail.intel.com ([198.175.65.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u3BVe-0005O8-F9 for qemu-devel@nongnu.org; Fri, 11 Apr 2025 06:21:20 -0400 Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2025 03:20:56 -0700 Received: from spr-s2600bt.bj.intel.com ([10.240.192.127]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2025 03:20:54 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744366878; x=1775902878; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/rp/9HOUYDxv/ff9Y/ZSJzLtkR8kKGoMvG5rWR7Fdcw=; b=K6+Gx6IQSV8Vi/EVSVjna+MnezfkbQj4JZ2mpZNgsjaXjFbK27jtgnzJ pts+Zw9s29ZxqKQAD4k6kSu9kwx29sJTqGbmMxhTRdpypB0tE9Y1AG1NH ZGJ6PIQpxyyomoTvKZsVX8vxAX/uMHck4iCLmTsn/pLIE6yxrcRkr/Tz3 zSY8XeRUe0aW46yufkjDUKYOZzstGo+ToOxAqe8ZiK3U/P8uJKe5CfY7K FpmIPge/pGx+LWIIVXzD3yilgpCRLLLI1ERjJPyVc8Orh16etA/fyXpZI DqejYfML0LkSctJPlVcylLFKy1t/AGM7+EOTPzo3V667To+DQ3KqKqqtR w==; X-CSE-ConnectionGUID: JB5IziwcRmi95T6R9LWQLg== X-CSE-MsgGUID: /gc5jUWFQpOuaA2moWJGMQ== X-IronPort-AV: E=McAfee;i="6700,10204,11400"; a="49566809" X-IronPort-AV: E=Sophos;i="6.15,205,1739865600"; d="scan'208";a="49566809" X-CSE-ConnectionGUID: xyN5YfHySWCyq4ci6QA5ow== X-CSE-MsgGUID: azB28qqXSkWJAsDymj72cw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,205,1739865600"; d="scan'208";a="133917420" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, nicolinc@nvidia.com, joao.m.martins@oracle.com, chao.p.peng@intel.com, Zhenzhong Duan , Yi Liu Subject: [PATCH 4/5] backends/iommufd: Drop hiod_iommufd_get_cap() Date: Fri, 11 Apr 2025 18:17:06 +0800 Message-Id: <20250411101707.3460429-5-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250411101707.3460429-1-zhenzhong.duan@intel.com> References: <20250411101707.3460429-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.15; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -49 X-Spam_score: -5.0 X-Spam_bar: ----- X-Spam_report: (-5.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.593, 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1744366958346019100 Content-Type: text/plain; charset="utf-8" Because sub-class TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO has it's own implementation of .get_cap(), hiod_iommufd_get_cap() isn't used any more, drop it. Signed-off-by: Zhenzhong Duan --- backends/iommufd.c | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/backends/iommufd.c b/backends/iommufd.c index 54fa3174d0..d2ecdc9c82 100644 --- a/backends/iommufd.c +++ b/backends/iommufd.c @@ -311,28 +311,6 @@ bool iommufd_backend_get_device_info(IOMMUFDBackend *b= e, uint32_t devid, return true; } =20 -static int hiod_iommufd_get_cap(HostIOMMUDevice *hiod, int cap, Error **er= rp) -{ - HostIOMMUDeviceCaps *caps =3D &hiod->caps; - - switch (cap) { - case HOST_IOMMU_DEVICE_CAP_IOMMU_TYPE: - return caps->type; - case HOST_IOMMU_DEVICE_CAP_AW_BITS: - return vfio_device_get_aw_bits(hiod->agent); - default: - error_setg(errp, "%s: unsupported capability %x", hiod->name, cap); - return -EINVAL; - } -} - -static void hiod_iommufd_class_init(ObjectClass *oc, void *data) -{ - HostIOMMUDeviceClass *hioc =3D HOST_IOMMU_DEVICE_CLASS(oc); - - hioc->get_cap =3D hiod_iommufd_get_cap; -}; - static const TypeInfo types[] =3D { { .name =3D TYPE_IOMMUFD_BACKEND, @@ -349,7 +327,6 @@ static const TypeInfo types[] =3D { }, { .name =3D TYPE_HOST_IOMMU_DEVICE_IOMMUFD, .parent =3D TYPE_HOST_IOMMU_DEVICE, - .class_init =3D hiod_iommufd_class_init, .abstract =3D true, } }; --=20 2.34.1 From nobody Sun Nov 16 01:08:07 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=1744366945; cv=none; d=zohomail.com; s=zohoarc; b=X77+qBOIuheRo9qZCcr0/UCfPM6BLDlLlO+zjLx/4TEdC5FlKFGTDQ3PnaHi73hPkGA0vNGGQyIT557SeOgIfOrrqBpu++KdwXaKNkeVUbeGwnn8pJvgXNX0w6Gvz97ZPuNOw/XjGXtCAWAzWbPGOtiq75ydGd6w4z9JceKDaYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744366945; 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=8XWwAjsoA8ueSloqiTsEh9zSeYpSPLd3L30R92pKVUs=; b=J6I+mr1P24NgSQDkJP5X1WcimSytJ3U18AN22GOQQ7QYAkBRlgsVfiYKAYXgwPZRO52Shp+QuXVVunQLrUZFLz7jIRSJiLIE68S2SzlM4K78EeHk+1dcLdr0BLCTZv2J2tcodR39mgoHNjWjzRFnuEej4UkoWt+tQthPUrY3T84= 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 1744366945207589.7215112143663; Fri, 11 Apr 2025 03:22:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u3BVt-0002zY-Im; Fri, 11 Apr 2025 06:21:33 -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 1u3BVh-0002fF-JS for qemu-devel@nongnu.org; Fri, 11 Apr 2025 06:21:21 -0400 Received: from mgamail.intel.com ([198.175.65.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u3BVe-0005Nr-Fb for qemu-devel@nongnu.org; Fri, 11 Apr 2025 06:21:20 -0400 Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2025 03:20:58 -0700 Received: from spr-s2600bt.bj.intel.com ([10.240.192.127]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2025 03:20:57 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744366878; x=1775902878; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=a1rqJgngFJ3/FyQqDL1AmQI5pB8InAlZ+NX9kWvKC+w=; b=FJOtqGhZO1eP1jM2G8DjupddGiZTWMKq5/uXM6Jmxfql2pNtkbUKDzD2 AfZa+9ZUk1OC1uHCa6Blr2uy8BCndy3lDcTGPyzQnL3u5HLyHlFuS1uQ/ i24RUF+hAm6TH0WABknkz+6b+dxXG48L0L3pv5g/8WBAK1XsZjI9o4pyu ERcB1tL8JIh8HID+8WSIbcD5elg28YFsIziS5Sjsu7OXGGYFZVoMsGsAE SfmP1Izfizn3zGBtaWHpW5XQuaBqQLku9UMAw3bX/Zh3VweA3V8K3/8dd DhRCXjIMgWu2FEvzqB0xArk0rvoHLQVru7bB88v94s7lR4fYLwKzjT5yo g==; X-CSE-ConnectionGUID: YM9D1xBhRzKu7Ls317bVtw== X-CSE-MsgGUID: QaYg1I8XQ0S676d/EJsRfg== X-IronPort-AV: E=McAfee;i="6700,10204,11400"; a="49566820" X-IronPort-AV: E=Sophos;i="6.15,205,1739865600"; d="scan'208";a="49566820" X-CSE-ConnectionGUID: 9/SwKHS4R6S3cgX0EKKMHQ== X-CSE-MsgGUID: oq4zwjX/S1+O/UgIkox3UA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,205,1739865600"; d="scan'208";a="133917424" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, nicolinc@nvidia.com, joao.m.martins@oracle.com, chao.p.peng@intel.com, Zhenzhong Duan , Yi Liu Subject: [PATCH 5/5] vfio/iommufd: Drop HostIOMMUDeviceCaps from HostIOMMUDevice Date: Fri, 11 Apr 2025 18:17:07 +0800 Message-Id: <20250411101707.3460429-6-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250411101707.3460429-1-zhenzhong.duan@intel.com> References: <20250411101707.3460429-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.15; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -49 X-Spam_score: -5.0 X-Spam_bar: ----- X-Spam_report: (-5.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.593, 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1744366946488019000 Content-Type: text/plain; charset="utf-8" Because hiod_iommufd_get_cap() was dropped, HostIOMMUDeviceCaps is not useful any more, drop it. This also hides HostIOMMUDeviceCaps from vIOMMU so the only way to check cap is through .get_cap() interface. This makes HostIOMMUDevice exposing data to vIOMMU as small as possible. Signed-off-by: Zhenzhong Duan --- include/system/host_iommu_device.h | 14 -------------- hw/vfio/iommufd.c | 15 --------------- 2 files changed, 29 deletions(-) diff --git a/include/system/host_iommu_device.h b/include/system/host_iommu= _device.h index 809cced4ba..6f10bea25f 100644 --- a/include/system/host_iommu_device.h +++ b/include/system/host_iommu_device.h @@ -15,19 +15,6 @@ #include "qom/object.h" #include "qapi/error.h" =20 -/** - * struct HostIOMMUDeviceCaps - Define host IOMMU device capabilities. - * - * @type: host platform IOMMU type. - * - * @hw_caps: host platform IOMMU capabilities (e.g. on IOMMUFD this repres= ents - * the @out_capabilities value returned from IOMMU_GET_HW_INFO i= octl) - */ -typedef struct HostIOMMUDeviceCaps { - uint32_t type; - uint64_t hw_caps; -} HostIOMMUDeviceCaps; - #define TYPE_HOST_IOMMU_DEVICE "host-iommu-device" OBJECT_DECLARE_TYPE(HostIOMMUDevice, HostIOMMUDeviceClass, HOST_IOMMU_DEVI= CE) =20 @@ -38,7 +25,6 @@ struct HostIOMMUDevice { void *agent; /* pointer to agent device, ie. VFIO or VDPA device */ PCIBus *aliased_bus; int aliased_devfn; - HostIOMMUDeviceCaps caps; }; =20 /** diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index e7ca92f81f..947c5456d8 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -811,24 +811,9 @@ static bool hiod_iommufd_vfio_realize(HostIOMMUDevice = *hiod, void *opaque, Error **errp) { VFIODevice *vdev =3D opaque; - HostIOMMUDeviceCaps *caps =3D &hiod->caps; - enum iommu_hw_info_type type; - union { - struct iommu_hw_info_vtd vtd; - } data; - uint64_t hw_caps; =20 hiod->agent =3D opaque; - - if (!iommufd_backend_get_device_info(vdev->iommufd, vdev->devid, - &type, &data, sizeof(data), - &hw_caps, errp)) { - return false; - } - hiod->name =3D g_strdup(vdev->name); - caps->type =3D type; - caps->hw_caps =3D hw_caps; =20 return true; } --=20 2.34.1