All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>, "H . Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
	Andy Lutomirski <luto@kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Brian Gerst <brgerst@gmail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Nilay Vaish <nilayvaish@gmail.com>
Subject: [PATCH 4/9] x86/head/32: fix the end of the stack for idle tasks
Date: Tue, 20 Sep 2016 15:02:46 -0500	[thread overview]
Message-ID: <1f3b094f522b9e955a65cffb6859096c51daa48a.1474400222.git.jpoimboe@redhat.com> (raw)
In-Reply-To: <cover.1474400222.git.jpoimboe@redhat.com>

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

Fix that by changing the initial code jumps to calls.  Also add infinite
loops after the calls to make it clear that the calls don't return, and
to hang if they do.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 arch/x86/kernel/head_32.S | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index 617fba2..7aac1b9 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -288,7 +288,8 @@ num_subarch_entries = (. - subarch_entries) / 4
 ENTRY(start_cpu0)
 	movl initial_stack, %ecx
 	movl %ecx, %esp
-	jmp  *(initial_code)
+	call *(initial_code)
+1:	jmp 1b
 ENDPROC(start_cpu0)
 #endif
 
@@ -469,8 +470,9 @@ ENTRY(startup_32_smp)
 	xorl %eax,%eax			# Clear LDT
 	lldt %ax
 
-	pushl $0		# fake return address for unwinder
-	jmp *(initial_code)
+	call *(initial_code)
+1:	jmp 1b
+ENDPROC(startup_32_smp)
 
 #include "verify_cpu.S"
 
-- 
2.7.4

  parent reply	other threads:[~2016-09-20 20:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-20 20:02 [PATCH 0/9] x86/entry/head: standardize the end of the stack Josh Poimboeuf
2016-09-20 20:02 ` [PATCH 1/9] x86/entry/head/32: use local labels Josh Poimboeuf
2016-09-21  0:57   ` Andy Lutomirski
2016-09-21  2:52     ` Josh Poimboeuf
2016-09-20 20:02 ` [PATCH 2/9] x86/entry/32: rename 'error_code' to 'common_exception' Josh Poimboeuf
2016-09-20 20:02 ` [PATCH 3/9] x86/entry/32: fix the end of the stack for newly forked tasks Josh Poimboeuf
2016-09-21  1:10   ` Brian Gerst
2016-09-21  3:25     ` Josh Poimboeuf
2016-09-21  3:33       ` Josh Poimboeuf
2016-09-21  6:39       ` Andy Lutomirski
2016-09-21 11:35         ` Josh Poimboeuf
2016-09-20 20:02 ` Josh Poimboeuf [this message]
2016-09-20 20:02 ` [PATCH 5/9] x86/smp: fix initial idle stack location on 32-bit Josh Poimboeuf
2016-09-20 20:02 ` [PATCH 6/9] x86/asm/head: use a common function for starting CPUs Josh Poimboeuf
2016-09-20 20:02 ` [PATCH 7/9] x86/head: put real return address on idle task stack Josh Poimboeuf
2016-09-20 20:02 ` [PATCH 8/9] x86/head: fix the end of the stack for idle tasks Josh Poimboeuf
2016-09-20 20:02 ` [PATCH 9/9] x86: move _stext marker to before head code Josh Poimboeuf

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=1f3b094f522b9e955a65cffb6859096c51daa48a.1474400222.git.jpoimboe@redhat.com \
    --to=jpoimboe@redhat.com \
    --cc=brgerst@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@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 \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.