x86/kasan: Prepare clear_pgds() to switch to <asm-generic/pgtable-nop4d.h>
authorKirill A. Shutemov <[email protected]>
Fri, 17 Mar 2017 18:55:13 +0000 (21:55 +0300)
committerIngo Molnar <[email protected]>
Mon, 27 Mar 2017 06:56:41 +0000 (08:56 +0200)
With folded p4d, pgd_clear() is a nop. Change clear_pgds() to use
p4d_clear() instead.

Signed-off-by: Kirill A. Shutemov <[email protected]>
Acked-by: Thomas Gleixner <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Brian Gerst <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: Denys Vlasenko <[email protected]>
Cc: Dmitry Vyukov <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Josh Poimboeuf <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: [email protected]
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
arch/x86/mm/kasan_init_64.c

index 8d63d7a104c3c445805dcf24a59fff2756a17b01..7b81f01067f2a9e6164728784848ee9f7068c3d0 100644 (file)
@@ -32,8 +32,19 @@ static int __init map_range(struct range *range)
 static void __init clear_pgds(unsigned long start,
                        unsigned long end)
 {
-       for (; start < end; start += PGDIR_SIZE)
-               pgd_clear(pgd_offset_k(start));
+       pgd_t *pgd;
+
+       for (; start < end; start += PGDIR_SIZE) {
+               pgd = pgd_offset_k(start);
+               /*
+                * With folded p4d, pgd_clear() is nop, use p4d_clear()
+                * instead.
+                */
+               if (CONFIG_PGTABLE_LEVELS < 5)
+                       p4d_clear(p4d_offset(pgd, start));
+               else
+                       pgd_clear(pgd);
+       }
 }
 
 static void __init kasan_map_early_shadow(pgd_t *pgd)