Commit 4496f99d authored by Joerg Roedel's avatar Joerg Roedel Committed by Luis Henriques

iommu/amd: Handle large pages correctly in free_pagetable

commit 0b3fff54 upstream.

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

Fixes: 5c34c403 ("iommu/amd: Fix memory leak in free_pagetable")
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent 43d2bcee
...@@ -1922,9 +1922,15 @@ static void free_pt_##LVL (unsigned long __pt) \ ...@@ -1922,9 +1922,15 @@ static void free_pt_##LVL (unsigned long __pt) \
pt = (u64 *)__pt; \ pt = (u64 *)__pt; \
\ \
for (i = 0; i < 512; ++i) { \ for (i = 0; i < 512; ++i) { \
/* PTE present? */ \
if (!IOMMU_PTE_PRESENT(pt[i])) \ if (!IOMMU_PTE_PRESENT(pt[i])) \
continue; \ 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]); \ p = (unsigned long)IOMMU_PTE_PAGE(pt[i]); \
FN(p); \ FN(p); \
} \ } \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment