Commit f7edb451 authored by Steven Rostedt (VMware)'s avatar Steven Rostedt (VMware)
Browse files

tracing/arm64: Have max stack tracer handle the case of return address after data

Most archs (well at least x86) store the function call return address on the
stack before storing the local variables for the function. The max stack
tracer depends on this in its algorithm to display the stack size of each
function it finds in the back trace.

Some archs (arm64), may store the return address (from its link register)
just before calling a nested function. There's no reason to save the link
register on leaf functions, as it wont be updated. This breaks the algorithm
of the max stack tracer.

Add a new define ARCH_FTRACE_SHIFT_STACK_TRACER that an architecture may set
if it stores the return address (link register) after it stores the
function's local variables, and have the stack trace shift the values of the
mapped stack size to the appropriate functions.

Reported-by: default avatarJiping Ma <>
Acked-by: default avatarWill Deacon <>
Signed-off-by: default avatarSteven Rostedt (VMware) <>
parent 4fbcf074
......@@ -14,6 +14,19 @@
#define MCOUNT_ADDR ((unsigned long)_mcount)
* Currently, gcc tends to save the link register after the local variables
* on the stack. This causes the max stack tracer to report the function
* frame sizes for the wrong functions. By defining
* ARCH_FTRACE_SHIFT_STACK_TRACER, it will tell the stack tracer to expect
* to find the return address on the stack after the local variables have
* been set up.
* Note, this may change in the future, and we will need to deal with that
* if it were to happen.
#ifndef __ASSEMBLY__
#include <linux/compat.h>
......@@ -158,6 +158,20 @@ static void check_stack(unsigned long ip, unsigned long *stack)
* Some archs will store the link register before calling
* nested functions. This means the saved return address
* comes after the local storage, and we need to shift
* for that.
if (x > 1) {
memmove(&stack_trace_index[0], &stack_trace_index[1],
sizeof(stack_trace_index[0]) * (x - 1));
stack_trace_nr_entries = x;
if (task_stack_end_corrupted(current)) {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment