|
23 | 23 | #include <linux/pgtable.h>
|
24 | 24 |
|
25 | 25 | #include <asm/asm.h>
|
| 26 | +#include <asm/page_64.h> |
26 | 27 | #include <asm/processor.h>
|
27 | 28 | #include <asm/proto.h>
|
28 | 29 | #include <asm/smp.h>
|
@@ -68,46 +69,20 @@ unsigned long vmemmap_base __ro_after_init = __VMEMMAP_BASE_L4;
|
68 | 69 | EXPORT_SYMBOL(vmemmap_base);
|
69 | 70 | #endif
|
70 | 71 |
|
71 |
| -#ifdef CONFIG_X86_5LEVEL |
72 |
| -static void __head *fixup_pointer(void *ptr, unsigned long physaddr) |
73 |
| -{ |
74 |
| - return ptr - (void *)_text + (void *)physaddr; |
75 |
| -} |
76 |
| - |
77 |
| -static unsigned long __head *fixup_long(void *ptr, unsigned long physaddr) |
| 72 | +static inline bool check_la57_support(void) |
78 | 73 | {
|
79 |
| - return fixup_pointer(ptr, physaddr); |
80 |
| -} |
81 |
| - |
82 |
| -static unsigned int __head *fixup_int(void *ptr, unsigned long physaddr) |
83 |
| -{ |
84 |
| - return fixup_pointer(ptr, physaddr); |
85 |
| -} |
| 74 | + if (!IS_ENABLED(CONFIG_X86_5LEVEL)) |
| 75 | + return false; |
86 | 76 |
|
87 |
| -static bool __head check_la57_support(unsigned long physaddr) |
88 |
| -{ |
89 | 77 | /*
|
90 | 78 | * 5-level paging is detected and enabled at kernel decompression
|
91 | 79 | * stage. Only check if it has been enabled there.
|
92 | 80 | */
|
93 | 81 | if (!(native_read_cr4() & X86_CR4_LA57))
|
94 | 82 | return false;
|
95 | 83 |
|
96 |
| - *fixup_int(&__pgtable_l5_enabled, physaddr) = 1; |
97 |
| - *fixup_int(&pgdir_shift, physaddr) = 48; |
98 |
| - *fixup_int(&ptrs_per_p4d, physaddr) = 512; |
99 |
| - *fixup_long(&page_offset_base, physaddr) = __PAGE_OFFSET_BASE_L5; |
100 |
| - *fixup_long(&vmalloc_base, physaddr) = __VMALLOC_BASE_L5; |
101 |
| - *fixup_long(&vmemmap_base, physaddr) = __VMEMMAP_BASE_L5; |
102 |
| - |
103 | 84 | return true;
|
104 | 85 | }
|
105 |
| -#else |
106 |
| -static bool __head check_la57_support(unsigned long physaddr) |
107 |
| -{ |
108 |
| - return false; |
109 |
| -} |
110 |
| -#endif |
111 | 86 |
|
112 | 87 | static unsigned long __head sme_postprocess_startup(struct boot_params *bp, pmdval_t *pmd)
|
113 | 88 | {
|
@@ -171,7 +146,7 @@ unsigned long __head __startup_64(unsigned long physaddr,
|
171 | 146 | bool la57;
|
172 | 147 | int i;
|
173 | 148 |
|
174 |
| - la57 = check_la57_support(physaddr); |
| 149 | + la57 = check_la57_support(); |
175 | 150 |
|
176 | 151 | /* Is the address too large? */
|
177 | 152 | if (physaddr >> MAX_PHYSMEM_BITS)
|
@@ -456,6 +431,15 @@ asmlinkage __visible void __init __noreturn x86_64_start_kernel(char * real_mode
|
456 | 431 | (__START_KERNEL & PGDIR_MASK)));
|
457 | 432 | BUILD_BUG_ON(__fix_to_virt(__end_of_fixed_addresses) <= MODULES_END);
|
458 | 433 |
|
| 434 | + if (check_la57_support()) { |
| 435 | + __pgtable_l5_enabled = 1; |
| 436 | + pgdir_shift = 48; |
| 437 | + ptrs_per_p4d = 512; |
| 438 | + page_offset_base = __PAGE_OFFSET_BASE_L5; |
| 439 | + vmalloc_base = __VMALLOC_BASE_L5; |
| 440 | + vmemmap_base = __VMEMMAP_BASE_L5; |
| 441 | + } |
| 442 | + |
459 | 443 | cr4_init_shadow();
|
460 | 444 |
|
461 | 445 | /* Kill off the identity-map trampoline */
|
|
0 commit comments