RE: [PATCH 4/4] iommupt: Return zero for invalid iova_to_phys() ranges

"Tian, Kevin" <[email protected]> Mon, 27 Jul 2026 09:39:29 +0000
Newsgroups dev.linux.lists.iommu,org.kernel.vger.linux-kernel
Message-ID <CO1PR11MB4835DF2133EFB4401292483C8CCC2@CO1PR11MB4835.namprd11.prod.outlook.com>
> From: Shuai Xue <[email protected]>
> Sent: Sunday, July 26, 2026 3:44 PM
> 
> DOMAIN_NS(iova_to_phys) returns a phys_addr_t and follows the IOMMU
> iova_to_phys() convention of returning 0 when there is no valid
> translation.
> 
> make_range() returns a negative errno if the input IOVA cannot be
> represented by this page table format. Returning that errno directly
> casts it to phys_addr_t. Callers treat zero as no translation and use
> non-zero values as physical addresses, so this can make them consume a
> bogus physical address instead of seeing a failed translation.
> 
> Match the page-table walk failure path and return 0 for range validation
> failures too.
> 
> Fixes: 9d4c274cd7d5 ("iommupt: Add iova_to_phys op")
> Cc: [email protected]
> Assisted-by: Qoder:Qwen-3.8-MAX-Preview
> Signed-off-by: Shuai Xue <[email protected]>

Reviewed-by: Kevin Tian <[email protected]>