diff options
author | Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> | 2019-09-05 14:20:29 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2019-09-17 22:24:55 -0400 |
commit | 370011a27028d6f05e598ed6211a0ca2dc0213f7 (patch) | |
tree | 9795c67704e2d5d70595e4e61e5517393d40f644 | |
parent | a3db31ff6ce31f5a544a66b61613a098029031cc (diff) |
powerpc/ftrace: Enable HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
This associates entries in the ftrace_ret_stack with corresponding stack
frames, enabling more robust stack unwinding. Also update the only user
of ftrace_graph_ret_addr() to pass the stack pointer.
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/0224f2d0971b069c678e2ff678cfc2cd1e114cfe.1567707399.git.naveen.n.rao@linux.vnet.ibm.com
-rw-r--r-- | arch/powerpc/include/asm/asm-prototypes.h | 3 | ||||
-rw-r--r-- | arch/powerpc/include/asm/ftrace.h | 2 | ||||
-rw-r--r-- | arch/powerpc/kernel/stacktrace.c | 2 | ||||
-rw-r--r-- | arch/powerpc/kernel/trace/ftrace.c | 5 | ||||
-rw-r--r-- | arch/powerpc/kernel/trace/ftrace_32.S | 1 | ||||
-rw-r--r-- | arch/powerpc/kernel/trace/ftrace_64_mprofile.S | 1 | ||||
-rw-r--r-- | arch/powerpc/kernel/trace/ftrace_64_pg.S | 1 |
7 files changed, 11 insertions, 4 deletions
diff --git a/arch/powerpc/include/asm/asm-prototypes.h b/arch/powerpc/include/asm/asm-prototypes.h index 49196d35e3bb..8561498e653c 100644 --- a/arch/powerpc/include/asm/asm-prototypes.h +++ b/arch/powerpc/include/asm/asm-prototypes.h | |||
@@ -134,7 +134,8 @@ extern int __ucmpdi2(u64, u64); | |||
134 | 134 | ||
135 | /* tracing */ | 135 | /* tracing */ |
136 | void _mcount(void); | 136 | void _mcount(void); |
137 | unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip); | 137 | unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip, |
138 | unsigned long sp); | ||
138 | 139 | ||
139 | void pnv_power9_force_smt4_catch(void); | 140 | void pnv_power9_force_smt4_catch(void); |
140 | void pnv_power9_force_smt4_release(void); | 141 | void pnv_power9_force_smt4_release(void); |
diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h index 3dfb80b86561..f54a08a2cd70 100644 --- a/arch/powerpc/include/asm/ftrace.h +++ b/arch/powerpc/include/asm/ftrace.h | |||
@@ -8,6 +8,8 @@ | |||
8 | #define MCOUNT_ADDR ((unsigned long)(_mcount)) | 8 | #define MCOUNT_ADDR ((unsigned long)(_mcount)) |
9 | #define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */ | 9 | #define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */ |
10 | 10 | ||
11 | #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR | ||
12 | |||
11 | #ifdef __ASSEMBLY__ | 13 | #ifdef __ASSEMBLY__ |
12 | 14 | ||
13 | /* Based off of objdump optput from glibc */ | 15 | /* Based off of objdump optput from glibc */ |
diff --git a/arch/powerpc/kernel/stacktrace.c b/arch/powerpc/kernel/stacktrace.c index 1e2276963f6d..e2a46cfed5fd 100644 --- a/arch/powerpc/kernel/stacktrace.c +++ b/arch/powerpc/kernel/stacktrace.c | |||
@@ -182,7 +182,7 @@ static int __save_stack_trace_tsk_reliable(struct task_struct *tsk, | |||
182 | * FIXME: IMHO these tests do not belong in | 182 | * FIXME: IMHO these tests do not belong in |
183 | * arch-dependent code, they are generic. | 183 | * arch-dependent code, they are generic. |
184 | */ | 184 | */ |
185 | ip = ftrace_graph_ret_addr(tsk, &graph_idx, ip, NULL); | 185 | ip = ftrace_graph_ret_addr(tsk, &graph_idx, ip, stack); |
186 | #ifdef CONFIG_KPROBES | 186 | #ifdef CONFIG_KPROBES |
187 | /* | 187 | /* |
188 | * Mark stacktraces with kretprobed functions on them | 188 | * Mark stacktraces with kretprobed functions on them |
diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c index be1ca98fce5c..7ea0ca044b65 100644 --- a/arch/powerpc/kernel/trace/ftrace.c +++ b/arch/powerpc/kernel/trace/ftrace.c | |||
@@ -944,7 +944,8 @@ int ftrace_disable_ftrace_graph_caller(void) | |||
944 | * Hook the return address and push it in the stack of return addrs | 944 | * Hook the return address and push it in the stack of return addrs |
945 | * in current thread info. Return the address we want to divert to. | 945 | * in current thread info. Return the address we want to divert to. |
946 | */ | 946 | */ |
947 | unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip) | 947 | unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip, |
948 | unsigned long sp) | ||
948 | { | 949 | { |
949 | unsigned long return_hooker; | 950 | unsigned long return_hooker; |
950 | 951 | ||
@@ -956,7 +957,7 @@ unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip) | |||
956 | 957 | ||
957 | return_hooker = ppc_function_entry(return_to_handler); | 958 | return_hooker = ppc_function_entry(return_to_handler); |
958 | 959 | ||
959 | if (!function_graph_enter(parent, ip, 0, NULL)) | 960 | if (!function_graph_enter(parent, ip, 0, (unsigned long *)sp)) |
960 | parent = return_hooker; | 961 | parent = return_hooker; |
961 | out: | 962 | out: |
962 | return parent; | 963 | return parent; |
diff --git a/arch/powerpc/kernel/trace/ftrace_32.S b/arch/powerpc/kernel/trace/ftrace_32.S index 183f608efb81..e023ae59c429 100644 --- a/arch/powerpc/kernel/trace/ftrace_32.S +++ b/arch/powerpc/kernel/trace/ftrace_32.S | |||
@@ -50,6 +50,7 @@ _GLOBAL(ftrace_stub) | |||
50 | 50 | ||
51 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | 51 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
52 | _GLOBAL(ftrace_graph_caller) | 52 | _GLOBAL(ftrace_graph_caller) |
53 | addi r5, r1, 48 | ||
53 | /* load r4 with local address */ | 54 | /* load r4 with local address */ |
54 | lwz r4, 44(r1) | 55 | lwz r4, 44(r1) |
55 | subi r4, r4, MCOUNT_INSN_SIZE | 56 | subi r4, r4, MCOUNT_INSN_SIZE |
diff --git a/arch/powerpc/kernel/trace/ftrace_64_mprofile.S b/arch/powerpc/kernel/trace/ftrace_64_mprofile.S index 74acbf16a666..f9fd5f743eba 100644 --- a/arch/powerpc/kernel/trace/ftrace_64_mprofile.S +++ b/arch/powerpc/kernel/trace/ftrace_64_mprofile.S | |||
@@ -294,6 +294,7 @@ _GLOBAL(ftrace_graph_caller) | |||
294 | std r2, 24(r1) | 294 | std r2, 24(r1) |
295 | ld r2, PACATOC(r13) /* get kernel TOC in r2 */ | 295 | ld r2, PACATOC(r13) /* get kernel TOC in r2 */ |
296 | 296 | ||
297 | addi r5, r1, 112 | ||
297 | mfctr r4 /* ftrace_caller has moved local addr here */ | 298 | mfctr r4 /* ftrace_caller has moved local addr here */ |
298 | std r4, 40(r1) | 299 | std r4, 40(r1) |
299 | mflr r3 /* ftrace_caller has restored LR from stack */ | 300 | mflr r3 /* ftrace_caller has restored LR from stack */ |
diff --git a/arch/powerpc/kernel/trace/ftrace_64_pg.S b/arch/powerpc/kernel/trace/ftrace_64_pg.S index e41a7d13c99c..6708e24db0ab 100644 --- a/arch/powerpc/kernel/trace/ftrace_64_pg.S +++ b/arch/powerpc/kernel/trace/ftrace_64_pg.S | |||
@@ -41,6 +41,7 @@ _GLOBAL(ftrace_stub) | |||
41 | 41 | ||
42 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | 42 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
43 | _GLOBAL(ftrace_graph_caller) | 43 | _GLOBAL(ftrace_graph_caller) |
44 | addi r5, r1, 112 | ||
44 | /* load r4 with local address */ | 45 | /* load r4 with local address */ |
45 | ld r4, 128(r1) | 46 | ld r4, 128(r1) |
46 | subi r4, r4, MCOUNT_INSN_SIZE | 47 | subi r4, r4, MCOUNT_INSN_SIZE |