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

x86/mm/64: Always use dynamic memory layout

Dynamic memory layout is used by KASLR and 5-level paging.

CONFIG_X86_5LEVEL is going to be removed, making 5-level paging support
unconditional which requires unconditional support of dynamic memory
layout.

Remove CONFIG_DYNAMIC_MEMORY_LAYOUT.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Borislav Petkov (AMD) <bp@alien8.de>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/20250516123306.3812286-2-kirill.shutemov@linux.intel.com

authored by

Kirill A. Shutemov and committed by
Ingo Molnar
1bffe6f6 a0f3fe54

+1 -23
-8
arch/x86/Kconfig
··· 1467 1467 config X86_5LEVEL 1468 1468 bool "Enable 5-level page tables support" 1469 1469 default y 1470 - select DYNAMIC_MEMORY_LAYOUT 1471 1470 select SPARSEMEM_VMEMMAP 1472 1471 depends on X86_64 1473 1472 help ··· 2167 2168 2168 2169 Don't change this unless you know what you are doing. 2169 2170 2170 - config DYNAMIC_MEMORY_LAYOUT 2171 - bool 2172 - help 2173 - This option makes base addresses of vmalloc and vmemmap as well as 2174 - __PAGE_OFFSET movable during boot. 2175 - 2176 2171 config RANDOMIZE_MEMORY 2177 2172 bool "Randomize the kernel memory sections" 2178 2173 depends on X86_64 2179 2174 depends on RANDOMIZE_BASE 2180 - select DYNAMIC_MEMORY_LAYOUT 2181 2175 default RANDOMIZE_BASE 2182 2176 help 2183 2177 Randomizes the base virtual address of kernel memory sections
-4
arch/x86/include/asm/page_64_types.h
··· 41 41 #define __PAGE_OFFSET_BASE_L5 _AC(0xff11000000000000, UL) 42 42 #define __PAGE_OFFSET_BASE_L4 _AC(0xffff888000000000, UL) 43 43 44 - #ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT 45 44 #define __PAGE_OFFSET page_offset_base 46 - #else 47 - #define __PAGE_OFFSET __PAGE_OFFSET_BASE_L4 48 - #endif /* CONFIG_DYNAMIC_MEMORY_LAYOUT */ 49 45 50 46 #define __START_KERNEL_map _AC(0xffffffff80000000, UL) 51 47
-6
arch/x86/include/asm/pgtable_64_types.h
··· 128 128 #define __VMEMMAP_BASE_L4 0xffffea0000000000UL 129 129 #define __VMEMMAP_BASE_L5 0xffd4000000000000UL 130 130 131 - #ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT 132 131 # define VMALLOC_START vmalloc_base 133 132 # define VMALLOC_SIZE_TB (pgtable_l5_enabled() ? VMALLOC_SIZE_TB_L5 : VMALLOC_SIZE_TB_L4) 134 133 # define VMEMMAP_START vmemmap_base 135 - #else 136 - # define VMALLOC_START __VMALLOC_BASE_L4 137 - # define VMALLOC_SIZE_TB VMALLOC_SIZE_TB_L4 138 - # define VMEMMAP_START __VMEMMAP_BASE_L4 139 - #endif /* CONFIG_DYNAMIC_MEMORY_LAYOUT */ 140 134 141 135 #ifdef CONFIG_RANDOMIZE_MEMORY 142 136 # define DIRECT_MAP_PHYSMEM_END direct_map_physmem_end
-2
arch/x86/kernel/head64.c
··· 59 59 EXPORT_SYMBOL(ptrs_per_p4d); 60 60 #endif 61 61 62 - #ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT 63 62 unsigned long page_offset_base __ro_after_init = __PAGE_OFFSET_BASE_L4; 64 63 EXPORT_SYMBOL(page_offset_base); 65 64 unsigned long vmalloc_base __ro_after_init = __VMALLOC_BASE_L4; 66 65 EXPORT_SYMBOL(vmalloc_base); 67 66 unsigned long vmemmap_base __ro_after_init = __VMEMMAP_BASE_L4; 68 67 EXPORT_SYMBOL(vmemmap_base); 69 - #endif 70 68 71 69 /* Wipe all early page tables except for the kernel symbol map */ 72 70 static void __init reset_early_page_tables(void)
+1 -3
scripts/gdb/linux/pgtable.py
··· 29 29 raise Exception(f'Unknown page level: {level}') 30 30 31 31 32 - #page_offset_base in case CONFIG_DYNAMIC_MEMORY_LAYOUT is disabled 33 - POB_NO_DYNAMIC_MEM_LAYOUT = '0xffff888000000000' 34 32 def _page_offset_base(): 35 33 pob_symbol = gdb.lookup_global_symbol('page_offset_base') 36 - pob = pob_symbol.name if pob_symbol else POB_NO_DYNAMIC_MEM_LAYOUT 34 + pob = pob_symbol.name 37 35 return gdb.parse_and_eval(pob) 38 36 39 37