From: "tip-bot2 for David Woodhouse" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: David Woodhouse <dwmw@amazon.co.uk>,
Ingo Molnar <mingo@kernel.org>, Brian Gerst <brgerst@gmail.com>,
Juergen Gross <jgross@suse.com>, "H. Peter Anvin" <hpa@zytor.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Kees Cook <keescook@chromium.org>,
Ard Biesheuvel <ardb@kernel.org>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: x86/asm] x86/kexec: Invalidate GDT/IDT from relocate_kernel() instead of earlier
Date: Thu, 10 Apr 2025 11:12:54 -0000 [thread overview]
Message-ID: <174428357481.31282.17425113277917466268.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20250326142404.256980-4-dwmw2@infradead.org>
The following commit has been merged into the x86/asm branch of tip:
Commit-ID: de085ddd493bccb77a3ec1b99ae7466133540f4d
Gitweb: https://git.kernel.org/tip/de085ddd493bccb77a3ec1b99ae7466133540f4d
Author: David Woodhouse <dwmw@amazon.co.uk>
AuthorDate: Wed, 26 Mar 2025 14:16:03
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Thu, 10 Apr 2025 12:17:14 +02:00
x86/kexec: Invalidate GDT/IDT from relocate_kernel() instead of earlier
Reduce the window during which exceptions are unhandled, by leaving the
GDT/IDT in place all the way into the relocate_kernel() function, until
the moment that %cr3 gets replaced.
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20250326142404.256980-4-dwmw2@infradead.org
---
arch/x86/kernel/machine_kexec_64.c | 10 ++--------
arch/x86/kernel/relocate_kernel_64.S | 9 +++++++--
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
index ecb0da5..949c9e4 100644
--- a/arch/x86/kernel/machine_kexec_64.c
+++ b/arch/x86/kernel/machine_kexec_64.c
@@ -434,16 +434,10 @@ void __nocfi machine_kexec(struct kimage *image)
* with from a table in memory. At no other time is the
* descriptor table in memory accessed.
*
- * I take advantage of this here by force loading the
- * segments, before I zap the gdt with an invalid value.
+ * Take advantage of this here by force loading the segments,
+ * before the GDT is zapped with an invalid value.
*/
load_segments();
- /*
- * The gdt & idt are now invalid.
- * If you want to load them you must set up your own idt & gdt.
- */
- native_idt_invalidate();
- native_gdt_invalidate();
/* now call it */
image->start = relocate_kernel_ptr((unsigned long)image->head,
diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
index 8808cfc..3062cb3 100644
--- a/arch/x86/kernel/relocate_kernel_64.S
+++ b/arch/x86/kernel/relocate_kernel_64.S
@@ -79,8 +79,13 @@ SYM_CODE_START_NOALIGN(relocate_kernel)
pushq %r15
pushf
- /* zero out flags, and disable interrupts */
- pushq $0
+ /* Invalidate GDT/IDT, zero out flags */
+ pushq $0
+ pushq $0
+
+ lidt (%rsp)
+ lgdt (%rsp)
+ addq $8, %rsp
popfq
/* Switch to the identity mapped page tables */
next prev parent reply other threads:[~2025-04-10 11:13 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-26 14:16 [PATCH v9 0/4] x86/kexec: Add exception handling for relocate_kernel David Woodhouse
2025-03-26 14:16 ` [PATCH v9 1/4] x86/kexec: Add 8250 serial port output David Woodhouse
2025-04-10 11:13 ` [tip: x86/asm] " tip-bot2 for David Woodhouse
2025-03-26 14:16 ` [PATCH v9 2/4] x86/kexec: Add 8250 MMIO " David Woodhouse
2025-04-10 11:13 ` [tip: x86/asm] " tip-bot2 for David Woodhouse
2025-03-26 14:16 ` [PATCH v9 3/4] x86/kexec: Invalidate GDT/IDT from relocate_kernel() instead of earlier David Woodhouse
2025-04-01 9:48 ` Huang, Kai
2025-04-01 9:53 ` David Woodhouse
2025-04-10 11:12 ` tip-bot2 for David Woodhouse [this message]
2025-03-26 14:16 ` [PATCH v9 4/4] selftests/kexec: Add x86_64 selftest for kexec-jump and exception handling David Woodhouse
2025-04-10 11:12 ` [tip: x86/asm] " tip-bot2 for David Woodhouse
2025-04-10 7:26 ` [PATCH v9 0/4] x86/kexec: Add exception handling for relocate_kernel David Woodhouse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=174428357481.31282.17425113277917466268.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=ardb@kernel.org \
--cc=brgerst@gmail.com \
--cc=dwmw@amazon.co.uk \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=jpoimboe@redhat.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®