linux/drivers/iommu/generic_pt
Shuai Xue 41cdc2a3d4 iommupt: Return zero for invalid iova_to_phys() ranges
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: 9d4c274cd7 ("iommupt: Add iova_to_phys op")
Cc: stable@vger.kernel.org
Assisted-by: Qoder:Qwen-3.8-MAX-Preview
Signed-off-by: Shuai Xue <xueshuai@linux.alibaba.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2026-08-10 09:51:52 +02:00
..
fmt Merge branches 'apple/dart', 'arm/smmu/updates', 'arm/smmu/bindings', 'rockchip', 'verisilicon', 'riscv', 'intel/vt-d', 'amd/amd-vi' and 'core' into next 2026-06-12 14:57:23 +02:00
.kunitconfig iommupt: Add the RISC-V page table format 2026-03-17 13:14:21 +01:00
iommu_pt.h iommupt: Return zero for invalid iova_to_phys() ranges 2026-08-10 09:51:52 +02:00
Kconfig iommupt: Add the RISC-V page table format 2026-03-17 13:14:21 +01:00
kunit_generic_pt.h iommu_pt: Fix pgsize_bitmap calculation in get_info for smaller vasz's 2026-05-19 10:49:02 +02:00
kunit_iommu_pt.h iommu_pt: add kunit config for 32-bit VA (amdv1_cfg_1) 2026-05-19 10:49:03 +02:00
kunit_iommu.h iommu/iommupt: Fix build error in genericpt unit-tests 2025-11-07 16:06:19 +01:00
pt_common.h iommupt: Actually correct pt_test_sw_bit_{acquire_release}() parameter description 2025-11-17 09:46:22 +01:00
pt_defs.h iommupt: Make pt_feature() always_inline 2026-01-10 10:50:45 +01:00
pt_fmt_defaults.h iommupt: Add basic support for SW bits in the page table 2025-11-05 09:47:44 +01:00
pt_iter.h iommupt: Avoid rewalking during map 2026-03-17 13:57:40 +01:00
pt_log2.h