diff options
| author | Jason Gunthorpe <jgg@nvidia.com> | 2024-08-22 11:45:55 -0300 |
|---|---|---|
| committer | Joerg Roedel <jroedel@suse.de> | 2024-08-26 09:16:13 +0200 |
| commit | 6093cd582f8e027117a8d4ad5d129a1aacdc53d2 (patch) | |
| tree | 0c8881c408e46f556f6c9dca62c60a3051989039 /drivers/iommu/io-pgtable-arm.c | |
| parent | 996dc53ac289b81957aa70d62ccadc6986d26a87 (diff) | |
| download | linux-6093cd582f8e027117a8d4ad5d129a1aacdc53d2.tar.gz linux-6093cd582f8e027117a8d4ad5d129a1aacdc53d2.tar.bz2 linux-6093cd582f8e027117a8d4ad5d129a1aacdc53d2.zip | |
iommu: Do not return 0 from map_pages if it doesn't do anything
These three implementations of map_pages() all succeed if a mapping is
requested with no read or write. Since they return back to __iommu_map()
leaving the mapped output as 0 it triggers an infinite loop. Therefore
nothing is using no-access protection bits.
Further, VFIO and iommufd rely on iommu_iova_to_phys() to get back PFNs
stored by map, if iommu_map() succeeds but iommu_iova_to_phys() fails that
will create serious bugs.
Thus remove this never used "nothing to do" concept and just fail map
immediately.
Fixes: e5fc9753b1a8 ("iommu/io-pgtable: Add ARMv7 short descriptor support")
Fixes: e1d3c0fd701d ("iommu: add ARM LPAE page table allocator")
Fixes: 745ef1092bcf ("iommu/io-pgtable: Move Apple DART support to its own file")
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Acked-by: Will Deacon <will@kernel.org>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Link: https://lore.kernel.org/r/2-v1-1211e1294c27+4b1-iommu_no_prot_jgg@nvidia.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu/io-pgtable-arm.c')
| -rw-r--r-- | drivers/iommu/io-pgtable-arm.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index f5d9fd1f45bf..ff4149ae1751 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -515,9 +515,8 @@ static int arm_lpae_map_pages(struct io_pgtable_ops *ops, unsigned long iova, if (WARN_ON(iaext || paddr >> cfg->oas)) return -ERANGE; - /* If no access, then nothing to do */ if (!(iommu_prot & (IOMMU_READ | IOMMU_WRITE))) - return 0; + return -EINVAL; prot = arm_lpae_prot_to_pte(data, iommu_prot); ret = __arm_lpae_map(data, iova, paddr, pgsize, pgcount, prot, lvl, |
