forked from Minki/linux
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: 4fc19708b1
("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>
This commit is contained in:
parent
3950746d9d
commit
caa8413601
@ -373,14 +373,14 @@ static void pgd_prepopulate_user_pmd(struct mm_struct *mm,
|
|||||||
|
|
||||||
static struct kmem_cache *pgd_cache;
|
static struct kmem_cache *pgd_cache;
|
||||||
|
|
||||||
static int __init pgd_cache_init(void)
|
void __init pgd_cache_init(void)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* When PAE kernel is running as a Xen domain, it does not use
|
* When PAE kernel is running as a Xen domain, it does not use
|
||||||
* shared kernel pmd. And this requires a whole page for pgd.
|
* shared kernel pmd. And this requires a whole page for pgd.
|
||||||
*/
|
*/
|
||||||
if (!SHARED_KERNEL_PMD)
|
if (!SHARED_KERNEL_PMD)
|
||||||
return 0;
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* when PAE kernel is not running as a Xen domain, it uses
|
* when PAE kernel is not running as a Xen domain, it uses
|
||||||
@ -390,9 +390,7 @@ static int __init pgd_cache_init(void)
|
|||||||
*/
|
*/
|
||||||
pgd_cache = kmem_cache_create("pgd_cache", PGD_SIZE, PGD_ALIGN,
|
pgd_cache = kmem_cache_create("pgd_cache", PGD_SIZE, PGD_ALIGN,
|
||||||
SLAB_PANIC, NULL);
|
SLAB_PANIC, NULL);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
core_initcall(pgd_cache_init);
|
|
||||||
|
|
||||||
static inline pgd_t *_pgd_alloc(void)
|
static inline pgd_t *_pgd_alloc(void)
|
||||||
{
|
{
|
||||||
@ -420,6 +418,10 @@ static inline void _pgd_free(pgd_t *pgd)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
void __init pgd_cache_init(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static inline pgd_t *_pgd_alloc(void)
|
static inline pgd_t *_pgd_alloc(void)
|
||||||
{
|
{
|
||||||
return (pgd_t *)__get_free_pages(PGALLOC_GFP, PGD_ALLOCATION_ORDER);
|
return (pgd_t *)__get_free_pages(PGALLOC_GFP, PGD_ALLOCATION_ORDER);
|
||||||
|
@ -1126,6 +1126,8 @@ int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
|
|||||||
static inline void init_espfix_bsp(void) { }
|
static inline void init_espfix_bsp(void) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern void __init pgd_cache_init(void);
|
||||||
|
|
||||||
#ifndef __HAVE_ARCH_PFN_MODIFY_ALLOWED
|
#ifndef __HAVE_ARCH_PFN_MODIFY_ALLOWED
|
||||||
static inline bool pfn_modify_allowed(unsigned long pfn, pgprot_t prot)
|
static inline bool pfn_modify_allowed(unsigned long pfn, pgprot_t prot)
|
||||||
{
|
{
|
||||||
|
@ -506,6 +506,8 @@ void __init __weak mem_encrypt_init(void) { }
|
|||||||
|
|
||||||
void __init __weak poking_init(void) { }
|
void __init __weak poking_init(void) { }
|
||||||
|
|
||||||
|
void __init __weak pgd_cache_init(void) { }
|
||||||
|
|
||||||
bool initcall_debug;
|
bool initcall_debug;
|
||||||
core_param(initcall_debug, initcall_debug, bool, 0644);
|
core_param(initcall_debug, initcall_debug, bool, 0644);
|
||||||
|
|
||||||
@ -537,6 +539,7 @@ static void __init mm_init(void)
|
|||||||
init_espfix_bsp();
|
init_espfix_bsp();
|
||||||
/* Should be run after espfix64 is set up. */
|
/* Should be run after espfix64 is set up. */
|
||||||
pti_init();
|
pti_init();
|
||||||
|
pgd_cache_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void __init __weak arch_call_rest_init(void)
|
void __init __weak arch_call_rest_init(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user