Hi, This introduces a framework for vIOMMU to get hw IOMMU cap/ecap information through IOMMUFD interface and check or sync with vIOMMU's own cap/ecap config.
This framework works by having device side, i.e. VFIO, register a IOMMUFDDevice to vIOMMU, IOMMUFDDevice includes necessary data to archive that. Currently only VFIO device is supported, but it could also be used for other devices, i.e., VDPA. This is also a prerequisite for incoming iommufd nesting series: 'intel_iommu: Enable stage-1 translation'. PATCH1-4: initialize IOMMUFDDevice and pass to vIOMMU PATCH5-6: cap/ecap sync mechanism between host IOMMU and vIOMMU Qemu code can be found at: https://github.com/yiliu1765/qemu/tree/zhenzhong/iommufd_nesting_preq_rfcv1 Thanks Zhenzhong Yi Liu (3): hw/pci: introduce pci_device_set/unset_iommu_device() intel_iommu: add set/unset_iommu_device callback intel_iommu: add a framework to check and sync host IOMMU cap/ecap Zhenzhong Duan (3): backends/iommufd_device: introduce IOMMUFDDevice vfio: initialize IOMMUFDDevice and pass to vIOMMU intel_iommu: extract out vtd_cap_init to initialize cap/ecap MAINTAINERS | 4 +- include/hw/i386/intel_iommu.h | 14 ++ include/hw/pci/pci.h | 39 +++++- include/hw/vfio/vfio-common.h | 2 + include/sysemu/iommufd_device.h | 31 +++++ backends/iommufd_device.c | 50 +++++++ hw/i386/intel_iommu.c | 239 ++++++++++++++++++++++++++------ hw/pci/pci.c | 49 ++++++- hw/vfio/iommufd.c | 2 + hw/vfio/pci.c | 24 +++- backends/meson.build | 2 +- 11 files changed, 402 insertions(+), 54 deletions(-) create mode 100644 include/sysemu/iommufd_device.h create mode 100644 backends/iommufd_device.c -- 2.34.1