diff options
| author | Nadav Amit <nadav.amit@gmail.com> | 2019-05-04 21:11:24 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2019-05-05 14:32:46 -0400 |
| commit | caa841360134f863987f2d4f77b8dc2fbb7596f8 (patch) | |
| tree | fc3f7b45f92fc38599a509945ee8b6970eb2c3d8 | |
| parent | 3950746d9d8ef981c1cb842384e0e86e8d1aad76 (diff) | |
x86/mm: Initialize PGD cache during mm initialization
Poking-mm initialization might require to duplicate the PGD in early
stage. Initialize the PGD cache earlier to prevent boot failures.
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Nadav Amit <namit@vmware.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rick Edgecombe <rick.p.edgecombe@intel.com>
Cc: Rik van Riel <riel@surriel.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: 4fc19708b165 ("x86/alternatives: Initialize temporary mm for patching")
Link: http://lkml.kernel.org/r/20190505011124.39692-1-namit@vmware.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
| -rw-r--r-- | arch/x86/mm/pgtable.c | 10 | ||||
| -rw-r--r-- | include/asm-generic/pgtable.h | 2 | ||||
| -rw-r--r-- | init/main.c | 3 |
3 files changed, 11 insertions, 4 deletions
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c index 7bd01709a091..c8177045b7d4 100644 --- a/arch/x86/mm/pgtable.c +++ b/arch/x86/mm/pgtable.c | |||
| @@ -373,14 +373,14 @@ static void pgd_prepopulate_user_pmd(struct mm_struct *mm, | |||
| 373 | 373 | ||
| 374 | static struct kmem_cache *pgd_cache; | 374 | static struct kmem_cache *pgd_cache; |
| 375 | 375 | ||
| 376 | static int __init pgd_cache_init(void) | 376 | void __init pgd_cache_init(void) |
| 377 | { | 377 | { |
| 378 | /* | 378 | /* |
| 379 | * When PAE kernel is running as a Xen domain, it does not use | 379 | * When PAE kernel is running as a Xen domain, it does not use |
| 380 | * shared kernel pmd. And this requires a whole page for pgd. | 380 | * shared kernel pmd. And this requires a whole page for pgd. |
| 381 | */ | 381 | */ |
| 382 | if (!SHARED_KERNEL_PMD) | 382 | if (!SHARED_KERNEL_PMD) |
| 383 | return 0; | 383 | return; |
| 384 | 384 | ||
| 385 | /* | 385 | /* |
| 386 | * when PAE kernel is not running as a Xen domain, it uses | 386 | * when PAE kernel is not running as a Xen domain, it uses |
| @@ -390,9 +390,7 @@ static int __init pgd_cache_init(void) | |||
| 390 | */ | 390 | */ |
| 391 | pgd_cache = kmem_cache_create("pgd_cache", PGD_SIZE, PGD_ALIGN, | 391 | pgd_cache = kmem_cache_create("pgd_cache", PGD_SIZE, PGD_ALIGN, |
| 392 | SLAB_PANIC, NULL); | 392 | SLAB_PANIC, NULL); |
| 393 | return 0; | ||
| 394 | } | 393 | } |
| 395 | core_initcall(pgd_cache_init); | ||
| 396 | 394 | ||
| 397 | static inline pgd_t *_pgd_alloc(void) | 395 | static inline pgd_t *_pgd_alloc(void) |
| 398 | { | 396 | { |
| @@ -420,6 +418,10 @@ static inline void _pgd_free(pgd_t *pgd) | |||
| 420 | } | 418 | } |
| 421 | #else | 419 | #else |
| 422 | 420 | ||
| 421 | void __init pgd_cache_init(void) | ||
| 422 | { | ||
| 423 | } | ||
| 424 | |||
| 423 | static inline pgd_t *_pgd_alloc(void) | 425 | static inline pgd_t *_pgd_alloc(void) |
| 424 | { | 426 | { |
| 425 | return (pgd_t *)__get_free_pages(PGALLOC_GFP, PGD_ALLOCATION_ORDER); | 427 | return (pgd_t *)__get_free_pages(PGALLOC_GFP, PGD_ALLOCATION_ORDER); |
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h index fa782fba51ee..75d9d68a6de7 100644 --- a/include/asm-generic/pgtable.h +++ b/include/asm-generic/pgtable.h | |||
| @@ -1126,6 +1126,8 @@ int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn, | |||
| 1126 | static inline void init_espfix_bsp(void) { } | 1126 | static inline void init_espfix_bsp(void) { } |
| 1127 | #endif | 1127 | #endif |
| 1128 | 1128 | ||
| 1129 | extern void __init pgd_cache_init(void); | ||
| 1130 | |||
| 1129 | #ifndef __HAVE_ARCH_PFN_MODIFY_ALLOWED | 1131 | #ifndef __HAVE_ARCH_PFN_MODIFY_ALLOWED |
| 1130 | static inline bool pfn_modify_allowed(unsigned long pfn, pgprot_t prot) | 1132 | static inline bool pfn_modify_allowed(unsigned long pfn, pgprot_t prot) |
| 1131 | { | 1133 | { |
diff --git a/init/main.c b/init/main.c index 95dd9406ee31..9dc2f3b4f753 100644 --- a/init/main.c +++ b/init/main.c | |||
| @@ -506,6 +506,8 @@ void __init __weak mem_encrypt_init(void) { } | |||
| 506 | 506 | ||
| 507 | void __init __weak poking_init(void) { } | 507 | void __init __weak poking_init(void) { } |
| 508 | 508 | ||
| 509 | void __init __weak pgd_cache_init(void) { } | ||
| 510 | |||
| 509 | bool initcall_debug; | 511 | bool initcall_debug; |
| 510 | core_param(initcall_debug, initcall_debug, bool, 0644); | 512 | core_param(initcall_debug, initcall_debug, bool, 0644); |
| 511 | 513 | ||
| @@ -537,6 +539,7 @@ static void __init mm_init(void) | |||
| 537 | init_espfix_bsp(); | 539 | init_espfix_bsp(); |
| 538 | /* Should be run after espfix64 is set up. */ | 540 | /* Should be run after espfix64 is set up. */ |
| 539 | pti_init(); | 541 | pti_init(); |
| 542 | pgd_cache_init(); | ||
| 540 | } | 543 | } |
| 541 | 544 | ||
| 542 | void __init __weak arch_call_rest_init(void) | 545 | void __init __weak arch_call_rest_init(void) |
