public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH rc] iommu/terga: Fix incorrect size calculation
@ 2025-06-03 19:14 Jason Gunthorpe
  2025-06-04 10:04 ` Diogo Ivo
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jason Gunthorpe @ 2025-06-03 19:14 UTC (permalink / raw)
  To: iommu, Jonathan Hunter, Joerg Roedel, linux-tegra, Robin Murphy,
	Thierry Reding, Krishna Reddy, Will Deacon
  Cc: Diogo Ivo, Joerg Roedel, patches

This driver uses a mixture of ways to get the size of a PTE,
tegra_smmu_set_pde() did it as sizeof(*pd) which became wrong when pd
switched to a struct tegra_pd.

Switch pd back to a u32* in tegra_smmu_set_pde() so the sizeof(*pd)
returns 4.

Fixes: 50568f87d1e2 ("iommu/terga: Do not use struct page as the handle for as->pd memory")
Reported-by: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
Closes: https://lore.kernel.org/all/62e7f7fe-6200-4e4f-ad42-d58ad272baa6@tecnico.ulisboa.pt/
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
 drivers/iommu/tegra-smmu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
index 61897d50162dd7..e58fe9d8b9e77e 100644
--- a/drivers/iommu/tegra-smmu.c
+++ b/drivers/iommu/tegra-smmu.c
@@ -559,11 +559,11 @@ static void tegra_smmu_set_pde(struct tegra_smmu_as *as, unsigned long iova,
 {
 	unsigned int pd_index = iova_pd_index(iova);
 	struct tegra_smmu *smmu = as->smmu;
-	struct tegra_pd *pd = as->pd;
+	u32 *pd = &as->pd->val[pd_index];
 	unsigned long offset = pd_index * sizeof(*pd);
 
 	/* Set the page directory entry first */
-	pd->val[pd_index] = value;
+	*pd = value;
 
 	/* The flush the page directory entry from caches */
 	dma_sync_single_range_for_device(smmu->dev, as->pd_dma, offset,

base-commit: 7d4dfa6140f75b67f8eff3ae6ebc9937be94c4d3
-- 
2.43.0


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

end of thread, other threads:[~2025-06-13 14:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-03 19:14 [PATCH rc] iommu/terga: Fix incorrect size calculation Jason Gunthorpe
2025-06-04 10:04 ` Diogo Ivo
2025-06-04 19:07 ` Jerry Snitselaar
2025-06-10  9:53 ` Thierry Reding
2025-06-13 14:59 ` Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox