From nobody Wed Apr 1 22:38:57 2026 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=1775030722; cv=none; d=zohomail.com; s=zohoarc; b=f7p6NugHphvR2Qe2gOAt6eHwGLulg0v3XaWBDCvPv+18sh41+xST/jxCE3Z/BZ/pfB22WGVYYhw77F5X08c/w69tnBPHBlWJXrrx6W/k/IET0dWH0k1yVtagDfBrSXa4Fr9R4XdV7e0ostl1/uS8kkS0TVemycFTidIQ8PYN5YI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775030722; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8Tb8icGnqkhz32Etcw5ZQNCYoUcULm+rG5VfrBxLKJI=; b=SJ9AIJDl9GyA1+avoq5ff/SfFxrbdXim/ClGCWk593C5WH3p3XKVPcH0eiH8VyhgYvWMmO2f4Kw5IbfqcXzUxsUf3QEigkEApHNKwmUBJmfpQlRSV3loPbVN8z/X8KTAhX85F/rrYg036s9BDi8vvdd6NmAqJWSWQMyR4rQqOxQ= 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 1775030722796588.2748148982289; Wed, 1 Apr 2026 01:05:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w7qYl-0000Y5-Mg; Wed, 01 Apr 2026 04:04:19 -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 1w7qYj-0000XD-2K; Wed, 01 Apr 2026 04:04:17 -0400 Received: from mgamail.intel.com ([198.175.65.13]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w7qYd-000436-AA; Wed, 01 Apr 2026 04:04:16 -0400 Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2026 01:04:05 -0700 Received: from unknown (HELO gnr-sp-2s-612.sh.intel.com) ([10.112.230.229]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2026 01:04:00 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775030652; x=1806566652; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=4l4y4LlFEhKjXWkq3k86xtA6HKJV+oSTE6YEEsl87FE=; b=MfaQ41UvNSttbk4jSftRIbgnLEgluellGn/Pamn2D0BVPQavGGKkgtPV FeOERBrxYVBnMocZoPqM67y98qbYDogjT4cy3Q6CbxUJsx0HAlfH7mftb ldIKAdZA/Diq1M3gW4Wh6oXcduL4ObNuDh+5THay0U+6RP0Djrc5ErUZR /ta2wVrzM4vP3xoP6kAEzqGwcIV4C6gRd6EAo3Lya14NqeU1SpTAhXNuG zuL4Da14ZovEkdcCTLqiV41qZSkxzP4+0kjnBXM0WJDgGg+dvlsXBgE6a Cg1Lj2jxD1CFg4D9VZgukMiG1Q8t596SNOwctkKXMGMGdXNrz7GIaxPaY w==; X-CSE-ConnectionGUID: lrSV2vB/QS2rBrjrCrS3RQ== X-CSE-MsgGUID: mAknkGBrTEyF/On9fnxtVQ== X-IronPort-AV: E=McAfee;i="6800,10657,11745"; a="87136640" X-IronPort-AV: E=Sophos;i="6.23,153,1770624000"; d="scan'208";a="87136640" X-CSE-ConnectionGUID: 0rePtZusRd69nY61sHxvWA== X-CSE-MsgGUID: JDW1E45pQX+lOsM6Ikw5eQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,153,1770624000"; d="scan'208";a="223727290" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex@shazbot.org, clg@redhat.com, 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, yi.l.liu@intel.com, Zhenzhong Duan , qemu-arm@nongnu.org Subject: [PATCH] iommufd: Rename all the idev and idevc variables to hiod and hiodc Date: Wed, 1 Apr 2026 04:03:53 -0400 Message-ID: <20260401080354.1347212-1-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.47.3 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.13; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.54, 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=1, RCVD_IN_VALIDITY_RPBL_BLOCKED=1, 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: qemu development 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: 1775030725916158500 We used idev and idevc naming for HostIOMMUDeviceIOMMUFD and corresponding class variables which followed the iommufd_device naming in linux kernel. This is mixed with the hiod naming for base type HostIOMMUDevice. Rename HostIOMMUDeviceIOMMUFD* to hiodi* for consistency in QEMU. No functional change intended. Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/arm/smmuv3-accel.h | 2 +- include/system/iommufd.h | 12 ++--- backends/iommufd.c | 26 +++++------ hw/arm/smmuv3-accel.c | 93 +++++++++++++++++++------------------ hw/i386/intel_iommu_accel.c | 44 +++++++++--------- hw/vfio/container-legacy.c | 10 ++-- hw/vfio/iommufd.c | 24 +++++----- 7 files changed, 107 insertions(+), 104 deletions(-) diff --git a/hw/arm/smmuv3-accel.h b/hw/arm/smmuv3-accel.h index dba6c71de5..908a13cbcc 100644 --- a/hw/arm/smmuv3-accel.h +++ b/hw/arm/smmuv3-accel.h @@ -34,7 +34,7 @@ typedef struct SMMUS1Hwpt { =20 typedef struct SMMUv3AccelDevice { SMMUDevice sdev; - HostIOMMUDeviceIOMMUFD *idev; + HostIOMMUDeviceIOMMUFD *hiodi; SMMUS1Hwpt *s1_hwpt; IOMMUFDVdev *vdev; QLIST_ENTRY(SMMUv3AccelDevice) next; diff --git a/include/system/iommufd.h b/include/system/iommufd.h index 7062944fe6..2925d116ac 100644 --- a/include/system/iommufd.h +++ b/include/system/iommufd.h @@ -136,7 +136,7 @@ struct HostIOMMUDeviceIOMMUFDClass { * * Mandatory callback. * - * @idev: host IOMMU device backed by IOMMUFD backend. + * @hiodi: host IOMMU device backed by IOMMUFD backend. * * @hwpt_id: ID of IOMMUFD hardware page table. * @@ -144,7 +144,7 @@ struct HostIOMMUDeviceIOMMUFDClass { * * Returns: true on success, false on failure. */ - bool (*attach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, uint32_t hwpt_id, + bool (*attach_hwpt)(HostIOMMUDeviceIOMMUFD *hiodi, uint32_t hwpt_id, Error **errp); /** * @detach_hwpt: detach host IOMMU device from IOMMUFD hardware page t= able. @@ -152,17 +152,17 @@ struct HostIOMMUDeviceIOMMUFDClass { * * Mandatory callback. * - * @idev: host IOMMU device backed by IOMMUFD backend. + * @hiodi: 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 (*detach_hwpt)(HostIOMMUDeviceIOMMUFD *hiodi, Error **errp); }; =20 -bool host_iommu_device_iommufd_attach_hwpt(HostIOMMUDeviceIOMMUFD *idev, +bool host_iommu_device_iommufd_attach_hwpt(HostIOMMUDeviceIOMMUFD *hiodi, uint32_t hwpt_id, Error **errp); -bool host_iommu_device_iommufd_detach_hwpt(HostIOMMUDeviceIOMMUFD *idev, +bool host_iommu_device_iommufd_detach_hwpt(HostIOMMUDeviceIOMMUFD *hiodi, Error **errp); #endif diff --git a/backends/iommufd.c b/backends/iommufd.c index e1fee16acf..410b044370 100644 --- a/backends/iommufd.c +++ b/backends/iommufd.c @@ -538,24 +538,24 @@ bool iommufd_backend_alloc_veventq(IOMMUFDBackend *be= , uint32_t viommu_id, return true; } =20 -bool host_iommu_device_iommufd_attach_hwpt(HostIOMMUDeviceIOMMUFD *idev, +bool host_iommu_device_iommufd_attach_hwpt(HostIOMMUDeviceIOMMUFD *hiodi, uint32_t hwpt_id, Error **errp) { - HostIOMMUDeviceIOMMUFDClass *idevc =3D - HOST_IOMMU_DEVICE_IOMMUFD_GET_CLASS(idev); + HostIOMMUDeviceIOMMUFDClass *hiodic =3D + HOST_IOMMU_DEVICE_IOMMUFD_GET_CLASS(hiodi); =20 - g_assert(idevc->attach_hwpt); - return idevc->attach_hwpt(idev, hwpt_id, errp); + g_assert(hiodic->attach_hwpt); + return hiodic->attach_hwpt(hiodi, hwpt_id, errp); } =20 -bool host_iommu_device_iommufd_detach_hwpt(HostIOMMUDeviceIOMMUFD *idev, +bool host_iommu_device_iommufd_detach_hwpt(HostIOMMUDeviceIOMMUFD *hiodi, Error **errp) { - HostIOMMUDeviceIOMMUFDClass *idevc =3D - HOST_IOMMU_DEVICE_IOMMUFD_GET_CLASS(idev); + HostIOMMUDeviceIOMMUFDClass *hiodic =3D + HOST_IOMMU_DEVICE_IOMMUFD_GET_CLASS(hiodi); =20 - g_assert(idevc->detach_hwpt); - return idevc->detach_hwpt(idev, errp); + g_assert(hiodic->detach_hwpt); + return hiodic->detach_hwpt(hiodi, errp); } =20 static int hiod_iommufd_get_cap(HostIOMMUDevice *hiod, int cap, Error **er= rp) @@ -591,10 +591,10 @@ static bool hiod_iommufd_get_pasid_info(HostIOMMUDevi= ce *hiod, =20 static void hiod_iommufd_class_init(ObjectClass *oc, const void *data) { - HostIOMMUDeviceClass *hioc =3D HOST_IOMMU_DEVICE_CLASS(oc); + HostIOMMUDeviceClass *hiodc =3D HOST_IOMMU_DEVICE_CLASS(oc); =20 - hioc->get_cap =3D hiod_iommufd_get_cap; - hioc->get_pasid_info =3D hiod_iommufd_get_pasid_info; + hiodc->get_cap =3D hiod_iommufd_get_cap; + hiodc->get_pasid_info =3D hiod_iommufd_get_pasid_info; }; =20 static const TypeInfo types[] =3D { diff --git a/hw/arm/smmuv3-accel.c b/hw/arm/smmuv3-accel.c index 65c2f44880..3630078751 100644 --- a/hw/arm/smmuv3-accel.c +++ b/hw/arm/smmuv3-accel.c @@ -129,16 +129,16 @@ smmuv3_accel_check_hw_compatible(SMMUv3State *s, } =20 static bool -smmuv3_accel_hw_compatible(SMMUv3State *s, HostIOMMUDeviceIOMMUFD *idev, +smmuv3_accel_hw_compatible(SMMUv3State *s, HostIOMMUDeviceIOMMUFD *hiodi, Error **errp) { struct iommu_hw_info_arm_smmuv3 info; uint32_t data_type; uint64_t caps; =20 - if (!iommufd_backend_get_device_info(idev->iommufd, idev->devid, &data= _type, - &info, sizeof(info), &caps, NULL, - errp)) { + if (!iommufd_backend_get_device_info(hiodi->iommufd, hiodi->devid, + &data_type, &info, sizeof(info), = &caps, + NULL, errp)) { return false; } =20 @@ -182,15 +182,15 @@ static bool smmuv3_accel_alloc_vdev(SMMUv3AccelDevice *accel_dev, int sid, Error **err= p) { SMMUv3AccelState *accel =3D accel_dev->s_accel; - HostIOMMUDeviceIOMMUFD *idev =3D accel_dev->idev; + HostIOMMUDeviceIOMMUFD *hiodi =3D accel_dev->hiodi; IOMMUFDVdev *vdev =3D accel_dev->vdev; uint32_t vdevice_id; =20 - if (!idev || vdev) { + if (!hiodi || vdev) { return true; } =20 - if (!iommufd_backend_alloc_vdev(idev->iommufd, idev->devid, + if (!iommufd_backend_alloc_vdev(hiodi->iommufd, hiodi->devid, accel->viommu->viommu_id, sid, &vdevice_id, errp)) { return false; @@ -209,7 +209,7 @@ smmuv3_accel_dev_alloc_translate(SMMUv3AccelDevice *acc= el_dev, STE *ste, { uint64_t ste_0 =3D (uint64_t)ste->word[0] | (uint64_t)ste->word[1] << = 32; uint64_t ste_1 =3D (uint64_t)ste->word[2] | (uint64_t)ste->word[3] << = 32; - HostIOMMUDeviceIOMMUFD *idev =3D accel_dev->idev; + HostIOMMUDeviceIOMMUFD *hiodi =3D accel_dev->hiodi; SMMUv3AccelState *accel =3D accel_dev->s_accel; struct iommu_hwpt_arm_smmuv3 nested_data =3D { .ste =3D { @@ -220,7 +220,7 @@ smmuv3_accel_dev_alloc_translate(SMMUv3AccelDevice *acc= el_dev, STE *ste, uint32_t hwpt_id =3D 0, flags =3D 0; SMMUS1Hwpt *s1_hwpt; =20 - if (!iommufd_backend_alloc_hwpt(idev->iommufd, idev->devid, + if (!iommufd_backend_alloc_hwpt(hiodi->iommufd, hiodi->devid, accel->viommu->viommu_id, flags, IOMMU_HWPT_DATA_ARM_SMMUV3, sizeof(nested_data), &nested_data, @@ -242,7 +242,7 @@ bool smmuv3_accel_install_ste(SMMUv3State *s, SMMUDevic= e *sdev, int sid, .inval_ste_allowed =3D true}; SMMUv3AccelState *accel =3D s->s_accel; SMMUv3AccelDevice *accel_dev; - HostIOMMUDeviceIOMMUFD *idev; + HostIOMMUDeviceIOMMUFD *hiodi; uint32_t config, hwpt_id =3D 0; SMMUS1Hwpt *s1_hwpt =3D NULL; const char *type; @@ -257,7 +257,7 @@ bool smmuv3_accel_install_ste(SMMUv3State *s, SMMUDevic= e *sdev, int sid, return true; } =20 - idev =3D accel_dev->idev; + hiodi =3D accel_dev->hiodi; if (!smmuv3_accel_alloc_vdev(accel_dev, sid, errp)) { return false; } @@ -300,9 +300,9 @@ bool smmuv3_accel_install_ste(SMMUv3State *s, SMMUDevic= e *sdev, int sid, return false; } =20 - if (!host_iommu_device_iommufd_attach_hwpt(idev, hwpt_id, errp)) { + if (!host_iommu_device_iommufd_attach_hwpt(hiodi, hwpt_id, errp)) { if (s1_hwpt) { - iommufd_backend_free_id(idev->iommufd, s1_hwpt->hwpt_id); + iommufd_backend_free_id(hiodi->iommufd, s1_hwpt->hwpt_id); g_free(s1_hwpt); } return false; @@ -310,7 +310,7 @@ bool smmuv3_accel_install_ste(SMMUv3State *s, SMMUDevic= e *sdev, int sid, =20 /* Free the previous s1_hwpt */ if (accel_dev->s1_hwpt) { - iommufd_backend_free_id(idev->iommufd, accel_dev->s1_hwpt->hwpt_id= ); + iommufd_backend_free_id(hiodi->iommufd, accel_dev->s1_hwpt->hwpt_i= d); g_free(accel_dev->s1_hwpt); } =20 @@ -524,7 +524,7 @@ free_veventq: } =20 static bool -smmuv3_accel_alloc_viommu(SMMUv3State *s, HostIOMMUDeviceIOMMUFD *idev, +smmuv3_accel_alloc_viommu(SMMUv3State *s, HostIOMMUDeviceIOMMUFD *hiodi, Error **errp) { SMMUv3AccelState *accel =3D s->s_accel; @@ -534,11 +534,11 @@ smmuv3_accel_alloc_viommu(SMMUv3State *s, HostIOMMUDe= viceIOMMUFD *idev, struct iommu_hwpt_arm_smmuv3 abort_data =3D { .ste =3D { SMMU_STE_VALID, 0x0ULL }, }; - uint32_t s2_hwpt_id =3D idev->hwpt_id; + uint32_t s2_hwpt_id =3D hiodi->hwpt_id; uint32_t viommu_id, hwpt_id; IOMMUFDViommu *viommu; =20 - if (!iommufd_backend_alloc_viommu(idev->iommufd, idev->devid, + if (!iommufd_backend_alloc_viommu(hiodi->iommufd, hiodi->devid, IOMMU_VIOMMU_TYPE_ARM_SMMUV3, s2_hwpt_id, &viommu_id, errp)) { return false; @@ -547,21 +547,21 @@ smmuv3_accel_alloc_viommu(SMMUv3State *s, HostIOMMUDe= viceIOMMUFD *idev, viommu =3D g_new0(IOMMUFDViommu, 1); viommu->viommu_id =3D viommu_id; viommu->s2_hwpt_id =3D s2_hwpt_id; - viommu->iommufd =3D idev->iommufd; + viommu->iommufd =3D hiodi->iommufd; accel->viommu =3D viommu; =20 /* * Pre-allocate HWPTs for S1 bypass and abort cases. These will be att= ached * later for guest STEs or GBPAs that require bypass or abort configur= ation. */ - if (!iommufd_backend_alloc_hwpt(idev->iommufd, idev->devid, viommu_id, + if (!iommufd_backend_alloc_hwpt(hiodi->iommufd, hiodi->devid, viommu_i= d, 0, IOMMU_HWPT_DATA_ARM_SMMUV3, sizeof(abort_data), &abort_data, &accel->abort_hwpt_id, errp)) { goto free_viommu; } =20 - if (!iommufd_backend_alloc_hwpt(idev->iommufd, idev->devid, viommu_id, + if (!iommufd_backend_alloc_hwpt(hiodi->iommufd, hiodi->devid, viommu_i= d, 0, IOMMU_HWPT_DATA_ARM_SMMUV3, sizeof(bypass_data), &bypass_data, &accel->bypass_hwpt_id, errp)) { @@ -575,7 +575,7 @@ smmuv3_accel_alloc_viommu(SMMUv3State *s, HostIOMMUDevi= ceIOMMUFD *idev, =20 /* Attach a HWPT based on SMMUv3 GBPA.ABORT value */ hwpt_id =3D smmuv3_accel_gbpa_hwpt(s, accel); - if (!host_iommu_device_iommufd_attach_hwpt(idev, hwpt_id, errp)) { + if (!host_iommu_device_iommufd_attach_hwpt(hiodi, hwpt_id, errp)) { goto free_veventq; } return true; @@ -583,11 +583,11 @@ smmuv3_accel_alloc_viommu(SMMUv3State *s, HostIOMMUDe= viceIOMMUFD *idev, free_veventq: smmuv3_accel_free_veventq(accel); free_bypass_hwpt: - iommufd_backend_free_id(idev->iommufd, accel->bypass_hwpt_id); + iommufd_backend_free_id(hiodi->iommufd, accel->bypass_hwpt_id); free_abort_hwpt: - iommufd_backend_free_id(idev->iommufd, accel->abort_hwpt_id); + iommufd_backend_free_id(hiodi->iommufd, accel->abort_hwpt_id); free_viommu: - iommufd_backend_free_id(idev->iommufd, viommu->viommu_id); + iommufd_backend_free_id(hiodi->iommufd, viommu->viommu_id); g_free(viommu); accel->viommu =3D NULL; return false; @@ -596,20 +596,20 @@ free_viommu: static bool smmuv3_accel_set_iommu_device(PCIBus *bus, void *opaque, int d= evfn, HostIOMMUDevice *hiod, Error **e= rrp) { - HostIOMMUDeviceIOMMUFD *idev =3D HOST_IOMMU_DEVICE_IOMMUFD(hiod); + HostIOMMUDeviceIOMMUFD *hiodi =3D HOST_IOMMU_DEVICE_IOMMUFD(hiod); SMMUState *bs =3D opaque; SMMUv3State *s =3D ARM_SMMUV3(bs); SMMUPciBus *sbus =3D smmu_get_sbus(bs, bus); SMMUv3AccelDevice *accel_dev =3D smmuv3_accel_get_dev(bs, sbus, bus, d= evfn); =20 - if (!idev) { + if (!hiodi) { return true; } =20 - if (accel_dev->idev) { - if (accel_dev->idev !=3D idev) { - error_setg(errp, "Device already has an associated idev 0x%x", - idev->devid); + if (accel_dev->hiodi) { + if (accel_dev->hiodi !=3D hiodi) { + error_setg(errp, "Device already has an associated hiodi 0x%x", + hiodi->devid); return false; } return true; @@ -619,7 +619,7 @@ static bool smmuv3_accel_set_iommu_device(PCIBus *bus, = void *opaque, int devfn, * Check the host SMMUv3 associated with the dev is compatible with the * QEMU SMMUv3 accel. */ - if (!smmuv3_accel_hw_compatible(s, idev, errp)) { + if (!smmuv3_accel_hw_compatible(s, hiodi, errp)) { return false; } =20 @@ -627,17 +627,17 @@ static bool smmuv3_accel_set_iommu_device(PCIBus *bus= , void *opaque, int devfn, goto done; } =20 - if (!smmuv3_accel_alloc_viommu(s, idev, errp)) { - error_append_hint(errp, "Unable to alloc vIOMMU: idev devid 0x%x: = ", - idev->devid); + if (!smmuv3_accel_alloc_viommu(s, hiodi, errp)) { + error_append_hint(errp, "Unable to alloc vIOMMU: hiodi devid 0x%x:= ", + hiodi->devid); return false; } =20 done: - accel_dev->idev =3D idev; + accel_dev->hiodi =3D hiodi; accel_dev->s_accel =3D s->s_accel; QLIST_INSERT_HEAD(&s->s_accel->device_list, accel_dev, next); - trace_smmuv3_accel_set_iommu_device(devfn, idev->devid); + trace_smmuv3_accel_set_iommu_device(devfn, hiodi->devid); return true; } =20 @@ -646,7 +646,7 @@ static void smmuv3_accel_unset_iommu_device(PCIBus *bus= , void *opaque, { SMMUState *bs =3D opaque; SMMUPciBus *sbus =3D g_hash_table_lookup(bs->smmu_pcibus_by_busptr, bu= s); - HostIOMMUDeviceIOMMUFD *idev; + HostIOMMUDeviceIOMMUFD *hiodi; SMMUv3AccelDevice *accel_dev; SMMUv3AccelState *accel; IOMMUFDVdev *vdev; @@ -662,16 +662,16 @@ static void smmuv3_accel_unset_iommu_device(PCIBus *b= us, void *opaque, } =20 accel_dev =3D container_of(sdev, SMMUv3AccelDevice, sdev); - idev =3D accel_dev->idev; + hiodi =3D accel_dev->hiodi; accel =3D accel_dev->s_accel; /* Re-attach the default s2 hwpt id */ - if (!host_iommu_device_iommufd_attach_hwpt(idev, idev->hwpt_id, NULL))= { - error_report("Unable to attach the default HW pagetable: idev devi= d " - "0x%x", idev->devid); + if (!host_iommu_device_iommufd_attach_hwpt(hiodi, hiodi->hwpt_id, NULL= )) { + error_report("Unable to attach the default HW pagetable: hiodi dev= id " + "0x%x", hiodi->devid); } =20 if (accel_dev->s1_hwpt) { - iommufd_backend_free_id(accel_dev->idev->iommufd, + iommufd_backend_free_id(accel_dev->hiodi->iommufd, accel_dev->s1_hwpt->hwpt_id); g_free(accel_dev->s1_hwpt); accel_dev->s1_hwpt =3D NULL; @@ -684,10 +684,10 @@ static void smmuv3_accel_unset_iommu_device(PCIBus *b= us, void *opaque, accel_dev->vdev =3D NULL; } =20 - accel_dev->idev =3D NULL; + accel_dev->hiodi =3D NULL; accel_dev->s_accel =3D NULL; QLIST_REMOVE(accel_dev, next); - trace_smmuv3_accel_unset_iommu_device(devfn, idev->devid); + trace_smmuv3_accel_unset_iommu_device(devfn, hiodi->devid); =20 if (QLIST_EMPTY(&accel->device_list)) { smmuv3_accel_free_viommu(accel); @@ -879,10 +879,11 @@ bool smmuv3_accel_attach_gbpa_hwpt(SMMUv3State *s, Er= ror **errp) =20 hwpt_id =3D 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_i= d, + if (!host_iommu_device_iommufd_attach_hwpt(accel_dev->hiodi, hwpt_= id, &local_err)) { error_append_hint(&local_err, "Failed to attach GBPA hwpt %u f= or " - "idev devid %u", hwpt_id, accel_dev->idev->d= evid); + "hiodi devid %u", hwpt_id, + accel_dev->hiodi->devid); error_report_err(local_err); local_err =3D NULL; all_ok =3D false; diff --git a/hw/i386/intel_iommu_accel.c b/hw/i386/intel_iommu_accel.c index 67d54849f2..ed3793602b 100644 --- a/hw/i386/intel_iommu_accel.c +++ b/hw/i386/intel_iommu_accel.c @@ -69,7 +69,7 @@ VTDHostIOMMUDevice *vtd_find_hiod_iommufd(VTDAddressSpace= *as) return NULL; } =20 -static bool vtd_create_fs_hwpt(HostIOMMUDeviceIOMMUFD *idev, +static bool vtd_create_fs_hwpt(HostIOMMUDeviceIOMMUFD *hiodi, VTDPASIDEntry *pe, uint32_t *fs_hwpt_id, Error **errp) { @@ -81,27 +81,27 @@ static bool vtd_create_fs_hwpt(HostIOMMUDeviceIOMMUFD *= idev, vtd.addr_width =3D vtd_pe_get_fs_aw(pe); vtd.pgtbl_addr =3D (uint64_t)vtd_pe_get_fspt_base(pe); =20 - return iommufd_backend_alloc_hwpt(idev->iommufd, idev->devid, idev->hw= pt_id, - 0, IOMMU_HWPT_DATA_VTD_S1, sizeof(vt= d), - &vtd, fs_hwpt_id, errp); + return iommufd_backend_alloc_hwpt(hiodi->iommufd, hiodi->devid, + hiodi->hwpt_id, 0, IOMMU_HWPT_DATA_V= TD_S1, + sizeof(vtd), &vtd, fs_hwpt_id, errp); } =20 -static void vtd_destroy_old_fs_hwpt(HostIOMMUDeviceIOMMUFD *idev, +static void vtd_destroy_old_fs_hwpt(HostIOMMUDeviceIOMMUFD *hiodi, VTDAddressSpace *vtd_as) { if (!vtd_as->fs_hwpt_id) { return; } - iommufd_backend_free_id(idev->iommufd, vtd_as->fs_hwpt_id); + iommufd_backend_free_id(hiodi->iommufd, vtd_as->fs_hwpt_id); vtd_as->fs_hwpt_id =3D 0; } =20 static bool vtd_device_attach_iommufd(VTDHostIOMMUDevice *vtd_hiod, VTDAddressSpace *vtd_as, Error **err= p) { - HostIOMMUDeviceIOMMUFD *idev =3D HOST_IOMMU_DEVICE_IOMMUFD(vtd_hiod->h= iod); + HostIOMMUDeviceIOMMUFD *hiodi =3D HOST_IOMMU_DEVICE_IOMMUFD(vtd_hiod->= hiod); VTDPASIDEntry *pe =3D &vtd_as->pasid_cache_entry.pasid_entry; - uint32_t hwpt_id =3D idev->hwpt_id; + uint32_t hwpt_id =3D hiodi->hwpt_id; bool ret; =20 /* @@ -116,21 +116,21 @@ static bool vtd_device_attach_iommufd(VTDHostIOMMUDev= ice *vtd_hiod, } =20 if (vtd_pe_pgtt_is_fst(pe)) { - if (!vtd_create_fs_hwpt(idev, pe, &hwpt_id, errp)) { + if (!vtd_create_fs_hwpt(hiodi, pe, &hwpt_id, errp)) { return false; } } =20 - ret =3D host_iommu_device_iommufd_attach_hwpt(idev, hwpt_id, errp); - trace_vtd_device_attach_hwpt(idev->devid, vtd_as->pasid, hwpt_id, ret); + ret =3D host_iommu_device_iommufd_attach_hwpt(hiodi, hwpt_id, errp); + trace_vtd_device_attach_hwpt(hiodi->devid, vtd_as->pasid, hwpt_id, ret= ); if (ret) { /* Destroy old fs_hwpt if it's a replacement */ - vtd_destroy_old_fs_hwpt(idev, vtd_as); + vtd_destroy_old_fs_hwpt(hiodi, vtd_as); if (vtd_pe_pgtt_is_fst(pe)) { vtd_as->fs_hwpt_id =3D hwpt_id; } } else if (vtd_pe_pgtt_is_fst(pe)) { - iommufd_backend_free_id(idev->iommufd, hwpt_id); + iommufd_backend_free_id(hiodi->iommufd, hwpt_id); } =20 return ret; @@ -139,27 +139,28 @@ static bool vtd_device_attach_iommufd(VTDHostIOMMUDev= ice *vtd_hiod, static bool vtd_device_detach_iommufd(VTDHostIOMMUDevice *vtd_hiod, VTDAddressSpace *vtd_as, Error **err= p) { - HostIOMMUDeviceIOMMUFD *idev =3D HOST_IOMMU_DEVICE_IOMMUFD(vtd_hiod->h= iod); + HostIOMMUDeviceIOMMUFD *hiodi =3D HOST_IOMMU_DEVICE_IOMMUFD(vtd_hiod->= hiod); IntelIOMMUState *s =3D vtd_as->iommu_state; uint32_t pasid =3D vtd_as->pasid; bool ret; =20 if (s->dmar_enabled && s->root_scalable) { - ret =3D host_iommu_device_iommufd_detach_hwpt(idev, errp); - trace_vtd_device_detach_hwpt(idev->devid, pasid, ret); + ret =3D host_iommu_device_iommufd_detach_hwpt(hiodi, errp); + trace_vtd_device_detach_hwpt(hiodi->devid, pasid, ret); } else { /* * If DMAR remapping is disabled or guest switches to legacy mode, * we fallback to the default HWPT which contains shadow page tabl= e. * So guest DMA could still work. */ - ret =3D host_iommu_device_iommufd_attach_hwpt(idev, idev->hwpt_id,= errp); - trace_vtd_device_reattach_def_hwpt(idev->devid, pasid, idev->hwpt_= id, + ret =3D host_iommu_device_iommufd_attach_hwpt(hiodi, hiodi->hwpt_i= d, + errp); + trace_vtd_device_reattach_def_hwpt(hiodi->devid, pasid, hiodi->hwp= t_id, ret); } =20 if (ret) { - vtd_destroy_old_fs_hwpt(idev, vtd_as); + vtd_destroy_old_fs_hwpt(hiodi, vtd_as); } =20 return ret; @@ -211,13 +212,14 @@ static void vtd_flush_host_piotlb_locked(gpointer key= , gpointer value, did =3D VTD_SM_PASID_ENTRY_DID(&pc_entry->pasid_entry); =20 if (piotlb_info->domain_id =3D=3D did && piotlb_info->pasid =3D=3D PAS= ID_0) { - HostIOMMUDeviceIOMMUFD *idev =3D + HostIOMMUDeviceIOMMUFD *hiodi =3D HOST_IOMMU_DEVICE_IOMMUFD(vtd_hiod->hiod); uint32_t entry_num =3D 1; /* Only implement one request for simpli= city */ Error *local_err =3D NULL; struct iommu_hwpt_vtd_s1_invalidate *cache =3D piotlb_info->inv_da= ta; =20 - if (!iommufd_backend_invalidate_cache(idev->iommufd, vtd_as->fs_hw= pt_id, + if (!iommufd_backend_invalidate_cache(hiodi->iommufd, + vtd_as->fs_hwpt_id, IOMMU_HWPT_INVALIDATE_DATA_V= TD_S1, sizeof(*cache), &entry_num, = cache, &local_err)) { diff --git a/hw/vfio/container-legacy.c b/hw/vfio/container-legacy.c index 625f151364..d301b27aa6 100644 --- a/hw/vfio/container-legacy.c +++ b/hw/vfio/container-legacy.c @@ -1244,12 +1244,12 @@ static void vfio_iommu_legacy_instance_init(Object = *obj) =20 static void hiod_legacy_vfio_class_init(ObjectClass *oc, const void *data) { - HostIOMMUDeviceClass *hioc =3D HOST_IOMMU_DEVICE_CLASS(oc); + HostIOMMUDeviceClass *hiodc =3D HOST_IOMMU_DEVICE_CLASS(oc); =20 - hioc->realize =3D hiod_legacy_vfio_realize; - hioc->get_cap =3D hiod_legacy_vfio_get_cap; - hioc->get_iova_ranges =3D hiod_legacy_vfio_get_iova_ranges; - hioc->get_page_size_mask =3D hiod_legacy_vfio_get_page_size_mask; + hiodc->realize =3D hiod_legacy_vfio_realize; + hiodc->get_cap =3D hiod_legacy_vfio_get_cap; + hiodc->get_iova_ranges =3D hiod_legacy_vfio_get_iova_ranges; + hiodc->get_page_size_mask =3D hiod_legacy_vfio_get_page_size_mask; }; =20 static const TypeInfo types[] =3D { diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 3e33dfbb35..399b36aa75 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -917,19 +917,19 @@ static void vfio_iommu_iommufd_class_init(ObjectClass= *klass, const void *data) }; =20 static bool -host_iommu_device_iommufd_vfio_attach_hwpt(HostIOMMUDeviceIOMMUFD *idev, +host_iommu_device_iommufd_vfio_attach_hwpt(HostIOMMUDeviceIOMMUFD *hiodi, uint32_t hwpt_id, Error **errp) { - VFIODevice *vbasedev =3D HOST_IOMMU_DEVICE(idev)->agent; + VFIODevice *vbasedev =3D HOST_IOMMU_DEVICE(hiodi)->agent; =20 return !iommufd_cdev_attach_ioas_hwpt(vbasedev, hwpt_id, errp); } =20 static bool -host_iommu_device_iommufd_vfio_detach_hwpt(HostIOMMUDeviceIOMMUFD *idev, +host_iommu_device_iommufd_vfio_detach_hwpt(HostIOMMUDeviceIOMMUFD *hiodi, Error **errp) { - VFIODevice *vbasedev =3D HOST_IOMMU_DEVICE(idev)->agent; + VFIODevice *vbasedev =3D HOST_IOMMU_DEVICE(hiodi)->agent; =20 return iommufd_cdev_detach_ioas_hwpt(vbasedev, errp); } @@ -938,7 +938,7 @@ static bool hiod_iommufd_vfio_realize(HostIOMMUDevice *= hiod, void *opaque, Error **errp) { VFIODevice *vdev =3D opaque; - HostIOMMUDeviceIOMMUFD *idev; + HostIOMMUDeviceIOMMUFD *hiodi; HostIOMMUDeviceCaps *caps =3D &hiod->caps; VendorCaps *vendor_caps =3D &caps->vendor_caps; enum iommu_hw_info_type type; @@ -958,10 +958,10 @@ static bool hiod_iommufd_vfio_realize(HostIOMMUDevice= *hiod, void *opaque, caps->hw_caps =3D hw_caps; caps->max_pasid_log2 =3D max_pasid_log2; =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; + hiodi =3D HOST_IOMMU_DEVICE_IOMMUFD(hiod); + hiodi->iommufd =3D vdev->iommufd; + hiodi->devid =3D vdev->devid; + hiodi->hwpt_id =3D vdev->hwpt->hwpt_id; =20 return true; } @@ -988,14 +988,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); + HostIOMMUDeviceIOMMUFDClass *hiodic =3D HOST_IOMMU_DEVICE_IOMMUFD_CLAS= S(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; =20 - idevc->attach_hwpt =3D host_iommu_device_iommufd_vfio_attach_hwpt; - idevc->detach_hwpt =3D host_iommu_device_iommufd_vfio_detach_hwpt; + hiodic->attach_hwpt =3D host_iommu_device_iommufd_vfio_attach_hwpt; + hiodic->detach_hwpt =3D host_iommu_device_iommufd_vfio_detach_hwpt; }; =20 static const TypeInfo types[] =3D { --=20 2.47.3