[<prev] [next>] [day] [month] [year] [list]
Message-ID: <tencent_AB982BDF5B2FBDD110C0ECB5A5474B9C4D0A@qq.com>
Date: Wed, 8 Oct 2025 22:43:00 +0800
From: "shengminghu512" <shengminghu512@...com>
To: "tglx" <tglx@...utronix.de>, "mingo" <mingo@...hat.com>, "bp" <bp@...en8.de>, "dave.hansen" <dave.hansen@...ux.intel.com>, "x86" <x86@...nel.org>
Cc: "hpa" <hpa@...or.com>, "broonie" <broonie@...nel.org>, "linux-kernel" <linux-kernel@...r.kernel.org>, "zhang.run" <zhang.run@....com.cn>, "hu.shengming" <hu.shengming@....com.cn>
Subject: [PATCH v1] x86/boot: Use pgd_index(__START_KERNEL_map) instead of hardcoded 511
From: Shengming Hu <shengminghu512@...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@...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
Powered by blists - more mailing lists