Commit-ID:  d691a3cf8004784303f0a4c1c036edfaa7d64d0b
Gitweb:     http://git.kernel.org/tip/d691a3cf8004784303f0a4c1c036edfaa7d64d0b
Author:     Kirill A. Shutemov <[email protected]>
AuthorDate: Fri, 17 Mar 2017 21:55:13 +0300
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 27 Mar 2017 08:56:41 +0200

x86/kasan: Prepare clear_pgds() to switch to <asm-generic/pgtable-nop4d.h>

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 | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/arch/x86/mm/kasan_init_64.c b/arch/x86/mm/kasan_init_64.c
index 8d63d7a..7b81f01 100644
--- a/arch/x86/mm/kasan_init_64.c
+++ b/arch/x86/mm/kasan_init_64.c
@@ -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)

Reply via email to