Skip to content

Commit 6be310c

Browse files
Dev Jaingregkh
authored andcommitted
arm64: Restrict pagetable teardown to avoid false warning
commit 650768c512faba8070bf4cfbb28c95eb5cd203f3 upstream. Commit 9c00697 ("arm64: mmu: drop pXd_present() checks from pXd_free_pYd_table()") removes the pxd_present() checks because the caller checks pxd_present(). But, in case of vmap_try_huge_pud(), the caller only checks pud_present(); pud_free_pmd_page() recurses on each pmd through pmd_free_pte_page(), wherein the pmd may be none. Thus it is possible to hit a warning in the latter, since pmd_none => !pmd_table(). Thus, add a pmd_present() check in pud_free_pmd_page(). This problem was found by code inspection. Fixes: 9c00697 ("arm64: mmu: drop pXd_present() checks from pXd_free_pYd_table()") Cc: [email protected] Reported-by: Ryan Roberts <[email protected]> Acked-by: David Hildenbrand <[email protected]> Signed-off-by: Dev Jain <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Reviewed-by: Anshuman Khandual <[email protected]> Reviewed-by: Ryan Roberts <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9429f3e commit 6be310c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/arm64/mm/mmu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,8 @@ int pud_free_pmd_page(pud_t *pudp, unsigned long addr)
15031503
next = addr;
15041504
end = addr + PUD_SIZE;
15051505
do {
1506-
pmd_free_pte_page(pmdp, next);
1506+
if (pmd_present(READ_ONCE(*pmdp)))
1507+
pmd_free_pte_page(pmdp, next);
15071508
} while (pmdp++, next += PMD_SIZE, next != end);
15081509

15091510
pud_clear(pudp);

0 commit comments

Comments
 (0)