| .. | .. |
|---|
| 5 | 5 | #include "pgtable.h" |
|---|
| 6 | 6 | #include "../string.h" |
|---|
| 7 | 7 | |
|---|
| 8 | | -/* |
|---|
| 9 | | - * __force_order is used by special_insns.h asm code to force instruction |
|---|
| 10 | | - * serialization. |
|---|
| 11 | | - * |
|---|
| 12 | | - * It is not referenced from the code, but GCC < 5 with -fPIE would fail |
|---|
| 13 | | - * due to an undefined symbol. Define it to make these ancient GCCs work. |
|---|
| 14 | | - */ |
|---|
| 15 | | -unsigned long __force_order; |
|---|
| 16 | | - |
|---|
| 17 | 8 | #define BIOS_START_MIN 0x20000U /* 128K, less than this is insane */ |
|---|
| 18 | 9 | #define BIOS_START_MAX 0x9f000U /* 640K, absolute maximum */ |
|---|
| 10 | + |
|---|
| 11 | +#ifdef CONFIG_X86_5LEVEL |
|---|
| 12 | +/* __pgtable_l5_enabled needs to be in .data to avoid being cleared along with .bss */ |
|---|
| 13 | +unsigned int __section(".data") __pgtable_l5_enabled; |
|---|
| 14 | +unsigned int __section(".data") pgdir_shift = 39; |
|---|
| 15 | +unsigned int __section(".data") ptrs_per_p4d = 1; |
|---|
| 16 | +#endif |
|---|
| 19 | 17 | |
|---|
| 20 | 18 | struct paging_config { |
|---|
| 21 | 19 | unsigned long trampoline_start; |
|---|
| .. | .. |
|---|
| 32 | 30 | * Avoid putting the pointer into .bss as it will be cleared between |
|---|
| 33 | 31 | * paging_prepare() and extract_kernel(). |
|---|
| 34 | 32 | */ |
|---|
| 35 | | -unsigned long *trampoline_32bit __section(.data); |
|---|
| 33 | +unsigned long *trampoline_32bit __section(".data"); |
|---|
| 36 | 34 | |
|---|
| 37 | 35 | extern struct boot_params *boot_params; |
|---|
| 38 | 36 | int cmdline_find_option_bool(const char *option); |
|---|
| .. | .. |
|---|
| 40 | 38 | static unsigned long find_trampoline_placement(void) |
|---|
| 41 | 39 | { |
|---|
| 42 | 40 | unsigned long bios_start = 0, ebda_start = 0; |
|---|
| 43 | | - unsigned long trampoline_start; |
|---|
| 44 | 41 | struct boot_e820_entry *entry; |
|---|
| 45 | 42 | char *signature; |
|---|
| 46 | 43 | int i; |
|---|
| .. | .. |
|---|
| 208 | 205 | |
|---|
| 209 | 206 | /* Restore trampoline memory */ |
|---|
| 210 | 207 | memcpy(trampoline_32bit, trampoline_save, TRAMPOLINE_32BIT_SIZE); |
|---|
| 208 | + |
|---|
| 209 | + /* Initialize variables for 5-level paging */ |
|---|
| 210 | +#ifdef CONFIG_X86_5LEVEL |
|---|
| 211 | + if (__read_cr4() & X86_CR4_LA57) { |
|---|
| 212 | + __pgtable_l5_enabled = 1; |
|---|
| 213 | + pgdir_shift = 48; |
|---|
| 214 | + ptrs_per_p4d = 512; |
|---|
| 215 | + } |
|---|
| 216 | +#endif |
|---|
| 211 | 217 | } |
|---|