* [PATCH v1] x86/boot: Use pgd_index(__START_KERNEL_map) instead of hardcoded 511
@ 2025-10-08 14:43 shengminghu512
0 siblings, 0 replies; only message in thread
From: shengminghu512 @ 2025-10-08 14:43 UTC (permalink / raw)
To: tglx, mingo, bp, dave.hansen, x86
Cc: hpa, broonie, linux-kernel, zhang.run, hu.shengming
From: Shengming Hu <shengminghu512@qq.com>
Date: Wed, 8 Oct 2025 21:46:03 +0800
Subject: [PATCH v1] x86/boot: Use pgd_index(__START_KERNEL_map) instead of
hardcoded 511
The index 511 is used to set up the kernel high mapping in the
top-level page table.
Replacing the magic number with pgd_index(__START_KERNEL_map)
improves code readability and future-proofs the code against
possible changes in paging structure.
Signed-off-by: Shengming Hu <shengminghu512@qq.com>
---
arch/x86/kernel/head64.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index fd28b53db..65d4c485a 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -286,7 +286,9 @@ asmlinkage __visible void __init __noreturn x86_64_start_kernel(char * real_mode
load_ucode_bsp();
/* set init_top_pgt kernel high mapping*/
- init_top_pgt[511] = early_top_pgt[511];
+ unsigned int kernel_pgd = pgd_index(__START_KERNEL_map);
+
+ init_top_pgt[kernel_pgd] = early_top_pgt[kernel_pgd];
x86_64_start_reservations(real_mode_data);
}
--
2.34.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-10-08 14:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-08 14:43 [PATCH v1] x86/boot: Use pgd_index(__START_KERNEL_map) instead of hardcoded 511 shengminghu512
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®