On Wed, Jul 09, 2025 at 03:38:49AM +0000, Duan, Zhenzhong wrote: > >> +enum { > >> + VIOMMU_CAP_STAGE1 = BIT_ULL(0), /* stage1 page table > >supported */ > >> +}; > > > >Thanks for this work. I am happy to see that we can share the > >common code that allocates a NESTING_PARENT in the core using > >this flag. > > > >Yet on ARM, a STAGE1 page table isn't always a nested S1, the > >hardware accelerated one. More often, it can be just a regular > >1-stage translation table via emulated translation code and an > >emulated iotlb. > > What to return for an emulated device, VIOMMU_CAP_NESTED_S1 or 0?
It would be ideally 0, since the get_viommu_cap is a per VFIO/PCI device op. But I see the caller of pci_device_get_viommu_cap() in this series has already done the identification between "emulated" and "passthrough" devices? That being said, it doesn't hurt to run it again in the callback function. > >I think this flag should indicate that the vIOMMU supports a > >HW-accelerated nested S1 HWPT allocation/invalidation. > > I'm OK to use VIOMMU_CAP_NESTED_S1 name. But still unclear which > checks should we have in .get_viommu_cap() callback to determine > returning VIOMMU_CAP_NESTED_S1 or not, > as we know nesting support is determined by host IOMMU not vIOMMU. I would say it's determined by both the host and vIOMMU. This is a common API that may return other caps too: eventually there can be a case where vIOMMU has its get_viommu_cap callback function but doesn't implement HW nesting via iommufd, even if the host IOMMU driver supports nesting. Thanks Nicolin