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

Configure Feed

Select the types of activity you want to include in your feed.

x86/boot: Defer initialization of VM space related global variables

The global pseudo-constants 'page_offset_base', 'vmalloc_base' and
'vmemmap_base' are not used extremely early during the boot, and cannot be
used safely until after the KASLR memory randomization code in
kernel_randomize_memory() executes, which may update their values.

So there is no point in setting these variables extremely early, and it
can wait until after the kernel itself is mapped and running from its
permanent virtual mapping.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/20250513111157.717727-9-ardb+git@google.com

authored by

Ard Biesheuvel and committed by
Ingo Molnar
64797551 891d3b8b

+6 -6
-3
arch/x86/boot/startup/map_kernel.c
··· 29 29 __pgtable_l5_enabled = 1; 30 30 pgdir_shift = 48; 31 31 ptrs_per_p4d = 512; 32 - page_offset_base = __PAGE_OFFSET_BASE_L5; 33 - vmalloc_base = __VMALLOC_BASE_L5; 34 - vmemmap_base = __VMEMMAP_BASE_L5; 35 32 36 33 return true; 37 34 }
+6 -3
arch/x86/kernel/head64.c
··· 62 62 #ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT 63 63 unsigned long page_offset_base __ro_after_init = __PAGE_OFFSET_BASE_L4; 64 64 EXPORT_SYMBOL(page_offset_base); 65 - SYM_PIC_ALIAS(page_offset_base); 66 65 unsigned long vmalloc_base __ro_after_init = __VMALLOC_BASE_L4; 67 66 EXPORT_SYMBOL(vmalloc_base); 68 - SYM_PIC_ALIAS(vmalloc_base); 69 67 unsigned long vmemmap_base __ro_after_init = __VMEMMAP_BASE_L4; 70 68 EXPORT_SYMBOL(vmemmap_base); 71 - SYM_PIC_ALIAS(vmemmap_base); 72 69 #endif 73 70 74 71 /* Wipe all early page tables except for the kernel symbol map */ ··· 240 243 241 244 /* Kill off the identity-map trampoline */ 242 245 reset_early_page_tables(); 246 + 247 + if (pgtable_l5_enabled()) { 248 + page_offset_base = __PAGE_OFFSET_BASE_L5; 249 + vmalloc_base = __VMALLOC_BASE_L5; 250 + vmemmap_base = __VMEMMAP_BASE_L5; 251 + } 243 252 244 253 clear_bss(); 245 254