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

MIPS: function_graph: Simplify with function_graph_enter()

The function_graph_enter() function does the work of calling the function
graph hook function and the management of the shadow stack, simplifying the
work done in the architecture dependent prepare_ftrace_return().

Have MIPS use the new code, and remove the shadow stack management as well as
having to set up the trace structure.

This is needed to prepare for a fix of a design bug on how the curr_ret_stack
is used.

Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Burton <paul.burton@mips.com>
Cc: James Hogan <jhogan@kernel.org>
Cc: linux-mips@linux-mips.org
Cc: stable@kernel.org
Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

+2 -12
+2 -12
arch/mips/kernel/ftrace.c
··· 322 322 unsigned long fp) 323 323 { 324 324 unsigned long old_parent_ra; 325 - struct ftrace_graph_ent trace; 326 325 unsigned long return_hooker = (unsigned long) 327 326 &return_to_handler; 328 327 int faulted, insns; ··· 368 369 if (unlikely(faulted)) 369 370 goto out; 370 371 371 - if (ftrace_push_return_trace(old_parent_ra, self_ra, &trace.depth, fp, 372 - NULL) == -EBUSY) { 373 - *parent_ra_addr = old_parent_ra; 374 - return; 375 - } 376 - 377 372 /* 378 373 * Get the recorded ip of the current mcount calling site in the 379 374 * __mcount_loc section, which will be used to filter the function ··· 375 382 */ 376 383 377 384 insns = core_kernel_text(self_ra) ? 2 : MCOUNT_OFFSET_INSNS + 1; 378 - trace.func = self_ra - (MCOUNT_INSN_SIZE * insns); 385 + self_ra -= (MCOUNT_INSN_SIZE * insns); 379 386 380 - /* Only trace if the calling function expects to */ 381 - if (!ftrace_graph_entry(&trace)) { 382 - current->curr_ret_stack--; 387 + if (function_graph_enter(old_parent_ra, self_ra, fp, NULL)) 383 388 *parent_ra_addr = old_parent_ra; 384 - } 385 389 return; 386 390 out: 387 391 ftrace_graph_stop();