• Josh Poimboeuf's avatar
    ftrace: Add ftrace_graph_ret_addr() stack unwinding helpers · 223918e3
    Josh Poimboeuf authored
    When function graph tracing is enabled for a function, ftrace modifies
    the stack by replacing the original return address with the address of a
    hook function (return_to_handler).
    
    Stack unwinders need a way to get the original return address.  Add an
    arch-independent helper function for that named ftrace_graph_ret_addr().
    
    This adds two variations of the function: one depends on
    HAVE_FUNCTION_GRAPH_RET_ADDR_PTR, and the other relies on an index state
    variable.
    
    The former is recommended because, in some cases, the latter can cause
    problems when the unwinder skips stack frames.  It can get out of sync
    with the ret_stack index and wrong addresses can be reported for the
    stack trace.
    
    Once all arches have been ported to use
    HAVE_FUNCTION_GRAPH_RET_ADDR_PTR, we can get rid of the distinction.
    Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
    Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
    Cc: Andy Lutomirski <luto@amacapital.net>
    Cc: Andy Lutomirski <luto@kernel.org>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: Brian Gerst <brgerst@gmail.com>
    Cc: Byungchul Park <byungchul.park@lge.com>
    Cc: Denys Vlasenko <dvlasenk@redhat.com>
    Cc: Frederic Weisbecker <fweisbec@gmail.com>
    Cc: H. Peter Anvin <hpa@zytor.com>
    Cc: Kees Cook <keescook@chromium.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Nilay Vaish <nilayvaish@gmail.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Link: http://lkml.kernel.org/r/36bd90f762fc5e5af3929e3797a68a64906421cf.1471607358.git.jpoimboe@redhat.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
    223918e3
trace_functions_graph.c 37.9 KB