Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+11 -8
+2
arch/s390/include/asm/ftrace.h
··· 11 11 #define MCOUNT_RETURN_FIXUP 18 12 12 #endif 13 13 14 + #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR 15 + 14 16 #ifndef __ASSEMBLY__ 15 17 16 18 #ifdef CONFIG_CC_IS_CLANG
+1 -1
arch/s390/kernel/entry.h
··· 65 65 void __init time_init(void); 66 66 int pfn_is_nosave(unsigned long); 67 67 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); 69 69 70 70 struct s390_mmap_arg_struct; 71 71 struct fadvise64_64_args;
+5 -4
arch/s390/kernel/ftrace.c
··· 201 201 * Hook the return address and push it in the stack of return addresses 202 202 * in current thread info. 203 203 */ 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) 205 206 { 206 207 if (unlikely(ftrace_graph_is_dead())) 207 208 goto out; 208 209 if (unlikely(atomic_read(&current->tracing_graph_pause))) 209 210 goto out; 210 211 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; 213 214 out: 214 - return parent; 215 + return ra; 215 216 } 216 217 NOKPROBE_SYMBOL(prepare_ftrace_return); 217 218
+2 -2
arch/s390/kernel/mcount.S
··· 65 65 .globl ftrace_graph_caller 66 66 ftrace_graph_caller: 67 67 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) 70 70 brasl %r14,prepare_ftrace_return 71 71 stg %r2,(STACK_PTREGS_GPRS+14*8)(%r15) 72 72 ftrace_graph_caller_end:
+1 -1
arch/s390/kernel/unwind_bc.c
··· 84 84 /* Decode any ftrace redirection */ 85 85 if (ip == (unsigned long) return_to_handler) 86 86 ip = ftrace_graph_ret_addr(state->task, &state->graph_idx, 87 - ip, NULL); 87 + ip, (void *) sp); 88 88 #endif 89 89 90 90 /* Update unwind state */