Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/mm: Allow to boot without LA57 if CONFIG_X86_5LEVEL=y

All pieces of the puzzle are in place and we can now allow to boot with
CONFIG_X86_5LEVEL=y on a machine without LA57 support.

Kernel will detect that LA57 is missing and fold p4d at runtime.

Update the documentation and the Kconfig option description to reflect the
change.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/20180214182542.69302-10-kirill.shutemov@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Kirill A. Shutemov and committed by
Ingo Molnar
6657fca0 91f606a8

+6 -31
+3 -6
Documentation/x86/x86_64/5level-paging.txt
··· 20 20 21 21 CONFIG_X86_5LEVEL=y enables the feature. 22 22 23 - So far, a kernel compiled with the option enabled will be able to boot 24 - only on machines that supports the feature -- see for 'la57' flag in 25 - /proc/cpuinfo. 26 - 27 - The plan is to implement boot-time switching between 4- and 5-level paging 28 - in the future. 23 + Kernel with CONFIG_X86_5LEVEL=y still able to boot on 4-level hardware. 24 + In this case additional page table level -- p4d -- will be folded at 25 + runtime. 29 26 30 27 == User-space and large virtual address space == 31 28
+2 -2
arch/x86/Kconfig
··· 1440 1440 1441 1441 It will be supported by future Intel CPUs. 1442 1442 1443 - Note: a kernel with this option enabled can only be booted 1444 - on machines that support the feature. 1443 + A kernel with the option enabled can be booted on machines that 1444 + support 4- or 5-level paging. 1445 1445 1446 1446 See Documentation/x86/x86_64/5level-paging.txt for more 1447 1447 information.
-16
arch/x86/boot/compressed/misc.c
··· 169 169 } 170 170 } 171 171 172 - static bool l5_supported(void) 173 - { 174 - /* Check if leaf 7 is supported. */ 175 - if (native_cpuid_eax(0) < 7) 176 - return 0; 177 - 178 - /* Check if la57 is supported. */ 179 - return native_cpuid_ecx(7) & (1 << (X86_FEATURE_LA57 & 31)); 180 - } 181 - 182 172 #if CONFIG_X86_NEED_RELOCS 183 173 static void handle_relocations(void *output, unsigned long output_len, 184 174 unsigned long virt_addr) ··· 361 371 362 372 console_init(); 363 373 debug_putstr("early console in extract_kernel\n"); 364 - 365 - if (IS_ENABLED(CONFIG_X86_5LEVEL) && !l5_supported()) { 366 - error("This linux kernel as configured requires 5-level paging\n" 367 - "This CPU does not support the required 'cr4.la57' feature\n" 368 - "Unable to boot - please use a kernel appropriate for your CPU\n"); 369 - } 370 374 371 375 free_mem_ptr = heap; /* Heap */ 372 376 free_mem_end_ptr = heap + BOOT_HEAP_SIZE;
+1 -7
arch/x86/include/asm/required-features.h
··· 53 53 # define NEED_MOVBE 0 54 54 #endif 55 55 56 - #ifdef CONFIG_X86_5LEVEL 57 - # define NEED_LA57 (1<<(X86_FEATURE_LA57 & 31)) 58 - #else 59 - # define NEED_LA57 0 60 - #endif 61 - 62 56 #ifdef CONFIG_X86_64 63 57 #ifdef CONFIG_PARAVIRT 64 58 /* Paravirtualized systems may not have PSE or PGE available */ ··· 98 104 #define REQUIRED_MASK13 0 99 105 #define REQUIRED_MASK14 0 100 106 #define REQUIRED_MASK15 0 101 - #define REQUIRED_MASK16 (NEED_LA57) 107 + #define REQUIRED_MASK16 0 102 108 #define REQUIRED_MASK17 0 103 109 #define REQUIRED_MASK18 0 104 110 #define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19)