Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f4edd6d5 authored by Joerg Roedel's avatar Joerg Roedel Committed by Sasha Levin
Browse files

iommu/amd: Handle large pages correctly in free_pagetable



[ Upstream commit 0b3fff54bc01e8e6064d222a33e6fa7adabd94cd ]

Make sure that we are skipping over large PTEs while walking
the page-table tree.

Cc: stable@kernel.org
Fixes: 5c34c403 ("iommu/amd: Fix memory leak in free_pagetable")
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
parent 87293694
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1870,9 +1870,15 @@ static void free_pt_##LVL (unsigned long __pt) \
	pt = (u64 *)__pt;					\
								\
	for (i = 0; i < 512; ++i) {				\
		/* PTE present? */				\
		if (!IOMMU_PTE_PRESENT(pt[i]))			\
			continue;				\
								\
		/* Large PTE? */				\
		if (PM_PTE_LEVEL(pt[i]) == 0 ||			\
		    PM_PTE_LEVEL(pt[i]) == 7)			\
			continue;				\
								\
		p = (unsigned long)IOMMU_PTE_PAGE(pt[i]);	\
		FN(p);						\
	}							\