>-----Original Message----- >From: Liu, Yi L <[email protected]> >Subject: Re: [PATCH v4 03/15] vfio/iommufd: Create nesting parent hwpt with >IOMMU_HWPT_ALLOC_PASID flag > >On 4/30/26 15:12, Zhenzhong Duan wrote: >> When both device and vIOMMU have PASID enabled, then guest may setup >> pasid attached translation. > >s/pasid attached translation/pasid usages such as SVM/
Will do. > >> VFIO needs to be aware of potential pasid usage and should attach the >> non-pasid part of pasid-capable device to hwpt flagged with >> IOMMU_HWPT_ALLOC_PASID. >> >> ARM SMMU doesn't support IOMMU_HWPT_ALLOC_PASID, only VTD need it. So >> we can't check the existing vIOMMU flag VIOMMU_FLAG_PASID_SUPPORTED to >> determine if set flag IOMMU_HWPT_ALLOC_PASID. Instead, introduce a new >> flag VIOMMU_FLAG_WANT_PASID_ATTACH which will only be exposed by VTD. >> >> Opportunistically add documentation for VIOMMU_FLAG_PASID_SUPPORTED >> and explain the difference with VIOMMU_FLAG_WANT_PASID_ATTACH. >> >> Signed-off-by: Zhenzhong Duan <[email protected]> >> Reviewed-by: Yi Liu <[email protected]> >> Tested-by: Xudong Hao <[email protected]> >> --- >> include/hw/core/iommu.h | 11 +++++++++++ >> include/hw/vfio/vfio-device.h | 1 + >> hw/vfio/device.c | 11 +++++++++++ >> hw/vfio/iommufd.c | 8 +++++++- >> 4 files changed, 30 insertions(+), 1 deletion(-) >> >> diff --git a/include/hw/core/iommu.h b/include/hw/core/iommu.h >> index 77739d4214..20d6d79062 100644 >> --- a/include/hw/core/iommu.h >> +++ b/include/hw/core/iommu.h >> @@ -20,9 +20,20 @@ >> enum viommu_flags { >> /* vIOMMU needs nesting parent HWPT to create nested HWPT */ >> VIOMMU_FLAG_WANT_NESTING_PARENT = BIT_ULL(0), >> + /* >> + * vIOMMU supports PASID capability, VFIO checks this flag and >> synthesize >> + * a PASID capability. >> + */ >> VIOMMU_FLAG_PASID_SUPPORTED = BIT_ULL(1), >> /* vIOMMU needs dirty tracking on the nesting parent HWPT for nested >> use >*/ >> VIOMMU_FLAG_WANT_NESTING_DIRTY_TRACKING = BIT_ULL(2), >> + /* >> + * vIOMMU requests other sub-system like VFIO to create a HWPT that can >be >> + * used with PASID attachment. VIOMMU_FLAG_PASID_SUPPORTED can't be >used >> + * for this purpose as PASID attachment is needed by VTD IOMMU but not >ARM >> + * SMMU. >> + */ >> + VIOMMU_FLAG_WANT_PASID_ATTACH = BIT_ULL(3), > >instead of having a flag, is there any chance to let vfio check the >struct iommu_hw_info::type? It appears that only >IOMMU_HW_INFO_TYPE_INTEL_VTD has explicit pasid attach. I remember Cedric didn't like vendor specific code in this common file😊 The other reason is this could be easily extended to other iommu which need pasid attach in future. Thanks Zhenzhong
