public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Josh Poimboeuf <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: nilayvaish@gmail.com, luto@kernel.org, hpa@zytor.com,
	linux-kernel@vger.kernel.org, bp@alien8.de,
	torvalds@linux-foundation.org, brgerst@gmail.com,
	tglx@linutronix.de, jpoimboe@redhat.com, dvlasenk@redhat.com,
	peterz@infradead.org, mingo@kernel.org
Subject: [tip:x86/asm] x86/boot/64: Put a real return address on the idle task stack
Date: Thu, 20 Oct 2016 04:11:45 -0700	[thread overview]
Message-ID: <tip-595c1e645d9fd8561104b5680931f68a429aaa1c@git.kernel.org> (raw)
In-Reply-To: <f59593ae7b15d5126f872b0a23143173d28aa32d.1474480779.git.jpoimboe@redhat.com>

Commit-ID:  595c1e645d9fd8561104b5680931f68a429aaa1c
Gitweb:     http://git.kernel.org/tip/595c1e645d9fd8561104b5680931f68a429aaa1c
Author:     Josh Poimboeuf <jpoimboe@redhat.com>
AuthorDate: Wed, 21 Sep 2016 16:04:05 -0500
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 20 Oct 2016 09:15:23 +0200

x86/boot/64: Put a real return address on the idle task stack

The frame at the end of each idle task stack has a zeroed return
address.  This is inconsistent with real task stacks, which have a real
return address at that spot.  This inconsistency can be confusing for
stack unwinders.  It also hides useful information about what asm code
was involved in calling into C.

Make it a real address by using the side effect of a call instruction to
push the instruction pointer on the stack.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Reviewed-by: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/f59593ae7b15d5126f872b0a23143173d28aa32d.1474480779.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/head_64.S | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index 3631777..1c5e5db 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -299,8 +299,9 @@ ENTRY(start_cpu)
 	 *	REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
 	 *		address given in m16:64.
 	 */
-	movq	initial_code(%rip),%rax
-	pushq	$0		# fake return address to stop unwinder
+	call	1f		# put return address on stack for unwinder
+1:	xorq	%rbp, %rbp	# clear frame pointer
+	movq	initial_code(%rip), %rax
 	pushq	$__KERNEL_CS	# set correct cs
 	pushq	%rax		# target address in negative space
 	lretq

  reply	other threads:[~2016-10-20 11:12 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-21 21:03 [PATCH v2 0/9] x86/entry/head: standardize the end of the stack Josh Poimboeuf
2016-09-21 21:03 ` [PATCH v2 1/9] x86/entry/head/32: use local labels Josh Poimboeuf
2016-10-20 11:08   ` [tip:x86/asm] x86/entry/32, x86/boot/32: Use " tip-bot for Josh Poimboeuf
2016-09-21 21:04 ` [PATCH v2 2/9] x86/entry/32: rename 'error_code' to 'common_exception' Josh Poimboeuf
2016-10-20 11:08   ` [tip:x86/asm] x86/entry/32: Rename " tip-bot for Josh Poimboeuf
2016-09-21 21:04 ` [PATCH v2 3/9] x86/entry/32: fix the end of the stack for newly forked tasks Josh Poimboeuf
2016-10-20 11:09   ` [tip:x86/asm] x86/entry/32: Fix " tip-bot for Josh Poimboeuf
2016-09-21 21:04 ` [PATCH v2 4/9] x86/head/32: fix the end of the stack for idle tasks Josh Poimboeuf
2016-10-20 11:10   ` [tip:x86/asm] x86/boot/32: Fix " tip-bot for Josh Poimboeuf
2016-09-21 21:04 ` [PATCH v2 5/9] x86/smp: fix initial idle stack location on 32-bit Josh Poimboeuf
2016-10-20 11:10   ` [tip:x86/asm] x86/boot/smp/32: Fix initial idle stack location on 32-bit kernels tip-bot for Josh Poimboeuf
2016-09-21 21:04 ` [PATCH v2 6/9] x86/asm/head: use a common function for starting CPUs Josh Poimboeuf
2016-10-20 11:11   ` [tip:x86/asm] x86/boot/64: Use " tip-bot for Josh Poimboeuf
2016-09-21 21:04 ` [PATCH v2 7/9] x86/head: put real return address on idle task stack Josh Poimboeuf
2016-10-20 11:11   ` tip-bot for Josh Poimboeuf [this message]
2016-09-21 21:04 ` [PATCH v2 8/9] x86/head: fix the end of the stack for idle tasks Josh Poimboeuf
2016-10-20 11:12   ` [tip:x86/asm] x86/boot: Fix " tip-bot for Josh Poimboeuf
2016-09-21 21:04 ` [PATCH v2 9/9] x86: move _stext marker to before head code Josh Poimboeuf
2016-10-20 11:12   ` [tip:x86/asm] x86/boot: Move the _stext marker to before the boot code tip-bot for Josh Poimboeuf
2016-10-18 17:17 ` [PATCH v2 0/9] x86/entry/head: standardize the end of the stack Josh Poimboeuf
2016-10-19 13:20   ` Ingo Molnar

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=tip-595c1e645d9fd8561104b5680931f68a429aaa1c@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=bp@alien8.de \
    --cc=brgerst@gmail.com \
    --cc=dvlasenk@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=nilayvaish@gmail.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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