From: tip-bot for Josh Poimboeuf <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: tglx@linutronix.de, brgerst@gmail.com, hpa@zytor.com,
luto@kernel.org, mingo@kernel.org, peterz@infradead.org,
linux-kernel@vger.kernel.org, jpoimboe@redhat.com,
torvalds@linux-foundation.org, dvlasenk@redhat.com, bp@alien8.de
Subject: [tip:x86/asm] x86/unwind: Create stack frames for saved syscall registers
Date: Fri, 21 Oct 2016 00:49:37 -0700 [thread overview]
Message-ID: <tip-acb4608ad1865a42af8e0a2db332a7c3a381e1f5@git.kernel.org> (raw)
In-Reply-To: <e176aa9272930cd3f51fda0b94e2eae356677da4.1476973742.git.jpoimboe@redhat.com>
Commit-ID: acb4608ad1865a42af8e0a2db332a7c3a381e1f5
Gitweb: http://git.kernel.org/tip/acb4608ad1865a42af8e0a2db332a7c3a381e1f5
Author: Josh Poimboeuf <jpoimboe@redhat.com>
AuthorDate: Thu, 20 Oct 2016 11:34:41 -0500
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 21 Oct 2016 09:26:04 +0200
x86/unwind: Create stack frames for saved syscall registers
The entry code doesn't encode the pt_regs pointer for syscalls. But the
pt_regs are always at the same location, so we can add a manual check
for them.
A later patch prints them as part of the oops stack dump. They could be
useful, for example, to determine the arguments to a system call.
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: 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: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/e176aa9272930cd3f51fda0b94e2eae356677da4.1476973742.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/kernel/unwind_frame.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/arch/x86/kernel/unwind_frame.c b/arch/x86/kernel/unwind_frame.c
index 2221ab1..5795427 100644
--- a/arch/x86/kernel/unwind_frame.c
+++ b/arch/x86/kernel/unwind_frame.c
@@ -24,6 +24,14 @@ unsigned long unwind_get_return_address(struct unwind_state *state)
}
EXPORT_SYMBOL_GPL(unwind_get_return_address);
+static bool is_last_task_frame(struct unwind_state *state)
+{
+ unsigned long bp = (unsigned long)state->bp;
+ unsigned long regs = (unsigned long)task_pt_regs(state->task);
+
+ return bp == regs - FRAME_HEADER_SIZE;
+}
+
/*
* This determines if the frame pointer actually contains an encoded pointer to
* pt_regs on the stack. See ENCODE_FRAME_POINTER.
@@ -71,6 +79,33 @@ bool unwind_next_frame(struct unwind_state *state)
if (state->regs && user_mode(state->regs))
goto the_end;
+ if (is_last_task_frame(state)) {
+ regs = task_pt_regs(state->task);
+
+ /*
+ * kthreads (other than the boot CPU's idle thread) have some
+ * partial regs at the end of their stack which were placed
+ * there by copy_thread_tls(). But the regs don't have any
+ * useful information, so we can skip them.
+ *
+ * This user_mode() check is slightly broader than a PF_KTHREAD
+ * check because it also catches the awkward situation where a
+ * newly forked kthread transitions into a user task by calling
+ * do_execve(), which eventually clears PF_KTHREAD.
+ */
+ if (!user_mode(regs))
+ goto the_end;
+
+ /*
+ * We're almost at the end, but not quite: there's still the
+ * syscall regs frame. Entry code doesn't encode the regs
+ * pointer for syscalls, so we have to set it manually.
+ */
+ state->regs = regs;
+ state->bp = NULL;
+ return true;
+ }
+
/* get the next frame pointer */
if (state->regs)
next_bp = (unsigned long *)state->regs->bp;
next prev parent reply other threads:[~2016-10-21 7:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-20 16:34 [PATCH 0/6] x86/dumpstack: print entry regs when dumping the stack Josh Poimboeuf
2016-10-20 16:34 ` [PATCH 1/6] x86/entry/unwind: create stack frames for saved interrupt registers Josh Poimboeuf
2016-10-21 7:49 ` [tip:x86/asm] x86/entry/unwind: Create " tip-bot for Josh Poimboeuf
2016-10-20 16:34 ` [PATCH 2/6] x86/unwind: create stack frames for saved syscall registers Josh Poimboeuf
2016-10-21 7:49 ` tip-bot for Josh Poimboeuf [this message]
2016-10-20 16:34 ` [PATCH 3/6] x86/dumpstack: print stack identifier on its own line Josh Poimboeuf
2016-10-21 7:50 ` [tip:x86/asm] x86/dumpstack: Print " tip-bot for Josh Poimboeuf
2016-10-20 16:34 ` [PATCH 4/6] x86/dumpstack: print any pt_regs found on the stack Josh Poimboeuf
2016-10-21 7:50 ` [tip:x86/asm] x86/dumpstack: Print " tip-bot for Josh Poimboeuf
2016-10-20 16:34 ` [PATCH 5/6] x86/dumpstack: fix duplicate RIP address display in __show_regs() Josh Poimboeuf
2016-10-21 7:51 ` [tip:x86/asm] x86/dumpstack: Fix " tip-bot for Josh Poimboeuf
2016-10-20 16:34 ` [PATCH 6/6] x86/dumpstack: print orig_ax " Josh Poimboeuf
2016-10-21 7:51 ` [tip:x86/asm] x86/dumpstack: Print " tip-bot for 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=tip-acb4608ad1865a42af8e0a2db332a7c3a381e1f5@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=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
Powered by JetHome