Skip to content

Commit 613e396

Browse files
KAGA-KOKOIngo Molnar
authored andcommitted
init: Invoke init_espfix_bsp() from mm_init()
init_espfix_bsp() needs to be invoked before the page table isolation initialization. Move it into mm_init() which is the place where pti_init() will be added. While at it get rid of the #ifdeffery and provide proper stub functions. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> 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: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Juergen Gross <jgross@suse.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 92a0f81 commit 613e396

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

arch/x86/include/asm/espfix.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#ifndef _ASM_X86_ESPFIX_H
33
#define _ASM_X86_ESPFIX_H
44

5-
#ifdef CONFIG_X86_64
5+
#ifdef CONFIG_X86_ESPFIX64
66

77
#include <asm/percpu.h>
88

@@ -11,7 +11,8 @@ DECLARE_PER_CPU_READ_MOSTLY(unsigned long, espfix_waddr);
1111

1212
extern void init_espfix_bsp(void);
1313
extern void init_espfix_ap(int cpu);
14-
15-
#endif /* CONFIG_X86_64 */
14+
#else
15+
static inline void init_espfix_ap(int cpu) { }
16+
#endif
1617

1718
#endif /* _ASM_X86_ESPFIX_H */

arch/x86/kernel/smpboot.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -990,12 +990,8 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle,
990990
initial_code = (unsigned long)start_secondary;
991991
initial_stack = idle->thread.sp;
992992

993-
/*
994-
* Enable the espfix hack for this CPU
995-
*/
996-
#ifdef CONFIG_X86_ESPFIX64
993+
/* Enable the espfix hack for this CPU */
997994
init_espfix_ap(cpu);
998-
#endif
999995

1000996
/* So we see what's up */
1001997
announce_cpu(cpu, apicid);

include/asm-generic/pgtable.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,11 @@ static inline int pmd_clear_huge(pmd_t *pmd)
10171017
struct file;
10181018
int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
10191019
unsigned long size, pgprot_t *vma_prot);
1020+
1021+
#ifndef CONFIG_X86_ESPFIX64
1022+
static inline void init_espfix_bsp(void) { }
1023+
#endif
1024+
10201025
#endif /* !__ASSEMBLY__ */
10211026

10221027
#ifndef io_remap_pfn_range

init/main.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,8 @@ static void __init mm_init(void)
504504
pgtable_init();
505505
vmalloc_init();
506506
ioremap_huge_init();
507+
/* Should be run before the first non-init thread is created */
508+
init_espfix_bsp();
507509
}
508510

509511
asmlinkage __visible void __init start_kernel(void)
@@ -673,10 +675,6 @@ asmlinkage __visible void __init start_kernel(void)
673675
#ifdef CONFIG_X86
674676
if (efi_enabled(EFI_RUNTIME_SERVICES))
675677
efi_enter_virtual_mode();
676-
#endif
677-
#ifdef CONFIG_X86_ESPFIX64
678-
/* Should be run before the first non-init thread is created */
679-
init_espfix_bsp();
680678
#endif
681679
thread_stack_cache_init();
682680
cred_init();

0 commit comments

Comments
 (0)