@samitouri / QOSamiQemu / commits / e2b7310276

iommufd: Rename all the idev and idevc variables to hiod and hiodc

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édric Le Goater <clg@redhat.com> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Cédric Le Goater <clg@redhat.com> Link: https://lore.kernel.org/qemu-devel/20260401080354.1347212-1-zhenzhong.duan@intel.com Signed-off-by: Cédric Le Goater <clg@redhat.com>

Zhenzhong Duan committed Apr 1, 2026 at 04:03 UTC e2b7310276087351fadd6afbe9e5a3fff9c25f8d
7 files changed +107 -104
backends/iommufd.c
+13 -13
@@ -538,24 +538,24 @@ bool iommufd_backend_alloc_veventq(IOMMUFDBackend *be, uint32_t viommu_id,
538 return true;
539 }
540
541 -bool host_iommu_device_iommufd_attach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
541 +bool host_iommu_device_iommufd_attach_hwpt(HostIOMMUDeviceIOMMUFD *hiodi,
542 uint32_t hwpt_id, Error **errp)
543 {
544 - HostIOMMUDeviceIOMMUFDClass *idevc =
545 - HOST_IOMMU_DEVICE_IOMMUFD_GET_CLASS(idev);
544 + HostIOMMUDeviceIOMMUFDClass *hiodic =
545 + HOST_IOMMU_DEVICE_IOMMUFD_GET_CLASS(hiodi);
546
547 - g_assert(idevc->attach_hwpt);
548 - return idevc->attach_hwpt(idev, hwpt_id, errp);
547 + g_assert(hiodic->attach_hwpt);
548 + return hiodic->attach_hwpt(hiodi, hwpt_id, errp);
549 }
550
551 -bool host_iommu_device_iommufd_detach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
551 +bool host_iommu_device_iommufd_detach_hwpt(HostIOMMUDeviceIOMMUFD *hiodi,
552 Error **errp)
553 {
554 - HostIOMMUDeviceIOMMUFDClass *idevc =
555 - HOST_IOMMU_DEVICE_IOMMUFD_GET_CLASS(idev);
554 + HostIOMMUDeviceIOMMUFDClass *hiodic =
555 + HOST_IOMMU_DEVICE_IOMMUFD_GET_CLASS(hiodi);
556
557 - g_assert(idevc->detach_hwpt);
558 - return idevc->detach_hwpt(idev, errp);
557 + g_assert(hiodic->detach_hwpt);
558 + return hiodic->detach_hwpt(hiodi, errp);
559 }
560
561 static int hiod_iommufd_get_cap(HostIOMMUDevice *hiod, int cap, Error **errp)
@@ -591,10 +591,10 @@ static bool hiod_iommufd_get_pasid_info(HostIOMMUDevice *hiod,
591
592 static void hiod_iommufd_class_init(ObjectClass *oc, const void *data)
593 {
594 - HostIOMMUDeviceClass *hioc = HOST_IOMMU_DEVICE_CLASS(oc);
594 + HostIOMMUDeviceClass *hiodc = HOST_IOMMU_DEVICE_CLASS(oc);
595
596 - hioc->get_cap = hiod_iommufd_get_cap;
597 - hioc->get_pasid_info = hiod_iommufd_get_pasid_info;
596 + hiodc->get_cap = hiod_iommufd_get_cap;
597 + hiodc->get_pasid_info = hiod_iommufd_get_pasid_info;
598 };
599
600 static const TypeInfo types[] = {
hw/arm/smmuv3-accel.c
+47 -46
@@ -129,16 +129,16 @@ smmuv3_accel_check_hw_compatible(SMMUv3State *s,
129 }
130
131 static bool
132 -smmuv3_accel_hw_compatible(SMMUv3State *s, HostIOMMUDeviceIOMMUFD *idev,
132 +smmuv3_accel_hw_compatible(SMMUv3State *s, HostIOMMUDeviceIOMMUFD *hiodi,
133 Error **errp)
134 {
135 struct iommu_hw_info_arm_smmuv3 info;
136 uint32_t data_type;
137 uint64_t caps;
138
139 - if (!iommufd_backend_get_device_info(idev->iommufd, idev->devid, &data_type,
140 - &info, sizeof(info), &caps, NULL,
141 - errp)) {
139 + if (!iommufd_backend_get_device_info(hiodi->iommufd, hiodi->devid,
140 + &data_type, &info, sizeof(info), &caps,
141 + NULL, errp)) {
142 return false;
143 }
144
@@ -182,15 +182,15 @@ static bool
182 smmuv3_accel_alloc_vdev(SMMUv3AccelDevice *accel_dev, int sid, Error **errp)
183 {
184 SMMUv3AccelState *accel = accel_dev->s_accel;
185 - HostIOMMUDeviceIOMMUFD *idev = accel_dev->idev;
185 + HostIOMMUDeviceIOMMUFD *hiodi = accel_dev->hiodi;
186 IOMMUFDVdev *vdev = accel_dev->vdev;
187 uint32_t vdevice_id;
188
189 - if (!idev || vdev) {
189 + if (!hiodi || vdev) {
190 return true;
191 }
192
193 - if (!iommufd_backend_alloc_vdev(idev->iommufd, idev->devid,
193 + if (!iommufd_backend_alloc_vdev(hiodi->iommufd, hiodi->devid,
194 accel->viommu->viommu_id, sid,
195 &vdevice_id, errp)) {
196 return false;
@@ -209,7 +209,7 @@ smmuv3_accel_dev_alloc_translate(SMMUv3AccelDevice *accel_dev, STE *ste,
209 {
210 uint64_t ste_0 = (uint64_t)ste->word[0] | (uint64_t)ste->word[1] << 32;
211 uint64_t ste_1 = (uint64_t)ste->word[2] | (uint64_t)ste->word[3] << 32;
212 - HostIOMMUDeviceIOMMUFD *idev = accel_dev->idev;
212 + HostIOMMUDeviceIOMMUFD *hiodi = accel_dev->hiodi;
213 SMMUv3AccelState *accel = accel_dev->s_accel;
214 struct iommu_hwpt_arm_smmuv3 nested_data = {
215 .ste = {
@@ -220,7 +220,7 @@ smmuv3_accel_dev_alloc_translate(SMMUv3AccelDevice *accel_dev, STE *ste,
220 uint32_t hwpt_id = 0, flags = 0;
221 SMMUS1Hwpt *s1_hwpt;
222
223 - if (!iommufd_backend_alloc_hwpt(idev->iommufd, idev->devid,
223 + if (!iommufd_backend_alloc_hwpt(hiodi->iommufd, hiodi->devid,
224 accel->viommu->viommu_id, flags,
225 IOMMU_HWPT_DATA_ARM_SMMUV3,
226 sizeof(nested_data), &nested_data,
@@ -242,7 +242,7 @@ bool smmuv3_accel_install_ste(SMMUv3State *s, SMMUDevice *sdev, int sid,
242 .inval_ste_allowed = true};
243 SMMUv3AccelState *accel = s->s_accel;
244 SMMUv3AccelDevice *accel_dev;
245 - HostIOMMUDeviceIOMMUFD *idev;
245 + HostIOMMUDeviceIOMMUFD *hiodi;
246 uint32_t config, hwpt_id = 0;
247 SMMUS1Hwpt *s1_hwpt = NULL;
248 const char *type;
@@ -257,7 +257,7 @@ bool smmuv3_accel_install_ste(SMMUv3State *s, SMMUDevice *sdev, int sid,
257 return true;
258 }
259
260 - idev = accel_dev->idev;
260 + hiodi = accel_dev->hiodi;
261 if (!smmuv3_accel_alloc_vdev(accel_dev, sid, errp)) {
262 return false;
263 }
@@ -300,9 +300,9 @@ bool smmuv3_accel_install_ste(SMMUv3State *s, SMMUDevice *sdev, int sid,
300 return false;
301 }
302
303 - if (!host_iommu_device_iommufd_attach_hwpt(idev, hwpt_id, errp)) {
303 + if (!host_iommu_device_iommufd_attach_hwpt(hiodi, hwpt_id, errp)) {
304 if (s1_hwpt) {
305 - iommufd_backend_free_id(idev->iommufd, s1_hwpt->hwpt_id);
305 + iommufd_backend_free_id(hiodi->iommufd, s1_hwpt->hwpt_id);
306 g_free(s1_hwpt);
307 }
308 return false;
@@ -310,7 +310,7 @@ bool smmuv3_accel_install_ste(SMMUv3State *s, SMMUDevice *sdev, int sid,
310
311 /* Free the previous s1_hwpt */
312 if (accel_dev->s1_hwpt) {
313 - iommufd_backend_free_id(idev->iommufd, accel_dev->s1_hwpt->hwpt_id);
313 + iommufd_backend_free_id(hiodi->iommufd, accel_dev->s1_hwpt->hwpt_id);
314 g_free(accel_dev->s1_hwpt);
315 }
316
@@ -524,7 +524,7 @@ free_veventq:
524 }
525
526 static bool
527 -smmuv3_accel_alloc_viommu(SMMUv3State *s, HostIOMMUDeviceIOMMUFD *idev,
527 +smmuv3_accel_alloc_viommu(SMMUv3State *s, HostIOMMUDeviceIOMMUFD *hiodi,
528 Error **errp)
529 {
530 SMMUv3AccelState *accel = s->s_accel;
@@ -534,11 +534,11 @@ smmuv3_accel_alloc_viommu(SMMUv3State *s, HostIOMMUDeviceIOMMUFD *idev,
534 struct iommu_hwpt_arm_smmuv3 abort_data = {
535 .ste = { SMMU_STE_VALID, 0x0ULL },
536 };
537 - uint32_t s2_hwpt_id = idev->hwpt_id;
537 + uint32_t s2_hwpt_id = hiodi->hwpt_id;
538 uint32_t viommu_id, hwpt_id;
539 IOMMUFDViommu *viommu;
540
541 - if (!iommufd_backend_alloc_viommu(idev->iommufd, idev->devid,
541 + if (!iommufd_backend_alloc_viommu(hiodi->iommufd, hiodi->devid,
542 IOMMU_VIOMMU_TYPE_ARM_SMMUV3,
543 s2_hwpt_id, &viommu_id, errp)) {
544 return false;
@@ -547,21 +547,21 @@ smmuv3_accel_alloc_viommu(SMMUv3State *s, HostIOMMUDeviceIOMMUFD *idev,
547 viommu = g_new0(IOMMUFDViommu, 1);
548 viommu->viommu_id = viommu_id;
549 viommu->s2_hwpt_id = s2_hwpt_id;
550 - viommu->iommufd = idev->iommufd;
550 + viommu->iommufd = hiodi->iommufd;
551 accel->viommu = viommu;
552
553 /*
554 * Pre-allocate HWPTs for S1 bypass and abort cases. These will be attached
555 * later for guest STEs or GBPAs that require bypass or abort configuration.
556 */
557 - if (!iommufd_backend_alloc_hwpt(idev->iommufd, idev->devid, viommu_id,
557 + if (!iommufd_backend_alloc_hwpt(hiodi->iommufd, hiodi->devid, viommu_id,
558 0, IOMMU_HWPT_DATA_ARM_SMMUV3,
559 sizeof(abort_data), &abort_data,
560 &accel->abort_hwpt_id, errp)) {
561 goto free_viommu;
562 }
563
564 - if (!iommufd_backend_alloc_hwpt(idev->iommufd, idev->devid, viommu_id,
564 + if (!iommufd_backend_alloc_hwpt(hiodi->iommufd, hiodi->devid, viommu_id,
565 0, IOMMU_HWPT_DATA_ARM_SMMUV3,
566 sizeof(bypass_data), &bypass_data,
567 &accel->bypass_hwpt_id, errp)) {
@@ -575,7 +575,7 @@ smmuv3_accel_alloc_viommu(SMMUv3State *s, HostIOMMUDeviceIOMMUFD *idev,
575
576 /* Attach a HWPT based on SMMUv3 GBPA.ABORT value */
577 hwpt_id = smmuv3_accel_gbpa_hwpt(s, accel);
578 - if (!host_iommu_device_iommufd_attach_hwpt(idev, hwpt_id, errp)) {
578 + if (!host_iommu_device_iommufd_attach_hwpt(hiodi, hwpt_id, errp)) {
579 goto free_veventq;
580 }
581 return true;
@@ -583,11 +583,11 @@ smmuv3_accel_alloc_viommu(SMMUv3State *s, HostIOMMUDeviceIOMMUFD *idev,
583 free_veventq:
584 smmuv3_accel_free_veventq(accel);
585 free_bypass_hwpt:
586 - iommufd_backend_free_id(idev->iommufd, accel->bypass_hwpt_id);
586 + iommufd_backend_free_id(hiodi->iommufd, accel->bypass_hwpt_id);
587 free_abort_hwpt:
588 - iommufd_backend_free_id(idev->iommufd, accel->abort_hwpt_id);
588 + iommufd_backend_free_id(hiodi->iommufd, accel->abort_hwpt_id);
589 free_viommu:
590 - iommufd_backend_free_id(idev->iommufd, viommu->viommu_id);
590 + iommufd_backend_free_id(hiodi->iommufd, viommu->viommu_id);
591 g_free(viommu);
592 accel->viommu = NULL;
593 return false;
@@ -596,20 +596,20 @@ free_viommu:
596 static bool smmuv3_accel_set_iommu_device(PCIBus *bus, void *opaque, int devfn,
597 HostIOMMUDevice *hiod, Error **errp)
598 {
599 - HostIOMMUDeviceIOMMUFD *idev = HOST_IOMMU_DEVICE_IOMMUFD(hiod);
599 + HostIOMMUDeviceIOMMUFD *hiodi = HOST_IOMMU_DEVICE_IOMMUFD(hiod);
600 SMMUState *bs = opaque;
601 SMMUv3State *s = ARM_SMMUV3(bs);
602 SMMUPciBus *sbus = smmu_get_sbus(bs, bus);
603 SMMUv3AccelDevice *accel_dev = smmuv3_accel_get_dev(bs, sbus, bus, devfn);
604
605 - if (!idev) {
605 + if (!hiodi) {
606 return true;
607 }
608
609 - if (accel_dev->idev) {
610 - if (accel_dev->idev != idev) {
611 - error_setg(errp, "Device already has an associated idev 0x%x",
612 - idev->devid);
609 + if (accel_dev->hiodi) {
610 + if (accel_dev->hiodi != hiodi) {
611 + error_setg(errp, "Device already has an associated hiodi 0x%x",
612 + hiodi->devid);
613 return false;
614 }
615 return true;
@@ -619,7 +619,7 @@ static bool smmuv3_accel_set_iommu_device(PCIBus *bus, void *opaque, int devfn,
619 * Check the host SMMUv3 associated with the dev is compatible with the
620 * QEMU SMMUv3 accel.
621 */
622 - if (!smmuv3_accel_hw_compatible(s, idev, errp)) {
622 + if (!smmuv3_accel_hw_compatible(s, hiodi, errp)) {
623 return false;
624 }
625
@@ -627,17 +627,17 @@ static bool smmuv3_accel_set_iommu_device(PCIBus *bus, void *opaque, int devfn,
627 goto done;
628 }
629
630 - if (!smmuv3_accel_alloc_viommu(s, idev, errp)) {
631 - error_append_hint(errp, "Unable to alloc vIOMMU: idev devid 0x%x: ",
632 - idev->devid);
630 + if (!smmuv3_accel_alloc_viommu(s, hiodi, errp)) {
631 + error_append_hint(errp, "Unable to alloc vIOMMU: hiodi devid 0x%x: ",
632 + hiodi->devid);
633 return false;
634 }
635
636 done:
637 - accel_dev->idev = idev;
637 + accel_dev->hiodi = hiodi;
638 accel_dev->s_accel = s->s_accel;
639 QLIST_INSERT_HEAD(&s->s_accel->device_list, accel_dev, next);
640 - trace_smmuv3_accel_set_iommu_device(devfn, idev->devid);
640 + trace_smmuv3_accel_set_iommu_device(devfn, hiodi->devid);
641 return true;
642 }
643
@@ -646,7 +646,7 @@ static void smmuv3_accel_unset_iommu_device(PCIBus *bus, void *opaque,
646 {
647 SMMUState *bs = opaque;
648 SMMUPciBus *sbus = g_hash_table_lookup(bs->smmu_pcibus_by_busptr, bus);
649 - HostIOMMUDeviceIOMMUFD *idev;
649 + HostIOMMUDeviceIOMMUFD *hiodi;
650 SMMUv3AccelDevice *accel_dev;
651 SMMUv3AccelState *accel;
652 IOMMUFDVdev *vdev;
@@ -662,16 +662,16 @@ static void smmuv3_accel_unset_iommu_device(PCIBus *bus, void *opaque,
662 }
663
664 accel_dev = container_of(sdev, SMMUv3AccelDevice, sdev);
665 - idev = accel_dev->idev;
665 + hiodi = accel_dev->hiodi;
666 accel = accel_dev->s_accel;
667 /* Re-attach the default s2 hwpt id */
668 - if (!host_iommu_device_iommufd_attach_hwpt(idev, idev->hwpt_id, NULL)) {
669 - error_report("Unable to attach the default HW pagetable: idev devid "
670 - "0x%x", idev->devid);
668 + if (!host_iommu_device_iommufd_attach_hwpt(hiodi, hiodi->hwpt_id, NULL)) {
669 + error_report("Unable to attach the default HW pagetable: hiodi devid "
670 + "0x%x", hiodi->devid);
671 }
672
673 if (accel_dev->s1_hwpt) {
674 - iommufd_backend_free_id(accel_dev->idev->iommufd,
674 + iommufd_backend_free_id(accel_dev->hiodi->iommufd,
675 accel_dev->s1_hwpt->hwpt_id);
676 g_free(accel_dev->s1_hwpt);
677 accel_dev->s1_hwpt = NULL;
@@ -684,10 +684,10 @@ static void smmuv3_accel_unset_iommu_device(PCIBus *bus, void *opaque,
684 accel_dev->vdev = NULL;
685 }
686
687 - accel_dev->idev = NULL;
687 + accel_dev->hiodi = NULL;
688 accel_dev->s_accel = NULL;
689 QLIST_REMOVE(accel_dev, next);
690 - trace_smmuv3_accel_unset_iommu_device(devfn, idev->devid);
690 + trace_smmuv3_accel_unset_iommu_device(devfn, hiodi->devid);
691
692 if (QLIST_EMPTY(&accel->device_list)) {
693 smmuv3_accel_free_viommu(accel);
@@ -879,10 +879,11 @@ bool smmuv3_accel_attach_gbpa_hwpt(SMMUv3State *s, Error **errp)
879
880 hwpt_id = smmuv3_accel_gbpa_hwpt(s, accel);
881 QLIST_FOREACH(accel_dev, &accel->device_list, next) {
882 - if (!host_iommu_device_iommufd_attach_hwpt(accel_dev->idev, hwpt_id,
882 + if (!host_iommu_device_iommufd_attach_hwpt(accel_dev->hiodi, hwpt_id,
883 &local_err)) {
884 error_append_hint(&local_err, "Failed to attach GBPA hwpt %u for "
885 - "idev devid %u", hwpt_id, accel_dev->idev->devid);
885 + "hiodi devid %u", hwpt_id,
886 + accel_dev->hiodi->devid);
887 error_report_err(local_err);
888 local_err = NULL;
889 all_ok = false;
hw/arm/smmuv3-accel.h
+1 -1
@@ -34,7 +34,7 @@ typedef struct SMMUS1Hwpt {
34
35 typedef struct SMMUv3AccelDevice {
36 SMMUDevice sdev;
37 - HostIOMMUDeviceIOMMUFD *idev;
37 + HostIOMMUDeviceIOMMUFD *hiodi;
38 SMMUS1Hwpt *s1_hwpt;
39 IOMMUFDVdev *vdev;
40 QLIST_ENTRY(SMMUv3AccelDevice) next;
hw/i386/intel_iommu_accel.c
+23 -21
@@ -69,7 +69,7 @@ VTDHostIOMMUDevice *vtd_find_hiod_iommufd(VTDAddressSpace *as)
69 return NULL;
70 }
71
72 -static bool vtd_create_fs_hwpt(HostIOMMUDeviceIOMMUFD *idev,
72 +static bool vtd_create_fs_hwpt(HostIOMMUDeviceIOMMUFD *hiodi,
73 VTDPASIDEntry *pe, uint32_t *fs_hwpt_id,
74 Error **errp)
75 {
@@ -81,27 +81,27 @@ static bool vtd_create_fs_hwpt(HostIOMMUDeviceIOMMUFD *idev,
81 vtd.addr_width = vtd_pe_get_fs_aw(pe);
82 vtd.pgtbl_addr = (uint64_t)vtd_pe_get_fspt_base(pe);
83
84 - return iommufd_backend_alloc_hwpt(idev->iommufd, idev->devid, idev->hwpt_id,
85 - 0, IOMMU_HWPT_DATA_VTD_S1, sizeof(vtd),
86 - &vtd, fs_hwpt_id, errp);
84 + return iommufd_backend_alloc_hwpt(hiodi->iommufd, hiodi->devid,
85 + hiodi->hwpt_id, 0, IOMMU_HWPT_DATA_VTD_S1,
86 + sizeof(vtd), &vtd, fs_hwpt_id, errp);
87 }
88
89 -static void vtd_destroy_old_fs_hwpt(HostIOMMUDeviceIOMMUFD *idev,
89 +static void vtd_destroy_old_fs_hwpt(HostIOMMUDeviceIOMMUFD *hiodi,
90 VTDAddressSpace *vtd_as)
91 {
92 if (!vtd_as->fs_hwpt_id) {
93 return;
94 }
95 - iommufd_backend_free_id(idev->iommufd, vtd_as->fs_hwpt_id);
95 + iommufd_backend_free_id(hiodi->iommufd, vtd_as->fs_hwpt_id);
96 vtd_as->fs_hwpt_id = 0;
97 }
98
99 static bool vtd_device_attach_iommufd(VTDHostIOMMUDevice *vtd_hiod,
100 VTDAddressSpace *vtd_as, Error **errp)
101 {
102 - HostIOMMUDeviceIOMMUFD *idev = HOST_IOMMU_DEVICE_IOMMUFD(vtd_hiod->hiod);
102 + HostIOMMUDeviceIOMMUFD *hiodi = HOST_IOMMU_DEVICE_IOMMUFD(vtd_hiod->hiod);
103 VTDPASIDEntry *pe = &vtd_as->pasid_cache_entry.pasid_entry;
104 - uint32_t hwpt_id = idev->hwpt_id;
104 + uint32_t hwpt_id = hiodi->hwpt_id;
105 bool ret;
106
107 /*
@@ -116,21 +116,21 @@ static bool vtd_device_attach_iommufd(VTDHostIOMMUDevice *vtd_hiod,
116 }
117
118 if (vtd_pe_pgtt_is_fst(pe)) {
119 - if (!vtd_create_fs_hwpt(idev, pe, &hwpt_id, errp)) {
119 + if (!vtd_create_fs_hwpt(hiodi, pe, &hwpt_id, errp)) {
120 return false;
121 }
122 }
123
124 - ret = host_iommu_device_iommufd_attach_hwpt(idev, hwpt_id, errp);
125 - trace_vtd_device_attach_hwpt(idev->devid, vtd_as->pasid, hwpt_id, ret);
124 + ret = host_iommu_device_iommufd_attach_hwpt(hiodi, hwpt_id, errp);
125 + trace_vtd_device_attach_hwpt(hiodi->devid, vtd_as->pasid, hwpt_id, ret);
126 if (ret) {
127 /* Destroy old fs_hwpt if it's a replacement */
128 - vtd_destroy_old_fs_hwpt(idev, vtd_as);
128 + vtd_destroy_old_fs_hwpt(hiodi, vtd_as);
129 if (vtd_pe_pgtt_is_fst(pe)) {
130 vtd_as->fs_hwpt_id = hwpt_id;
131 }
132 } else if (vtd_pe_pgtt_is_fst(pe)) {
133 - iommufd_backend_free_id(idev->iommufd, hwpt_id);
133 + iommufd_backend_free_id(hiodi->iommufd, hwpt_id);
134 }
135
136 return ret;
@@ -139,27 +139,28 @@ static bool vtd_device_attach_iommufd(VTDHostIOMMUDevice *vtd_hiod,
139 static bool vtd_device_detach_iommufd(VTDHostIOMMUDevice *vtd_hiod,
140 VTDAddressSpace *vtd_as, Error **errp)
141 {
142 - HostIOMMUDeviceIOMMUFD *idev = HOST_IOMMU_DEVICE_IOMMUFD(vtd_hiod->hiod);
142 + HostIOMMUDeviceIOMMUFD *hiodi = HOST_IOMMU_DEVICE_IOMMUFD(vtd_hiod->hiod);
143 IntelIOMMUState *s = vtd_as->iommu_state;
144 uint32_t pasid = vtd_as->pasid;
145 bool ret;
146
147 if (s->dmar_enabled && s->root_scalable) {
148 - ret = host_iommu_device_iommufd_detach_hwpt(idev, errp);
149 - trace_vtd_device_detach_hwpt(idev->devid, pasid, ret);
148 + ret = host_iommu_device_iommufd_detach_hwpt(hiodi, errp);
149 + trace_vtd_device_detach_hwpt(hiodi->devid, pasid, ret);
150 } else {
151 /*
152 * If DMAR remapping is disabled or guest switches to legacy mode,
153 * we fallback to the default HWPT which contains shadow page table.
154 * So guest DMA could still work.
155 */
156 - ret = host_iommu_device_iommufd_attach_hwpt(idev, idev->hwpt_id, errp);
157 - trace_vtd_device_reattach_def_hwpt(idev->devid, pasid, idev->hwpt_id,
156 + ret = host_iommu_device_iommufd_attach_hwpt(hiodi, hiodi->hwpt_id,
157 + errp);
158 + trace_vtd_device_reattach_def_hwpt(hiodi->devid, pasid, hiodi->hwpt_id,
159 ret);
160 }
161
162 if (ret) {
162 - vtd_destroy_old_fs_hwpt(idev, vtd_as);
163 + vtd_destroy_old_fs_hwpt(hiodi, vtd_as);
164 }
165
166 return ret;
@@ -211,13 +212,14 @@ static void vtd_flush_host_piotlb_locked(gpointer key, gpointer value,
212 did = VTD_SM_PASID_ENTRY_DID(&pc_entry->pasid_entry);
213
214 if (piotlb_info->domain_id == did && piotlb_info->pasid == PASID_0) {
214 - HostIOMMUDeviceIOMMUFD *idev =
215 + HostIOMMUDeviceIOMMUFD *hiodi =
216 HOST_IOMMU_DEVICE_IOMMUFD(vtd_hiod->hiod);
217 uint32_t entry_num = 1; /* Only implement one request for simplicity */
218 Error *local_err = NULL;
219 struct iommu_hwpt_vtd_s1_invalidate *cache = piotlb_info->inv_data;
220
220 - if (!iommufd_backend_invalidate_cache(idev->iommufd, vtd_as->fs_hwpt_id,
221 + if (!iommufd_backend_invalidate_cache(hiodi->iommufd,
222 + vtd_as->fs_hwpt_id,
223 IOMMU_HWPT_INVALIDATE_DATA_VTD_S1,
224 sizeof(*cache), &entry_num, cache,
225 &local_err)) {
hw/vfio/container-legacy.c
+5 -5
@@ -1244,12 +1244,12 @@ static void vfio_iommu_legacy_instance_init(Object *obj)
1244
1245 static void hiod_legacy_vfio_class_init(ObjectClass *oc, const void *data)
1246 {
1247 - HostIOMMUDeviceClass *hioc = HOST_IOMMU_DEVICE_CLASS(oc);
1247 + HostIOMMUDeviceClass *hiodc = HOST_IOMMU_DEVICE_CLASS(oc);
1248
1249 - hioc->realize = hiod_legacy_vfio_realize;
1250 - hioc->get_cap = hiod_legacy_vfio_get_cap;
1251 - hioc->get_iova_ranges = hiod_legacy_vfio_get_iova_ranges;
1252 - hioc->get_page_size_mask = hiod_legacy_vfio_get_page_size_mask;
1249 + hiodc->realize = hiod_legacy_vfio_realize;
1250 + hiodc->get_cap = hiod_legacy_vfio_get_cap;
1251 + hiodc->get_iova_ranges = hiod_legacy_vfio_get_iova_ranges;
1252 + hiodc->get_page_size_mask = hiod_legacy_vfio_get_page_size_mask;
1253 };
1254
1255 static const TypeInfo types[] = {
hw/vfio/iommufd.c
+12 -12
@@ -917,19 +917,19 @@ static void vfio_iommu_iommufd_class_init(ObjectClass *klass, const void *data)
917 };
918
919 static bool
920 -host_iommu_device_iommufd_vfio_attach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
920 +host_iommu_device_iommufd_vfio_attach_hwpt(HostIOMMUDeviceIOMMUFD *hiodi,
921 uint32_t hwpt_id, Error **errp)
922 {
923 - VFIODevice *vbasedev = HOST_IOMMU_DEVICE(idev)->agent;
923 + VFIODevice *vbasedev = HOST_IOMMU_DEVICE(hiodi)->agent;
924
925 return !iommufd_cdev_attach_ioas_hwpt(vbasedev, hwpt_id, errp);
926 }
927
928 static bool
929 -host_iommu_device_iommufd_vfio_detach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
929 +host_iommu_device_iommufd_vfio_detach_hwpt(HostIOMMUDeviceIOMMUFD *hiodi,
930 Error **errp)
931 {
932 - VFIODevice *vbasedev = HOST_IOMMU_DEVICE(idev)->agent;
932 + VFIODevice *vbasedev = HOST_IOMMU_DEVICE(hiodi)->agent;
933
934 return iommufd_cdev_detach_ioas_hwpt(vbasedev, errp);
935 }
@@ -938,7 +938,7 @@ static bool hiod_iommufd_vfio_realize(HostIOMMUDevice *hiod, void *opaque,
938 Error **errp)
939 {
940 VFIODevice *vdev = opaque;
941 - HostIOMMUDeviceIOMMUFD *idev;
941 + HostIOMMUDeviceIOMMUFD *hiodi;
942 HostIOMMUDeviceCaps *caps = &hiod->caps;
943 VendorCaps *vendor_caps = &caps->vendor_caps;
944 enum iommu_hw_info_type type;
@@ -958,10 +958,10 @@ static bool hiod_iommufd_vfio_realize(HostIOMMUDevice *hiod, void *opaque,
958 caps->hw_caps = hw_caps;
959 caps->max_pasid_log2 = max_pasid_log2;
960
961 - idev = HOST_IOMMU_DEVICE_IOMMUFD(hiod);
962 - idev->iommufd = vdev->iommufd;
963 - idev->devid = vdev->devid;
964 - idev->hwpt_id = vdev->hwpt->hwpt_id;
961 + hiodi = HOST_IOMMU_DEVICE_IOMMUFD(hiod);
962 + hiodi->iommufd = vdev->iommufd;
963 + hiodi->devid = vdev->devid;
964 + hiodi->hwpt_id = vdev->hwpt->hwpt_id;
965
966 return true;
967 }
@@ -988,14 +988,14 @@ hiod_iommufd_vfio_get_page_size_mask(HostIOMMUDevice *hiod)
988 static void hiod_iommufd_vfio_class_init(ObjectClass *oc, const void *data)
989 {
990 HostIOMMUDeviceClass *hiodc = HOST_IOMMU_DEVICE_CLASS(oc);
991 - HostIOMMUDeviceIOMMUFDClass *idevc = HOST_IOMMU_DEVICE_IOMMUFD_CLASS(oc);
991 + HostIOMMUDeviceIOMMUFDClass *hiodic = HOST_IOMMU_DEVICE_IOMMUFD_CLASS(oc);
992
993 hiodc->realize = hiod_iommufd_vfio_realize;
994 hiodc->get_iova_ranges = hiod_iommufd_vfio_get_iova_ranges;
995 hiodc->get_page_size_mask = hiod_iommufd_vfio_get_page_size_mask;
996
997 - idevc->attach_hwpt = host_iommu_device_iommufd_vfio_attach_hwpt;
998 - idevc->detach_hwpt = host_iommu_device_iommufd_vfio_detach_hwpt;
997 + hiodic->attach_hwpt = host_iommu_device_iommufd_vfio_attach_hwpt;
998 + hiodic->detach_hwpt = host_iommu_device_iommufd_vfio_detach_hwpt;
999 };
1000
1001 static const TypeInfo types[] = {
include/system/iommufd.h
+6 -6
@@ -136,7 +136,7 @@ struct HostIOMMUDeviceIOMMUFDClass {
136 *
137 * Mandatory callback.
138 *
139 - * @idev: host IOMMU device backed by IOMMUFD backend.
139 + * @hiodi: host IOMMU device backed by IOMMUFD backend.
140 *
141 * @hwpt_id: ID of IOMMUFD hardware page table.
142 *
@@ -144,7 +144,7 @@ struct HostIOMMUDeviceIOMMUFDClass {
144 *
145 * Returns: true on success, false on failure.
146 */
147 - bool (*attach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, uint32_t hwpt_id,
147 + bool (*attach_hwpt)(HostIOMMUDeviceIOMMUFD *hiodi, uint32_t hwpt_id,
148 Error **errp);
149 /**
150 * @detach_hwpt: detach host IOMMU device from IOMMUFD hardware page table.
@@ -152,17 +152,17 @@ struct HostIOMMUDeviceIOMMUFDClass {
152 *
153 * Mandatory callback.
154 *
155 - * @idev: host IOMMU device backed by IOMMUFD backend.
155 + * @hiodi: host IOMMU device backed by IOMMUFD backend.
156 *
157 * @errp: pass an Error out when attachment fails.
158 *
159 * Returns: true on success, false on failure.
160 */
161 - bool (*detach_hwpt)(HostIOMMUDeviceIOMMUFD *idev, Error **errp);
161 + bool (*detach_hwpt)(HostIOMMUDeviceIOMMUFD *hiodi, Error **errp);
162 };
163
164 -bool host_iommu_device_iommufd_attach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
164 +bool host_iommu_device_iommufd_attach_hwpt(HostIOMMUDeviceIOMMUFD *hiodi,
165 uint32_t hwpt_id, Error **errp);
166 -bool host_iommu_device_iommufd_detach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
166 +bool host_iommu_device_iommufd_detach_hwpt(HostIOMMUDeviceIOMMUFD *hiodi,
167 Error **errp);
168 #endif