Skip to content

Commit 1bffe6f

Browse files
kirylIngo Molnar
authored andcommitted
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 <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Reviewed-by: Ard Biesheuvel <[email protected]> Reviewed-by: Borislav Petkov (AMD) <[email protected]> Cc: Jan Kiszka <[email protected]> Cc: Kieran Bingham <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Linus Torvalds <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent a0f3fe5 commit 1bffe6f

File tree

5 files changed

+1
-23
lines changed

5 files changed

+1
-23
lines changed

arch/x86/Kconfig

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,6 @@ config X86_PAE
14671467
config X86_5LEVEL
14681468
bool "Enable 5-level page tables support"
14691469
default y
1470-
select DYNAMIC_MEMORY_LAYOUT
14711470
select SPARSEMEM_VMEMMAP
14721471
depends on X86_64
14731472
help
@@ -2168,17 +2167,10 @@ config PHYSICAL_ALIGN
21682167

21692168
Don't change this unless you know what you are doing.
21702169

2171-
config DYNAMIC_MEMORY_LAYOUT
2172-
bool
2173-
help
2174-
This option makes base addresses of vmalloc and vmemmap as well as
2175-
__PAGE_OFFSET movable during boot.
2176-
21772170
config RANDOMIZE_MEMORY
21782171
bool "Randomize the kernel memory sections"
21792172
depends on X86_64
21802173
depends on RANDOMIZE_BASE
2181-
select DYNAMIC_MEMORY_LAYOUT
21822174
default RANDOMIZE_BASE
21832175
help
21842176
Randomizes the base virtual address of kernel memory sections

arch/x86/include/asm/page_64_types.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@
4141
#define __PAGE_OFFSET_BASE_L5 _AC(0xff11000000000000, UL)
4242
#define __PAGE_OFFSET_BASE_L4 _AC(0xffff888000000000, UL)
4343

44-
#ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT
4544
#define __PAGE_OFFSET page_offset_base
46-
#else
47-
#define __PAGE_OFFSET __PAGE_OFFSET_BASE_L4
48-
#endif /* CONFIG_DYNAMIC_MEMORY_LAYOUT */
4945

5046
#define __START_KERNEL_map _AC(0xffffffff80000000, UL)
5147

arch/x86/include/asm/pgtable_64_types.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,9 @@ extern unsigned int ptrs_per_p4d;
128128
#define __VMEMMAP_BASE_L4 0xffffea0000000000UL
129129
#define __VMEMMAP_BASE_L5 0xffd4000000000000UL
130130

131-
#ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT
132131
# define VMALLOC_START vmalloc_base
133132
# define VMALLOC_SIZE_TB (pgtable_l5_enabled() ? VMALLOC_SIZE_TB_L5 : VMALLOC_SIZE_TB_L4)
134133
# 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 */
140134

141135
#ifdef CONFIG_RANDOMIZE_MEMORY
142136
# define DIRECT_MAP_PHYSMEM_END direct_map_physmem_end

arch/x86/kernel/head64.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,12 @@ unsigned int ptrs_per_p4d __ro_after_init = 1;
5959
EXPORT_SYMBOL(ptrs_per_p4d);
6060
#endif
6161

62-
#ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT
6362
unsigned long page_offset_base __ro_after_init = __PAGE_OFFSET_BASE_L4;
6463
EXPORT_SYMBOL(page_offset_base);
6564
unsigned long vmalloc_base __ro_after_init = __VMALLOC_BASE_L4;
6665
EXPORT_SYMBOL(vmalloc_base);
6766
unsigned long vmemmap_base __ro_after_init = __VMEMMAP_BASE_L4;
6867
EXPORT_SYMBOL(vmemmap_base);
69-
#endif
7068

7169
/* Wipe all early page tables except for the kernel symbol map */
7270
static void __init reset_early_page_tables(void)

scripts/gdb/linux/pgtable.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ def page_mask(level=1):
2929
raise Exception(f'Unknown page level: {level}')
3030

3131

32-
#page_offset_base in case CONFIG_DYNAMIC_MEMORY_LAYOUT is disabled
33-
POB_NO_DYNAMIC_MEM_LAYOUT = '0xffff888000000000'
3432
def _page_offset_base():
3533
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
3735
return gdb.parse_and_eval(pob)
3836

3937

0 commit comments

Comments
 (0)