From: Sasha Levin Date: Mon, 3 Dec 2018 14:59:14 +0000 (-0500) Subject: remove function_graph series from 4.9 and 4.14 X-Git-Tag: v4.19.7~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=40b43b3b7d50b1c42ea2d91d0b047edb12d452da;p=thirdparty%2Fkernel%2Fstable-queue.git remove function_graph series from 4.9 and 4.14 Signed-off-by: Sasha Levin --- diff --git a/queue-4.14/arm-function_graph-simplify-with-function_graph_enter.patch b/queue-4.14/arm-function_graph-simplify-with-function_graph_enter.patch deleted file mode 100644 index 8026e6d1928..00000000000 --- a/queue-4.14/arm-function_graph-simplify-with-function_graph_enter.patch +++ /dev/null @@ -1,66 +0,0 @@ -From f1f5b14afd7cce39e6a9b25c685e1ea34c231096 Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -Date: Sun, 18 Nov 2018 17:19:26 -0500 -Subject: ARM: function_graph: Simplify with function_graph_enter() - -From: Steven Rostedt (VMware) - -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 -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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 diff --git a/queue-4.14/arm64-function_graph-simplify-with-function_graph_enter.patch b/queue-4.14/arm64-function_graph-simplify-with-function_graph_enter.patch deleted file mode 100644 index 6259867b333..00000000000 --- a/queue-4.14/arm64-function_graph-simplify-with-function_graph_enter.patch +++ /dev/null @@ -1,63 +0,0 @@ -From 01e0ab2c4ff12358f15a856fd1a7bbea0670972b Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -Date: Sun, 18 Nov 2018 17:21:51 -0500 -Subject: arm64: function_graph: Simplify with function_graph_enter() - -From: Steven Rostedt (VMware) - -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 -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 -Reviewed-by: Masami Hiramatsu -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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; - } - diff --git a/queue-4.14/function_graph-create-function_graph_enter-to-consolidate-architecture-code.patch b/queue-4.14/function_graph-create-function_graph_enter-to-consolidate-architecture-code.patch deleted file mode 100644 index 3151019bcfa..00000000000 --- a/queue-4.14/function_graph-create-function_graph_enter-to-consolidate-architecture-code.patch +++ /dev/null @@ -1,70 +0,0 @@ -From 8114865ff82e200b383e46821c25cb0625b842b5 Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -Date: Sun, 18 Nov 2018 17:10:15 -0500 -Subject: function_graph: Create function_graph_enter() to consolidate architecture code - -From: Steven Rostedt (VMware) - -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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, diff --git a/queue-4.14/function_graph-have-profiler-use-curr_ret_stack-and-not-depth.patch b/queue-4.14/function_graph-have-profiler-use-curr_ret_stack-and-not-depth.patch deleted file mode 100644 index ca08c1514d3..00000000000 --- a/queue-4.14/function_graph-have-profiler-use-curr_ret_stack-and-not-depth.patch +++ /dev/null @@ -1,48 +0,0 @@ -From b1b35f2e218a5b57d03bbc3b0667d5064570dc60 Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -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) - -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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) diff --git a/queue-4.14/function_graph-make-ftrace_push_return_trace-static.patch b/queue-4.14/function_graph-make-ftrace_push_return_trace-static.patch deleted file mode 100644 index e71c914572e..00000000000 --- a/queue-4.14/function_graph-make-ftrace_push_return_trace-static.patch +++ /dev/null @@ -1,49 +0,0 @@ -From d125f3f866df88da5a85df00291f88f0baa89f7c Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -Date: Mon, 19 Nov 2018 07:40:39 -0500 -Subject: function_graph: Make ftrace_push_return_trace() static - -From: Steven Rostedt (VMware) - -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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) - { diff --git a/queue-4.14/function_graph-move-return-callback-before-update-of-curr_ret_stack.patch b/queue-4.14/function_graph-move-return-callback-before-update-of-curr_ret_stack.patch deleted file mode 100644 index 71ffa40a2cf..00000000000 --- a/queue-4.14/function_graph-move-return-callback-before-update-of-curr_ret_stack.patch +++ /dev/null @@ -1,88 +0,0 @@ -From 552701dd0fa7c3d448142e87210590ba424694a0 Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -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) - -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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); diff --git a/queue-4.14/function_graph-reverse-the-order-of-pushing-the-ret_stack-and-the-callback.patch b/queue-4.14/function_graph-reverse-the-order-of-pushing-the-ret_stack-and-the-callback.patch deleted file mode 100644 index 88b5ad89c7f..00000000000 --- a/queue-4.14/function_graph-reverse-the-order-of-pushing-the-ret_stack-and-the-callback.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 7c6ea35ef50810aa12ab26f21cb858d980881576 Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -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) - -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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; diff --git a/queue-4.14/function_graph-use-new-curr_ret_depth-to-manage-depth-instead-of-curr_ret_stack.patch b/queue-4.14/function_graph-use-new-curr_ret_depth-to-manage-depth-instead-of-curr_ret_stack.patch deleted file mode 100644 index 04bb8fdb593..00000000000 --- a/queue-4.14/function_graph-use-new-curr_ret_depth-to-manage-depth-instead-of-curr_ret_stack.patch +++ /dev/null @@ -1,140 +0,0 @@ -From 39eb456dacb543de90d3bc6a8e0ac5cf51ac475e Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -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) - -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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. diff --git a/queue-4.14/microblaze-function_graph-simplify-with-function_graph_enter.patch b/queue-4.14/microblaze-function_graph-simplify-with-function_graph_enter.patch deleted file mode 100644 index ecdb00758d3..00000000000 --- a/queue-4.14/microblaze-function_graph-simplify-with-function_graph_enter.patch +++ /dev/null @@ -1,62 +0,0 @@ -From 556763e5a500d71879d632867b75826551acd49c Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -Date: Sun, 18 Nov 2018 17:23:30 -0500 -Subject: microblaze: function_graph: Simplify with function_graph_enter() - -From: Steven Rostedt (VMware) - -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 -Cc: stable@kernel.org -Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback") -Reviewed-by: Masami Hiramatsu -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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 */ - diff --git a/queue-4.14/mips-function_graph-simplify-with-function_graph_enter.patch b/queue-4.14/mips-function_graph-simplify-with-function_graph_enter.patch deleted file mode 100644 index b12598fd4fa..00000000000 --- a/queue-4.14/mips-function_graph-simplify-with-function_graph_enter.patch +++ /dev/null @@ -1,72 +0,0 @@ -From 8712b27c5723c26400a2b350faf1d6d9fd7ffaad Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -Date: Sun, 18 Nov 2018 17:25:18 -0500 -Subject: MIPS: function_graph: Simplify with function_graph_enter() - -From: Steven Rostedt (VMware) - -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 -Cc: Paul Burton -Cc: James Hogan -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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(); diff --git a/queue-4.14/parisc-function_graph-simplify-with-function_graph_enter.patch b/queue-4.14/parisc-function_graph-simplify-with-function_graph_enter.patch deleted file mode 100644 index 39fedb4034c..00000000000 --- a/queue-4.14/parisc-function_graph-simplify-with-function_graph_enter.patch +++ /dev/null @@ -1,65 +0,0 @@ -From a87532c78d291265efadc4b20a8c7a70cd59ea29 Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -Date: Sun, 18 Nov 2018 17:27:43 -0500 -Subject: parisc: function_graph: Simplify with function_graph_enter() - -From: Steven Rostedt (VMware) - -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" -Cc: Helge Deller -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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 */ - diff --git a/queue-4.14/powerpc-function_graph-simplify-with-function_graph_enter.patch b/queue-4.14/powerpc-function_graph-simplify-with-function_graph_enter.patch deleted file mode 100644 index f7873d1bc24..00000000000 --- a/queue-4.14/powerpc-function_graph-simplify-with-function_graph_enter.patch +++ /dev/null @@ -1,64 +0,0 @@ -From fe60522ec60082a1dd735691b82c64f65d4ad15e Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -Date: Sun, 18 Nov 2018 17:28:53 -0500 -Subject: powerpc/function_graph: Simplify with function_graph_enter() - -From: Steven Rostedt (VMware) - -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 -Cc: Paul Mackerras -Cc: Michael Ellerman -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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; - } diff --git a/queue-4.14/s390-function_graph-simplify-with-function_graph_enter.patch b/queue-4.14/s390-function_graph-simplify-with-function_graph_enter.patch deleted file mode 100644 index c7926388f19..00000000000 --- a/queue-4.14/s390-function_graph-simplify-with-function_graph_enter.patch +++ /dev/null @@ -1,60 +0,0 @@ -From 18588e1487b19e45bd90bd55ec8d3a1d44f3257f Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -Date: Sun, 18 Nov 2018 17:33:17 -0500 -Subject: s390/function_graph: Simplify with function_graph_enter() - -From: Steven Rostedt (VMware) - -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 -Cc: Heiko Carstens -Cc: Julian Wiedmann -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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; - } diff --git a/queue-4.14/series b/queue-4.14/series index 82a324de28e..f51bca2deef 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -128,22 +128,6 @@ alsa-control-fix-race-between-adding-and-removing-a-user-element.patch 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 arm-dts-rockchip-remove-0-from-the-veyron-memory-node.patch dmaengine-at_hdmac-fix-memory-leak-in-at_dma_xlate.patch diff --git a/queue-4.14/sh-function_graph-simplify-with-function_graph_enter.patch b/queue-4.14/sh-function_graph-simplify-with-function_graph_enter.patch deleted file mode 100644 index 79e45dbbca6..00000000000 --- a/queue-4.14/sh-function_graph-simplify-with-function_graph_enter.patch +++ /dev/null @@ -1,64 +0,0 @@ -From bc715ee4dbc5db462c59b9cfba92d31b3274fe3a Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -Date: Sun, 18 Nov 2018 17:35:37 -0500 -Subject: sh/function_graph: Simplify with function_graph_enter() - -From: Steven Rostedt (VMware) - -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 -Cc: Rich Felker -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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 */ diff --git a/queue-4.14/sparc-function_graph-simplify-with-function_graph_enter.patch b/queue-4.14/sparc-function_graph-simplify-with-function_graph_enter.patch deleted file mode 100644 index 049349f3a77..00000000000 --- a/queue-4.14/sparc-function_graph-simplify-with-function_graph_enter.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 9c4bf5e0db164f330a2d3e128e9832661f69f0e9 Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -Date: Sun, 18 Nov 2018 17:37:40 -0500 -Subject: sparc/function_graph: Simplify with function_graph_enter() - -From: Steven Rostedt (VMware) - -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" -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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; diff --git a/queue-4.14/x86-function_graph-simplify-with-function_graph_enter.patch b/queue-4.14/x86-function_graph-simplify-with-function_graph_enter.patch deleted file mode 100644 index bf049e461ed..00000000000 --- a/queue-4.14/x86-function_graph-simplify-with-function_graph_enter.patch +++ /dev/null @@ -1,65 +0,0 @@ -From 07f7175b43827640d1e69c9eded89aa089a234b4 Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -Date: Sun, 18 Nov 2018 17:14:10 -0500 -Subject: x86/function_graph: Simplify with function_graph_enter() - -From: Steven Rostedt (VMware) - -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 -Cc: Ingo Molnar -Cc: Borislav Petkov -Cc: "H. Peter Anvin" -Cc: x86@kernel.org -Cc: stable@kernel.org -Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback") -Reviewed-by: Masami Hiramatsu -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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 */ diff --git a/queue-4.9/arm-function_graph-simplify-with-function_graph_enter.patch b/queue-4.9/arm-function_graph-simplify-with-function_graph_enter.patch deleted file mode 100644 index 42b7cc3b8e7..00000000000 --- a/queue-4.9/arm-function_graph-simplify-with-function_graph_enter.patch +++ /dev/null @@ -1,66 +0,0 @@ -From f1f5b14afd7cce39e6a9b25c685e1ea34c231096 Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -Date: Sun, 18 Nov 2018 17:19:26 -0500 -Subject: ARM: function_graph: Simplify with function_graph_enter() - -From: Steven Rostedt (VMware) - -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 -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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 -@@ -199,9 +199,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; -@@ -209,21 +207,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 diff --git a/queue-4.9/arm64-function_graph-simplify-with-function_graph_enter.patch b/queue-4.9/arm64-function_graph-simplify-with-function_graph_enter.patch deleted file mode 100644 index e8fb0a52acd..00000000000 --- a/queue-4.9/arm64-function_graph-simplify-with-function_graph_enter.patch +++ /dev/null @@ -1,63 +0,0 @@ -From 01e0ab2c4ff12358f15a856fd1a7bbea0670972b Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -Date: Sun, 18 Nov 2018 17:21:51 -0500 -Subject: arm64: function_graph: Simplify with function_graph_enter() - -From: Steven Rostedt (VMware) - -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 -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 -Reviewed-by: Masami Hiramatsu -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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 -@@ -117,8 +117,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; -@@ -130,18 +128,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; - } - diff --git a/queue-4.9/function_graph-create-function_graph_enter-to-consolidate-architecture-code.patch b/queue-4.9/function_graph-create-function_graph_enter-to-consolidate-architecture-code.patch deleted file mode 100644 index a5f5edc1fea..00000000000 --- a/queue-4.9/function_graph-create-function_graph_enter-to-consolidate-architecture-code.patch +++ /dev/null @@ -1,70 +0,0 @@ -From 8114865ff82e200b383e46821c25cb0625b842b5 Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -Date: Sun, 18 Nov 2018 17:10:15 -0500 -Subject: function_graph: Create function_graph_enter() to consolidate architecture code - -From: Steven Rostedt (VMware) - -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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 -@@ -815,6 +815,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 -@@ -181,6 +181,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, diff --git a/queue-4.9/function_graph-have-profiler-use-curr_ret_stack-and-not-depth.patch b/queue-4.9/function_graph-have-profiler-use-curr_ret_stack-and-not-depth.patch deleted file mode 100644 index 13135353ff0..00000000000 --- a/queue-4.9/function_graph-have-profiler-use-curr_ret_stack-and-not-depth.patch +++ /dev/null @@ -1,48 +0,0 @@ -From b1b35f2e218a5b57d03bbc3b0667d5064570dc60 Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -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) - -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - kernel/trace/ftrace.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - ---- a/kernel/trace/ftrace.c -+++ b/kernel/trace/ftrace.c -@@ -872,7 +872,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); - -@@ -907,7 +907,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) diff --git a/queue-4.9/function_graph-make-ftrace_push_return_trace-static.patch b/queue-4.9/function_graph-make-ftrace_push_return_trace-static.patch deleted file mode 100644 index 9ecaf226acc..00000000000 --- a/queue-4.9/function_graph-make-ftrace_push_return_trace-static.patch +++ /dev/null @@ -1,49 +0,0 @@ -From d125f3f866df88da5a85df00291f88f0baa89f7c Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -Date: Mon, 19 Nov 2018 07:40:39 -0500 -Subject: function_graph: Make ftrace_push_return_trace() static - -From: Steven Rostedt (VMware) - -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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 -@@ -813,9 +813,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 -@@ -117,7 +117,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) - { diff --git a/queue-4.9/function_graph-move-return-callback-before-update-of-curr_ret_stack.patch b/queue-4.9/function_graph-move-return-callback-before-update-of-curr_ret_stack.patch deleted file mode 100644 index 8a1a7dfab20..00000000000 --- a/queue-4.9/function_graph-move-return-callback-before-update-of-curr_ret_stack.patch +++ /dev/null @@ -1,88 +0,0 @@ -From 552701dd0fa7c3d448142e87210590ba424694a0 Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -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) - -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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 -@@ -260,7 +260,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(); - } - - /* -@@ -274,9 +280,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. -@@ -287,13 +298,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); diff --git a/queue-4.9/function_graph-reverse-the-order-of-pushing-the-ret_stack-and-the-callback.patch b/queue-4.9/function_graph-reverse-the-order-of-pushing-the-ret_stack-and-the-callback.patch deleted file mode 100644 index 63f1cdfe2c2..00000000000 --- a/queue-4.9/function_graph-reverse-the-order-of-pushing-the-ret_stack-and-the-callback.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 7c6ea35ef50810aa12ab26f21cb858d980881576 Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -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) - -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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 -@@ -187,15 +187,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; diff --git a/queue-4.9/function_graph-use-new-curr_ret_depth-to-manage-depth-instead-of-curr_ret_stack.patch b/queue-4.9/function_graph-use-new-curr_ret_depth-to-manage-depth-instead-of-curr_ret_stack.patch deleted file mode 100644 index 7dd037f71e4..00000000000 --- a/queue-4.9/function_graph-use-new-curr_ret_depth-to-manage-depth-instead-of-curr_ret_stack.patch +++ /dev/null @@ -1,140 +0,0 @@ -From 39eb456dacb543de90d3bc6a8e0ac5cf51ac475e Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -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) - -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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 -@@ -1914,6 +1914,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; - /* time stamp for last schedule */ ---- a/kernel/trace/ftrace.c -+++ b/kernel/trace/ftrace.c -@@ -5777,6 +5777,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++]; -@@ -6001,6 +6002,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. -@@ -6030,6 +6032,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 -@@ -118,7 +118,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; -@@ -176,8 +176,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; - } - -@@ -187,14 +185,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.*/ -@@ -256,7 +260,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; - } - - /* -@@ -272,6 +276,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. diff --git a/queue-4.9/microblaze-function_graph-simplify-with-function_graph_enter.patch b/queue-4.9/microblaze-function_graph-simplify-with-function_graph_enter.patch deleted file mode 100644 index ecdb00758d3..00000000000 --- a/queue-4.9/microblaze-function_graph-simplify-with-function_graph_enter.patch +++ /dev/null @@ -1,62 +0,0 @@ -From 556763e5a500d71879d632867b75826551acd49c Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -Date: Sun, 18 Nov 2018 17:23:30 -0500 -Subject: microblaze: function_graph: Simplify with function_graph_enter() - -From: Steven Rostedt (VMware) - -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 -Cc: stable@kernel.org -Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback") -Reviewed-by: Masami Hiramatsu -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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 */ - diff --git a/queue-4.9/parisc-function_graph-simplify-with-function_graph_enter.patch b/queue-4.9/parisc-function_graph-simplify-with-function_graph_enter.patch deleted file mode 100644 index 546408db3ef..00000000000 --- a/queue-4.9/parisc-function_graph-simplify-with-function_graph_enter.patch +++ /dev/null @@ -1,65 +0,0 @@ -From a87532c78d291265efadc4b20a8c7a70cd59ea29 Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -Date: Sun, 18 Nov 2018 17:27:43 -0500 -Subject: parisc: function_graph: Simplify with function_graph_enter() - -From: Steven Rostedt (VMware) - -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" -Cc: Helge Deller -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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 -@@ -29,7 +29,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())) -@@ -40,19 +39,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 */ - diff --git a/queue-4.9/s390-function_graph-simplify-with-function_graph_enter.patch b/queue-4.9/s390-function_graph-simplify-with-function_graph_enter.patch deleted file mode 100644 index b1b790416c6..00000000000 --- a/queue-4.9/s390-function_graph-simplify-with-function_graph_enter.patch +++ /dev/null @@ -1,60 +0,0 @@ -From 18588e1487b19e45bd90bd55ec8d3a1d44f3257f Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -Date: Sun, 18 Nov 2018 17:33:17 -0500 -Subject: s390/function_graph: Simplify with function_graph_enter() - -From: Steven Rostedt (VMware) - -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 -Cc: Heiko Carstens -Cc: Julian Wiedmann -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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 -@@ -197,22 +197,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; - } diff --git a/queue-4.9/series b/queue-4.9/series index 46539d877ca..c0dc20607bc 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -29,20 +29,6 @@ alsa-wss-fix-invalid-snd_free_pages-at-error-path.patch alsa-ac97-fix-incorrect-bit-shift-at-ac97-spsa-control-write.patch alsa-control-fix-race-between-adding-and-removing-a-user-element.patch alsa-sparc-fix-invalid-snd_free_pages-at-error-path.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 -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 -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 dmaengine-at_hdmac-fix-memory-leak-in-at_dma_xlate.patch dmaengine-at_hdmac-fix-module-unloading.patch diff --git a/queue-4.9/sh-function_graph-simplify-with-function_graph_enter.patch b/queue-4.9/sh-function_graph-simplify-with-function_graph_enter.patch deleted file mode 100644 index 53a4cd034a2..00000000000 --- a/queue-4.9/sh-function_graph-simplify-with-function_graph_enter.patch +++ /dev/null @@ -1,64 +0,0 @@ -From bc715ee4dbc5db462c59b9cfba92d31b3274fe3a Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -Date: Sun, 18 Nov 2018 17:35:37 -0500 -Subject: sh/function_graph: Simplify with function_graph_enter() - -From: Steven Rostedt (VMware) - -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 -Cc: Rich Felker -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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 -@@ -338,8 +338,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())) -@@ -382,18 +381,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 */ diff --git a/queue-4.9/sparc-function_graph-simplify-with-function_graph_enter.patch b/queue-4.9/sparc-function_graph-simplify-with-function_graph_enter.patch deleted file mode 100644 index 034efab6283..00000000000 --- a/queue-4.9/sparc-function_graph-simplify-with-function_graph_enter.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 9c4bf5e0db164f330a2d3e128e9832661f69f0e9 Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -Date: Sun, 18 Nov 2018 17:37:40 -0500 -Subject: sparc/function_graph: Simplify with function_graph_enter() - -From: Steven Rostedt (VMware) - -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" -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 -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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 -@@ -125,20 +125,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; diff --git a/queue-4.9/x86-function_graph-simplify-with-function_graph_enter.patch b/queue-4.9/x86-function_graph-simplify-with-function_graph_enter.patch deleted file mode 100644 index a961635145d..00000000000 --- a/queue-4.9/x86-function_graph-simplify-with-function_graph_enter.patch +++ /dev/null @@ -1,65 +0,0 @@ -From 07f7175b43827640d1e69c9eded89aa089a234b4 Mon Sep 17 00:00:00 2001 -From: "Steven Rostedt (VMware)" -Date: Sun, 18 Nov 2018 17:14:10 -0500 -Subject: x86/function_graph: Simplify with function_graph_enter() - -From: Steven Rostedt (VMware) - -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 -Cc: Ingo Molnar -Cc: Borislav Petkov -Cc: "H. Peter Anvin" -Cc: x86@kernel.org -Cc: stable@kernel.org -Fixes: 03274a3ffb449 ("tracing/fgraph: Adjust fgraph depth before calling trace return callback") -Reviewed-by: Masami Hiramatsu -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Greg Kroah-Hartman - ---- - 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 -@@ -980,7 +980,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; - -@@ -1032,19 +1031,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 */