>-----Original Message----- >From: Cédric Le Goater <[email protected]> >Subject: Re: [PATCH v7 10/23] intel_iommu: Check for compatibility with >IOMMUFD backed device when x-flts=on > >On 10/24/25 10:43, Zhenzhong Duan wrote: >> When vIOMMU is configured x-flts=on in scalable mode, first stage page >table >> is passed to host to construct nested page table for passthrough devices. >> >> We need to check compatibility of some critical IOMMU capabilities >between >> vIOMMU and host IOMMU to ensure guest first stage page table could be >used by >> host. >> >> For instance, vIOMMU supports first stage 1GB large page mapping, but >host does >> not, then this IOMMUFD backed device should fail. >> >> Even of the checks pass, for now we willingly reject the association because >> all the bits are not there yet, it will be relaxed in the end of this series. >> >> Note vIOMMU has exposed IOMMU_HWPT_ALLOC_NEST_PARENT flag to >force VFIO core to >> create nesting parent HWPT, if host doesn't support nested translation, the >> creation will fail. So no need to check nested capability here. >> >> Reviewed-by: Yi Liu <[email protected]> >> Signed-off-by: Zhenzhong Duan <[email protected]> >> Reviewed-by: Eric Auger <[email protected]> >> --- >> hw/i386/intel_iommu.c | 25 ++++++++++++++++++++++++- >> 1 file changed, 24 insertions(+), 1 deletion(-) >> >> diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c >> index ce4c54165e..7d908cdb58 100644 >> --- a/hw/i386/intel_iommu.c >> +++ b/hw/i386/intel_iommu.c >> @@ -4636,8 +4636,31 @@ static bool vtd_check_hiod(IntelIOMMUState *s, >HostIOMMUDevice *hiod, >> return true; >> } >> >> +#ifdef CONFIG_IOMMUFD > > >Before using CONFIG_IOMMUFD, '#include CONFIG_DEVICES' should be done >first. But as said earlier, this is something we wanted to avoid in the >intel-iommu model which can have different host IOMMU backends.
Ah, yes, should have '#include CONFIG_DEVICES' in this patch. > >At first glance, it seems to me that these changes take the fast path >and avoid an abstract layer. Is it too complex to keep on using >HostIOMMUDeviceClass ? It looks question in patch13 is same as here, so reply all here. We can benefit from exposing IOMMUFD in vIOMMU, because in foreseeable future, it's the only backend supporting nested HWPT, it's straightforward for vIOMMU to create nested HWPT and do attachment through IOMMUFD. Most of the code guarded by CONFIG_IOMMUFD are cooperation between vIOMMU and IOMMUFD backend, it's hard to abstract them with comon callbacks into VFIO, we need to take both vtd and smmu into consideration. We are using HostIOMMUDevice whenever suitable, it's used as a connection between VFIO and vIOMMU, we do capability check and call attach/detach_dev callback through it. Thanks Zhenzhong
