From: Jiri Slaby <jslaby@suse.cz>
Date: Thu, 14 Dec 2017 22:54:20 +0100
Subject: x86/stacktrace: make clear the success paths
Patch-mainline: submitted on 2017/12/5
References: bnc#1058115
Make clear which path is for user tasks and for kthreads and idle
tasks. This will allow easier plug-in of ORC unwinder in the next
patches.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
---
arch/x86/kernel/stacktrace.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
--- a/arch/x86/kernel/stacktrace.c
+++ b/arch/x86/kernel/stacktrace.c
@@ -104,16 +104,18 @@ __save_stack_trace_reliable(struct stack
regs = unwind_get_entry_regs(&state, NULL);
if (regs) {
+ /* Success path for user tasks */
+ if (user_mode(regs))
+ goto success;
+
/*
* Kernel mode registers on the stack indicate an
* in-kernel interrupt or exception (e.g., preemption
* or a page fault), which can make frame pointers
* unreliable.
*/
- if (!user_mode(regs))
- return -EINVAL;
- break;
+ return -EINVAL;
}
addr = unwind_get_return_address(&state);
@@ -138,6 +140,11 @@ __save_stack_trace_reliable(struct stack
return -EINVAL;
}
+ /* Success path for non-user tasks, i.e. kthreads and idle tasks */
+ if (!(task->flags & (PF_KTHREAD | PF_IDLE)))
+ return -EINVAL;
+
+success:
if (trace->nr_entries < trace->max_entries)
trace->entries[trace->nr_entries++] = ULONG_MAX;