diff options
| -rw-r--r-- | arch/x86/boot/compressed/kaslr.c | 4 | ||||
| -rw-r--r-- | arch/x86/boot/compressed/misc.h | 6 | ||||
| -rw-r--r-- | arch/x86/include/asm/pgtable_64_types.h | 13 | ||||
| -rw-r--r-- | arch/x86/kernel/head64.c | 12 | ||||
| -rw-r--r-- | arch/x86/mm/kasan_init_64.c | 6 |
5 files changed, 21 insertions, 20 deletions
diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index a0a50b91ecef..b87a7582853d 100644 --- a/arch/x86/boot/compressed/kaslr.c +++ b/arch/x86/boot/compressed/kaslr.c | |||
| @@ -47,7 +47,7 @@ | |||
| 47 | #include <linux/decompress/mm.h> | 47 | #include <linux/decompress/mm.h> |
| 48 | 48 | ||
| 49 | #ifdef CONFIG_X86_5LEVEL | 49 | #ifdef CONFIG_X86_5LEVEL |
| 50 | unsigned int pgtable_l5_enabled __ro_after_init; | 50 | unsigned int __pgtable_l5_enabled; |
| 51 | unsigned int pgdir_shift __ro_after_init = 39; | 51 | unsigned int pgdir_shift __ro_after_init = 39; |
| 52 | unsigned int ptrs_per_p4d __ro_after_init = 1; | 52 | unsigned int ptrs_per_p4d __ro_after_init = 1; |
| 53 | #endif | 53 | #endif |
| @@ -734,7 +734,7 @@ void choose_random_location(unsigned long input, | |||
| 734 | 734 | ||
| 735 | #ifdef CONFIG_X86_5LEVEL | 735 | #ifdef CONFIG_X86_5LEVEL |
| 736 | if (__read_cr4() & X86_CR4_LA57) { | 736 | if (__read_cr4() & X86_CR4_LA57) { |
| 737 | pgtable_l5_enabled = 1; | 737 | __pgtable_l5_enabled = 1; |
| 738 | pgdir_shift = 48; | 738 | pgdir_shift = 48; |
| 739 | ptrs_per_p4d = 512; | 739 | ptrs_per_p4d = 512; |
| 740 | } | 740 | } |
diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h index 9e11be4cae19..a423bdb42686 100644 --- a/arch/x86/boot/compressed/misc.h +++ b/arch/x86/boot/compressed/misc.h | |||
| @@ -12,10 +12,8 @@ | |||
| 12 | #undef CONFIG_PARAVIRT_SPINLOCKS | 12 | #undef CONFIG_PARAVIRT_SPINLOCKS |
| 13 | #undef CONFIG_KASAN | 13 | #undef CONFIG_KASAN |
| 14 | 14 | ||
| 15 | #ifdef CONFIG_X86_5LEVEL | 15 | /* cpu_feature_enabled() cannot be used this early */ |
| 16 | /* cpu_feature_enabled() cannot be used that early */ | 16 | #define USE_EARLY_PGTABLE_L5 |
| 17 | #define pgtable_l5_enabled __pgtable_l5_enabled | ||
| 18 | #endif | ||
| 19 | 17 | ||
| 20 | #include <linux/linkage.h> | 18 | #include <linux/linkage.h> |
| 21 | #include <linux/screen_info.h> | 19 | #include <linux/screen_info.h> |
diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h index adb47552e6bb..c14a4116a693 100644 --- a/arch/x86/include/asm/pgtable_64_types.h +++ b/arch/x86/include/asm/pgtable_64_types.h | |||
| @@ -22,12 +22,19 @@ typedef struct { pteval_t pte; } pte_t; | |||
| 22 | 22 | ||
| 23 | #ifdef CONFIG_X86_5LEVEL | 23 | #ifdef CONFIG_X86_5LEVEL |
| 24 | extern unsigned int __pgtable_l5_enabled; | 24 | extern unsigned int __pgtable_l5_enabled; |
| 25 | #ifndef pgtable_l5_enabled | 25 | |
| 26 | #ifdef USE_EARLY_PGTABLE_L5 | ||
| 27 | /* | ||
| 28 | * cpu_feature_enabled() is not available in early boot code. | ||
| 29 | * Use variable instead. | ||
| 30 | */ | ||
| 31 | #define pgtable_l5_enabled __pgtable_l5_enabled | ||
| 32 | #else | ||
| 26 | #define pgtable_l5_enabled cpu_feature_enabled(X86_FEATURE_LA57) | 33 | #define pgtable_l5_enabled cpu_feature_enabled(X86_FEATURE_LA57) |
| 27 | #endif | 34 | #endif /* USE_EARLY_PGTABLE_L5 */ |
| 28 | #else | 35 | #else |
| 29 | #define pgtable_l5_enabled 0 | 36 | #define pgtable_l5_enabled 0 |
| 30 | #endif | 37 | #endif /* CONFIG_X86_5LEVEL */ |
| 31 | 38 | ||
| 32 | extern unsigned int pgdir_shift; | 39 | extern unsigned int pgdir_shift; |
| 33 | extern unsigned int ptrs_per_p4d; | 40 | extern unsigned int ptrs_per_p4d; |
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index 2d29e47c056e..494fea1dbd6e 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c | |||
| @@ -6,6 +6,10 @@ | |||
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | #define DISABLE_BRANCH_PROFILING | 8 | #define DISABLE_BRANCH_PROFILING |
| 9 | |||
| 10 | /* cpu_feature_enabled() cannot be used this early */ | ||
| 11 | #define USE_EARLY_PGTABLE_L5 | ||
| 12 | |||
| 9 | #include <linux/init.h> | 13 | #include <linux/init.h> |
| 10 | #include <linux/linkage.h> | 14 | #include <linux/linkage.h> |
| 11 | #include <linux/types.h> | 15 | #include <linux/types.h> |
| @@ -32,11 +36,6 @@ | |||
| 32 | #include <asm/microcode.h> | 36 | #include <asm/microcode.h> |
| 33 | #include <asm/kasan.h> | 37 | #include <asm/kasan.h> |
| 34 | 38 | ||
| 35 | #ifdef CONFIG_X86_5LEVEL | ||
| 36 | #undef pgtable_l5_enabled | ||
| 37 | #define pgtable_l5_enabled __pgtable_l5_enabled | ||
| 38 | #endif | ||
| 39 | |||
| 40 | /* | 39 | /* |
| 41 | * Manage page tables very early on. | 40 | * Manage page tables very early on. |
| 42 | */ | 41 | */ |
| @@ -46,7 +45,6 @@ pmdval_t early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX); | |||
| 46 | 45 | ||
| 47 | #ifdef CONFIG_X86_5LEVEL | 46 | #ifdef CONFIG_X86_5LEVEL |
| 48 | unsigned int __pgtable_l5_enabled __ro_after_init; | 47 | unsigned int __pgtable_l5_enabled __ro_after_init; |
| 49 | EXPORT_SYMBOL(__pgtable_l5_enabled); | ||
| 50 | unsigned int pgdir_shift __ro_after_init = 39; | 48 | unsigned int pgdir_shift __ro_after_init = 39; |
| 51 | EXPORT_SYMBOL(pgdir_shift); | 49 | EXPORT_SYMBOL(pgdir_shift); |
| 52 | unsigned int ptrs_per_p4d __ro_after_init = 1; | 50 | unsigned int ptrs_per_p4d __ro_after_init = 1; |
| @@ -88,7 +86,7 @@ static bool __head check_la57_support(unsigned long physaddr) | |||
| 88 | if (!(native_cpuid_ecx(7) & (1 << (X86_FEATURE_LA57 & 31)))) | 86 | if (!(native_cpuid_ecx(7) & (1 << (X86_FEATURE_LA57 & 31)))) |
| 89 | return false; | 87 | return false; |
| 90 | 88 | ||
| 91 | *fixup_int(&pgtable_l5_enabled, physaddr) = 1; | 89 | *fixup_int(&__pgtable_l5_enabled, physaddr) = 1; |
| 92 | *fixup_int(&pgdir_shift, physaddr) = 48; | 90 | *fixup_int(&pgdir_shift, physaddr) = 48; |
| 93 | *fixup_int(&ptrs_per_p4d, physaddr) = 512; | 91 | *fixup_int(&ptrs_per_p4d, physaddr) = 512; |
| 94 | *fixup_long(&page_offset_base, physaddr) = __PAGE_OFFSET_BASE_L5; | 92 | *fixup_long(&page_offset_base, physaddr) = __PAGE_OFFSET_BASE_L5; |
diff --git a/arch/x86/mm/kasan_init_64.c b/arch/x86/mm/kasan_init_64.c index 980dbebd0ca7..340bb9b32e01 100644 --- a/arch/x86/mm/kasan_init_64.c +++ b/arch/x86/mm/kasan_init_64.c | |||
| @@ -2,10 +2,8 @@ | |||
| 2 | #define DISABLE_BRANCH_PROFILING | 2 | #define DISABLE_BRANCH_PROFILING |
| 3 | #define pr_fmt(fmt) "kasan: " fmt | 3 | #define pr_fmt(fmt) "kasan: " fmt |
| 4 | 4 | ||
| 5 | #ifdef CONFIG_X86_5LEVEL | 5 | /* cpu_feature_enabled() cannot be used this early */ |
| 6 | /* Too early to use cpu_feature_enabled() */ | 6 | #define USE_EARLY_PGTABLE_L5 |
| 7 | #define pgtable_l5_enabled __pgtable_l5_enabled | ||
| 8 | #endif | ||
| 9 | 7 | ||
| 10 | #include <linux/bootmem.h> | 8 | #include <linux/bootmem.h> |
| 11 | #include <linux/kasan.h> | 9 | #include <linux/kasan.h> |
