@@ -290,8 +290,7 @@ static inline unsigned long make_data_type_val(int idx, int size, int offset)
290290}
291291
292292/* ftrace_graph_entry set to this to tell some archs to run function graph */
293- static int entry_run (struct ftrace_graph_ent * trace , struct fgraph_ops * ops ,
294- struct fgraph_extras * extras )
293+ static int entry_run (struct ftrace_graph_ent * trace , struct fgraph_ops * ops )
295294{
296295 return 0 ;
297296}
@@ -519,8 +518,7 @@ int __weak ftrace_disable_ftrace_graph_caller(void)
519518#endif
520519
521520int ftrace_graph_entry_stub (struct ftrace_graph_ent * trace ,
522- struct fgraph_ops * gops ,
523- struct fgraph_extras * extras )
521+ struct fgraph_ops * gops )
524522{
525523 return 0 ;
526524}
@@ -648,20 +646,13 @@ int function_graph_enter(unsigned long ret, unsigned long func,
648646 unsigned long frame_pointer , unsigned long * retp )
649647{
650648 struct ftrace_graph_ent trace ;
651- struct fgraph_extras extras ;
652649 unsigned long bitmap = 0 ;
653650 int offset ;
654651 int i ;
655- int idx = 0 ;
656652
657653 trace .func = func ;
658654 trace .depth = ++ current -> curr_ret_depth ;
659655
660- extras .flags = graph_tracer_flags_get (TRACE_GRAPH_PRINT_RETADDR );
661- if (IS_ENABLED (CONFIG_FUNCTION_GRAPH_RETADDR )
662- && extras .flags & TRACE_GRAPH_PRINT_RETADDR )
663- extras .retaddr = ftrace_graph_ret_addr (current , & idx , ret , retp );
664-
665656 offset = ftrace_push_return_trace (ret , func , frame_pointer , retp , 0 );
666657 if (offset < 0 )
667658 goto out ;
@@ -670,7 +661,7 @@ int function_graph_enter(unsigned long ret, unsigned long func,
670661 if (static_branch_likely (& fgraph_do_direct )) {
671662 int save_curr_ret_stack = current -> curr_ret_stack ;
672663
673- if (static_call (fgraph_func )(& trace , fgraph_direct_gops , & extras ))
664+ if (static_call (fgraph_func )(& trace , fgraph_direct_gops ))
674665 bitmap |= BIT (fgraph_direct_gops -> idx );
675666 else
676667 /* Clear out any saved storage */
@@ -688,7 +679,7 @@ int function_graph_enter(unsigned long ret, unsigned long func,
688679
689680 save_curr_ret_stack = current -> curr_ret_stack ;
690681 if (ftrace_ops_test (& gops -> ops , func , NULL ) &&
691- gops -> entryfunc (& trace , gops , & extras ))
682+ gops -> entryfunc (& trace , gops ))
692683 bitmap |= BIT (i );
693684 else
694685 /* Clear out any saved storage */
@@ -905,6 +896,29 @@ ftrace_graph_get_ret_stack(struct task_struct *task, int idx)
905896 return ret_stack ;
906897}
907898
899+ /**
900+ * ftrace_graph_top_ret_addr - return the top return address in the shadow stack
901+ * @task: The task to read the shadow stack from.
902+ *
903+ * Return the first return address on the shadow stack of the @task, which is
904+ * not the fgraph's return_to_handler.
905+ */
906+ unsigned long ftrace_graph_top_ret_addr (struct task_struct * task )
907+ {
908+ unsigned long return_handler = (unsigned long )dereference_kernel_function_descriptor (return_to_handler );
909+ struct ftrace_ret_stack * ret_stack = NULL ;
910+ int offset = task -> curr_ret_stack ;
911+
912+ if (offset < 0 )
913+ return 0 ;
914+
915+ do {
916+ ret_stack = get_ret_stack (task , offset , & offset );
917+ } while (ret_stack && ret_stack -> ret == return_handler );
918+
919+ return ret_stack ? ret_stack -> ret : 0 ;
920+ }
921+
908922/**
909923 * ftrace_graph_ret_addr - return the original value of the return address
910924 * @task: The task the unwinder is being executed on
@@ -1145,8 +1159,7 @@ void ftrace_graph_exit_task(struct task_struct *t)
11451159
11461160#ifdef CONFIG_DYNAMIC_FTRACE
11471161static int fgraph_pid_func (struct ftrace_graph_ent * trace ,
1148- struct fgraph_ops * gops ,
1149- struct fgraph_extras * extras )
1162+ struct fgraph_ops * gops )
11501163{
11511164 struct trace_array * tr = gops -> ops .private ;
11521165 int pid ;
@@ -1160,7 +1173,7 @@ static int fgraph_pid_func(struct ftrace_graph_ent *trace,
11601173 return 0 ;
11611174 }
11621175
1163- return gops -> saved_func (trace , gops , NULL );
1176+ return gops -> saved_func (trace , gops );
11641177}
11651178
11661179void fgraph_update_pid_func (void )
0 commit comments