Implement get_host_iommu_quirks() callback to retrieve the vendor specific hardware information data and convert it into bitmaps defined with enum host_iommu_quirks. It will be used by VFIO in subsequent patch.
Suggested-by: Eric Auger <[email protected]> Suggested-by: Nicolin Chen <[email protected]> Signed-off-by: Zhenzhong Duan <[email protected]> --- hw/i386/intel_iommu_accel.h | 5 +++++ hw/i386/intel_iommu.c | 2 ++ hw/i386/intel_iommu_accel.c | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/hw/i386/intel_iommu_accel.h b/hw/i386/intel_iommu_accel.h index 76862310c2..c7ad6daa87 100644 --- a/hw/i386/intel_iommu_accel.h +++ b/hw/i386/intel_iommu_accel.h @@ -20,6 +20,7 @@ bool vtd_bind_guest_pasid(VTDAddressSpace *vtd_as, Error **errp); void vtd_flush_host_piotlb_all_locked(IntelIOMMUState *s, uint16_t domain_id, uint32_t pasid, hwaddr addr, uint64_t npages, bool ih); +void vtd_iommu_ops_update_accel(PCIIOMMUOps *ops); #else static inline bool vtd_check_hiod_accel(IntelIOMMUState *s, VTDHostIOMMUDevice *vtd_hiod, @@ -46,5 +47,9 @@ static inline void vtd_flush_host_piotlb_all_locked(IntelIOMMUState *s, uint64_t npages, bool ih) { } + +static inline void vtd_iommu_ops_update_accel(PCIIOMMUOps *ops) +{ +} #endif #endif diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 269b7da958..33ed11e207 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -5590,6 +5590,8 @@ static void vtd_class_init(ObjectClass *klass, const void *data) x86_class->int_remap = vtd_int_remap; set_bit(DEVICE_CATEGORY_MISC, dc->categories); dc->desc = "Intel IOMMU (VT-d) DMA Remapping device"; + + vtd_iommu_ops_update_accel(&vtd_iommu_ops); } static const TypeInfo vtd_info = { diff --git a/hw/i386/intel_iommu_accel.c b/hw/i386/intel_iommu_accel.c index 41d0e4107b..700284864d 100644 --- a/hw/i386/intel_iommu_accel.c +++ b/hw/i386/intel_iommu_accel.c @@ -12,6 +12,7 @@ #include "system/iommufd.h" #include "intel_iommu_internal.h" #include "intel_iommu_accel.h" +#include "hw/iommu.h" #include "hw/pci/pci_bus.h" #include "trace.h" @@ -251,3 +252,23 @@ void vtd_flush_host_piotlb_all_locked(IntelIOMMUState *s, uint16_t domain_id, g_hash_table_foreach(s->vtd_address_spaces, vtd_flush_host_piotlb_locked, &piotlb_info); } + +static uint64_t vtd_get_host_iommu_quirks(uint32_t type, + void *caps, uint32_t size) +{ + struct iommu_hw_info_vtd *vtd = caps; + uint64_t quirks = 0; + + if (type == IOMMU_HW_INFO_TYPE_INTEL_VTD && + sizeof(struct iommu_hw_info_vtd) <= size && + vtd->flags & IOMMU_HW_INFO_VTD_ERRATA_772415_SPR17) { + quirks |= HOST_IOMMU_QUIRK_NESTING_PARENT_BYPASS_RO; + } + + return quirks; +} + +void vtd_iommu_ops_update_accel(PCIIOMMUOps *ops) +{ + ops->get_host_iommu_quirks = vtd_get_host_iommu_quirks; +} -- 2.47.1
