Skip to content

Commit ec7bf47

Browse files
author
Martin Schwidefsky
committed
s390/ftrace: use HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
Make the call chain more reliable by tagging the ftrace stack entries with the stack pointer that is associated with the return address. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
1 parent 78c98f9 commit ec7bf47

5 files changed

Lines changed: 11 additions & 8 deletions

File tree

‎arch/s390/include/asm/ftrace.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#define MCOUNT_RETURN_FIXUP 18
1212
#endif
1313

14+
#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
15+
1416
#ifndef __ASSEMBLY__
1517

1618
#ifdef CONFIG_CC_IS_CLANG

‎arch/s390/kernel/entry.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ int setup_profiling_timer(unsigned int multiplier);
6565
void __init time_init(void);
6666
int pfn_is_nosave(unsigned long);
6767
void s390_early_resume(void);
68-
unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip);
68+
unsigned long prepare_ftrace_return(unsigned long parent, unsigned long sp, unsigned long ip);
6969

7070
struct s390_mmap_arg_struct;
7171
struct fadvise64_64_args;

‎arch/s390/kernel/ftrace.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,17 +201,18 @@ device_initcall(ftrace_plt_init);
201201
* Hook the return address and push it in the stack of return addresses
202202
* in current thread info.
203203
*/
204-
unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip)
204+
unsigned long prepare_ftrace_return(unsigned long ra, unsigned long sp,
205+
unsigned long ip)
205206
{
206207
if (unlikely(ftrace_graph_is_dead()))
207208
goto out;
208209
if (unlikely(atomic_read(&current->tracing_graph_pause)))
209210
goto out;
210211
ip -= MCOUNT_INSN_SIZE;
211-
if (!function_graph_enter(parent, ip, 0, NULL))
212-
parent = (unsigned long) return_to_handler;
212+
if (!function_graph_enter(ra, ip, 0, (void *) sp))
213+
ra = (unsigned long) return_to_handler;
213214
out:
214-
return parent;
215+
return ra;
215216
}
216217
NOKPROBE_SYMBOL(prepare_ftrace_return);
217218

‎arch/s390/kernel/mcount.S‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ ENTRY(ftrace_caller)
6565
.globl ftrace_graph_caller
6666
ftrace_graph_caller:
6767
j ftrace_graph_caller_end
68-
lg %r2,(STACK_PTREGS_GPRS+14*8)(%r15)
69-
lg %r3,(STACK_PTREGS_PSW+8)(%r15)
68+
lmg %r2,%r3,(STACK_PTREGS_GPRS+14*8)(%r15)
69+
lg %r4,(STACK_PTREGS_PSW+8)(%r15)
7070
brasl %r14,prepare_ftrace_return
7171
stg %r2,(STACK_PTREGS_GPRS+14*8)(%r15)
7272
ftrace_graph_caller_end:

‎arch/s390/kernel/unwind_bc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ bool unwind_next_frame(struct unwind_state *state)
8484
/* Decode any ftrace redirection */
8585
if (ip == (unsigned long) return_to_handler)
8686
ip = ftrace_graph_ret_addr(state->task, &state->graph_idx,
87-
ip, NULL);
87+
ip, (void *) sp);
8888
#endif
8989

9090
/* Update unwind state */

0 commit comments

Comments
 (0)