--- /dev/null
+From f1f5b14afd7cce39e6a9b25c685e1ea34c231096 Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:19:26 -0500
+Subject: ARM: function_graph: Simplify with function_graph_enter()
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit f1f5b14afd7cce39e6a9b25c685e1ea34c231096 upstream.
+
+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 ARM 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: Russell King <linux@armlinux.org.uk>
+Cc: linux-arm-kernel@lists.infradead.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>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/kernel/ftrace.c | 17 +----------------
+ 1 file changed, 1 insertion(+), 16 deletions(-)
+
+--- a/arch/arm/kernel/ftrace.c
++++ b/arch/arm/kernel/ftrace.c
+@@ -227,9 +227,7 @@ void prepare_ftrace_return(unsigned long
+ unsigned long frame_pointer)
+ {
+ unsigned long return_hooker = (unsigned long) &return_to_handler;
+- struct ftrace_graph_ent trace;
+ unsigned long old;
+- int err;
+
+ if (unlikely(atomic_read(¤t->tracing_graph_pause)))
+ return;
+@@ -237,21 +235,8 @@ void prepare_ftrace_return(unsigned long
+ old = *parent;
+ *parent = return_hooker;
+
+- trace.func = self_addr;
+- trace.depth = current->curr_ret_stack + 1;
+-
+- /* Only trace if the calling function expects to */
+- if (!ftrace_graph_entry(&trace)) {
++ if (function_graph_enter(old, self_addr, frame_pointer, NULL))
+ *parent = old;
+- return;
+- }
+-
+- err = ftrace_push_return_trace(old, self_addr, &trace.depth,
+- frame_pointer, NULL);
+- if (err == -EBUSY) {
+- *parent = old;
+- return;
+- }
+ }
+
+ #ifdef CONFIG_DYNAMIC_FTRACE
--- /dev/null
+From 01e0ab2c4ff12358f15a856fd1a7bbea0670972b Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:21:51 -0500
+Subject: arm64: function_graph: Simplify with function_graph_enter()
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit 01e0ab2c4ff12358f15a856fd1a7bbea0670972b upstream.
+
+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 arm64 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: Catalin Marinas <catalin.marinas@arm.com>
+Cc: linux-arm-kernel@lists.infradead.org
+Cc: stable@kernel.org
+Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback")
+Acked-by: Will Deacon <will.deacon@arm.com>
+Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm64/kernel/ftrace.c | 15 +--------------
+ 1 file changed, 1 insertion(+), 14 deletions(-)
+
+--- a/arch/arm64/kernel/ftrace.c
++++ b/arch/arm64/kernel/ftrace.c
+@@ -216,8 +216,6 @@ void prepare_ftrace_return(unsigned long
+ {
+ unsigned long return_hooker = (unsigned long)&return_to_handler;
+ unsigned long old;
+- struct ftrace_graph_ent trace;
+- int err;
+
+ if (unlikely(atomic_read(¤t->tracing_graph_pause)))
+ return;
+@@ -229,18 +227,7 @@ void prepare_ftrace_return(unsigned long
+ */
+ old = *parent;
+
+- trace.func = self_addr;
+- trace.depth = current->curr_ret_stack + 1;
+-
+- /* Only trace if the calling function expects to */
+- if (!ftrace_graph_entry(&trace))
+- return;
+-
+- err = ftrace_push_return_trace(old, self_addr, &trace.depth,
+- frame_pointer, NULL);
+- if (err == -EBUSY)
+- return;
+- else
++ if (!function_graph_enter(old, self_addr, frame_pointer, NULL))
+ *parent = return_hooker;
+ }
+
--- /dev/null
+From ecebf55d27a11538ea84aee0be643dd953f830d5 Mon Sep 17 00:00:00 2001
+From: Pan Bian <bianpan2016@163.com>
+Date: Sun, 25 Nov 2018 08:58:02 +0800
+Subject: ext2: fix potential use after free
+
+From: Pan Bian <bianpan2016@163.com>
+
+commit ecebf55d27a11538ea84aee0be643dd953f830d5 upstream.
+
+The function ext2_xattr_set calls brelse(bh) to drop the reference count
+of bh. After that, bh may be freed. However, following brelse(bh),
+it reads bh->b_data via macro HDR(bh). This may result in a
+use-after-free bug. This patch moves brelse(bh) after reading field.
+
+CC: stable@vger.kernel.org
+Signed-off-by: Pan Bian <bianpan2016@163.com>
+Signed-off-by: Jan Kara <jack@suse.cz>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/ext2/xattr.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/fs/ext2/xattr.c
++++ b/fs/ext2/xattr.c
+@@ -612,9 +612,9 @@ skip_replace:
+ }
+
+ cleanup:
+- brelse(bh);
+ if (!(bh && header == HDR(bh)))
+ kfree(header);
++ brelse(bh);
+ up_write(&EXT2_I(inode)->xattr_sem);
+
+ return error;
--- /dev/null
+From 8114865ff82e200b383e46821c25cb0625b842b5 Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:10:15 -0500
+Subject: function_graph: Create function_graph_enter() to consolidate architecture code
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit 8114865ff82e200b383e46821c25cb0625b842b5 upstream.
+
+Currently all the architectures do basically the same thing in preparing the
+function graph tracer on entry to a function. This code can be pulled into a
+generic location and then this will allow the function graph tracer to be
+fixed, as well as extended.
+
+Create a new function graph helper function_graph_enter() that will call the
+hook function (ftrace_graph_entry) and the shadow stack operation
+(ftrace_push_return_trace), and remove the need of the architecture code to
+manage the shadow stack.
+
+This is needed to prepare for a fix of a design bug on how the curr_ret_stack
+is used.
+
+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>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ include/linux/ftrace.h | 3 +++
+ kernel/trace/trace_functions_graph.c | 16 ++++++++++++++++
+ 2 files changed, 19 insertions(+)
+
+--- a/include/linux/ftrace.h
++++ b/include/linux/ftrace.h
+@@ -824,6 +824,9 @@ extern void return_to_handler(void);
+ extern int
+ ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
+ unsigned long frame_pointer, unsigned long *retp);
++extern int
++function_graph_enter(unsigned long ret, unsigned long func,
++ unsigned long frame_pointer, unsigned long *retp);
+
+ unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx,
+ unsigned long ret, unsigned long *retp);
+--- a/kernel/trace/trace_functions_graph.c
++++ b/kernel/trace/trace_functions_graph.c
+@@ -182,6 +182,22 @@ ftrace_push_return_trace(unsigned long r
+ return 0;
+ }
+
++int function_graph_enter(unsigned long ret, unsigned long func,
++ unsigned long frame_pointer, unsigned long *retp)
++{
++ struct ftrace_graph_ent trace;
++
++ trace.func = func;
++ trace.depth = current->curr_ret_stack + 1;
++
++ /* Only trace if the calling function expects to */
++ if (!ftrace_graph_entry(&trace))
++ return -EBUSY;
++
++ return ftrace_push_return_trace(ret, func, &trace.depth,
++ frame_pointer, retp);
++}
++
+ /* Retrieve a function return address to the trace stack on thread info.*/
+ static void
+ ftrace_pop_return_trace(struct ftrace_graph_ret *trace, unsigned long *ret,
--- /dev/null
+From b1b35f2e218a5b57d03bbc3b0667d5064570dc60 Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Tue, 20 Nov 2018 12:51:07 -0500
+Subject: function_graph: Have profiler use curr_ret_stack and not depth
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit b1b35f2e218a5b57d03bbc3b0667d5064570dc60 upstream.
+
+The profiler uses trace->depth to find its entry on the ret_stack, but the
+depth may not match the actual location of where its entry is (if an
+interrupt were to preempt the processing of the profiler for another
+function, the depth and the curr_ret_stack will be different).
+
+Have it use the curr_ret_stack as the index to find its ret_stack entry
+instead of using the depth variable, as that is no longer guaranteed to be
+the same.
+
+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>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ kernel/trace/ftrace.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/kernel/trace/ftrace.c
++++ b/kernel/trace/ftrace.c
+@@ -885,7 +885,7 @@ function_profile_call(unsigned long ip,
+ #ifdef CONFIG_FUNCTION_GRAPH_TRACER
+ static int profile_graph_entry(struct ftrace_graph_ent *trace)
+ {
+- int index = trace->depth;
++ int index = current->curr_ret_stack;
+
+ function_profile_call(trace->func, 0, NULL, NULL);
+
+@@ -920,7 +920,7 @@ static void profile_graph_return(struct
+ if (!fgraph_graph_time) {
+ int index;
+
+- index = trace->depth;
++ index = current->curr_ret_stack;
+
+ /* Append this call time to the parent time to subtract */
+ if (index)
--- /dev/null
+From d125f3f866df88da5a85df00291f88f0baa89f7c Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Mon, 19 Nov 2018 07:40:39 -0500
+Subject: function_graph: Make ftrace_push_return_trace() static
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit d125f3f866df88da5a85df00291f88f0baa89f7c upstream.
+
+As all architectures now call function_graph_enter() to do the entry work,
+no architecture should ever call ftrace_push_return_trace(). Make it static.
+
+This is needed to prepare for a fix of a design bug on how the curr_ret_stack
+is used.
+
+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>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ include/linux/ftrace.h | 3 ---
+ kernel/trace/trace_functions_graph.c | 2 +-
+ 2 files changed, 1 insertion(+), 4 deletions(-)
+
+--- a/include/linux/ftrace.h
++++ b/include/linux/ftrace.h
+@@ -822,9 +822,6 @@ struct ftrace_ret_stack {
+ extern void return_to_handler(void);
+
+ extern int
+-ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
+- unsigned long frame_pointer, unsigned long *retp);
+-extern int
+ function_graph_enter(unsigned long ret, unsigned long func,
+ unsigned long frame_pointer, unsigned long *retp);
+
+--- a/kernel/trace/trace_functions_graph.c
++++ b/kernel/trace/trace_functions_graph.c
+@@ -118,7 +118,7 @@ print_graph_duration(struct trace_array
+ struct trace_seq *s, u32 flags);
+
+ /* Add a function return address to the trace stack on thread info.*/
+-int
++static int
+ ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
+ unsigned long frame_pointer, unsigned long *retp)
+ {
--- /dev/null
+From 552701dd0fa7c3d448142e87210590ba424694a0 Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Mon, 19 Nov 2018 15:18:40 -0500
+Subject: function_graph: Move return callback before update of curr_ret_stack
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit 552701dd0fa7c3d448142e87210590ba424694a0 upstream.
+
+In the past, curr_ret_stack had two functions. One was to denote the depth
+of the call graph, the other is to keep track of where on the ret_stack the
+data is used. Although they may be slightly related, there are two cases
+where they need to be used differently.
+
+The one case is that it keeps the ret_stack data from being corrupted by an
+interrupt coming in and overwriting the data still in use. The other is just
+to know where the depth of the stack currently is.
+
+The function profiler uses the ret_stack to save a "subtime" variable that
+is part of the data on the ret_stack. If curr_ret_stack is modified too
+early, then this variable can be corrupted.
+
+The "max_depth" option, when set to 1, will record the first functions going
+into the kernel. To see all top functions (when dealing with timings), the
+depth variable needs to be lowered before calling the return hook. But by
+lowering the curr_ret_stack, it makes the data on the ret_stack still being
+used by the return hook susceptible to being overwritten.
+
+Now that there's two variables to handle both cases (curr_ret_depth), we can
+move them to the locations where they can handle both cases.
+
+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>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ kernel/trace/trace_functions_graph.c | 22 +++++++++++++---------
+ 1 file changed, 13 insertions(+), 9 deletions(-)
+
+--- a/kernel/trace/trace_functions_graph.c
++++ b/kernel/trace/trace_functions_graph.c
+@@ -261,7 +261,13 @@ ftrace_pop_return_trace(struct ftrace_gr
+ trace->func = current->ret_stack[index].func;
+ trace->calltime = current->ret_stack[index].calltime;
+ trace->overrun = atomic_read(¤t->trace_overrun);
+- trace->depth = current->curr_ret_depth;
++ trace->depth = current->curr_ret_depth--;
++ /*
++ * We still want to trace interrupts coming in if
++ * max_depth is set to 1. Make sure the decrement is
++ * seen before ftrace_graph_return.
++ */
++ barrier();
+ }
+
+ /*
+@@ -275,9 +281,14 @@ unsigned long ftrace_return_to_handler(u
+
+ ftrace_pop_return_trace(&trace, &ret, frame_pointer);
+ trace.rettime = trace_clock_local();
++ ftrace_graph_return(&trace);
++ /*
++ * The ftrace_graph_return() may still access the current
++ * ret_stack structure, we need to make sure the update of
++ * curr_ret_stack is after that.
++ */
+ barrier();
+ current->curr_ret_stack--;
+- current->curr_ret_depth--;
+ /*
+ * The curr_ret_stack can be less than -1 only if it was
+ * filtered out and it's about to return from the function.
+@@ -288,13 +299,6 @@ unsigned long ftrace_return_to_handler(u
+ return ret;
+ }
+
+- /*
+- * The trace should run after decrementing the ret counter
+- * in case an interrupt were to come in. We don't want to
+- * lose the interrupt if max_depth is set.
+- */
+- ftrace_graph_return(&trace);
+-
+ if (unlikely(!ret)) {
+ ftrace_graph_stop();
+ WARN_ON(1);
--- /dev/null
+From 7c6ea35ef50810aa12ab26f21cb858d980881576 Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Tue, 20 Nov 2018 12:40:25 -0500
+Subject: function_graph: Reverse the order of pushing the ret_stack and the callback
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit 7c6ea35ef50810aa12ab26f21cb858d980881576 upstream.
+
+The function graph profiler uses the ret_stack to store the "subtime" and
+reuse it by nested functions and also on the return. But the current logic
+has the profiler callback called before the ret_stack is updated, and it is
+just modifying the ret_stack that will later be allocated (it's just lucky
+that the "subtime" is not touched when it is allocated).
+
+This could also cause a crash if we are at the end of the ret_stack when
+this happens.
+
+By reversing the order of the allocating the ret_stack and then calling the
+callbacks attached to a function being traced, the ret_stack entry is no
+longer used before it is allocated.
+
+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>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ kernel/trace/trace_functions_graph.c | 10 ++++++----
+ 1 file changed, 6 insertions(+), 4 deletions(-)
+
+--- a/kernel/trace/trace_functions_graph.c
++++ b/kernel/trace/trace_functions_graph.c
+@@ -188,15 +188,17 @@ int function_graph_enter(unsigned long r
+ trace.func = func;
+ trace.depth = ++current->curr_ret_depth;
+
+- /* Only trace if the calling function expects to */
+- if (!ftrace_graph_entry(&trace))
+- goto out;
+-
+ if (ftrace_push_return_trace(ret, func,
+ frame_pointer, retp))
+ goto out;
+
++ /* Only trace if the calling function expects to */
++ if (!ftrace_graph_entry(&trace))
++ goto out_ret;
++
+ return 0;
++ out_ret:
++ current->curr_ret_stack--;
+ out:
+ current->curr_ret_depth--;
+ return -EBUSY;
--- /dev/null
+From 39eb456dacb543de90d3bc6a8e0ac5cf51ac475e Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Mon, 19 Nov 2018 08:07:12 -0500
+Subject: function_graph: Use new curr_ret_depth to manage depth instead of curr_ret_stack
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit 39eb456dacb543de90d3bc6a8e0ac5cf51ac475e upstream.
+
+Currently, the depth of the ret_stack is determined by curr_ret_stack index.
+The issue is that there's a race between setting of the curr_ret_stack and
+calling of the callback attached to the return of the function.
+
+Commit 03274a3ffb44 ("tracing/fgraph: Adjust fgraph depth before calling
+trace return callback") moved the calling of the callback to after the
+setting of the curr_ret_stack, even stating that it was safe to do so, when
+in fact, it was the reason there was a barrier() there (yes, I should have
+commented that barrier()).
+
+Not only does the curr_ret_stack keep track of the current call graph depth,
+it also keeps the ret_stack content from being overwritten by new data.
+
+The function profiler, uses the "subtime" variable of ret_stack structure
+and by moving the curr_ret_stack, it allows for interrupts to use the same
+structure it was using, corrupting the data, and breaking the profiler.
+
+To fix this, there needs to be two variables to handle the call stack depth
+and the pointer to where the ret_stack is being used, as they need to change
+at two different locations.
+
+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>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ include/linux/sched.h | 1 +
+ kernel/trace/ftrace.c | 3 +++
+ kernel/trace/trace_functions_graph.c | 21 +++++++++++++--------
+ 3 files changed, 17 insertions(+), 8 deletions(-)
+
+--- a/include/linux/sched.h
++++ b/include/linux/sched.h
+@@ -1061,6 +1061,7 @@ struct task_struct {
+ #ifdef CONFIG_FUNCTION_GRAPH_TRACER
+ /* Index of current stored address in ret_stack: */
+ int curr_ret_stack;
++ int curr_ret_depth;
+
+ /* Stack of return addresses for return function tracing: */
+ struct ftrace_ret_stack *ret_stack;
+--- a/kernel/trace/ftrace.c
++++ b/kernel/trace/ftrace.c
+@@ -6604,6 +6604,7 @@ static int alloc_retstack_tasklist(struc
+ atomic_set(&t->tracing_graph_pause, 0);
+ atomic_set(&t->trace_overrun, 0);
+ t->curr_ret_stack = -1;
++ t->curr_ret_depth = -1;
+ /* Make sure the tasks see the -1 first: */
+ smp_wmb();
+ t->ret_stack = ret_stack_list[start++];
+@@ -6828,6 +6829,7 @@ graph_init_task(struct task_struct *t, s
+ void ftrace_graph_init_idle_task(struct task_struct *t, int cpu)
+ {
+ t->curr_ret_stack = -1;
++ t->curr_ret_depth = -1;
+ /*
+ * The idle task has no parent, it either has its own
+ * stack or no stack at all.
+@@ -6857,6 +6859,7 @@ void ftrace_graph_init_task(struct task_
+ /* Make sure we do not use the parent ret_stack */
+ t->ret_stack = NULL;
+ t->curr_ret_stack = -1;
++ t->curr_ret_depth = -1;
+
+ if (ftrace_graph_active) {
+ struct ftrace_ret_stack *ret_stack;
+--- a/kernel/trace/trace_functions_graph.c
++++ b/kernel/trace/trace_functions_graph.c
+@@ -119,7 +119,7 @@ print_graph_duration(struct trace_array
+
+ /* Add a function return address to the trace stack on thread info.*/
+ static int
+-ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
++ftrace_push_return_trace(unsigned long ret, unsigned long func,
+ unsigned long frame_pointer, unsigned long *retp)
+ {
+ unsigned long long calltime;
+@@ -177,8 +177,6 @@ ftrace_push_return_trace(unsigned long r
+ #ifdef HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
+ current->ret_stack[index].retp = retp;
+ #endif
+- *depth = current->curr_ret_stack;
+-
+ return 0;
+ }
+
+@@ -188,14 +186,20 @@ int function_graph_enter(unsigned long r
+ struct ftrace_graph_ent trace;
+
+ trace.func = func;
+- trace.depth = current->curr_ret_stack + 1;
++ trace.depth = ++current->curr_ret_depth;
+
+ /* Only trace if the calling function expects to */
+ if (!ftrace_graph_entry(&trace))
+- return -EBUSY;
++ goto out;
+
+- return ftrace_push_return_trace(ret, func, &trace.depth,
+- frame_pointer, retp);
++ if (ftrace_push_return_trace(ret, func,
++ frame_pointer, retp))
++ goto out;
++
++ return 0;
++ out:
++ current->curr_ret_depth--;
++ return -EBUSY;
+ }
+
+ /* Retrieve a function return address to the trace stack on thread info.*/
+@@ -257,7 +261,7 @@ ftrace_pop_return_trace(struct ftrace_gr
+ trace->func = current->ret_stack[index].func;
+ trace->calltime = current->ret_stack[index].calltime;
+ trace->overrun = atomic_read(¤t->trace_overrun);
+- trace->depth = index;
++ trace->depth = current->curr_ret_depth;
+ }
+
+ /*
+@@ -273,6 +277,7 @@ unsigned long ftrace_return_to_handler(u
+ trace.rettime = trace_clock_local();
+ barrier();
+ current->curr_ret_stack--;
++ current->curr_ret_depth--;
+ /*
+ * The curr_ret_stack can be less than -1 only if it was
+ * filtered out and it's about to return from the function.
--- /dev/null
+From 556763e5a500d71879d632867b75826551acd49c Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:23:30 -0500
+Subject: microblaze: function_graph: Simplify with function_graph_enter()
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit 556763e5a500d71879d632867b75826551acd49c upstream.
+
+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 microblaze 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: Michal Simek <monstr@monstr.eu>
+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>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/microblaze/kernel/ftrace.c | 15 ++-------------
+ 1 file changed, 2 insertions(+), 13 deletions(-)
+
+--- a/arch/microblaze/kernel/ftrace.c
++++ b/arch/microblaze/kernel/ftrace.c
+@@ -22,8 +22,7 @@
+ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
+ {
+ unsigned long old;
+- int faulted, err;
+- struct ftrace_graph_ent trace;
++ int faulted;
+ unsigned long return_hooker = (unsigned long)
+ &return_to_handler;
+
+@@ -63,18 +62,8 @@ void prepare_ftrace_return(unsigned long
+ return;
+ }
+
+- err = ftrace_push_return_trace(old, self_addr, &trace.depth, 0, NULL);
+- if (err == -EBUSY) {
++ if (function_graph_enter(old, self_addr, 0, NULL))
+ *parent = old;
+- return;
+- }
+-
+- trace.func = self_addr;
+- /* Only trace if the calling function expects to */
+- if (!ftrace_graph_entry(&trace)) {
+- current->curr_ret_stack--;
+- *parent = old;
+- }
+ }
+ #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
+
--- /dev/null
+From 8712b27c5723c26400a2b350faf1d6d9fd7ffaad Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:25:18 -0500
+Subject: MIPS: function_graph: Simplify with function_graph_enter()
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit 8712b27c5723c26400a2b350faf1d6d9fd7ffaad upstream.
+
+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>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/mips/kernel/ftrace.c | 14 ++------------
+ 1 file changed, 2 insertions(+), 12 deletions(-)
+
+--- a/arch/mips/kernel/ftrace.c
++++ b/arch/mips/kernel/ftrace.c
+@@ -322,7 +322,6 @@ void prepare_ftrace_return(unsigned long
+ unsigned long fp)
+ {
+ unsigned long old_parent_ra;
+- struct ftrace_graph_ent trace;
+ unsigned long return_hooker = (unsigned long)
+ &return_to_handler;
+ int faulted, insns;
+@@ -369,12 +368,6 @@ void prepare_ftrace_return(unsigned long
+ if (unlikely(faulted))
+ goto out;
+
+- if (ftrace_push_return_trace(old_parent_ra, self_ra, &trace.depth, fp,
+- NULL) == -EBUSY) {
+- *parent_ra_addr = old_parent_ra;
+- return;
+- }
+-
+ /*
+ * Get the recorded ip of the current mcount calling site in the
+ * __mcount_loc section, which will be used to filter the function
+@@ -382,13 +375,10 @@ void prepare_ftrace_return(unsigned long
+ */
+
+ insns = core_kernel_text(self_ra) ? 2 : MCOUNT_OFFSET_INSNS + 1;
+- trace.func = self_ra - (MCOUNT_INSN_SIZE * insns);
++ self_ra -= (MCOUNT_INSN_SIZE * insns);
+
+- /* Only trace if the calling function expects to */
+- if (!ftrace_graph_entry(&trace)) {
+- current->curr_ret_stack--;
++ if (function_graph_enter(old_parent_ra, self_ra, fp, NULL))
+ *parent_ra_addr = old_parent_ra;
+- }
+ return;
+ out:
+ ftrace_graph_stop();
--- /dev/null
+From a87532c78d291265efadc4b20a8c7a70cd59ea29 Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:27:43 -0500
+Subject: parisc: function_graph: Simplify with function_graph_enter()
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit a87532c78d291265efadc4b20a8c7a70cd59ea29 upstream.
+
+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 parisc 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: "James E.J. Bottomley" <jejb@parisc-linux.org>
+Cc: Helge Deller <deller@gmx.de>
+Cc: linux-parisc@vger.kernel.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>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/parisc/kernel/ftrace.c | 17 +++--------------
+ 1 file changed, 3 insertions(+), 14 deletions(-)
+
+--- a/arch/parisc/kernel/ftrace.c
++++ b/arch/parisc/kernel/ftrace.c
+@@ -30,7 +30,6 @@ static void __hot prepare_ftrace_return(
+ unsigned long self_addr)
+ {
+ unsigned long old;
+- struct ftrace_graph_ent trace;
+ extern int parisc_return_to_handler;
+
+ if (unlikely(ftrace_graph_is_dead()))
+@@ -41,19 +40,9 @@ static void __hot prepare_ftrace_return(
+
+ old = *parent;
+
+- trace.func = self_addr;
+- trace.depth = current->curr_ret_stack + 1;
+-
+- /* Only trace if the calling function expects to */
+- if (!ftrace_graph_entry(&trace))
+- return;
+-
+- if (ftrace_push_return_trace(old, self_addr, &trace.depth,
+- 0, NULL) == -EBUSY)
+- return;
+-
+- /* activate parisc_return_to_handler() as return point */
+- *parent = (unsigned long) &parisc_return_to_handler;
++ if (!function_graph_enter(old, self_addr, 0, NULL))
++ /* activate parisc_return_to_handler() as return point */
++ *parent = (unsigned long) &parisc_return_to_handler;
+ }
+ #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
+
--- /dev/null
+From fe60522ec60082a1dd735691b82c64f65d4ad15e Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:28:53 -0500
+Subject: powerpc/function_graph: Simplify with function_graph_enter()
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit fe60522ec60082a1dd735691b82c64f65d4ad15e upstream.
+
+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 powerpc 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: Benjamin Herrenschmidt <benh@kernel.crashing.org>
+Cc: Paul Mackerras <paulus@samba.org>
+Cc: Michael Ellerman <mpe@ellerman.id.au>
+Cc: linuxppc-dev@lists.ozlabs.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>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/powerpc/kernel/trace/ftrace.c | 15 ++-------------
+ 1 file changed, 2 insertions(+), 13 deletions(-)
+
+--- a/arch/powerpc/kernel/trace/ftrace.c
++++ b/arch/powerpc/kernel/trace/ftrace.c
+@@ -575,7 +575,6 @@ int ftrace_disable_ftrace_graph_caller(v
+ */
+ unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip)
+ {
+- struct ftrace_graph_ent trace;
+ unsigned long return_hooker;
+
+ if (unlikely(ftrace_graph_is_dead()))
+@@ -586,18 +585,8 @@ unsigned long prepare_ftrace_return(unsi
+
+ return_hooker = ppc_function_entry(return_to_handler);
+
+- trace.func = ip;
+- trace.depth = current->curr_ret_stack + 1;
+-
+- /* Only trace if the calling function expects to */
+- if (!ftrace_graph_entry(&trace))
+- goto out;
+-
+- if (ftrace_push_return_trace(parent, ip, &trace.depth, 0,
+- NULL) == -EBUSY)
+- goto out;
+-
+- parent = return_hooker;
++ if (!function_graph_enter(parent, ip, 0, NULL))
++ parent = return_hooker;
+ out:
+ return parent;
+ }
--- /dev/null
+From 18588e1487b19e45bd90bd55ec8d3a1d44f3257f Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:33:17 -0500
+Subject: s390/function_graph: Simplify with function_graph_enter()
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit 18588e1487b19e45bd90bd55ec8d3a1d44f3257f upstream.
+
+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 s390 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.
+
+Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
+Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
+Cc: Julian Wiedmann <jwi@linux.ibm.com>
+Cc: linux-s390@vger.kernel.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>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/s390/kernel/ftrace.c | 13 ++-----------
+ 1 file changed, 2 insertions(+), 11 deletions(-)
+
+--- a/arch/s390/kernel/ftrace.c
++++ b/arch/s390/kernel/ftrace.c
+@@ -203,22 +203,13 @@ device_initcall(ftrace_plt_init);
+ */
+ unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip)
+ {
+- struct ftrace_graph_ent trace;
+-
+ if (unlikely(ftrace_graph_is_dead()))
+ goto out;
+ if (unlikely(atomic_read(¤t->tracing_graph_pause)))
+ goto out;
+ ip -= MCOUNT_INSN_SIZE;
+- trace.func = ip;
+- trace.depth = current->curr_ret_stack + 1;
+- /* Only trace if the calling function expects to. */
+- if (!ftrace_graph_entry(&trace))
+- goto out;
+- if (ftrace_push_return_trace(parent, ip, &trace.depth, 0,
+- NULL) == -EBUSY)
+- goto out;
+- parent = (unsigned long) return_to_handler;
++ if (!function_graph_enter(parent, ip, 0, NULL))
++ parent = (unsigned long) return_to_handler;
+ out:
+ return parent;
+ }
alsa-sparc-fix-invalid-snd_free_pages-at-error-path.patch
alsa-hda-realtek-support-alc300.patch
alsa-hda-realtek-fix-headset-mic-detection-for-msi-ms-b171.patch
+function_graph-create-function_graph_enter-to-consolidate-architecture-code.patch
+arm-function_graph-simplify-with-function_graph_enter.patch
+microblaze-function_graph-simplify-with-function_graph_enter.patch
+x86-function_graph-simplify-with-function_graph_enter.patch
+powerpc-function_graph-simplify-with-function_graph_enter.patch
+sh-function_graph-simplify-with-function_graph_enter.patch
+sparc-function_graph-simplify-with-function_graph_enter.patch
+parisc-function_graph-simplify-with-function_graph_enter.patch
+s390-function_graph-simplify-with-function_graph_enter.patch
+arm64-function_graph-simplify-with-function_graph_enter.patch
+mips-function_graph-simplify-with-function_graph_enter.patch
+function_graph-make-ftrace_push_return_trace-static.patch
+function_graph-use-new-curr_ret_depth-to-manage-depth-instead-of-curr_ret_stack.patch
+function_graph-have-profiler-use-curr_ret_stack-and-not-depth.patch
+function_graph-move-return-callback-before-update-of-curr_ret_stack.patch
+function_graph-reverse-the-order-of-pushing-the-ret_stack-and-the-callback.patch
+ext2-fix-potential-use-after-free.patch
--- /dev/null
+From bc715ee4dbc5db462c59b9cfba92d31b3274fe3a Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:35:37 -0500
+Subject: sh/function_graph: Simplify with function_graph_enter()
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit bc715ee4dbc5db462c59b9cfba92d31b3274fe3a upstream.
+
+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 superh 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: Yoshinori Sato <ysato@users.sourceforge.jp>
+Cc: Rich Felker <dalias@libc.org>
+Cc: linux-sh@vger.kernel.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>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/sh/kernel/ftrace.c | 16 ++--------------
+ 1 file changed, 2 insertions(+), 14 deletions(-)
+
+--- a/arch/sh/kernel/ftrace.c
++++ b/arch/sh/kernel/ftrace.c
+@@ -321,8 +321,7 @@ int ftrace_disable_ftrace_graph_caller(v
+ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
+ {
+ unsigned long old;
+- int faulted, err;
+- struct ftrace_graph_ent trace;
++ int faulted;
+ unsigned long return_hooker = (unsigned long)&return_to_handler;
+
+ if (unlikely(ftrace_graph_is_dead()))
+@@ -365,18 +364,7 @@ void prepare_ftrace_return(unsigned long
+ return;
+ }
+
+- err = ftrace_push_return_trace(old, self_addr, &trace.depth, 0, NULL);
+- if (err == -EBUSY) {
++ if (function_graph_enter(old, self_addr, 0, NULL))
+ __raw_writel(old, parent);
+- return;
+- }
+-
+- trace.func = self_addr;
+-
+- /* Only trace if the calling function expects to */
+- if (!ftrace_graph_entry(&trace)) {
+- current->curr_ret_stack--;
+- __raw_writel(old, parent);
+- }
+ }
+ #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
--- /dev/null
+From 9c4bf5e0db164f330a2d3e128e9832661f69f0e9 Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:37:40 -0500
+Subject: sparc/function_graph: Simplify with function_graph_enter()
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit 9c4bf5e0db164f330a2d3e128e9832661f69f0e9 upstream.
+
+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 sparc 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: "David S. Miller" <davem@davemloft.net>
+Cc: sparclinux@vger.kernel.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>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/sparc/kernel/ftrace.c | 11 +----------
+ 1 file changed, 1 insertion(+), 10 deletions(-)
+
+--- a/arch/sparc/kernel/ftrace.c
++++ b/arch/sparc/kernel/ftrace.c
+@@ -126,20 +126,11 @@ unsigned long prepare_ftrace_return(unsi
+ unsigned long frame_pointer)
+ {
+ unsigned long return_hooker = (unsigned long) &return_to_handler;
+- struct ftrace_graph_ent trace;
+
+ if (unlikely(atomic_read(¤t->tracing_graph_pause)))
+ return parent + 8UL;
+
+- trace.func = self_addr;
+- trace.depth = current->curr_ret_stack + 1;
+-
+- /* Only trace if the calling function expects to */
+- if (!ftrace_graph_entry(&trace))
+- return parent + 8UL;
+-
+- if (ftrace_push_return_trace(parent, self_addr, &trace.depth,
+- frame_pointer, NULL) == -EBUSY)
++ if (function_graph_enter(parent, self_addr, frame_pointer, NULL))
+ return parent + 8UL;
+
+ return return_hooker;
--- /dev/null
+From 07f7175b43827640d1e69c9eded89aa089a234b4 Mon Sep 17 00:00:00 2001
+From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
+Date: Sun, 18 Nov 2018 17:14:10 -0500
+Subject: x86/function_graph: Simplify with function_graph_enter()
+
+From: Steven Rostedt (VMware) <rostedt@goodmis.org>
+
+commit 07f7175b43827640d1e69c9eded89aa089a234b4 upstream.
+
+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 x86 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: Thomas Gleixner <tglx@linutronix.de>
+Cc: Ingo Molnar <mingo@redhat.com>
+Cc: Borislav Petkov <bp@alien8.de>
+Cc: "H. Peter Anvin" <hpa@zytor.com>
+Cc: x86@kernel.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>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/x86/kernel/ftrace.c | 15 +--------------
+ 1 file changed, 1 insertion(+), 14 deletions(-)
+
+--- a/arch/x86/kernel/ftrace.c
++++ b/arch/x86/kernel/ftrace.c
+@@ -995,7 +995,6 @@ void prepare_ftrace_return(unsigned long
+ {
+ unsigned long old;
+ int faulted;
+- struct ftrace_graph_ent trace;
+ unsigned long return_hooker = (unsigned long)
+ &return_to_handler;
+
+@@ -1047,19 +1046,7 @@ void prepare_ftrace_return(unsigned long
+ return;
+ }
+
+- trace.func = self_addr;
+- trace.depth = current->curr_ret_stack + 1;
+-
+- /* Only trace if the calling function expects to */
+- if (!ftrace_graph_entry(&trace)) {
++ if (function_graph_enter(old, self_addr, frame_pointer, parent))
+ *parent = old;
+- return;
+- }
+-
+- if (ftrace_push_return_trace(old, self_addr, &trace.depth,
+- frame_pointer, parent) == -EBUSY) {
+- *parent = old;
+- return;
+- }
+ }
+ #endif /* CONFIG_FUNCTION_GRAPH_TRACER */