Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1622473 > unrolled thread
| Started by | Josh Poimboeuf <jpoimboe@redhat.com> |
|---|---|
| First post | 2017-04-12 20:50 +0200 |
| Last post | 2017-04-14 11:40 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 2/3] x86/unwind: read stack return address in update_stack_state() Josh Poimboeuf <jpoimboe@redhat.com> - 2017-04-12 20:50 +0200
[tip:x86/asm] x86/unwind: Read stack return address in update_stack_state() tip-bot for Josh Poimboeuf <tipbot@zytor.com> - 2017-04-14 11:40 +0200
| From | Josh Poimboeuf <jpoimboe@redhat.com> |
|---|---|
| Date | 2017-04-12 20:50 +0200 |
| Subject | [PATCH 2/3] x86/unwind: read stack return address in update_stack_state() |
| Message-ID | <tvvv3-81S-1@gated-at.bofh.it> |
Instead of reading the return address when unwind_get_return_address()
is called, read it from update_stack_state() and store it in the unwind
state. This enables the next patch to check the return address from
unwind_next_frame() so it can detect an entry code frame.
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
arch/x86/include/asm/unwind.h | 1 +
arch/x86/kernel/unwind_frame.c | 25 +++++++++++++------------
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/arch/x86/include/asm/unwind.h b/arch/x86/include/asm/unwind.h
index 6fa75b1..5663425 100644
--- a/arch/x86/include/asm/unwind.h
+++ b/arch/x86/include/asm/unwind.h
@@ -14,6 +14,7 @@ struct unwind_state {
#ifdef CONFIG_FRAME_POINTER
unsigned long *bp, *orig_sp;
struct pt_regs *regs;
+ unsigned long ip;
#else
unsigned long *sp;
#endif
diff --git a/arch/x86/kernel/unwind_frame.c b/arch/x86/kernel/unwind_frame.c
index 9098ef1..c67a059 100644
--- a/arch/x86/kernel/unwind_frame.c
+++ b/arch/x86/kernel/unwind_frame.c
@@ -56,20 +56,10 @@ static void unwind_dump(struct unwind_state *state, unsigned long *sp)
unsigned long unwind_get_return_address(struct unwind_state *state)
{
- unsigned long addr;
- unsigned long *addr_p = unwind_get_return_address_ptr(state);
-
if (unwind_done(state))
return 0;
- if (state->regs && user_mode(state->regs))
- return 0;
-
- addr = READ_ONCE_TASK_STACK(state->task, *addr_p);
- addr = ftrace_graph_ret_addr(state->task, &state->graph_idx, addr,
- addr_p);
-
- return __kernel_text_address(addr) ? addr : 0;
+ return __kernel_text_address(state->ip) ? state->ip : 0;
}
EXPORT_SYMBOL_GPL(unwind_get_return_address);
@@ -141,7 +131,7 @@ static bool update_stack_state(struct unwind_state *state,
struct stack_info *info = &state->stack_info;
enum stack_type prev_type = info->type;
struct pt_regs *regs;
- unsigned long *frame, *prev_frame_end;
+ unsigned long *frame, *prev_frame_end, *addr_p, addr;
size_t len;
if (state->regs)
@@ -185,6 +175,16 @@ static bool update_stack_state(struct unwind_state *state,
state->regs = NULL;
}
+ /* Save the return address: */
+ if (state->regs && user_mode(state->regs))
+ state->ip = 0;
+ else {
+ addr_p = unwind_get_return_address_ptr(state);
+ addr = READ_ONCE_TASK_STACK(state->task, *addr_p);
+ state->ip = ftrace_graph_ret_addr(state->task, &state->graph_idx,
+ addr, addr_p);
+ }
+
/* Save the original stack pointer for unwind_dump(): */
if (!state->orig_sp || info->type != prev_type)
state->orig_sp = frame;
@@ -228,6 +228,7 @@ bool unwind_next_frame(struct unwind_state *state)
*/
state->regs = regs;
state->bp = NULL;
+ state->ip = 0;
return true;
}
--
2.7.4
[toc] | [next] | [standalone]
| From | tip-bot for Josh Poimboeuf <tipbot@zytor.com> |
|---|---|
| Date | 2017-04-14 11:40 +0200 |
| Subject | [tip:x86/asm] x86/unwind: Read stack return address in update_stack_state() |
| Message-ID | <tw5RU-7Pb-19@gated-at.bofh.it> |
| In reply to | #1622473 |
Commit-ID: 6bcdf9d51b9892dd5c6892d50cf5e9628efb8062
Gitweb: http://git.kernel.org/tip/6bcdf9d51b9892dd5c6892d50cf5e9628efb8062
Author: Josh Poimboeuf <jpoimboe@redhat.com>
AuthorDate: Wed, 12 Apr 2017 13:47:11 -0500
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 14 Apr 2017 10:19:59 +0200
x86/unwind: Read stack return address in update_stack_state()
Instead of reading the return address when unwind_get_return_address()
is called, read it from update_stack_state() and store it in the unwind
state. This enables the next patch to check the return address from
unwind_next_frame() so it can detect an entry code frame.
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Dave Jones <davej@codemonkey.org.uk>
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>
Link: http://lkml.kernel.org/r/af0c5e4560c49c0343dca486ea26c4fa92bc4e35.1492020577.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/include/asm/unwind.h | 1 +
arch/x86/kernel/unwind_frame.c | 25 +++++++++++++------------
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/arch/x86/include/asm/unwind.h b/arch/x86/include/asm/unwind.h
index 6fa75b1..5663425 100644
--- a/arch/x86/include/asm/unwind.h
+++ b/arch/x86/include/asm/unwind.h
@@ -14,6 +14,7 @@ struct unwind_state {
#ifdef CONFIG_FRAME_POINTER
unsigned long *bp, *orig_sp;
struct pt_regs *regs;
+ unsigned long ip;
#else
unsigned long *sp;
#endif
diff --git a/arch/x86/kernel/unwind_frame.c b/arch/x86/kernel/unwind_frame.c
index 9098ef1..c67a059 100644
--- a/arch/x86/kernel/unwind_frame.c
+++ b/arch/x86/kernel/unwind_frame.c
@@ -56,20 +56,10 @@ static void unwind_dump(struct unwind_state *state, unsigned long *sp)
unsigned long unwind_get_return_address(struct unwind_state *state)
{
- unsigned long addr;
- unsigned long *addr_p = unwind_get_return_address_ptr(state);
-
if (unwind_done(state))
return 0;
- if (state->regs && user_mode(state->regs))
- return 0;
-
- addr = READ_ONCE_TASK_STACK(state->task, *addr_p);
- addr = ftrace_graph_ret_addr(state->task, &state->graph_idx, addr,
- addr_p);
-
- return __kernel_text_address(addr) ? addr : 0;
+ return __kernel_text_address(state->ip) ? state->ip : 0;
}
EXPORT_SYMBOL_GPL(unwind_get_return_address);
@@ -141,7 +131,7 @@ static bool update_stack_state(struct unwind_state *state,
struct stack_info *info = &state->stack_info;
enum stack_type prev_type = info->type;
struct pt_regs *regs;
- unsigned long *frame, *prev_frame_end;
+ unsigned long *frame, *prev_frame_end, *addr_p, addr;
size_t len;
if (state->regs)
@@ -185,6 +175,16 @@ static bool update_stack_state(struct unwind_state *state,
state->regs = NULL;
}
+ /* Save the return address: */
+ if (state->regs && user_mode(state->regs))
+ state->ip = 0;
+ else {
+ addr_p = unwind_get_return_address_ptr(state);
+ addr = READ_ONCE_TASK_STACK(state->task, *addr_p);
+ state->ip = ftrace_graph_ret_addr(state->task, &state->graph_idx,
+ addr, addr_p);
+ }
+
/* Save the original stack pointer for unwind_dump(): */
if (!state->orig_sp || info->type != prev_type)
state->orig_sp = frame;
@@ -228,6 +228,7 @@ bool unwind_next_frame(struct unwind_state *state)
*/
state->regs = regs;
state->bp = NULL;
+ state->ip = 0;
return true;
}
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web