The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* Re: [PATCH v2] x86/kexec: Push kjump return address even for non-kjump kexec
       [not found] <32d627134143ffd957891cb697138e839c623211.camel@infradead.org>
@ 2026-05-07 22:08 ` Dave Hansen
  2026-05-08 15:02 ` [tip: x86/urgent] " tip-bot2 for David Woodhouse
  1 sibling, 0 replies; 2+ messages in thread
From: Dave Hansen @ 2026-05-07 22:08 UTC (permalink / raw)
  To: David Woodhouse, Rohan Kakulawaram, kexec
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, David Woodhouse, Kai Huang, Paolo Bonzini,
	Uros Bizjak, Sohil Mehta, linux-kernel

On 4/28/26 13:59, David Woodhouse wrote:
> +	/*
> +	 * Set return address to 0 if not preserving context. The purgatory
> +	 * shipped in kexec-tools will unconditionally look for the return
> +	 * address on the stack and set a kexec_jump_back_entry= command
> +	 * line option if it's non-zero. There's no other way that it can
> +	 * tell a preserve-context (kjump) kexec from a normal one.
> +	 */
> +	pushq	$0

Thanks for the update. LGTM:

Acked-by: Dave Hansen <dave.hansen@linux.intel.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [tip: x86/urgent] x86/kexec: Push kjump return address even for non-kjump kexec
       [not found] <32d627134143ffd957891cb697138e839c623211.camel@infradead.org>
  2026-05-07 22:08 ` [PATCH v2] x86/kexec: Push kjump return address even for non-kjump kexec Dave Hansen
@ 2026-05-08 15:02 ` tip-bot2 for David Woodhouse
  1 sibling, 0 replies; 2+ messages in thread
From: tip-bot2 for David Woodhouse @ 2026-05-08 15:02 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Rohan Kakulawaram, David Woodhouse, Borislav Petkov (AMD),
	Dave Hansen, stable, x86, linux-kernel

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     786a45757dcdf8f2beb9d4a6db605db16c18b2b4
Gitweb:        https://git.kernel.org/tip/786a45757dcdf8f2beb9d4a6db605db16c18b2b4
Author:        David Woodhouse <dwmw@amazon.co.uk>
AuthorDate:    Tue, 28 Apr 2026 21:59:52 +01:00
Committer:     Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 08 May 2026 17:00:12 +02:00

x86/kexec: Push kjump return address even for non-kjump kexec

The version of purgatory code shipped by kexec-tools attempts to look above
the top of its stack to find a return address for a kjump, even in a non-kjump
kexec.

After the commit in Fixes: the word above the stack might not be there,
leading to a fault (which is at least now caught by my exception-handling code
in kexec).

That commit fixed things for the actual kjump path, but no longer
"gratuitously" pushes the unused return address to the stack in the non-kjump
path. Put that *back* in the non-kjump path, to prevent purgatory from
crashing when trying to access it.

Fixes: 2cacf7f23a02 ("x86/kexec: Fix stack and handling of re-entry point for ::preserve_context")
Reported-by: Rohan Kakulawaram <rohanka@google.com>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
Tested-by: Rohan Kakulawaram <rohanka@google.com>
Cc: <stable@kernel.org>
Link: https://patch.msgid.link/32d627134143ffd957891cb697138e839c623211.camel@infradead.org
---
 arch/x86/kernel/relocate_kernel_64.S | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
index 4ffba68..eaeb774 100644
--- a/arch/x86/kernel/relocate_kernel_64.S
+++ b/arch/x86/kernel/relocate_kernel_64.S
@@ -136,6 +136,14 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_mapped)
 	 * %r13 original CR4 when relocate_kernel() was invoked
 	 */
 
+	/*
+	 * Set return address to 0 if not preserving context. The purgatory
+	 * shipped in kexec-tools will unconditionally look for the return
+	 * address on the stack and set a kexec_jump_back_entry= command
+	 * line option if it's non-zero. There's no other way that it can
+	 * tell a preserve-context (kjump) kexec from a normal one.
+	 */
+	pushq	$0
 	/* store the start address on the stack */
 	pushq   %rdx
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-08 15:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <32d627134143ffd957891cb697138e839c623211.camel@infradead.org>
2026-05-07 22:08 ` [PATCH v2] x86/kexec: Push kjump return address even for non-kjump kexec Dave Hansen
2026-05-08 15:02 ` [tip: x86/urgent] " tip-bot2 for David Woodhouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox