forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/arch/x86/boot/compressed/pgtable_64.c
....@@ -5,17 +5,15 @@
55 #include "pgtable.h"
66 #include "../string.h"
77
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
-
178 #define BIOS_START_MIN 0x20000U /* 128K, less than this is insane */
189 #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
1917
2018 struct paging_config {
2119 unsigned long trampoline_start;
....@@ -32,7 +30,7 @@
3230 * Avoid putting the pointer into .bss as it will be cleared between
3331 * paging_prepare() and extract_kernel().
3432 */
35
-unsigned long *trampoline_32bit __section(.data);
33
+unsigned long *trampoline_32bit __section(".data");
3634
3735 extern struct boot_params *boot_params;
3836 int cmdline_find_option_bool(const char *option);
....@@ -40,7 +38,6 @@
4038 static unsigned long find_trampoline_placement(void)
4139 {
4240 unsigned long bios_start = 0, ebda_start = 0;
43
- unsigned long trampoline_start;
4441 struct boot_e820_entry *entry;
4542 char *signature;
4643 int i;
....@@ -208,4 +205,13 @@
208205
209206 /* Restore trampoline memory */
210207 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
211217 }