iommu/amd: Handle large pages correctly in free_pagetable
authorJoerg Roedel <jroedel@suse.de>
Thu, 18 Jun 2015 08:48:34 +0000 (10:48 +0200)
committerJoerg Roedel <jroedel@suse.de>
Fri, 19 Jun 2015 15:17:34 +0000 (17:17 +0200)
Make sure that we are skipping over large PTEs while walking
the page-table tree.

Cc: stable@kernel.org
Fixes: 5c34c403b723 ("iommu/amd: Fix memory leak in free_pagetable")
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/amd_iommu.c

index 4dfadcfed34ae55dc2cc3dc6553678f340229046..31e90c472c76d762922c9c9afea68edeef85a3bc 100644 (file)
@@ -1866,9 +1866,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);                                          \
        }                                                       \