aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/include/asm
diff options
context:
space:
mode:
authorNikolay Borisov <Nikolay.Borisov@arm.com>2014-06-03 14:48:10 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2014-07-18 07:29:11 -0400
commit9865f1d46a68a5f58cb623054c8308484007d8a4 (patch)
treef20a30ff2e839e9dab1a04204cc44904c22a821d /arch/arm/include/asm
parent9696fcae9251610f5935a3823be40d1365649720 (diff)
ARM: 8070/1: Introduce arm_get_current_stack_frame()
Currently there are numerous places where "struct pt_regs" are used to populate "struct stackframe", however all of those location do not consider the situation where the kernel might be compiled in THUMB2 mode, in which case the framepointer member of pt_regs become ARM_r7 instead of ARM_fp (r11). Document this idiosyncracy in the definition of "struct stackframe" The easiest solution is to introduce a new function (in the spirit of https://groups.google.com/forum/#!topic/linux.kernel/dA2YuUcSpZ4) which would hide the complexity of initializing the stackframe struct from pt_regs. Also implement a macro frame_pointer(regs) that would return the correct register so that we can use it in cases where we just require the frame pointer and not a whole struct stackframe Signed-off-by: Nikolay Borisov <Nikolay.Borisov@arm.com> Acked-by: Will Deacon <will.deacon@arm.com> Acked-by: Robert Richter <rric@kernel.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/include/asm')
-rw-r--r--arch/arm/include/asm/ptrace.h6
-rw-r--r--arch/arm/include/asm/stacktrace.h15
2 files changed, 21 insertions, 0 deletions
diff --git a/arch/arm/include/asm/ptrace.h b/arch/arm/include/asm/ptrace.h
index c877654fe3bf..601264d983fa 100644
--- a/arch/arm/include/asm/ptrace.h
+++ b/arch/arm/include/asm/ptrace.h
@@ -84,6 +84,12 @@ static inline long regs_return_value(struct pt_regs *regs)
84 84
85#define instruction_pointer(regs) (regs)->ARM_pc 85#define instruction_pointer(regs) (regs)->ARM_pc
86 86
87#ifdef CONFIG_THUMB2_KERNEL
88#define frame_pointer(regs) (regs)->ARM_r7
89#else
90#define frame_pointer(regs) (regs)->ARM_fp
91#endif
92
87static inline void instruction_pointer_set(struct pt_regs *regs, 93static inline void instruction_pointer_set(struct pt_regs *regs,
88 unsigned long val) 94 unsigned long val)
89{ 95{
diff --git a/arch/arm/include/asm/stacktrace.h b/arch/arm/include/asm/stacktrace.h
index 4d0a16441b29..7722201ead19 100644
--- a/arch/arm/include/asm/stacktrace.h
+++ b/arch/arm/include/asm/stacktrace.h
@@ -1,13 +1,28 @@
1#ifndef __ASM_STACKTRACE_H 1#ifndef __ASM_STACKTRACE_H
2#define __ASM_STACKTRACE_H 2#define __ASM_STACKTRACE_H
3 3
4#include <asm/ptrace.h>
5
4struct stackframe { 6struct stackframe {
7 /*
8 * FP member should hold R7 when CONFIG_THUMB2_KERNEL is enabled
9 * and R11 otherwise.
10 */
5 unsigned long fp; 11 unsigned long fp;
6 unsigned long sp; 12 unsigned long sp;
7 unsigned long lr; 13 unsigned long lr;
8 unsigned long pc; 14 unsigned long pc;
9}; 15};
10 16
17static __always_inline
18void arm_get_current_stackframe(struct pt_regs *regs, struct stackframe *frame)
19{
20 frame->fp = frame_pointer(regs);
21 frame->sp = regs->ARM_sp;
22 frame->lr = regs->ARM_lr;
23 frame->pc = regs->ARM_pc;
24}
25
11extern int unwind_frame(struct stackframe *frame); 26extern int unwind_frame(struct stackframe *frame);
12extern void walk_stackframe(struct stackframe *frame, 27extern void walk_stackframe(struct stackframe *frame,
13 int (*fn)(struct stackframe *, void *), void *data); 28 int (*fn)(struct stackframe *, void *), void *data);