Hi Eric, >-----Original Message----- >From: Eric Auger <eric.au...@redhat.com> >Sent: Tuesday, May 6, 2025 12:15 AM >To: Cédric Le Goater <c...@redhat.com>; Duan, Zhenzhong ><zhenzhong.d...@intel.com>; qemu-devel@nongnu.org >Cc: alex.william...@redhat.com; nicol...@nvidia.com; >joao.m.mart...@oracle.com; Peng, Chao P <chao.p.p...@intel.com>; Liu, Yi L ><yi.l....@intel.com> >Subject: Re: [PATCH 1/5] vfio/iommufd: Save host iommu capabilities in >VFIODevice.caps > >Hi Zhenzhong, > >On 4/11/25 1:28 PM, Cédric Le Goater wrote: >> On 4/11/25 12:17, Zhenzhong Duan wrote: >>> 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édric Le Goater <c...@redhat.com> >>> Suggested-by: Eric Auger <eric.au...@redhat.com> >>> Suggested-by: Nicolin Chen <nicol...@nvidia.com> >>> Signed-off-by: Zhenzhong Duan <zhenzhong.d...@intel.com> >>> --- >>> 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; >> >> IMO, these capabilities belong to HostIOMMUDevice and not VFIODevice. >I do agree with Cédric that it looks a wrong place to put this caps. I >feel this somehow breaks the abstraction layering.
This change was dropped in "[PATCH v2 0/5] vfio: Move realize after attach_dev". > >Now "[PATCH v2 0/5] vfio: Move realize after attach_dev" has landed, I >think it would help if you could respin with a clear functional goal >such as the one targeted in[PATCH v2 0/5] Check host IOMMU compatilibity >with vIOMMU ><https://lore.kernel.org/all/20240408084404.1111628-1- >zhenzhong.d...@intel.com/> See a rfcv3 candidate at link https://github.com/yiliu1765/qemu/commits/zhenzhong/iommufd_nesting_rfcv3.wip/ for example implementation. In this example, I used .get_cap() interface for vIOMMU to get cap. vIOMMU could also access HostIOMMUDevice::HostIOMMUDeviceCaps directly as it's passed from VFIO to vIOMMU along with HostIOMMUDevice. Thanks Zhenzhong