All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu: Up front sanity check in the arm_lpae_map
@ 2020-12-05  8:29 ` Keqian Zhu
  0 siblings, 0 replies; 24+ messages in thread
From: Keqian Zhu @ 2020-12-05  8:29 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, iommu
  Cc: Will Deacon, Marc Zyngier, Robin Murphy, Joerg Roedel,
	Catalin Marinas, James Morse, Suzuki K Poulose,
	Sean Christopherson, Julien Thierry, Mark Brown, Thomas Gleixner,
	Andrew Morton, Alexios Zavras, wanghaibin.wang, jiangkunkun,
	Keqian Zhu

... then we have more chance to detect wrong code logic.

Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
---
 drivers/iommu/io-pgtable-arm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
index a7a9bc08dcd1..8ade72adab31 100644
--- a/drivers/iommu/io-pgtable-arm.c
+++ b/drivers/iommu/io-pgtable-arm.c
@@ -444,10 +444,6 @@ static int arm_lpae_map(struct io_pgtable_ops *ops, unsigned long iova,
 	arm_lpae_iopte prot;
 	long iaext = (s64)iova >> cfg->ias;
 
-	/* If no access, then nothing to do */
-	if (!(iommu_prot & (IOMMU_READ | IOMMU_WRITE)))
-		return 0;
-
 	if (WARN_ON(!size || (size & cfg->pgsize_bitmap) != size))
 		return -EINVAL;
 
@@ -456,6 +452,10 @@ static int arm_lpae_map(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;
+
 	prot = arm_lpae_prot_to_pte(data, iommu_prot);
 	ret = __arm_lpae_map(data, iova, paddr, size, prot, lvl, ptep, gfp);
 	/*
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2020-12-07 13:38 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-05  8:29 [PATCH] iommu: Up front sanity check in the arm_lpae_map Keqian Zhu
2020-12-05  8:29 ` Keqian Zhu
2020-12-05  8:29 ` Keqian Zhu
2020-12-07 10:59 ` Will Deacon
2020-12-07 10:59   ` Will Deacon
2020-12-07 10:59   ` Will Deacon
2020-12-07 11:37   ` zhukeqian
2020-12-07 11:37     ` zhukeqian
2020-12-07 11:37     ` zhukeqian
2020-12-07 12:01 ` Robin Murphy
2020-12-07 12:01   ` Robin Murphy
2020-12-07 12:01   ` Robin Murphy
2020-12-07 12:05   ` Will Deacon
2020-12-07 12:05     ` Will Deacon
2020-12-07 12:05     ` Will Deacon
2020-12-07 12:15     ` zhukeqian
2020-12-07 12:15       ` zhukeqian
2020-12-07 12:15       ` zhukeqian
2020-12-07 12:46       ` Robin Murphy
2020-12-07 12:46         ` Robin Murphy
2020-12-07 12:46         ` Robin Murphy
2020-12-07 13:36         ` zhukeqian
2020-12-07 13:36           ` zhukeqian
2020-12-07 13:36           ` zhukeqian

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.