On Thu, May 29, 2025 at 06:46:20AM +0000, Duan, Zhenzhong wrote:
> >Looking at the kernel iommufd_hwpt_invalidate() routine and
> >intel_nested_cache_invalidate_user(), it doesn't seem possible to
> >return a different number of cache entries. Are you anticipating
> >other implementations (sMMU) ?
> 
> Yes, same for sMMU's arm_vsmmu_cache_invalidate() and selftest's
> mock_viommu_cache_invalidate() and mock_domain_cache_invalidate_user().
> 
> I'm not sure if this should apply to all types of IOMMUs, uAPI doc doesn't 
> talk about it.

It should. The uAPI defines that at entry_num:
 * struct iommu_hwpt_invalidate - ioctl(IOMMU_HWPT_INVALIDATE)
 ...
 * @entry_num: Input the number of cache invalidation requests in the array.
 *             Output the number of requests successfully handled by kernel.

This applies to either ret != 0 case too.

> @Liu, Yi L, @nicol...@nvidia.com, @Jason Gunthorpe, should I treat ret = 0
> and total_entries != cache.entry_num as a kernel bug or not?

Selftest has that coverage, so it would be a kernel bug that will
unlikely occur. That being said, it doesn't hurt to do that IMHO.

Thanks
Nicolin

Reply via email to