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>
This commit is contained in:
Martin Schwidefsky 2019-02-18 16:51:28 +01:00
parent 78c98f9074
commit ec7bf4789d
5 changed files with 11 additions and 8 deletions

View file

@ -11,6 +11,8 @@
#define MCOUNT_RETURN_FIXUP 18 #define MCOUNT_RETURN_FIXUP 18
#endif #endif
#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#ifdef CONFIG_CC_IS_CLANG #ifdef CONFIG_CC_IS_CLANG

View file

@ -65,7 +65,7 @@ int setup_profiling_timer(unsigned int multiplier);
void __init time_init(void); void __init time_init(void);
int pfn_is_nosave(unsigned long); int pfn_is_nosave(unsigned long);
void s390_early_resume(void); void s390_early_resume(void);
unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip); unsigned long prepare_ftrace_return(unsigned long parent, unsigned long sp, unsigned long ip);
struct s390_mmap_arg_struct; struct s390_mmap_arg_struct;
struct fadvise64_64_args; struct fadvise64_64_args;

View file

@ -201,17 +201,18 @@ device_initcall(ftrace_plt_init);
* Hook the return address and push it in the stack of return addresses * Hook the return address and push it in the stack of return addresses
* in current thread info. * in current thread info.
*/ */
unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip) unsigned long prepare_ftrace_return(unsigned long ra, unsigned long sp,
unsigned long ip)
{ {
if (unlikely(ftrace_graph_is_dead())) if (unlikely(ftrace_graph_is_dead()))
goto out; goto out;
if (unlikely(atomic_read(&current->tracing_graph_pause))) if (unlikely(atomic_read(&current->tracing_graph_pause)))
goto out; goto out;
ip -= MCOUNT_INSN_SIZE; ip -= MCOUNT_INSN_SIZE;
if (!function_graph_enter(parent, ip, 0, NULL)) if (!function_graph_enter(ra, ip, 0, (void *) sp))
parent = (unsigned long) return_to_handler; ra = (unsigned long) return_to_handler;
out: out:
return parent; return ra;
} }
NOKPROBE_SYMBOL(prepare_ftrace_return); NOKPROBE_SYMBOL(prepare_ftrace_return);

View file

@ -65,8 +65,8 @@ ENTRY(ftrace_caller)
.globl ftrace_graph_caller .globl ftrace_graph_caller
ftrace_graph_caller: ftrace_graph_caller:
j ftrace_graph_caller_end j ftrace_graph_caller_end
lg %r2,(STACK_PTREGS_GPRS+14*8)(%r15) lmg %r2,%r3,(STACK_PTREGS_GPRS+14*8)(%r15)
lg %r3,(STACK_PTREGS_PSW+8)(%r15) lg %r4,(STACK_PTREGS_PSW+8)(%r15)
brasl %r14,prepare_ftrace_return brasl %r14,prepare_ftrace_return
stg %r2,(STACK_PTREGS_GPRS+14*8)(%r15) stg %r2,(STACK_PTREGS_GPRS+14*8)(%r15)
ftrace_graph_caller_end: ftrace_graph_caller_end:

View file

@ -84,7 +84,7 @@ bool unwind_next_frame(struct unwind_state *state)
/* Decode any ftrace redirection */ /* Decode any ftrace redirection */
if (ip == (unsigned long) return_to_handler) if (ip == (unsigned long) return_to_handler)
ip = ftrace_graph_ret_addr(state->task, &state->graph_idx, ip = ftrace_graph_ret_addr(state->task, &state->graph_idx,
ip, NULL); ip, (void *) sp);
#endif #endif
/* Update unwind state */ /* Update unwind state */