x86/mm: Fix 'no5lvl' handling in v4.18-rc1
cover x86/mm: Fix 'no5lvl' handling in v4.18-rc1
One of patches from 'no5lvl' patchset didn't get merged due collision with other code and I screwed up bisectablity. As result 'no5lvl' is broken in v4.18-rc1.
Fix the mess.
Kirill A. Shutemov (2):
Revert "x86/mm: Mark __pgtable_l5_enabled __initdata" x86/mm: Fix 'no5lvl' handling
arch/x86/kernel/cpu/common.c | 3 +++ arch/x86/kernel/head64.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-)
Signature · 1 line
2.17.1
PATCH 1/2 Revert "x86/mm: Mark __pgtable_l5_enabled __initdata"
This reverts commit e4e961e36f063484c48bed919013c106d178995d.
We need to use early version of pgtable_l5_enabled() in early_identify_cpu() as this code runs before cpu_feature_enabled() is usable.
But it leads to section mismatch:
cpu_init()
load_mm_ldt()
ldt_slot_va()
LDT_BASE_ADDR
LDT_PGD_ENTRY
pgtable_l5_enabled()
__pgtable_l5_enabled__pgtable_l5_enabled marked as __initdata, but cpu_init() is not __init.
It's fixable: early code can be isolated into a separate translation unit, but such change collides with other work in the area. That's too much hassle to save 4 bytes of memory.
Return __pgtable_l5_enabled back to be __ro_after_init.
--- arch/x86/kernel/head64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/head64.c +1 -1
@@ -44,7 +44,7 @@ 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__initdata ; +unsigned int __pgtable_l5_enabled__ro_after_init ;unsigned int pgdir_shift__ro_after_init =39 ;EXPORT_SYMBOL (pgdir_shift);unsigned int ptrs_per_p4d__ro_after_init =1 ;
Signature · 1 line
2.17.1
tip-bot for Kirill A. Shutemov
merge bot[tip:x86/urgent] Revert "x86/mm: Mark __pgtable_l5_enabled __initdata"
Revert "x86/mm: Mark __pgtable_l5_enabled __initdata"
Commit-ID: 51be1335151771075dcb19f3464ca9f331134285 Gitweb: https://git.kernel.org/tip/51be1335151771075dcb19f3464ca9f331134285 Author: Kirill A. Shutemov <[email protected]> AuthorDate: Sat, 23 Jun 2018 01:08:40 +0300 Committer: Thomas Gleixner <[email protected]> CommitDate: Sat, 23 Jun 2018 14:20:37 +0200
Revert "x86/mm: Mark __pgtable_l5_enabled __initdata"
This reverts commit e4e961e36f063484c48bed919013c106d178995d.
We need to use early version of pgtable_l5_enabled() in early_identify_cpu() as this code runs before cpu_feature_enabled() is usable.
But it leads to section mismatch:
cpu_init()
load_mm_ldt()
ldt_slot_va()
LDT_BASE_ADDR
LDT_PGD_ENTRY
pgtable_l5_enabled()
__pgtable_l5_enabled__pgtable_l5_enabled marked as __initdata, but cpu_init() is not __init.
It's fixable: early code can be isolated into a separate translation unit, but such change collides with other work in the area. That's too much hassle to save 4 bytes of memory.
Return __pgtable_l5_enabled back to be __ro_after_init.
--- arch/x86/kernel/head64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/head64.c +1 -1
@@ -44,7 +44,7 @@ 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__initdata ; +unsigned int __pgtable_l5_enabled__ro_after_init ;unsigned int pgdir_shift__ro_after_init =39 ;EXPORT_SYMBOL (pgdir_shift);unsigned int ptrs_per_p4d__ro_after_init =1 ;
PATCH 2/2 x86/mm: Fix 'no5lvl' handling
In reply to Kirill A. Shutemovearly_identify_cpu() has to use early version of pgtable_l5_enabled() that doesn't rely on cpu_feature_enabled().
Defining USE_EARLY_PGTABLE_L5 before all includes does the trick.
I lost the define in one of reworks of the original patch.
--- arch/x86/kernel/cpu/common.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kernel/cpu/common.c +3 -0
@@ -1,3 +1,6 @@ +/* cpu_feature_enabled() cannot be used this early */ +#define USE_EARLY_PGTABLE_L5 +#include <linux/bootmem.h> #include <linux/linkage.h> #include <linux/bitops.h>
Signature · 1 line
2.17.1
tip-bot for Kirill A. Shutemov
merge bot[tip:x86/urgent] x86/mm: Fix 'no5lvl' handling
x86/mm: Fix 'no5lvl' handling
Commit-ID: 2458e53ff74cd1063ed3e00459da1d35c559d369 Gitweb: https://git.kernel.org/tip/2458e53ff74cd1063ed3e00459da1d35c559d369 Author: Kirill A. Shutemov <[email protected]> AuthorDate: Sat, 23 Jun 2018 01:08:41 +0300 Committer: Thomas Gleixner <[email protected]> CommitDate: Sat, 23 Jun 2018 14:20:37 +0200
x86/mm: Fix 'no5lvl' handling
early_identify_cpu() has to use early version of pgtable_l5_enabled() that doesn't rely on cpu_feature_enabled().
Defining USE_EARLY_PGTABLE_L5 before all includes does the trick.
I lost the define in one of reworks of the original patch.
--- arch/x86/kernel/cpu/common.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kernel/cpu/common.c +3 -0
@@ -1,3 +1,6 @@ +/* cpu_feature_enabled() cannot be used this early */ +#define USE_EARLY_PGTABLE_L5 +#include <linux/bootmem.h> #include <linux/linkage.h> #include <linux/bitops.h>