On Fri, May 30, 2025 at 05:35:10PM +0800, Zhenzhong Duan wrote: > Enhance HostIOMMUDeviceIOMMUFD object with 3 new members, specific > to the iommufd BE + 2 new class functions. > > IOMMUFD BE includes IOMMUFD handle, devid and hwpt_id. IOMMUFD handle > and devid are used to allocate/free ioas and hwpt. hwpt_id is used to > re-attach IOMMUFD backed device to its default VFIO sub-system created > hwpt, i.e., when vIOMMU is disabled by guest. These properties are > initialized in hiod::realize() after attachment. > > 2 new class functions are [at|de]tach_hwpt(). They are used to > attach/detach hwpt. VFIO and VDPA can have different implementions, > so implementation will be in sub-class instead of HostIOMMUDeviceIOMMUFD, > e.g., in HostIOMMUDeviceIOMMUFDVFIO.
You mean HostIOMMUDeviceVFIO and HostIOMMUDeviceVDPA? I wonder what are the difference between their implementations. Main reason for asking this is that we have alloc_hwpt (and will have alloc_viommu soon) too, and should that/those be a part of the Class op(s) too? > @@ -833,6 +834,11 @@ static bool hiod_iommufd_vfio_realize(HostIOMMUDevice > *hiod, void *opaque, > caps->type = type; > caps->hw_caps = hw_caps; > > + idev = HOST_IOMMU_DEVICE_IOMMUFD(hiod); > + idev->iommufd = vdev->iommufd; > + idev->devid = vdev->devid; > + idev->hwpt_id = vdev->hwpt->hwpt_id; Since it's the default hwpt that VFIO contain allocated, perhaps it's better to call it default_hwpt_id, indicating that won't be changed by further HWPT attachment. Thanks Nicolin