Skip to content

Commit 6093cd5

Browse files
jgunthorpejoergroedel
authored andcommitted
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: e5fc975 ("iommu/io-pgtable: Add ARMv7 short descriptor support") Fixes: e1d3c0f ("iommu: add ARM LPAE page table allocator") Fixes: 745ef10 ("iommu/io-pgtable: Move Apple DART support to its own file") Signed-off-by: Jason Gunthorpe <[email protected]> Acked-by: Will Deacon <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 996dc53 commit 6093cd5

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

drivers/iommu/io-pgtable-arm-v7s.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,9 +552,8 @@ static int arm_v7s_map_pages(struct io_pgtable_ops *ops, unsigned long iova,
552552
paddr >= (1ULL << data->iop.cfg.oas)))
553553
return -ERANGE;
554554

555-
/* If no access, then nothing to do */
556555
if (!(prot & (IOMMU_READ | IOMMU_WRITE)))
557-
return 0;
556+
return -EINVAL;
558557

559558
while (pgcount--) {
560559
ret = __arm_v7s_map(data, iova, paddr, pgsize, prot, 1, data->pgd,

drivers/iommu/io-pgtable-arm.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,9 +515,8 @@ static int arm_lpae_map_pages(struct io_pgtable_ops *ops, unsigned long iova,
515515
if (WARN_ON(iaext || paddr >> cfg->oas))
516516
return -ERANGE;
517517

518-
/* If no access, then nothing to do */
519518
if (!(iommu_prot & (IOMMU_READ | IOMMU_WRITE)))
520-
return 0;
519+
return -EINVAL;
521520

522521
prot = arm_lpae_prot_to_pte(data, iommu_prot);
523522
ret = __arm_lpae_map(data, iova, paddr, pgsize, pgcount, prot, lvl,

drivers/iommu/io-pgtable-dart.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,8 @@ static int dart_map_pages(struct io_pgtable_ops *ops, unsigned long iova,
245245
if (WARN_ON(paddr >> cfg->oas))
246246
return -ERANGE;
247247

248-
/* If no access, then nothing to do */
249248
if (!(iommu_prot & (IOMMU_READ | IOMMU_WRITE)))
250-
return 0;
249+
return -EINVAL;
251250

252251
tbl = dart_get_table(data, iova);
253252

0 commit comments

Comments
 (0)