[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <170911508625.398.12452118843438429976.tip-bot2@tip-bot2>
Date: Wed, 28 Feb 2024 10:11:26 -0000
From: "tip-bot2 for Brian Gerst" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Brian Gerst <brgerst@...il.com>, Ingo Molnar <mingo@...nel.org>,
Ard Biesheuvel <ardb@...nel.org>, Kees Cook <keescook@...omium.org>,
Andy Lutomirski <luto@...nel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
"H. Peter Anvin" <hpa@...or.com>, Josh Poimboeuf <jpoimboe@...hat.com>,
x86@...nel.org, linux-kernel@...r.kernel.org
Subject: [tip: x86/boot] x86/boot/64: Load the final kernel GDT during early
boot directly, remove startup_gdt[]
The following commit has been merged into the x86/boot branch of tip:
Commit-ID: 11e36b0f7c2150a6453872b79555767b43c846d0
Gitweb: https://git.kernel.org/tip/11e36b0f7c2150a6453872b79555767b43c846d0
Author: Brian Gerst <brgerst@...il.com>
AuthorDate: Mon, 26 Feb 2024 17:05:44 -05:00
Committer: Ingo Molnar <mingo@...nel.org>
CommitterDate: Wed, 28 Feb 2024 11:02:16 +01:00
x86/boot/64: Load the final kernel GDT during early boot directly, remove startup_gdt[]
Instead of loading a duplicate GDT just for early boot, load the kernel
GDT from its physical address.
Signed-off-by: Brian Gerst <brgerst@...il.com>
Signed-off-by: Ingo Molnar <mingo@...nel.org>
Acked-by: Ard Biesheuvel <ardb@...nel.org>
Cc: Kees Cook <keescook@...omium.org>
Cc: Andy Lutomirski <luto@...nel.org>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: "H. Peter Anvin" <hpa@...or.com>
Cc: Josh Poimboeuf <jpoimboe@...hat.com>
Link: https://lore.kernel.org/r/20240226220544.70769-1-brgerst@gmail.com
---
arch/x86/include/asm/desc.h | 1 +
arch/x86/kernel/head64.c | 13 ++-----------
2 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
index ab97b22..52c0150 100644
--- a/arch/x86/include/asm/desc.h
+++ b/arch/x86/include/asm/desc.h
@@ -46,6 +46,7 @@ struct gdt_page {
} __attribute__((aligned(PAGE_SIZE)));
DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
+DECLARE_INIT_PER_CPU(gdt_page);
/* Provide the original GDT */
static inline struct desc_struct *get_cpu_gdt_rw(unsigned int cpu)
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index 72351c3..fd77a26 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -68,15 +68,6 @@ unsigned long vmemmap_base __ro_after_init = __VMEMMAP_BASE_L4;
EXPORT_SYMBOL(vmemmap_base);
#endif
-/*
- * GDT used on the boot CPU before switching to virtual addresses.
- */
-static struct desc_struct startup_gdt[GDT_ENTRIES] __initdata = {
- [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(DESC_CODE32, 0, 0xfffff),
- [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(DESC_CODE64, 0, 0xfffff),
- [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(DESC_DATA64, 0, 0xfffff),
-};
-
#ifdef CONFIG_X86_5LEVEL
static void __head *fixup_pointer(void *ptr, unsigned long physaddr)
{
@@ -589,8 +580,8 @@ void __head startup_64_setup_gdt_idt(void)
void *handler = NULL;
struct desc_ptr startup_gdt_descr = {
- .address = (unsigned long)&RIP_REL_REF(startup_gdt),
- .size = sizeof(startup_gdt) - 1,
+ .address = (unsigned long)&RIP_REL_REF(init_per_cpu_var(gdt_page.gdt)),
+ .size = GDT_SIZE - 1,
};
/* Load GDT */
Powered by blists - more mailing lists