All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/arm-smmu-v3: Align size in __arm_smmu_tlb_inv_range
@ 2022-04-13  4:17 ` Nicolin Chen via iommu
  0 siblings, 0 replies; 27+ messages in thread
From: Nicolin Chen @ 2022-04-13  4:17 UTC (permalink / raw)
  To: will, robin.murphy, joro
  Cc: thunder.leizhen, jgg, tglx, john.garry, jean-philippe,
	christophe.jaillet, linux-arm-kernel, iommu, linux-kernel

To calculate num_pages, the size should be aligned with
"page size", determined by the tg value. Otherwise, its
following "while (iova < end)" might become an infinite
loop if unaligned size is slightly greater than 1 << tg.

Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index 627a3ed5ee8f..8249dad5ae44 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -1879,7 +1879,7 @@ static void __arm_smmu_tlb_inv_range(struct arm_smmu_cmdq_ent *cmd,
 		/* Determine what level the granule is at */
 		cmd->tlbi.ttl = 4 - ((ilog2(granule) - 3) / (tg - 3));
 
-		num_pages = size >> tg;
+		num_pages = ALIGN(size, 1 << tg) >> tg;
 	}
 
 	cmds.num = 0;
-- 
2.17.1


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

end of thread, other threads:[~2022-04-19 20:23 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-13  4:17 [PATCH] iommu/arm-smmu-v3: Align size in __arm_smmu_tlb_inv_range Nicolin Chen
2022-04-13  4:17 ` Nicolin Chen
2022-04-13  4:17 ` Nicolin Chen via iommu
2022-04-13 13:40 ` Robin Murphy
2022-04-13 13:40   ` Robin Murphy
2022-04-13 13:40   ` Robin Murphy
2022-04-13 20:19   ` Nicolin Chen
2022-04-13 20:19     ` Nicolin Chen
2022-04-13 20:19     ` Nicolin Chen via iommu
2022-04-14 10:32     ` Robin Murphy
2022-04-14 10:32       ` Robin Murphy
2022-04-14 10:32       ` Robin Murphy
2022-04-15  3:56       ` Nicolin Chen
2022-04-15  3:56         ` Nicolin Chen
2022-04-15  3:56         ` Nicolin Chen via iommu
2022-04-16  2:03       ` Nicolin Chen via iommu
2022-04-16  2:03         ` Nicolin Chen
2022-04-16  2:03         ` Nicolin Chen
2022-04-19 20:02         ` Jason Gunthorpe
2022-04-19 20:02           ` Jason Gunthorpe
2022-04-19 20:02           ` Jason Gunthorpe
2022-04-19 20:05           ` Nicolin Chen
2022-04-19 20:05             ` Nicolin Chen
2022-04-19 20:05             ` Nicolin Chen via iommu
2022-04-19 20:15             ` Robin Murphy
2022-04-19 20:15               ` Robin Murphy
2022-04-19 20:15               ` Robin Murphy

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.