x86/mm: Dynamic memory layout
Subsystems (8)
cover x86/mm: Dynamic memory layout
This is the next batch of patches required to bring boot-time switching between 4- and 5-level paging. Please review and consider applying.
Patches in this patchset makes memory layout dynamic enough to be able to switch between paging modes at boot-time.
Ingo, it worth noticing that we discussed some parts of the patchset before (back in October) and had disagrement on how to handle situation. You can read my position on the matter by the link[1].
Some changes made in this patchset can be replaced by patching constants in code once we have infrastructure for this.
[1] http://lkml.kernel.org/r/[email protected]
Kirill A. Shutemov (9):
x86/mm/64: Make __PHYSICAL_MASK_SHIFT always 52 mm/zsmalloc: Prepare to variable MAX_PHYSMEM_BITS x86/mm: Make virtual memory layout movable for CONFIG_X86_5LEVEL
x86: Introduce pgtable_l5_enabled
x86/mm: Make LDT_BASE_ADDR dynamic
x86/mm: Make PGDIR_SHIFT and PTRS_PER_P4D variable x86/mm: Make MAX_PHYSADDR_BITS and MAX_PHYSMEM_BITS dynamic x86/mm: Make __VIRTUAL_MASK_SHIFT dynamic
x86/mm: Adjust virtual address space layout in early boot
arch/x86/Kconfig | 9 ++++ arch/x86/boot/compressed/kaslr.c | 14 ++++++ arch/x86/entry/entry_64.S | 12 ++++++ arch/x86/include/asm/kaslr.h | 4 -- arch/x86/include/asm/page_64.h | 4 ++ arch/x86/include/asm/page_64_types.h | 20 ++++----- arch/x86/include/asm/pgtable-3level_types.h | 1 + arch/x86/include/asm/pgtable_32.h | 2 + arch/x86/include/asm/pgtable_32_types.h | 2 + arch/x86/include/asm/pgtable_64_types.h | 67 ++++++++++++++++++----------- arch/x86/include/asm/sparsemem.h | 9 +--- arch/x86/kernel/cpu/mcheck/mce.c | 18 +++----- arch/x86/kernel/head64.c | 57 ++++++++++++++++++++++-- arch/x86/kernel/head_64.S | 2 +- arch/x86/kernel/setup.c | 5 +-- arch/x86/mm/dump_pagetables.c | 32 +++++++++----- arch/x86/mm/init_64.c | 2 +- arch/x86/mm/kasan_init_64.c | 2 +- arch/x86/mm/kaslr.c | 23 ++++------ arch/x86/platform/efi/efi_64.c | 4 +- include/asm-generic/5level-fixup.h | 1 + include/asm-generic/pgtable-nop4d.h | 9 ++-- include/linux/kasan.h | 2 +- mm/kasan/kasan_init.c | 2 +- mm/zsmalloc.c | 13 +++--- 25 files changed, 208 insertions(+), 108 deletions(-)
Signature · 1 line
2.15.1
PATCH 1/9 x86/mm/64: Make __PHYSICAL_MASK_SHIFT always 52
__PHYSICAL_MASK_SHIFT is used to define the mask that helps to extract physical address from a page table entry.
Although, real physical address space available may differ between machines, it's safe to use 52 as __PHYSICAL_MASK_SHIFT. Unused bits above log2(MAXPHYADDR) up to bit 51 are reserved and must be 0.
--- arch/x86/include/asm/page_64_types.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/include/asm/page_64_types.h +3 -2
@@ -52,11 +52,12 @@#define __START_KERNEL_map _AC(0xffffffff80000000, UL)/* See Documentation/x86/x86_64/mm.txt for a description of the memory map. */ -#ifdef CONFIG_X86_5LEVEL +#define __PHYSICAL_MASK_SHIFT 52 + +#ifdef CONFIG_X86_5LEVEL #define __VIRTUAL_MASK_SHIFT 56#else -#define __PHYSICAL_MASK_SHIFT 46#define __VIRTUAL_MASK_SHIFT 47#endif
Signature · 7 lines
2.15.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
tip-bot for Kirill A. Shutemov
merge bot[tip:x86/mm] x86/mm/64: Make __PHYSICAL_MASK_SHIFT always 52
x86/mm/64: Make __PHYSICAL_MASK_SHIFT always 52
Commit-ID: b83ce5ee91471d19c403ff91227204fb37c95fb2 Gitweb: https://git.kernel.org/tip/b83ce5ee91471d19c403ff91227204fb37c95fb2 Author: Kirill A. Shutemov <[email protected]> AuthorDate: Wed, 14 Feb 2018 14:16:48 +0300 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 14 Feb 2018 13:11:13 +0100
x86/mm/64: Make __PHYSICAL_MASK_SHIFT always 52
__PHYSICAL_MASK_SHIFT is used to define the mask that helps to extract physical address from a page table entry.
Although real physical address space available may differ between machines, it's safe to use 52 as __PHYSICAL_MASK_SHIFT. Unused bits above log2(MAXPHYADDR) up to bit 51 are reserved and must be 0.
--- arch/x86/include/asm/page_64_types.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/include/asm/page_64_types.h +3 -2
@@ -52,11 +52,12 @@#define __START_KERNEL_map _AC(0xffffffff80000000, UL)/* See Documentation/x86/x86_64/mm.txt for a description of the memory map. */ -#ifdef CONFIG_X86_5LEVEL +#define __PHYSICAL_MASK_SHIFT 52 + +#ifdef CONFIG_X86_5LEVEL #define __VIRTUAL_MASK_SHIFT 56#else -#define __PHYSICAL_MASK_SHIFT 46#define __VIRTUAL_MASK_SHIFT 47#endif
PATCH 2/9 mm/zsmalloc: Prepare to variable MAX_PHYSMEM_BITS
In reply to Kirill A. ShutemovWith boot-time switching between paging mode we will have variable MAX_PHYSMEM_BITS.
Let's use the maximum variable possible for CONFIG_X86_5LEVEL=y configuration to define zsmalloc data structures.
The patch introduces MAX_POSSIBLE_PHYSMEM_BITS to cover such case. It also suits well to handle PAE special case.
--- arch/x86/include/asm/pgtable-3level_types.h | 1 + arch/x86/include/asm/pgtable_64_types.h | 2 ++ mm/zsmalloc.c | 13 +++++++------ 3 files changed, 10 insertions(+), 6 deletions(-)
arch/x86/include/asm/pgtable-3level_types.h +1 -0
@@ -44,5 +44,6 @@ typedef union {*/ #define PTRS_PER_PTE 512 +#define MAX_POSSIBLE_PHYSMEM_BITS 36#endif /* _ASM_X86_PGTABLE_3LEVEL_DEFS_H */
arch/x86/include/asm/pgtable_64_types.h +2 -0
@@ -40,6 +40,8 @@ typedef struct { pteval_t pte; } pte_t;#define P4D_SIZE (_AC(1, UL) << P4D_SHIFT)#define P4D_MASK (~(P4D_SIZE - 1)) +#define MAX_POSSIBLE_PHYSMEM_BITS 52 +#else /* CONFIG_X86_5LEVEL */ /*
mm/zsmalloc.c +7 -6
@@ -84,18 +84,19 @@* This is made more complicated by various memory models and PAE. */ -#ifndef MAX_PHYSMEM_BITS -#ifdef CONFIG_HIGHMEM64G -#define MAX_PHYSMEM_BITS 36 -#else /* !CONFIG_HIGHMEM64G */ +#ifndef MAX_POSSIBLE_PHYSMEM_BITS +#ifdef MAX_PHYSMEM_BITS +#define MAX_POSSIBLE_PHYSMEM_BITS MAX_PHYSMEM_BITS +#else /* * If this definition of MAX_PHYSMEM_BITS is used, OBJ_INDEX_BITS will just * be PAGE_SHIFT */ -#define MAX_PHYSMEM_BITS BITS_PER_LONG +#define MAX_POSSIBLE_PHYSMEM_BITS BITS_PER_LONG#endif #endif -#define _PFN_BITS (MAX_PHYSMEM_BITS - PAGE_SHIFT) + +#define _PFN_BITS (MAX_POSSIBLE_PHYSMEM_BITS - PAGE_SHIFT)/* * Memory for allocating for handle keeps object position by
Signature · 7 lines
2.15.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
tip-bot for Kirill A. Shutemov
merge bot[tip:x86/mm] mm/zsmalloc: Prepare to variable MAX_PHYSMEM_BITS
mm/zsmalloc: Prepare to variable MAX_PHYSMEM_BITS
Commit-ID: 02390b87a9459937cdb299e6b34ff33992512ec7 Gitweb: https://git.kernel.org/tip/02390b87a9459937cdb299e6b34ff33992512ec7 Author: Kirill A. Shutemov <[email protected]> AuthorDate: Wed, 14 Feb 2018 14:16:49 +0300 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 14 Feb 2018 13:11:13 +0100
mm/zsmalloc: Prepare to variable MAX_PHYSMEM_BITS
With boot-time switching between paging mode we will have variable MAX_PHYSMEM_BITS.
Let's use the maximum variable possible for CONFIG_X86_5LEVEL=y configuration to define zsmalloc data structures.
The patch introduces MAX_POSSIBLE_PHYSMEM_BITS to cover such case. It also suits well to handle PAE special case.
--- arch/x86/include/asm/pgtable-3level_types.h | 1 + arch/x86/include/asm/pgtable_64_types.h | 2 ++ mm/zsmalloc.c | 13 +++++++------ 3 files changed, 10 insertions(+), 6 deletions(-)
arch/x86/include/asm/pgtable-3level_types.h +1 -0
@@ -44,5 +44,6 @@ typedef union {*/ #define PTRS_PER_PTE 512 +#define MAX_POSSIBLE_PHYSMEM_BITS 36#endif /* _ASM_X86_PGTABLE_3LEVEL_DEFS_H */
arch/x86/include/asm/pgtable_64_types.h +2 -0
@@ -40,6 +40,8 @@ typedef struct { pteval_t pte; } pte_t;#define P4D_SIZE (_AC(1, UL) << P4D_SHIFT)#define P4D_MASK (~(P4D_SIZE - 1)) +#define MAX_POSSIBLE_PHYSMEM_BITS 52 +#else /* CONFIG_X86_5LEVEL */ /*
mm/zsmalloc.c +7 -6
@@ -84,18 +84,19 @@* This is made more complicated by various memory models and PAE. */ -#ifndef MAX_PHYSMEM_BITS -#ifdef CONFIG_HIGHMEM64G -#define MAX_PHYSMEM_BITS 36 -#else /* !CONFIG_HIGHMEM64G */ +#ifndef MAX_POSSIBLE_PHYSMEM_BITS +#ifdef MAX_PHYSMEM_BITS +#define MAX_POSSIBLE_PHYSMEM_BITS MAX_PHYSMEM_BITS +#else /* * If this definition of MAX_PHYSMEM_BITS is used, OBJ_INDEX_BITS will just * be PAGE_SHIFT */ -#define MAX_PHYSMEM_BITS BITS_PER_LONG +#define MAX_POSSIBLE_PHYSMEM_BITS BITS_PER_LONG#endif #endif -#define _PFN_BITS (MAX_PHYSMEM_BITS - PAGE_SHIFT) + +#define _PFN_BITS (MAX_POSSIBLE_PHYSMEM_BITS - PAGE_SHIFT)/* * Memory for allocating for handle keeps object position by
PATCH 3/9 x86/mm: Make virtual memory layout movable for CONFIG_X86_5LEVEL
In reply to Kirill A. ShutemovWe need to be able to adjust virtual memory layout at runtime to be able to switch between 4- and 5-level paging at boot-time.
KASLR already has movable __VMALLOC_BASE, __VMEMMAP_BASE and __PAGE_OFFSET. Let's re-use it.
--- arch/x86/Kconfig | 8 ++++++++ arch/x86/include/asm/kaslr.h | 4 ---- arch/x86/include/asm/page_64.h | 4 ++++ arch/x86/include/asm/page_64_types.h | 4 ++-- arch/x86/include/asm/pgtable_64_types.h | 4 ++-- arch/x86/kernel/head64.c | 9 +++++++++ arch/x86/mm/kaslr.c | 8 -------- 7 files changed, 25 insertions(+), 16 deletions(-)
arch/x86/Kconfig +8 -0
@@ -1471,6 +1471,7 @@ config X86_PAE config X86_5LEVEL bool "Enable 5-level page tables support" + select DYNAMIC_MEMORY_LAYOUT depends on X86_64 ---help--- 5-level paging enables access to larger address space:
@@ -2184,10 +2185,17 @@ config PHYSICAL_ALIGN Don't change this unless you know what you are doing. +config DYNAMIC_MEMORY_LAYOUT + bool + ---help--- + This option makes base addresses of vmalloc and vmemmap as well as + __PAGE_OFFSET movable during boot. + config RANDOMIZE_MEMORY bool "Randomize the kernel memory sections" depends on X86_64 depends on RANDOMIZE_BASE + select DYNAMIC_MEMORY_LAYOUT default RANDOMIZE_BASE ---help--- Randomizes the base virtual address of kernel memory sections
arch/x86/include/asm/kaslr.h +0 -4
@@ -5,10 +5,6 @@unsigned long kaslr_get_random_long (const char *purpose);#ifdef CONFIG_RANDOMIZE_MEMORY -extern unsigned long page_offset_base; -extern unsigned long vmalloc_base; -extern unsigned long vmemmap_base; -void kernel_randomize_memory (void );#else static inline void kernel_randomize_memory (void ) { }
arch/x86/include/asm/page_64.h +4 -0
@@ -11,6 +11,10 @@extern unsigned long max_pfn;extern unsigned long phys_base; +extern unsigned long page_offset_base; +extern unsigned long vmalloc_base; +extern unsigned long vmemmap_base; +static inline unsigned long __phys_addr_nodebug (unsigned long x) {unsigned long y = x - __START_KERNEL_map;
arch/x86/include/asm/page_64_types.h +2 -2
@@ -43,11 +43,11 @@#define __PAGE_OFFSET_BASE _AC(0xffff880000000000, UL)#endif -#ifdef CONFIG_RANDOMIZE_MEMORY +#ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT #define __PAGE_OFFSET page_offset_base#else #define __PAGE_OFFSET __PAGE_OFFSET_BASE -#endif /* CONFIG_RANDOMIZE_MEMORY */ +#endif /* CONFIG_DYNAMIC_MEMORY_LAYOUT */ #define __START_KERNEL_map _AC(0xffffffff80000000, UL)
arch/x86/include/asm/pgtable_64_types.h +2 -2
@@ -100,13 +100,13 @@ typedef struct { pteval_t pte; } pte_t;# define LDT_BASE_ADDR (LDT_PGD_ENTRY << PGDIR_SHIFT)#endif -#ifdef CONFIG_RANDOMIZE_MEMORY +#ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT # define VMALLOC_START vmalloc_base# define VMEMMAP_START vmemmap_base#else # define VMALLOC_START __VMALLOC_BASE# define VMEMMAP_START __VMEMMAP_BASE -#endif /* CONFIG_RANDOMIZE_MEMORY */ +#endif /* CONFIG_DYNAMIC_MEMORY_LAYOUT */ #define VMALLOC_END (VMALLOC_START + _AC((VMALLOC_SIZE_TB << 40) - 1, UL))
arch/x86/kernel/head64.c +9 -0
@@ -39,6 +39,15 @@ extern pmd_t early_dynamic_pgts[EARLY_DYNAMIC_PAGE_TABLES][PTRS_PER_PMD];static unsigned int __initdata next_early_pgt;pmdval_t early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX); +#ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT +unsigned long page_offset_base__ro_after_init = __PAGE_OFFSET_BASE; +EXPORT_SYMBOL (page_offset_base); +unsigned long vmalloc_base__ro_after_init = __VMALLOC_BASE; +EXPORT_SYMBOL (vmalloc_base); +unsigned long vmemmap_base__ro_after_init = __VMEMMAP_BASE; +EXPORT_SYMBOL (vmemmap_base); +#endif +#define __head __section(.head.text) static void __head *fixup_pointer(void *ptr, unsigned long physaddr)
arch/x86/mm/kaslr.c +0 -8
@@ -43,14 +43,6 @@static const unsigned long vaddr_start = __PAGE_OFFSET_BASE;static const unsigned long vaddr_end =CPU_ENTRY_AREA_BASE ; -/* Default values */ -unsigned long page_offset_base = __PAGE_OFFSET_BASE; -EXPORT_SYMBOL (page_offset_base); -unsigned long vmalloc_base = __VMALLOC_BASE; -EXPORT_SYMBOL (vmalloc_base); -unsigned long vmemmap_base = __VMEMMAP_BASE; -EXPORT_SYMBOL (vmemmap_base); -/* * Memory regions randomized by KASLR (except modules that use a separate logic * earlier during boot). The list is ordered based on virtual addresses. This
Signature · 7 lines
2.15.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
tip-bot for Kirill A. Shutemov
merge bot[tip:x86/mm] x86/mm: Make virtual memory layout dynamic for CONFIG_X86_5LEVEL=y
x86/mm: Make virtual memory layout dynamic for CONFIG_X86_5LEVEL=y
Commit-ID: eedb92abb9bb03ef21442614a6f5867eaac6e77f Gitweb: https://git.kernel.org/tip/eedb92abb9bb03ef21442614a6f5867eaac6e77f Author: Kirill A. Shutemov <[email protected]> AuthorDate: Wed, 14 Feb 2018 14:16:50 +0300 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 14 Feb 2018 13:11:13 +0100
x86/mm: Make virtual memory layout dynamic for CONFIG_X86_5LEVEL=y
We need to be able to adjust virtual memory layout at runtime to be able to switch between 4- and 5-level paging at boot-time.
KASLR already has movable __VMALLOC_BASE, __VMEMMAP_BASE and __PAGE_OFFSET. Let's re-use it.
--- arch/x86/Kconfig | 8 ++++++++ arch/x86/include/asm/kaslr.h | 4 ---- arch/x86/include/asm/page_64.h | 4 ++++ arch/x86/include/asm/page_64_types.h | 4 ++-- arch/x86/include/asm/pgtable_64_types.h | 4 ++-- arch/x86/kernel/head64.c | 9 +++++++++ arch/x86/mm/kaslr.c | 8 -------- 7 files changed, 25 insertions(+), 16 deletions(-)
arch/x86/Kconfig +8 -0
@@ -1430,6 +1430,7 @@ config X86_PAE config X86_5LEVEL bool "Enable 5-level page tables support" + select DYNAMIC_MEMORY_LAYOUT depends on X86_64 ---help--- 5-level paging enables access to larger address space:
@@ -2143,10 +2144,17 @@ config PHYSICAL_ALIGN Don't change this unless you know what you are doing. +config DYNAMIC_MEMORY_LAYOUT + bool + ---help--- + This option makes base addresses of vmalloc and vmemmap as well as + __PAGE_OFFSET movable during boot. + config RANDOMIZE_MEMORY bool "Randomize the kernel memory sections" depends on X86_64 depends on RANDOMIZE_BASE + select DYNAMIC_MEMORY_LAYOUT default RANDOMIZE_BASE ---help--- Randomizes the base virtual address of kernel memory sections
arch/x86/include/asm/kaslr.h +0 -4
@@ -5,10 +5,6 @@unsigned long kaslr_get_random_long (const char *purpose);#ifdef CONFIG_RANDOMIZE_MEMORY -extern unsigned long page_offset_base; -extern unsigned long vmalloc_base; -extern unsigned long vmemmap_base; -void kernel_randomize_memory (void );#else static inline void kernel_randomize_memory (void ) { }
arch/x86/include/asm/page_64.h +4 -0
@@ -11,6 +11,10 @@extern unsigned long max_pfn;extern unsigned long phys_base; +extern unsigned long page_offset_base; +extern unsigned long vmalloc_base; +extern unsigned long vmemmap_base; +static inline unsigned long __phys_addr_nodebug (unsigned long x) {unsigned long y = x - __START_KERNEL_map;
arch/x86/include/asm/page_64_types.h +2 -2
@@ -43,11 +43,11 @@#define __PAGE_OFFSET_BASE _AC(0xffff880000000000, UL)#endif -#ifdef CONFIG_RANDOMIZE_MEMORY +#ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT #define __PAGE_OFFSET page_offset_base#else #define __PAGE_OFFSET __PAGE_OFFSET_BASE -#endif /* CONFIG_RANDOMIZE_MEMORY */ +#endif /* CONFIG_DYNAMIC_MEMORY_LAYOUT */ #define __START_KERNEL_map _AC(0xffffffff80000000, UL)
arch/x86/include/asm/pgtable_64_types.h +2 -2
@@ -100,13 +100,13 @@ typedef struct { pteval_t pte; } pte_t;# define LDT_BASE_ADDR (LDT_PGD_ENTRY << PGDIR_SHIFT)#endif -#ifdef CONFIG_RANDOMIZE_MEMORY +#ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT # define VMALLOC_START vmalloc_base# define VMEMMAP_START vmemmap_base#else # define VMALLOC_START __VMALLOC_BASE# define VMEMMAP_START __VMEMMAP_BASE -#endif /* CONFIG_RANDOMIZE_MEMORY */ +#endif /* CONFIG_DYNAMIC_MEMORY_LAYOUT */ #define VMALLOC_END (VMALLOC_START + _AC((VMALLOC_SIZE_TB << 40) - 1, UL))
arch/x86/kernel/head64.c +9 -0
@@ -39,6 +39,15 @@ extern pmd_t early_dynamic_pgts[EARLY_DYNAMIC_PAGE_TABLES][PTRS_PER_PMD];static unsigned int __initdata next_early_pgt;pmdval_t early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX); +#ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT +unsigned long page_offset_base__ro_after_init = __PAGE_OFFSET_BASE; +EXPORT_SYMBOL (page_offset_base); +unsigned long vmalloc_base__ro_after_init = __VMALLOC_BASE; +EXPORT_SYMBOL (vmalloc_base); +unsigned long vmemmap_base__ro_after_init = __VMEMMAP_BASE; +EXPORT_SYMBOL (vmemmap_base); +#endif +#define __head __section(.head.text) static void __head *fixup_pointer(void *ptr, unsigned long physaddr)
arch/x86/mm/kaslr.c +0 -8
@@ -43,14 +43,6 @@static const unsigned long vaddr_start = __PAGE_OFFSET_BASE;static const unsigned long vaddr_end =CPU_ENTRY_AREA_BASE ; -/* Default values */ -unsigned long page_offset_base = __PAGE_OFFSET_BASE; -EXPORT_SYMBOL (page_offset_base); -unsigned long vmalloc_base = __VMALLOC_BASE; -EXPORT_SYMBOL (vmalloc_base); -unsigned long vmemmap_base = __VMEMMAP_BASE; -EXPORT_SYMBOL (vmemmap_base); -/* * Memory regions randomized by KASLR (except modules that use a separate logic * earlier during boot). The list is ordered based on virtual addresses. This
PATCH 4/9 x86: Introduce pgtable_l5_enabled
In reply to Kirill A. ShutemovThe new flag would indicate what paging mode we are in.
--- arch/x86/boot/compressed/kaslr.c | 4 ++++ arch/x86/include/asm/pgtable_32_types.h | 2 ++ arch/x86/include/asm/pgtable_64_types.h | 6 ++++++ arch/x86/kernel/head64.c | 5 +++++ 4 files changed, 17 insertions(+)
arch/x86/boot/compressed/kaslr.c +4 -0
@@ -46,6 +46,10 @@#define STATIC #include <linux/decompress/mm.h> +#ifdef CONFIG_X86_5LEVEL +unsigned int pgtable_l5_enabled__ro_after_init =1 ; +#endif +extern unsigned long get_cmd_line_ptr (void );/* Simplified build-specific string for starting entropy. */
arch/x86/include/asm/pgtable_32_types.h +2 -0
@@ -15,6 +15,8 @@# include <asm/pgtable-2level_types.h> #endif +#define pgtable_l5_enabled 0 +#define PGDIR_SIZE (1UL << PGDIR_SHIFT)#define PGDIR_MASK (~(PGDIR_SIZE - 1))
arch/x86/include/asm/pgtable_64_types.h +6 -0
@@ -20,6 +20,12 @@ typedef unsigned long pgprotval_t;typedef struct {pteval_t pte; }pte_t ; +#ifdef CONFIG_X86_5LEVEL +extern unsigned int pgtable_l5_enabled; +#else +#define pgtable_l5_enabled 0 +#endif +#endif /* !__ASSEMBLY__ */ #define SHARED_KERNEL_PMD 0
arch/x86/kernel/head64.c +5 -0
@@ -39,6 +39,11 @@ extern pmd_t early_dynamic_pgts[EARLY_DYNAMIC_PAGE_TABLES][PTRS_PER_PMD];static unsigned int __initdata next_early_pgt;pmdval_t early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX); +#ifdef CONFIG_X86_5LEVEL +unsigned int pgtable_l5_enabled__ro_after_init =1 ; +EXPORT_SYMBOL (pgtable_l5_enabled); +#endif +#ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT unsigned long page_offset_base__ro_after_init = __PAGE_OFFSET_BASE;EXPORT_SYMBOL (page_offset_base);
Signature · 7 lines
2.15.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
tip-bot for Kirill A. Shutemov
merge bot[tip:x86/mm] x86/mm: Introduce 'pgtable_l5_enabled'
x86/mm: Introduce 'pgtable_l5_enabled'
Commit-ID: e626e6bb0dfaca41487241d49ce0ae827716101a Gitweb: https://git.kernel.org/tip/e626e6bb0dfaca41487241d49ce0ae827716101a Author: Kirill A. Shutemov <[email protected]> AuthorDate: Wed, 14 Feb 2018 14:16:51 +0300 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 14 Feb 2018 13:11:14 +0100
x86/mm: Introduce 'pgtable_l5_enabled'
The new flag would indicate what paging mode we are in.
--- arch/x86/boot/compressed/kaslr.c | 4 ++++ arch/x86/include/asm/pgtable_32_types.h | 2 ++ arch/x86/include/asm/pgtable_64_types.h | 6 ++++++ arch/x86/kernel/head64.c | 5 +++++ 4 files changed, 17 insertions(+)
arch/x86/boot/compressed/kaslr.c +4 -0
@@ -46,6 +46,10 @@#define STATIC #include <linux/decompress/mm.h> +#ifdef CONFIG_X86_5LEVEL +unsigned int pgtable_l5_enabled__ro_after_init =1 ; +#endif +extern unsigned long get_cmd_line_ptr (void );/* Simplified build-specific string for starting entropy. */
arch/x86/include/asm/pgtable_32_types.h +2 -0
@@ -15,6 +15,8 @@# include <asm/pgtable-2level_types.h> #endif +#define pgtable_l5_enabled 0 +#define PGDIR_SIZE (1UL << PGDIR_SHIFT)#define PGDIR_MASK (~(PGDIR_SIZE - 1))
arch/x86/include/asm/pgtable_64_types.h +6 -0
@@ -20,6 +20,12 @@ typedef unsigned long pgprotval_t;typedef struct {pteval_t pte; }pte_t ; +#ifdef CONFIG_X86_5LEVEL +extern unsigned int pgtable_l5_enabled; +#else +#define pgtable_l5_enabled 0 +#endif +#endif /* !__ASSEMBLY__ */ #define SHARED_KERNEL_PMD 0
arch/x86/kernel/head64.c +5 -0
@@ -39,6 +39,11 @@ extern pmd_t early_dynamic_pgts[EARLY_DYNAMIC_PAGE_TABLES][PTRS_PER_PMD];static unsigned int __initdata next_early_pgt;pmdval_t early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX); +#ifdef CONFIG_X86_5LEVEL +unsigned int pgtable_l5_enabled__ro_after_init =1 ; +EXPORT_SYMBOL (pgtable_l5_enabled); +#endif +#ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT unsigned long page_offset_base__ro_after_init = __PAGE_OFFSET_BASE;EXPORT_SYMBOL (page_offset_base);
PATCH 5/9 x86/mm: Make LDT_BASE_ADDR dynamic
In reply to Kirill A. ShutemovLDT_BASE_ADDR has different value in 4- and 5-level paging configurations.
We need to make it dynamic in preparation for boot-time switching between paging modes.
--- arch/x86/include/asm/pgtable_64_types.h | 9 +++++---- arch/x86/mm/dump_pagetables.c | 5 ++++- 2 files changed, 9 insertions(+), 5 deletions(-)
arch/x86/include/asm/pgtable_64_types.h +5 -4
@@ -92,18 +92,19 @@ extern unsigned int pgtable_l5_enabled;*/ #define MAXMEM _AC(__AC(1, UL) << MAX_PHYSMEM_BITS, UL) +#define LDT_PGD_ENTRY_L4 -3UL +#define LDT_PGD_ENTRY_L5 -112UL +#define LDT_PGD_ENTRY (pgtable_l5_enabled ? LDT_PGD_ENTRY_L5 : LDT_PGD_ENTRY_L4) +#define LDT_BASE_ADDR (LDT_PGD_ENTRY << PGDIR_SHIFT) +#ifdef CONFIG_X86_5LEVEL # define VMALLOC_SIZE_TB _AC(12800, UL)# define __VMALLOC_BASE _AC(0xffa0000000000000, UL)# define __VMEMMAP_BASE _AC(0xffd4000000000000, UL) -# define LDT_PGD_ENTRY _AC(-112, UL) -# define LDT_BASE_ADDR (LDT_PGD_ENTRY << PGDIR_SHIFT)#else # define VMALLOC_SIZE_TB _AC(32, UL)# define __VMALLOC_BASE _AC(0xffffc90000000000, UL)# define __VMEMMAP_BASE _AC(0xffffea0000000000, UL) -# define LDT_PGD_ENTRY _AC(-3, UL) -# define LDT_BASE_ADDR (LDT_PGD_ENTRY << PGDIR_SHIFT)#endif #ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT
arch/x86/mm/dump_pagetables.c +4 -1
@@ -89,7 +89,7 @@ static struct addr_marker address_markers[] = { [KASAN_SHADOW_END_NR] = { KASAN_SHADOW_END, "KASAN shadow end" }, #endif #ifdef CONFIG_MODIFY_LDT_SYSCALL - [LDT_NR] = { LDT_BASE_ADDR, "LDT remap" }, + [LDT_NR] = { 0UL, "LDT remap" }, #endif [CPU_ENTRY_AREA_NR] = { CPU_ENTRY_AREA_BASE,"CPU entry Area" }, #ifdef CONFIG_X86_ESPFIX64
@@ -570,6 +570,9 @@ static int __init pt_dump_init(void) address_markers[LOW_KERNEL_NR ].start_address =PAGE_OFFSET ; address_markers[VMALLOC_START_NR ].start_address =VMALLOC_START ; address_markers[VMEMMAP_START_NR ].start_address =VMEMMAP_START ; +#ifdef CONFIG_MODIFY_LDT_SYSCALL + address_markers[LDT_NR ].start_address =LDT_BASE_ADDR ; +#endif #endif #ifdef CONFIG_X86_32 address_markers[VMALLOC_START_NR ].start_address =VMALLOC_START ;
Signature · 7 lines
2.15.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
tip-bot for Kirill A. Shutemov
merge bot[tip:x86/mm] x86/mm: Make LDT_BASE_ADDR dynamic
x86/mm: Make LDT_BASE_ADDR dynamic
Commit-ID: 5c7919bb1994f8dc7fed219a5db09e6bb9d473a5 Gitweb: https://git.kernel.org/tip/5c7919bb1994f8dc7fed219a5db09e6bb9d473a5 Author: Kirill A. Shutemov <[email protected]> AuthorDate: Wed, 14 Feb 2018 14:16:52 +0300 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 14 Feb 2018 13:11:14 +0100
x86/mm: Make LDT_BASE_ADDR dynamic
LDT_BASE_ADDR has different value in 4- and 5-level paging configurations.
We need to make it dynamic in preparation for boot-time switching between paging modes.
--- arch/x86/include/asm/pgtable_64_types.h | 9 +++++---- arch/x86/mm/dump_pagetables.c | 5 ++++- 2 files changed, 9 insertions(+), 5 deletions(-)
arch/x86/include/asm/pgtable_64_types.h +5 -4
@@ -92,18 +92,19 @@ extern unsigned int pgtable_l5_enabled;*/ #define MAXMEM _AC(__AC(1, UL) << MAX_PHYSMEM_BITS, UL) +#define LDT_PGD_ENTRY_L4 -3UL +#define LDT_PGD_ENTRY_L5 -112UL +#define LDT_PGD_ENTRY (pgtable_l5_enabled ? LDT_PGD_ENTRY_L5 : LDT_PGD_ENTRY_L4) +#define LDT_BASE_ADDR (LDT_PGD_ENTRY << PGDIR_SHIFT) +#ifdef CONFIG_X86_5LEVEL # define VMALLOC_SIZE_TB _AC(12800, UL)# define __VMALLOC_BASE _AC(0xffa0000000000000, UL)# define __VMEMMAP_BASE _AC(0xffd4000000000000, UL) -# define LDT_PGD_ENTRY _AC(-112, UL) -# define LDT_BASE_ADDR (LDT_PGD_ENTRY << PGDIR_SHIFT)#else # define VMALLOC_SIZE_TB _AC(32, UL)# define __VMALLOC_BASE _AC(0xffffc90000000000, UL)# define __VMEMMAP_BASE _AC(0xffffea0000000000, UL) -# define LDT_PGD_ENTRY _AC(-3, UL) -# define LDT_BASE_ADDR (LDT_PGD_ENTRY << PGDIR_SHIFT)#endif #ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT
arch/x86/mm/dump_pagetables.c +4 -1
@@ -89,7 +89,7 @@ static struct addr_marker address_markers[] = { [KASAN_SHADOW_END_NR] = { KASAN_SHADOW_END, "KASAN shadow end" }, #endif #ifdef CONFIG_MODIFY_LDT_SYSCALL - [LDT_NR] = { LDT_BASE_ADDR, "LDT remap" }, + [LDT_NR] = { 0UL, "LDT remap" }, #endif [CPU_ENTRY_AREA_NR] = { CPU_ENTRY_AREA_BASE,"CPU entry Area" }, #ifdef CONFIG_X86_ESPFIX64
@@ -570,6 +570,9 @@ static int __init pt_dump_init(void) address_markers[LOW_KERNEL_NR ].start_address =PAGE_OFFSET ; address_markers[VMALLOC_START_NR ].start_address =VMALLOC_START ; address_markers[VMEMMAP_START_NR ].start_address =VMEMMAP_START ; +#ifdef CONFIG_MODIFY_LDT_SYSCALL + address_markers[LDT_NR ].start_address =LDT_BASE_ADDR ; +#endif #endif #ifdef CONFIG_X86_32 address_markers[VMALLOC_START_NR ].start_address =VMALLOC_START ;
Re: [PATCH 5/9] x86/mm: Make LDT_BASE_ADDR dynamic
In reply to Kirill A. ShutemovQuoted 7 lines · Kirill A. Shutemov
LDT_BASE_ADDRhas different value in 4- and 5-level paging configurations.We need to make it dynamic in preparation for boot-time switching between paging modes.
Signed-off-by Kirill A. Shutemov <[email protected]>
I've just realized that the patch that I'm splitting has hunk that belong here.
Could you fold it in?
Sorry for this.
arch/x86/mm/dump_pagetables.c +3 -0
@@ -579,6 +579,9 @@ static int __init pt_dump_init(void) address_markers[KASAN_SHADOW_START_NR ].start_address =KASAN_SHADOW_START ; address_markers[KASAN_SHADOW_END_NR ].start_address =KASAN_SHADOW_END ;#endif +#ifdef CONFIG_MODIFY_LDT_SYSCALL + address_markers[LDT_NR ].start_address =LDT_BASE_ADDR ; +#endif #endif #ifdef CONFIG_X86_32 address_markers[VMALLOC_START_NR ].start_address =VMALLOC_START ;
Signature · 7 lines
Kirill A. Shutemov -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 6/9 x86/mm: Make PGDIR_SHIFT and PTRS_PER_P4D variable
In reply to Kirill A. ShutemovFor boot-time switching between 4- and 5-level paging we need to be able to fold p4d page table level at runtime. It requires variable PGDIR_SHIFT and PTRS_PER_P4D.
The change doesn't affect the kernel image size much:
text data bss dec hex filename
8628091 4734304 1368064 14730459 e0c4db vmlinux.before
8628393 4734340 1368064 14730797 e0c62d vmlinux.after
--- arch/x86/boot/compressed/kaslr.c | 2 ++ arch/x86/include/asm/pgtable_32.h | 2 ++ arch/x86/include/asm/pgtable_64_types.h | 19 ++++++++++++------- arch/x86/kernel/cpu/mcheck/mce.c | 18 ++++++------------ arch/x86/kernel/head64.c | 6 +++++- arch/x86/mm/dump_pagetables.c | 12 +++++------- arch/x86/mm/init_64.c | 2 +- arch/x86/mm/kasan_init_64.c | 2 +- arch/x86/platform/efi/efi_64.c | 4 ++-- include/asm-generic/5level-fixup.h | 1 + include/asm-generic/pgtable-nop4d.h | 9 +++++---- include/linux/kasan.h | 2 +- mm/kasan/kasan_init.c | 2 +- 13 files changed, 44 insertions(+), 37 deletions(-)
arch/x86/boot/compressed/kaslr.c +2 -0
@@ -48,6 +48,8 @@#ifdef CONFIG_X86_5LEVEL unsigned int pgtable_l5_enabled__ro_after_init =1 ; +unsigned int pgdir_shift__ro_after_init =48 ; +unsigned int ptrs_per_p4d__ro_after_init =512 ;#endif extern unsigned long get_cmd_line_ptr (void );
arch/x86/include/asm/pgtable_32.h +2 -0
@@ -33,6 +33,8 @@ static inline void pgtable_cache_init(void) { }static inline void check_pgt_cache (void ) { }void paging_init (void ); +static inline int pgd_large (pgd_t pgd) {return 0 ; } +/* * Define this if things work differently on an i386 and an i486: * it will (on an i486) warn about kernel memory accesses that are
arch/x86/include/asm/pgtable_64_types.h +12 -7
@@ -26,6 +26,9 @@ extern unsigned int pgtable_l5_enabled;#define pgtable_l5_enabled 0#endif +extern unsigned int pgdir_shift; +extern unsigned int ptrs_per_p4d; +#endif /* !__ASSEMBLY__ */ #define SHARED_KERNEL_PMD 0
@@ -35,16 +38,17 @@ extern unsigned int pgtable_l5_enabled;/* * PGDIR_SHIFT determines what a top-level page table entry can map */ -#define PGDIR_SHIFT 48 +#define PGDIR_SHIFT pgdir_shift#define PTRS_PER_PGD 512/* * 4th level page in 5-level paging case */ -#define P4D_SHIFT 39 -#define PTRS_PER_P4D 512 -#define P4D_SIZE (_AC(1, UL) << P4D_SHIFT) -#define P4D_MASK (~(P4D_SIZE - 1)) +#define P4D_SHIFT 39 +#define MAX_PTRS_PER_P4D 512 +#define PTRS_PER_P4D ptrs_per_p4d +#define P4D_SIZE (_AC(1, UL) << P4D_SHIFT) +#define P4D_MASK (~(P4D_SIZE - 1))#define MAX_POSSIBLE_PHYSMEM_BITS 52
@@ -53,8 +57,9 @@ extern unsigned int pgtable_l5_enabled;/* * PGDIR_SHIFT determines what a top-level page table entry can map */ -#define PGDIR_SHIFT 39 -#define PTRS_PER_PGD 512 +#define PGDIR_SHIFT 39 +#define PTRS_PER_PGD 512 +#define MAX_PTRS_PER_P4D 1#endif /* CONFIG_X86_5LEVEL */
arch/x86/kernel/cpu/mcheck/mce.c +6 -12
@@ -1088,19 +1088,7 @@ static void mce_unmap_kpfn(unsigned long pfn)* a legal address. */ -/* -* Build time check to see if we have a spare virtual bit. Don't want -* to leave this until run time because most developers don't have a -* system that can exercise this code path. This will only become a -* problem if/when we move beyond 5-level page tables. -* -* Hard code "9" here because cpp doesn't grok ilog2(PTRS_PER_PGD) -*/ -#if PGDIR_SHIFT +9 <63 decoy_addr = (pfn <<PAGE_SHIFT ) + (PAGE_OFFSET ^BIT (63 )); -#else -#error "no unused virtual bit available" -#endif if (set_memory_np (decoy_addr,1 ))pr_warn ("Could not invalidate pfn=0x%lx from 1:1 map\n" , pfn);
@@ -2333,6 +2321,12 @@ static __init int mcheck_init_device(void) {int err; +/* +* Check if we have a spare virtual bit. This will only become +* a problem if/when we move beyond 5-level page tables. +*/ +MAYBE_BUILD_BUG_ON (__VIRTUAL_MASK_SHIFT >=63 ); +if (!mce_available (&boot_cpu_data)) { err = -EIO ; goto err_out;
arch/x86/kernel/head64.c +5 -1
@@ -42,6 +42,10 @@ pmdval_t early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX);#ifdef CONFIG_X86_5LEVEL unsigned int pgtable_l5_enabled__ro_after_init =1 ;EXPORT_SYMBOL (pgtable_l5_enabled); +unsigned int pgdir_shift__ro_after_init =48 ; +EXPORT_SYMBOL (pgdir_shift); +unsigned int ptrs_per_p4d__ro_after_init =512 ; +EXPORT_SYMBOL (ptrs_per_p4d);#endif #ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT
@@ -336,7 +340,7 @@ asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data)BUILD_BUG_ON ((__START_KERNEL_map & ~PMD_MASK ) !=0 );BUILD_BUG_ON ((MODULES_VADDR & ~PMD_MASK ) !=0 );BUILD_BUG_ON (!(MODULES_VADDR > __START_KERNEL)); -BUILD_BUG_ON (!(((MODULES_END -1 ) &PGDIR_MASK ) == +MAYBE_BUILD_BUG_ON (!(((MODULES_END -1 ) &PGDIR_MASK ) == (__START_KERNEL &PGDIR_MASK )));BUILD_BUG_ON (__fix_to_virt (__end_of_fixed_addresses) <=MODULES_END );
arch/x86/mm/dump_pagetables.c +5 -7
@@ -428,14 +428,15 @@ static void walk_pud_level(struct seq_file *m, struct pg_state *st, p4d_t addr,#define p4d_none (a) pud_none(__pud(p4d_val(a)))#endif -#if PTRS_PER_P4D >1 -static void walk_p4d_level (struct seq_file *m,struct pg_state *st,pgd_t addr,unsigned long P ) {int i;p4d_t *start, *p4d_start;pgprotval_t prot; +if (PTRS_PER_P4D ==1 ) +return walk_pud_level (m, st,__p4d (pgd_val (addr)),P ); + p4d_start = start = (p4d_t *)pgd_page_vaddr (addr);for (i =0 ; i <PTRS_PER_P4D ; i++) {
@@ -455,11 +456,8 @@ static void walk_p4d_level(struct seq_file *m, struct pg_state *st, pgd_t addr, } } -#else -#define walk_p4d_level (m,s,a,p) walk_pud_level(m,s,__p4d(pgd_val(a)),p) -#define pgd_large (a) p4d_large(__p4d(pgd_val(a))) -#define pgd_none (a) p4d_none(__p4d(pgd_val(a))) -#endif +#define pgd_large (a) (pgtable_l5_enabled ? pgd_large(a) : p4d_large(__p4d(pgd_val(a)))) +#define pgd_none (a) (pgtable_l5_enabled ? pgd_none(a) : p4d_none(__p4d(pgd_val(a))))static inline bool is_hypervisor_range (int idx) {
arch/x86/mm/init_64.c +1 -1
@@ -143,7 +143,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)* With folded p4d, pgd_none() is always false, we need to * handle synchonization on p4d level. */ -BUILD_BUG_ON (pgd_none (*pgd_ref)); +MAYBE_BUILD_BUG_ON (pgd_none (*pgd_ref)); p4d_ref =p4d_offset (pgd_ref, addr);if (p4d_none (*p4d_ref))
arch/x86/mm/kasan_init_64.c +1 -1
@@ -19,7 +19,7 @@extern struct range pfn_mapped[E820_MAX_ENTRIES ]; -static p4d_t tmp_p4d_table[PTRS_PER_P4D ]__initdata __aligned(PAGE_SIZE) ; +static p4d_t tmp_p4d_table[MAX_PTRS_PER_P4D ]__initdata __aligned(PAGE_SIZE) ;static __init void *early_alloc (size_t size,int nid,bool panic) {
arch/x86/platform/efi/efi_64.c +2 -2
@@ -257,8 +257,8 @@ void efi_sync_low_kernel_mappings(void)* only span a single PGD entry and that the entry also maps * other important kernel regions. */ -BUILD_BUG_ON (pgd_index (EFI_VA_END ) !=pgd_index (MODULES_END )); -BUILD_BUG_ON ((EFI_VA_START &PGDIR_MASK ) != +MAYBE_BUILD_BUG_ON (pgd_index (EFI_VA_END ) !=pgd_index (MODULES_END )); +MAYBE_BUILD_BUG_ON ((EFI_VA_START &PGDIR_MASK ) != (EFI_VA_END &PGDIR_MASK )); pgd_efi = efi_pgd +pgd_index (PAGE_OFFSET );
include/asm-generic/5level-fixup.h +1 -0
@@ -8,6 +8,7 @@#define P4D_SHIFT PGDIR_SHIFT#define P4D_SIZE PGDIR_SIZE#define P4D_MASK PGDIR_MASK +#define MAX_PTRS_PER_P4D 1#define PTRS_PER_P4D 1#define p4d_t pgd_t
include/asm-generic/pgtable-nop4d.h +5 -4
@@ -8,10 +8,11 @@typedef struct {pgd_t pgd; }p4d_t ; -#define P4D_SHIFT PGDIR_SHIFT -#define PTRS_PER_P4D 1 -#define P4D_SIZE (1UL << P4D_SHIFT) -#define P4D_MASK (~(P4D_SIZE-1)) +#define P4D_SHIFT PGDIR_SHIFT +#define MAX_PTRS_PER_P4D 1 +#define PTRS_PER_P4D 1 +#define P4D_SIZE (1UL << P4D_SHIFT) +#define P4D_MASK (~(P4D_SIZE-1))/* * The "pgd_xxx()" functions here are trivial for a folded two-level
include/linux/kasan.h +1 -1
@@ -18,7 +18,7 @@ extern unsigned char kasan_zero_page[PAGE_SIZE];extern pte_t kasan_zero_pte[PTRS_PER_PTE ];extern pmd_t kasan_zero_pmd[PTRS_PER_PMD ];extern pud_t kasan_zero_pud[PTRS_PER_PUD ]; -extern p4d_t kasan_zero_p4d[PTRS_PER_P4D ]; +extern p4d_t kasan_zero_p4d[MAX_PTRS_PER_P4D ];void kasan_populate_zero_shadow (const void *shadow_start,const void *shadow_end);
mm/kasan/kasan_init.c +1 -1
@@ -31,7 +31,7 @@ unsigned char kasan_zero_page[PAGE_SIZE] __page_aligned_bss;#if CONFIG_PGTABLE_LEVELS >4 -p4d_t kasan_zero_p4d[PTRS_PER_P4D] __page_aligned_bss; +p4d_t kasan_zero_p4d[MAX_PTRS_PER_P4D] __page_aligned_bss;#endif #if CONFIG_PGTABLE_LEVELS >3 pud_t kasan_zero_pud[PTRS_PER_PUD] __page_aligned_bss;
Signature · 7 lines
2.15.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
tip-bot for Kirill A. Shutemov
merge bot[tip:x86/mm] x86/mm: Make PGDIR_SHIFT and PTRS_PER_P4D variable
x86/mm: Make PGDIR_SHIFT and PTRS_PER_P4D variable
Commit-ID: c65e774fb3f6af212641538694b9778ff9ab4300 Gitweb: https://git.kernel.org/tip/c65e774fb3f6af212641538694b9778ff9ab4300 Author: Kirill A. Shutemov <[email protected]> AuthorDate: Wed, 14 Feb 2018 14:16:53 +0300 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 14 Feb 2018 13:11:14 +0100
x86/mm: Make PGDIR_SHIFT and PTRS_PER_P4D variable
For boot-time switching between 4- and 5-level paging we need to be able to fold p4d page table level at runtime. It requires variable PGDIR_SHIFT and PTRS_PER_P4D.
The change doesn't affect the kernel image size much:
text data bss dec hex filename
8628091 4734304 1368064 14730459 e0c4db vmlinux.before
8628393 4734340 1368064 14730797 e0c62d vmlinux.after
--- arch/x86/boot/compressed/kaslr.c | 2 ++ arch/x86/include/asm/pgtable_32.h | 2 ++ arch/x86/include/asm/pgtable_64_types.h | 19 ++++++++++++------- arch/x86/kernel/cpu/mcheck/mce.c | 18 ++++++------------ arch/x86/kernel/head64.c | 6 +++++- arch/x86/mm/dump_pagetables.c | 12 +++++------- arch/x86/mm/init_64.c | 2 +- arch/x86/mm/kasan_init_64.c | 2 +- arch/x86/platform/efi/efi_64.c | 4 ++-- include/asm-generic/5level-fixup.h | 1 + include/asm-generic/pgtable-nop4d.h | 9 +++++---- include/linux/kasan.h | 2 +- mm/kasan/kasan_init.c | 2 +- 13 files changed, 44 insertions(+), 37 deletions(-)
arch/x86/boot/compressed/kaslr.c +2 -0
@@ -48,6 +48,8 @@#ifdef CONFIG_X86_5LEVEL unsigned int pgtable_l5_enabled__ro_after_init =1 ; +unsigned int pgdir_shift__ro_after_init =48 ; +unsigned int ptrs_per_p4d__ro_after_init =512 ;#endif extern unsigned long get_cmd_line_ptr (void );
arch/x86/include/asm/pgtable_32.h +2 -0
@@ -33,6 +33,8 @@ static inline void pgtable_cache_init(void) { }static inline void check_pgt_cache (void ) { }void paging_init (void ); +static inline int pgd_large (pgd_t pgd) {return 0 ; } +/* * Define this if things work differently on an i386 and an i486: * it will (on an i486) warn about kernel memory accesses that are
arch/x86/include/asm/pgtable_64_types.h +12 -7
@@ -26,6 +26,9 @@ extern unsigned int pgtable_l5_enabled;#define pgtable_l5_enabled 0#endif +extern unsigned int pgdir_shift; +extern unsigned int ptrs_per_p4d; +#endif /* !__ASSEMBLY__ */ #define SHARED_KERNEL_PMD 0
@@ -35,16 +38,17 @@ extern unsigned int pgtable_l5_enabled;/* * PGDIR_SHIFT determines what a top-level page table entry can map */ -#define PGDIR_SHIFT 48 +#define PGDIR_SHIFT pgdir_shift#define PTRS_PER_PGD 512/* * 4th level page in 5-level paging case */ -#define P4D_SHIFT 39 -#define PTRS_PER_P4D 512 -#define P4D_SIZE (_AC(1, UL) << P4D_SHIFT) -#define P4D_MASK (~(P4D_SIZE - 1)) +#define P4D_SHIFT 39 +#define MAX_PTRS_PER_P4D 512 +#define PTRS_PER_P4D ptrs_per_p4d +#define P4D_SIZE (_AC(1, UL) << P4D_SHIFT) +#define P4D_MASK (~(P4D_SIZE - 1))#define MAX_POSSIBLE_PHYSMEM_BITS 52
@@ -53,8 +57,9 @@ extern unsigned int pgtable_l5_enabled;/* * PGDIR_SHIFT determines what a top-level page table entry can map */ -#define PGDIR_SHIFT 39 -#define PTRS_PER_PGD 512 +#define PGDIR_SHIFT 39 +#define PTRS_PER_PGD 512 +#define MAX_PTRS_PER_P4D 1#endif /* CONFIG_X86_5LEVEL */
arch/x86/kernel/cpu/mcheck/mce.c +6 -12
@@ -1082,19 +1082,7 @@ void arch_unmap_kpfn(unsigned long pfn)* a legal address. */ -/* -* Build time check to see if we have a spare virtual bit. Don't want -* to leave this until run time because most developers don't have a -* system that can exercise this code path. This will only become a -* problem if/when we move beyond 5-level page tables. -* -* Hard code "9" here because cpp doesn't grok ilog2(PTRS_PER_PGD) -*/ -#if PGDIR_SHIFT +9 <63 decoy_addr = (pfn <<PAGE_SHIFT ) + (PAGE_OFFSET ^BIT (63 )); -#else -#error "no unused virtual bit available" -#endif if (set_memory_np (decoy_addr,1 ))pr_warn ("Could not invalidate pfn=0x%lx from 1:1 map\n" , pfn);
@@ -2328,6 +2316,12 @@ static __init int mcheck_init_device(void) {int err; +/* +* Check if we have a spare virtual bit. This will only become +* a problem if/when we move beyond 5-level page tables. +*/ +MAYBE_BUILD_BUG_ON (__VIRTUAL_MASK_SHIFT >=63 ); +if (!mce_available (&boot_cpu_data)) { err = -EIO ; goto err_out;
arch/x86/kernel/head64.c +5 -1
@@ -42,6 +42,10 @@ pmdval_t early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX);#ifdef CONFIG_X86_5LEVEL unsigned int pgtable_l5_enabled__ro_after_init =1 ;EXPORT_SYMBOL (pgtable_l5_enabled); +unsigned int pgdir_shift__ro_after_init =48 ; +EXPORT_SYMBOL (pgdir_shift); +unsigned int ptrs_per_p4d__ro_after_init =512 ; +EXPORT_SYMBOL (ptrs_per_p4d);#endif #ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT
@@ -336,7 +340,7 @@ asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data)BUILD_BUG_ON ((__START_KERNEL_map & ~PMD_MASK ) !=0 );BUILD_BUG_ON ((MODULES_VADDR & ~PMD_MASK ) !=0 );BUILD_BUG_ON (!(MODULES_VADDR > __START_KERNEL)); -BUILD_BUG_ON (!(((MODULES_END -1 ) &PGDIR_MASK ) == +MAYBE_BUILD_BUG_ON (!(((MODULES_END -1 ) &PGDIR_MASK ) == (__START_KERNEL &PGDIR_MASK )));BUILD_BUG_ON (__fix_to_virt (__end_of_fixed_addresses) <=MODULES_END );
arch/x86/mm/dump_pagetables.c +5 -7
@@ -428,14 +428,15 @@ static void walk_pud_level(struct seq_file *m, struct pg_state *st, p4d_t addr,#define p4d_none (a) pud_none(__pud(p4d_val(a)))#endif -#if PTRS_PER_P4D >1 -static void walk_p4d_level (struct seq_file *m,struct pg_state *st,pgd_t addr,unsigned long P ) {int i;p4d_t *start, *p4d_start;pgprotval_t prot; +if (PTRS_PER_P4D ==1 ) +return walk_pud_level (m, st,__p4d (pgd_val (addr)),P ); + p4d_start = start = (p4d_t *)pgd_page_vaddr (addr);for (i =0 ; i <PTRS_PER_P4D ; i++) {
@@ -455,11 +456,8 @@ static void walk_p4d_level(struct seq_file *m, struct pg_state *st, pgd_t addr, } } -#else -#define walk_p4d_level (m,s,a,p) walk_pud_level(m,s,__p4d(pgd_val(a)),p) -#define pgd_large (a) p4d_large(__p4d(pgd_val(a))) -#define pgd_none (a) p4d_none(__p4d(pgd_val(a))) -#endif +#define pgd_large (a) (pgtable_l5_enabled ? pgd_large(a) : p4d_large(__p4d(pgd_val(a)))) +#define pgd_none (a) (pgtable_l5_enabled ? pgd_none(a) : p4d_none(__p4d(pgd_val(a))))static inline bool is_hypervisor_range (int idx) {
arch/x86/mm/init_64.c +1 -1
@@ -143,7 +143,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)* With folded p4d, pgd_none() is always false, we need to * handle synchonization on p4d level. */ -BUILD_BUG_ON (pgd_none (*pgd_ref)); +MAYBE_BUILD_BUG_ON (pgd_none (*pgd_ref)); p4d_ref =p4d_offset (pgd_ref, addr);if (p4d_none (*p4d_ref))
arch/x86/mm/kasan_init_64.c +1 -1
@@ -19,7 +19,7 @@extern struct range pfn_mapped[E820_MAX_ENTRIES ]; -static p4d_t tmp_p4d_table[PTRS_PER_P4D ]__initdata __aligned(PAGE_SIZE) ; +static p4d_t tmp_p4d_table[MAX_PTRS_PER_P4D ]__initdata __aligned(PAGE_SIZE) ;static __init void *early_alloc (size_t size,int nid,bool panic) {
arch/x86/platform/efi/efi_64.c +2 -2
@@ -257,8 +257,8 @@ void efi_sync_low_kernel_mappings(void)* only span a single PGD entry and that the entry also maps * other important kernel regions. */ -BUILD_BUG_ON (pgd_index (EFI_VA_END ) !=pgd_index (MODULES_END )); -BUILD_BUG_ON ((EFI_VA_START &PGDIR_MASK ) != +MAYBE_BUILD_BUG_ON (pgd_index (EFI_VA_END ) !=pgd_index (MODULES_END )); +MAYBE_BUILD_BUG_ON ((EFI_VA_START &PGDIR_MASK ) != (EFI_VA_END &PGDIR_MASK )); pgd_efi = efi_pgd +pgd_index (PAGE_OFFSET );
include/asm-generic/5level-fixup.h +1 -0
@@ -8,6 +8,7 @@#define P4D_SHIFT PGDIR_SHIFT#define P4D_SIZE PGDIR_SIZE#define P4D_MASK PGDIR_MASK +#define MAX_PTRS_PER_P4D 1#define PTRS_PER_P4D 1#define p4d_t pgd_t
include/asm-generic/pgtable-nop4d.h +5 -4
@@ -8,10 +8,11 @@typedef struct {pgd_t pgd; }p4d_t ; -#define P4D_SHIFT PGDIR_SHIFT -#define PTRS_PER_P4D 1 -#define P4D_SIZE (1UL << P4D_SHIFT) -#define P4D_MASK (~(P4D_SIZE-1)) +#define P4D_SHIFT PGDIR_SHIFT +#define MAX_PTRS_PER_P4D 1 +#define PTRS_PER_P4D 1 +#define P4D_SIZE (1UL << P4D_SHIFT) +#define P4D_MASK (~(P4D_SIZE-1))/* * The "pgd_xxx()" functions here are trivial for a folded two-level
include/linux/kasan.h +1 -1
@@ -18,7 +18,7 @@ extern unsigned char kasan_zero_page[PAGE_SIZE];extern pte_t kasan_zero_pte[PTRS_PER_PTE ];extern pmd_t kasan_zero_pmd[PTRS_PER_PMD ];extern pud_t kasan_zero_pud[PTRS_PER_PUD ]; -extern p4d_t kasan_zero_p4d[PTRS_PER_P4D ]; +extern p4d_t kasan_zero_p4d[MAX_PTRS_PER_P4D ];void kasan_populate_zero_shadow (const void *shadow_start,const void *shadow_end);
mm/kasan/kasan_init.c +1 -1
@@ -31,7 +31,7 @@ unsigned char kasan_zero_page[PAGE_SIZE] __page_aligned_bss;#if CONFIG_PGTABLE_LEVELS >4 -p4d_t kasan_zero_p4d[PTRS_PER_P4D] __page_aligned_bss; +p4d_t kasan_zero_p4d[MAX_PTRS_PER_P4D] __page_aligned_bss;#endif #if CONFIG_PGTABLE_LEVELS >3 pud_t kasan_zero_pud[PTRS_PER_PUD] __page_aligned_bss;
PATCH 7/9 x86/mm: Make MAX_PHYSADDR_BITS and MAX_PHYSMEM_BITS dynamic
In reply to Kirill A. ShutemovFor boot-time switching between paging modes, we need to be able to adjust size of physical address space at runtime.
As part of making physical address space size variable, we have to make X86_5LEVEL dependent on SPARSEMEM_VMEMMAP. !SPARSEMEM_VMEMMAP configuration doesn't build with variable MAX_PHYSMEM_BITS.
For !SPARSEMEM_VMEMMAP SECTIONS_WIDTH depends on MAX_PHYSMEM_BITS:
SECTIONS_WIDTH
SECTIONS_SHIFT
MAX_PHYSMEM_BITS
And SECTIONS_WIDTH is used on pre-processor stage, it doesn't work if it's dyncamic. See include/linux/page-flags-layout.h.
Affect on kernel image size:
text data bss dec hex filename
8628393 4734340 1368064 14730797 e0c62d vmlinux.before
8628892 4734340 1368064 14731296 e0c820 vmlinux.after
--- arch/x86/Kconfig | 1 + arch/x86/include/asm/pgtable_64_types.h | 2 +- arch/x86/include/asm/sparsemem.h | 9 ++------- arch/x86/kernel/setup.c | 5 ++--- 4 files changed, 6 insertions(+), 11 deletions(-)
arch/x86/Kconfig +1 -0
@@ -1472,6 +1472,7 @@ config X86_PAE config X86_5LEVEL bool "Enable 5-level page tables support" select DYNAMIC_MEMORY_LAYOUT + select SPARSEMEM_VMEMMAP depends on X86_64 ---help--- 5-level paging enables access to larger address space:
arch/x86/include/asm/pgtable_64_types.h +1 -1
@@ -95,7 +95,7 @@ extern unsigned int ptrs_per_p4d;* range must not overlap with anything except the KASAN shadow area, which * is correct as KASAN disables KASLR. */ -#define MAXMEM _AC(__AC(1, UL) << MAX_PHYSMEM_BITS, UL) +#define MAXMEM (1UL << MAX_PHYSMEM_BITS)#define LDT_PGD_ENTRY_L4 -3UL#define LDT_PGD_ENTRY_L5 -112UL
arch/x86/include/asm/sparsemem.h +2 -7
@@ -27,13 +27,8 @@# endif #else /* CONFIG_X86_32 */ # define SECTION_SIZE_BITS 27/* matt - 128 is convenient right now */ -# ifdef CONFIG_X86_5LEVEL -# define MAX_PHYSADDR_BITS 52 -# define MAX_PHYSMEM_BITS 52 -# else -# define MAX_PHYSADDR_BITS 44 -# define MAX_PHYSMEM_BITS 46 -# endif +# define MAX_PHYSADDR_BITS (pgtable_l5_enabled ? 52 : 44) +# define MAX_PHYSMEM_BITS (pgtable_l5_enabled ? 52 : 46)#endif #endif /* CONFIG_SPARSEMEM */
arch/x86/kernel/setup.c +2 -3
@@ -189,9 +189,7 @@ struct ist_info ist_info;#endif #else -struct cpuinfo_x86 boot_cpu_data__read_mostly = { - .x86_phys_bits =MAX_PHYSMEM_BITS , -}; +struct cpuinfo_x86 boot_cpu_data__read_mostly ;EXPORT_SYMBOL (boot_cpu_data);#endif
@@ -851,6 +849,7 @@ void __init setup_arch(char **cmdline_p)__flush_tlb_all ();#else printk (KERN_INFO "Command line: %s\n" , boot_command_line); + boot_cpu_data.x86_phys_bits =MAX_PHYSMEM_BITS ;#endif /*
Signature · 7 lines
2.15.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
tip-bot for Kirill A. Shutemov
merge bot[tip:x86/mm] x86/mm: Make MAX_PHYSADDR_BITS and MAX_PHYSMEM_BITS dynamic
x86/mm: Make MAX_PHYSADDR_BITS and MAX_PHYSMEM_BITS dynamic
Commit-ID: 162434e7f58b21f0b6c9cc5fb02222cd7d9064cc Gitweb: https://git.kernel.org/tip/162434e7f58b21f0b6c9cc5fb02222cd7d9064cc Author: Kirill A. Shutemov <[email protected]> AuthorDate: Wed, 14 Feb 2018 14:16:54 +0300 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 14 Feb 2018 13:11:15 +0100
x86/mm: Make MAX_PHYSADDR_BITS and MAX_PHYSMEM_BITS dynamic
For boot-time switching between paging modes, we need to be able to adjust size of physical address space at runtime.
As part of making physical address space size variable, we have to make X86_5LEVEL dependent on SPARSEMEM_VMEMMAP. !SPARSEMEM_VMEMMAP configuration doesn't build with variable MAX_PHYSMEM_BITS.
For !SPARSEMEM_VMEMMAP SECTIONS_WIDTH depends on MAX_PHYSMEM_BITS:
SECTIONS_WIDTH
SECTIONS_SHIFT
MAX_PHYSMEM_BITS
And SECTIONS_WIDTH is used on pre-processor stage, it doesn't work if it's dyncamic. See include/linux/page-flags-layout.h.
Effect on kernel image size:
text data bss dec hex filename
8628393 4734340 1368064 14730797 e0c62d vmlinux.before
8628892 4734340 1368064 14731296 e0c820 vmlinux.after
--- arch/x86/Kconfig | 1 + arch/x86/include/asm/pgtable_64_types.h | 2 +- arch/x86/include/asm/sparsemem.h | 9 ++------- arch/x86/kernel/setup.c | 5 ++--- 4 files changed, 6 insertions(+), 11 deletions(-)
arch/x86/Kconfig +1 -0
@@ -1431,6 +1431,7 @@ config X86_PAE config X86_5LEVEL bool "Enable 5-level page tables support" select DYNAMIC_MEMORY_LAYOUT + select SPARSEMEM_VMEMMAP depends on X86_64 ---help--- 5-level paging enables access to larger address space:
arch/x86/include/asm/pgtable_64_types.h +1 -1
@@ -95,7 +95,7 @@ extern unsigned int ptrs_per_p4d;* range must not overlap with anything except the KASAN shadow area, which * is correct as KASAN disables KASLR. */ -#define MAXMEM _AC(__AC(1, UL) << MAX_PHYSMEM_BITS, UL) +#define MAXMEM (1UL << MAX_PHYSMEM_BITS)#define LDT_PGD_ENTRY_L4 -3UL#define LDT_PGD_ENTRY_L5 -112UL
arch/x86/include/asm/sparsemem.h +2 -7
@@ -27,13 +27,8 @@# endif #else /* CONFIG_X86_32 */ # define SECTION_SIZE_BITS 27/* matt - 128 is convenient right now */ -# ifdef CONFIG_X86_5LEVEL -# define MAX_PHYSADDR_BITS 52 -# define MAX_PHYSMEM_BITS 52 -# else -# define MAX_PHYSADDR_BITS 44 -# define MAX_PHYSMEM_BITS 46 -# endif +# define MAX_PHYSADDR_BITS (pgtable_l5_enabled ? 52 : 44) +# define MAX_PHYSMEM_BITS (pgtable_l5_enabled ? 52 : 46)#endif #endif /* CONFIG_SPARSEMEM */
arch/x86/kernel/setup.c +2 -3
@@ -189,9 +189,7 @@ struct ist_info ist_info;#endif #else -struct cpuinfo_x86 boot_cpu_data__read_mostly = { - .x86_phys_bits =MAX_PHYSMEM_BITS , -}; +struct cpuinfo_x86 boot_cpu_data__read_mostly ;EXPORT_SYMBOL (boot_cpu_data);#endif
@@ -851,6 +849,7 @@ void __init setup_arch(char **cmdline_p)__flush_tlb_all ();#else printk (KERN_INFO "Command line: %s\n" , boot_command_line); + boot_cpu_data.x86_phys_bits =MAX_PHYSMEM_BITS ;#endif /*
PATCH 8/9 x86/mm: Make __VIRTUAL_MASK_SHIFT dynamic
In reply to Kirill A. ShutemovFor boot-time switching between paging modes, we need to be able to adjust virtual mask shifts.
The change doesn't affect the kernel image size much:
text data bss dec hex filename
8628892 4734340 1368064 14731296 e0c820 vmlinux.before
8628966 4734340 1368064 14731370 e0c86a vmlinux.after
--- arch/x86/entry/entry_64.S | 12 ++++++++++++ arch/x86/include/asm/page_64_types.h | 2 +- arch/x86/mm/dump_pagetables.c | 12 ++++++++++-- arch/x86/mm/kaslr.c | 4 +++- 4 files changed, 26 insertions(+), 4 deletions(-)
arch/x86/entry/entry_64.S +12 -0
@@ -260,8 +260,20 @@ GLOBAL(entry_SYSCALL_64_after_hwframe) * Change top bits to match most significant bit (47th or 56th bit * depending on paging mode) in the address. */ +#ifdef CONFIG_X86_5LEVEL + testl $1, pgtable_l5_enabled(%rip) + jz 1f + shl $(64 - 57), %rcx + sar $(64 - 57), %rcx + jmp 2f +1: + shl $(64 - 48), %rcx + sar $(64 - 48), %rcx +2: +#else shl $(64 - (__VIRTUAL_MASK_SHIFT+1)), %rcx sar $(64 - (__VIRTUAL_MASK_SHIFT+1)), %rcx +#endif /* If this changed %rcx, it was not canonical */ cmpq %rcx, %r11
arch/x86/include/asm/page_64_types.h +1 -1
@@ -56,7 +56,7 @@#define __PHYSICAL_MASK_SHIFT 52#ifdef CONFIG_X86_5LEVEL -#define __VIRTUAL_MASK_SHIFT 56 +#define __VIRTUAL_MASK_SHIFT (pgtable_l5_enabled ? 56 : 47)#else #define __VIRTUAL_MASK_SHIFT 47#endif
arch/x86/mm/dump_pagetables.c +10 -2
@@ -85,8 +85,12 @@ static struct addr_marker address_markers[] = { [VMALLOC_START_NR] = { 0UL, "vmalloc() Area" }, [VMEMMAP_START_NR ] = {0UL ,"Vmemmap" }, #ifdef CONFIG_KASAN - [KASAN_SHADOW_START_NR] = { KASAN_SHADOW_START, "KASAN shadow" }, - [KASAN_SHADOW_END_NR ] = {KASAN_SHADOW_END ,"KASAN shadow end" }, +/* +* These fields get initialized with the (dynamic) +* KASAN_SHADOW_{START,END} values in pt_dump_init(). +*/ + [KASAN_SHADOW_START_NR] = { 0UL, "KASAN shadow" }, + [KASAN_SHADOW_END_NR ] = {0UL ,"KASAN shadow end" }, #endif #ifdef CONFIG_MODIFY_LDT_SYSCALL [LDT_NR] = { 0UL, "LDT remap" },
@@ -571,6 +575,10 @@ static int __init pt_dump_init(void)#ifdef CONFIG_MODIFY_LDT_SYSCALL address_markers[LDT_NR ].start_address =LDT_BASE_ADDR ;#endif +#ifdef CONFIG_KASAN + address_markers[KASAN_SHADOW_START_NR ].start_address =KASAN_SHADOW_START ; + address_markers[KASAN_SHADOW_END_NR ].start_address =KASAN_SHADOW_END ; +#endif #endif #ifdef CONFIG_X86_32 address_markers[VMALLOC_START_NR ].start_address =VMALLOC_START ;
arch/x86/mm/kaslr.c +3 -1
@@ -52,7 +52,7 @@ static __initdata struct kaslr_memory_region {unsigned long *base;unsigned long size_tb; } kaslr_regions[] = { - { &page_offset_base, 1 << (__PHYSICAL_MASK_SHIFT - TB_SHIFT) /* Maximum */ }, + { &page_offset_base, 0 }, { &vmalloc_base, VMALLOC_SIZE_TB }, { &vmemmap_base, 1 }, };
@@ -93,6 +93,8 @@ void __init kernel_randomize_memory(void)if (!kaslr_memory_enabled ())return ; + kaslr_regions[0 ].size_tb =1 << (__PHYSICAL_MASK_SHIFT -TB_SHIFT ); +/* * Update Physical memory mapping to available and * add padding if needed (especially for memory hotplug support).
Signature · 7 lines
2.15.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
tip-bot for Kirill A. Shutemov
merge bot[tip:x86/mm] x86/mm: Make __VIRTUAL_MASK_SHIFT dynamic
x86/mm: Make __VIRTUAL_MASK_SHIFT dynamic
Commit-ID: 09e61a779e7f171c50325e6d7108a593afb2e5d4 Gitweb: https://git.kernel.org/tip/09e61a779e7f171c50325e6d7108a593afb2e5d4 Author: Kirill A. Shutemov <[email protected]> AuthorDate: Wed, 14 Feb 2018 14:16:55 +0300 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 14 Feb 2018 13:11:15 +0100
x86/mm: Make __VIRTUAL_MASK_SHIFT dynamic
For boot-time switching between paging modes, we need to be able to adjust virtual mask shifts.
The change doesn't affect the kernel image size much:
text data bss dec hex filename
8628892 4734340 1368064 14731296 e0c820 vmlinux.before
8628966 4734340 1368064 14731370 e0c86a vmlinux.after
--- arch/x86/entry/entry_64.S | 12 ++++++++++++ arch/x86/include/asm/page_64_types.h | 2 +- arch/x86/mm/dump_pagetables.c | 12 ++++++++++-- arch/x86/mm/kaslr.c | 4 +++- 4 files changed, 26 insertions(+), 4 deletions(-)
arch/x86/entry/entry_64.S +12 -0
@@ -274,8 +274,20 @@ GLOBAL(entry_SYSCALL_64_after_hwframe) * Change top bits to match most significant bit (47th or 56th bit * depending on paging mode) in the address. */ +#ifdef CONFIG_X86_5LEVEL + testl $1, pgtable_l5_enabled(%rip) + jz 1f + shl $(64 - 57), %rcx + sar $(64 - 57), %rcx + jmp 2f +1: + shl $(64 - 48), %rcx + sar $(64 - 48), %rcx +2: +#else shl $(64 - (__VIRTUAL_MASK_SHIFT+1)), %rcx sar $(64 - (__VIRTUAL_MASK_SHIFT+1)), %rcx +#endif /* If this changed %rcx, it was not canonical */ cmpq %rcx, %r11
arch/x86/include/asm/page_64_types.h +1 -1
@@ -56,7 +56,7 @@#define __PHYSICAL_MASK_SHIFT 52#ifdef CONFIG_X86_5LEVEL -#define __VIRTUAL_MASK_SHIFT 56 +#define __VIRTUAL_MASK_SHIFT (pgtable_l5_enabled ? 56 : 47)#else #define __VIRTUAL_MASK_SHIFT 47#endif
arch/x86/mm/dump_pagetables.c +10 -2
@@ -85,8 +85,12 @@ static struct addr_marker address_markers[] = { [VMALLOC_START_NR] = { 0UL, "vmalloc() Area" }, [VMEMMAP_START_NR ] = {0UL ,"Vmemmap" }, #ifdef CONFIG_KASAN - [KASAN_SHADOW_START_NR] = { KASAN_SHADOW_START, "KASAN shadow" }, - [KASAN_SHADOW_END_NR ] = {KASAN_SHADOW_END ,"KASAN shadow end" }, +/* +* These fields get initialized with the (dynamic) +* KASAN_SHADOW_{START,END} values in pt_dump_init(). +*/ + [KASAN_SHADOW_START_NR] = { 0UL, "KASAN shadow" }, + [KASAN_SHADOW_END_NR ] = {0UL ,"KASAN shadow end" }, #endif #ifdef CONFIG_MODIFY_LDT_SYSCALL [LDT_NR] = { 0UL, "LDT remap" },
@@ -571,6 +575,10 @@ static int __init pt_dump_init(void)#ifdef CONFIG_MODIFY_LDT_SYSCALL address_markers[LDT_NR ].start_address =LDT_BASE_ADDR ;#endif +#ifdef CONFIG_KASAN + address_markers[KASAN_SHADOW_START_NR ].start_address =KASAN_SHADOW_START ; + address_markers[KASAN_SHADOW_END_NR ].start_address =KASAN_SHADOW_END ; +#endif #endif #ifdef CONFIG_X86_32 address_markers[VMALLOC_START_NR ].start_address =VMALLOC_START ;
arch/x86/mm/kaslr.c +3 -1
@@ -52,7 +52,7 @@ static __initdata struct kaslr_memory_region {unsigned long *base;unsigned long size_tb; } kaslr_regions[] = { - { &page_offset_base, 1 << (__PHYSICAL_MASK_SHIFT - TB_SHIFT) /* Maximum */ }, + { &page_offset_base, 0 }, { &vmalloc_base, VMALLOC_SIZE_TB }, { &vmemmap_base, 1 }, };
@@ -93,6 +93,8 @@ void __init kernel_randomize_memory(void)if (!kaslr_memory_enabled ())return ; + kaslr_regions[0 ].size_tb =1 << (__PHYSICAL_MASK_SHIFT -TB_SHIFT ); +/* * Update Physical memory mapping to available and * add padding if needed (especially for memory hotplug support).
Re: [PATCH 8/9] x86/mm: Make __VIRTUAL_MASK_SHIFT dynamic
In reply to Kirill A. ShutemovQuoted 29 lines · Kirill A. Shutemov
For boot-time switching between paging modes, we need to be able to adjust virtual mask shifts.
The change doesn't affect the kernel image size much:
text data bss dec hex filename
8628892 4734340 1368064 14731296 e0c820 vmlinux.before
8628966 4734340 1368064 14731370 e0c86a vmlinux.afterSigned-off-by Kirill A. Shutemov <[email protected]>--- arch/x86/entry/entry_64.S | 12 ++++++++++++ arch/x86/include/asm/page_64_types.h | 2 +- arch/x86/mm/dump_pagetables.c | 12 ++++++++++-- arch/x86/mm/kaslr.c | 4 +++- 4 files changed, 26 insertions(+), 4 deletions(-)arch/x86/entry/entry_64.S +4
-0@@ -260,8 +260,20 @@ GLOBAL(entry_SYSCALL_64_after_hwframe) * Change top bits to match most significant bit (47th or 56th bit * depending on paging mode) in the address. */ +#ifdef CONFIG_X86_5LEVEL + testl $1, pgtable_l5_enabled(%rip) + jz 1f + shl $(64 - 57), %rcx
arch/x86/entry/entry_64.S GLOBAL(entry_SYSCALL_64_after_hwframe) · line 276
Quoted 10 lines
arch/x86/entry/entry_64.S +8
-0+ sar $(64 - 57), %rcx + jmp 2f +1: + shl $(64 - 48), %rcx + sar $(64 - 48), %rcx +2: +#else shl $(64 - (__VIRTUAL_MASK_SHIFT+1)), %rcx sar $(64 - (__VIRTUAL_MASK_SHIFT+1)), %rcx +#endif
Eww.
Can't this be ALTERNATIVE "shl ... sar ...", "shl ... sar ...", X86_FEATURE_5LEVEL or similar?
--Andy
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 8/9] x86/mm: Make __VIRTUAL_MASK_SHIFT dynamic
Quoted 44 lines · Andy Lutomirski
Quoted 29 lines · Kirill A. Shutemov
For boot-time switching between paging modes, we need to be able to adjust virtual mask shifts.
The change doesn't affect the kernel image size much:
text data bss dec hex filename
8628892 4734340 1368064 14731296 e0c820 vmlinux.before
8628966 4734340 1368064 14731370 e0c86a vmlinux.afterSigned-off-by Kirill A. Shutemov <[email protected]>--- arch/x86/entry/entry_64.S | 12 ++++++++++++ arch/x86/include/asm/page_64_types.h | 2 +- arch/x86/mm/dump_pagetables.c | 12 ++++++++++-- arch/x86/mm/kaslr.c | 4 +++- 4 files changed, 26 insertions(+), 4 deletions(-)arch/x86/entry/entry_64.S +4
-0@@ -260,8 +260,20 @@ GLOBAL(entry_SYSCALL_64_after_hwframe) * Change top bits to match most significant bit (47th or 56th bit * depending on paging mode) in the address. */ +#ifdef CONFIG_X86_5LEVEL + testl $1, pgtable_l5_enabled(%rip) + jz 1f + shl $(64 - 57), %rcxarch/x86/entry/entry_64.S GLOBAL(entry_SYSCALL_64_after_hwframe) · line 276
Quoted 10 lines
arch/x86/entry/entry_64.S +8
-0+ sar $(64 - 57), %rcx + jmp 2f +1: + shl $(64 - 48), %rcx + sar $(64 - 48), %rcx +2: +#else shl $(64 - (__VIRTUAL_MASK_SHIFT+1)), %rcx sar $(64 - (__VIRTUAL_MASK_SHIFT+1)), %rcx +#endifEww.
Quoted 2 lines
Can't this be ALTERNATIVE "shl ... sar ...", "shl ... sar ...",
X86_FEATURE_5LEVELor similar?
Optimization comes in a separate patch:
Signature · 7 lines
Kirill A. Shutemov -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andy Lutomirski
maintainerRe: [PATCH 8/9] x86/mm: Make __VIRTUAL_MASK_SHIFT dynamic
Quoted 45 lines · Kirill A. Shutemov
Quoted 44 lines · Andy Lutomirski
Quoted 29 lines · Kirill A. Shutemov
For boot-time switching between paging modes, we need to be able to adjust virtual mask shifts.
The change doesn't affect the kernel image size much:
text data bss dec hex filename
8628892 4734340 1368064 14731296 e0c820 vmlinux.before
8628966 4734340 1368064 14731370 e0c86a vmlinux.afterSigned-off-by Kirill A. Shutemov <[email protected]>--- arch/x86/entry/entry_64.S | 12 ++++++++++++ arch/x86/include/asm/page_64_types.h | 2 +- arch/x86/mm/dump_pagetables.c | 12 ++++++++++-- arch/x86/mm/kaslr.c | 4 +++- 4 files changed, 26 insertions(+), 4 deletions(-)arch/x86/entry/entry_64.S +4
-0@@ -260,8 +260,20 @@ GLOBAL(entry_SYSCALL_64_after_hwframe) * Change top bits to match most significant bit (47th or 56th bit * depending on paging mode) in the address. */ +#ifdef CONFIG_X86_5LEVEL + testl $1, pgtable_l5_enabled(%rip) + jz 1f + shl $(64 - 57), %rcxarch/x86/entry/entry_64.S GLOBAL(entry_SYSCALL_64_after_hwframe) · line 276
Quoted 10 lines
arch/x86/entry/entry_64.S +8
-0+ sar $(64 - 57), %rcx + jmp 2f +1: + shl $(64 - 48), %rcx + sar $(64 - 48), %rcx +2: +#else shl $(64 - (__VIRTUAL_MASK_SHIFT+1)), %rcx sar $(64 - (__VIRTUAL_MASK_SHIFT+1)), %rcx +#endifEww.
Quoted 7 lines
Quoted 2 lines
Can't this be ALTERNATIVE "shl ... sar ...", "shl ... sar ...",
X86_FEATURE_5LEVELor similar?Optimization comes in a separate patch:
Nice!
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 9/9 x86/mm: Adjust virtual address space layout in early boot
In reply to Kirill A. ShutemovWe need to adjust virtual address space to support switching between paging modes.
The adjustment happens in __startup_64().
We also have to change KASLR code that doesn't expect variable VMALLOC_SIZE_TB.
--- arch/x86/boot/compressed/kaslr.c | 14 ++++++++-- arch/x86/include/asm/page_64_types.h | 9 ++---- arch/x86/include/asm/pgtable_64_types.h | 25 +++++++++-------- arch/x86/kernel/head64.c | 49 +++++++++++++++++++++++++++------ arch/x86/kernel/head_64.S | 2 +- arch/x86/mm/dump_pagetables.c | 3 ++ arch/x86/mm/kaslr.c | 11 ++++---- 7 files changed, 77 insertions(+), 36 deletions(-)
arch/x86/boot/compressed/kaslr.c +11 -3
@@ -47,9 +47,9 @@#include <linux/decompress/mm.h> #ifdef CONFIG_X86_5LEVEL -unsigned int pgtable_l5_enabled__ro_after_init =1 ; -unsigned int pgdir_shift__ro_after_init =48 ; -unsigned int ptrs_per_p4d__ro_after_init =512 ; +unsigned int pgtable_l5_enabled__ro_after_init ; +unsigned int pgdir_shift__ro_after_init =39 ; +unsigned int ptrs_per_p4d__ro_after_init =1 ;#endif extern unsigned long get_cmd_line_ptr (void );
@@ -729,6 +729,14 @@ void choose_random_location(unsigned long input,return ; } +#ifdef CONFIG_X86_5LEVEL +if (__read_cr4 () &X86_CR4_LA57 ) { + pgtable_l5_enabled =1 ; + pgdir_shift =48 ; + ptrs_per_p4d =512 ; + } +#endif + boot_params->hdr.loadflags |=KASLR_FLAG ;/* Prepare to add new identity pagetables on demand. */
arch/x86/include/asm/page_64_types.h +3 -6
@@ -37,16 +37,13 @@* hypervisor to fit. Choosing 16 slots here is arbitrary, but it's * what Xen requires. */ -#ifdef CONFIG_X86_5LEVEL -#define __PAGE_OFFSET_BASE _AC(0xff10000000000000, UL) -#else -#define __PAGE_OFFSET_BASE _AC(0xffff880000000000, UL) -#endif +#define __PAGE_OFFSET_BASE_L5 _AC(0xff10000000000000, UL) +#define __PAGE_OFFSET_BASE_L4 _AC(0xffff880000000000, UL)#ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT #define __PAGE_OFFSET page_offset_base#else -#define __PAGE_OFFSET __PAGE_OFFSET_BASE +#define __PAGE_OFFSET __PAGE_OFFSET_BASE_L4#endif /* CONFIG_DYNAMIC_MEMORY_LAYOUT */ #define __START_KERNEL_map _AC(0xffffffff80000000, UL)
arch/x86/include/asm/pgtable_64_types.h +13 -12
@@ -102,25 +102,26 @@ extern unsigned int ptrs_per_p4d;#define LDT_PGD_ENTRY (pgtable_l5_enabled ? LDT_PGD_ENTRY_L5 : LDT_PGD_ENTRY_L4)#define LDT_BASE_ADDR (LDT_PGD_ENTRY << PGDIR_SHIFT) -#ifdef CONFIG_X86_5LEVEL -# define VMALLOC_SIZE_TB _AC(12800, UL) -# define __VMALLOC_BASE _AC(0xffa0000000000000, UL) -# define __VMEMMAP_BASE _AC(0xffd4000000000000, UL) -#else -# define VMALLOC_SIZE_TB _AC(32, UL) -# define __VMALLOC_BASE _AC(0xffffc90000000000, UL) -# define __VMEMMAP_BASE _AC(0xffffea0000000000, UL) -#endif +#define __VMALLOC_BASE_L4 0xffffc90000000000 +#define __VMALLOC_BASE_L5 0xffa0000000000000 + +#define VMALLOC_SIZE_TB_L4 32UL +#define VMALLOC_SIZE_TB_L5 12800UL + +#define __VMEMMAP_BASE_L4 0xffffea0000000000 +#define __VMEMMAP_BASE_L5 0xffd4000000000000#ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT # define VMALLOC_START vmalloc_base +# define VMALLOC_SIZE_TB (pgtable_l5_enabled ? VMALLOC_SIZE_TB_L5 : VMALLOC_SIZE_TB_L4)# define VMEMMAP_START vmemmap_base#else -# define VMALLOC_START __VMALLOC_BASE -# define VMEMMAP_START __VMEMMAP_BASE +# define VMALLOC_START __VMALLOC_BASE_L4 +# define VMALLOC_SIZE_TB VMALLOC_SIZE_TB_L4 +# define VMEMMAP_START __VMEMMAP_BASE_L4#endif /* CONFIG_DYNAMIC_MEMORY_LAYOUT */ -#define VMALLOC_END (VMALLOC_START + _AC((VMALLOC_SIZE_TB << 40) - 1, UL)) +#define VMALLOC_END (VMALLOC_START + (VMALLOC_SIZE_TB << 40) - 1)#define MODULES_VADDR (__START_KERNEL_map + KERNEL_IMAGE_SIZE)/* The module sections ends with the start of the fixmap */
arch/x86/kernel/head64.c +40 -9
84 lines not on this page · raw message
arch/x86/kernel/head_64.S +1 -1
@@ -41,7 +41,7 @@ #define pud_index(x) (((x) >> PUD_SHIFT) & (PTRS_PER_PUD-1)) #if defined(CONFIG_XEN_PV) || defined(CONFIG_XEN_PVH) -PGD_PAGE_OFFSET = pgd_index(__PAGE_OFFSET_BASE) +PGD_PAGE_OFFSET = pgd_index(__PAGE_OFFSET_BASE_L4) PGD_START_KERNEL = pgd_index(__START_KERNEL_map) #endif L3_START_KERNEL = pud_index(__START_KERNEL_map)
arch/x86/mm/dump_pagetables.c +3 -0
@@ -579,6 +579,9 @@ static int __init pt_dump_init(void) address_markers[KASAN_SHADOW_START_NR ].start_address =KASAN_SHADOW_START ; address_markers[KASAN_SHADOW_END_NR ].start_address =KASAN_SHADOW_END ;#endif +#ifdef CONFIG_MODIFY_LDT_SYSCALL + address_markers[LDT_NR ].start_address =LDT_BASE_ADDR ; +#endif #endif #ifdef CONFIG_X86_32 address_markers[VMALLOC_START_NR ].start_address =VMALLOC_START ;
arch/x86/mm/kaslr.c +6 -5
@@ -34,13 +34,10 @@#define TB_SHIFT 40/* -* Virtual address start and end range for randomization. -* * The end address could depend on more configuration options to make the * highest amount of space for randomization available, but that's too hard * to keep straight and caused issues already. */ -static const unsigned long vaddr_start = __PAGE_OFFSET_BASE;static const unsigned long vaddr_end =CPU_ENTRY_AREA_BASE ;/*
@@ -53,7 +50,7 @@ static __initdata struct kaslr_memory_region {unsigned long size_tb; } kaslr_regions[] = { { &page_offset_base, 0 }, - { &vmalloc_base, VMALLOC_SIZE_TB }, + { &vmalloc_base, 0 }, { &vmemmap_base, 1 }, };
@@ -76,11 +73,14 @@ static inline bool kaslr_memory_enabled(void)void __init kernel_randomize_memory (void ) {size_t i; -unsigned long vaddr = vaddr_start; +unsigned long vaddr_start, vaddr;unsigned long rand, memory_tb;struct rnd_state rand_state;unsigned long remain_entropy; + vaddr_start = pgtable_l5_enabled ? __PAGE_OFFSET_BASE_L5 : __PAGE_OFFSET_BASE_L4; + vaddr = vaddr_start; +/* * These BUILD_BUG_ON checks ensure the memory layout is consistent * with the vaddr_start/vaddr_end variables. These checks are very
@@ -94,6 +94,7 @@ void __init kernel_randomize_memory(void)return ; kaslr_regions[0 ].size_tb =1 << (__PHYSICAL_MASK_SHIFT -TB_SHIFT ); + kaslr_regions[1 ].size_tb =VMALLOC_SIZE_TB ;/* * Update Physical memory mapping to available and
Signature · 7 lines
2.15.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 9/9] x86/mm: Adjust virtual address space layout in early boot
Quoted 9 lines · Kirill A. Shutemov
We need to adjust virtual address space to support switching between paging modes.
The adjustment happens in
__startup_64().We also have to change KASLR code that doesn't expect variable
VMALLOC_SIZE_TB.Signed-off-by Kirill A. Shutemov <[email protected]>
Quoted 9 lines
--- arch/x86/boot/compressed/kaslr.c | 14 ++++++++-- arch/x86/include/asm/page_64_types.h | 9 ++---- arch/x86/include/asm/pgtable_64_types.h | 25 +++++++++-------- arch/x86/kernel/head64.c | 49 +++++++++++++++++++++++++++------ arch/x86/kernel/head_64.S | 2 +- arch/x86/mm/dump_pagetables.c | 3 ++ arch/x86/mm/kaslr.c | 11 ++++---- 7 files changed, 77 insertions(+), 36 deletions(-)
This is too large and risky - would it be possible to split this up into multiple, smaller patches?
Thanks,
Ingo
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 9/9] x86/mm: Adjust virtual address space layout in early boot
Quoted 22 lines · Ingo Molnar
Quoted 9 lines · Kirill A. Shutemov
We need to adjust virtual address space to support switching between paging modes.
The adjustment happens in
__startup_64().We also have to change KASLR code that doesn't expect variable
VMALLOC_SIZE_TB.Signed-off-by Kirill A. Shutemov <[email protected]>Quoted 9 lines
--- arch/x86/boot/compressed/kaslr.c | 14 ++++++++-- arch/x86/include/asm/page_64_types.h | 9 ++---- arch/x86/include/asm/pgtable_64_types.h | 25 +++++++++-------- arch/x86/kernel/head64.c | 49 +++++++++++++++++++++++++++------ arch/x86/kernel/head_64.S | 2 +- arch/x86/mm/dump_pagetables.c | 3 ++ arch/x86/mm/kaslr.c | 11 ++++---- 7 files changed, 77 insertions(+), 36 deletions(-)
Quoted 2 lines
This is too large and risky - would it be possible to split this up into multiple, smaller patches?
Let me check what I can do here.
If you are fine with previous patches please apply. I will send split up of this patch separately.
Signature · 7 lines
Kirill A. Shutemov -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 9/9] x86/mm: Adjust virtual address space layout in early boot
Quoted 23 lines · Kirill A. Shutemov
Quoted 22 lines · Ingo Molnar
Quoted 18 lines · Kirill A. Shutemov
We need to adjust virtual address space to support switching between paging modes.
The adjustment happens in
__startup_64().We also have to change KASLR code that doesn't expect variable
VMALLOC_SIZE_TB.Signed-off-by Kirill A. Shutemov <[email protected]>--- arch/x86/boot/compressed/kaslr.c | 14 ++++++++-- arch/x86/include/asm/page_64_types.h | 9 ++---- arch/x86/include/asm/pgtable_64_types.h | 25 +++++++++-------- arch/x86/kernel/head64.c | 49 +++++++++++++++++++++++++++------ arch/x86/kernel/head_64.S | 2 +- arch/x86/mm/dump_pagetables.c | 3 ++ arch/x86/mm/kaslr.c | 11 ++++---- 7 files changed, 77 insertions(+), 36 deletions(-)
Quoted 7 lines
Quoted 2 lines
This is too large and risky - would it be possible to split this up into multiple, smaller patches?
Let me check what I can do here.
If you are fine with previous patches please apply. I will send split up of this patch separately.
Yes, the first 8 patches are looking good and I have already applied them locally, will push them out after testing.
Thanks,
Ingo
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>