hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/arc/kernel/stacktrace.c
....@@ -1,12 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * stacktrace.c : stacktracing APIs needed by rest of kernel
34 * (wrappers over ARC dwarf based unwinder)
45 *
56 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
107 *
118 * vineetg: aug 2009
129 * -Implemented CONFIG_STACKTRACE APIs, primarily save_stack_trace_tsk( )
....@@ -45,11 +42,23 @@
4542 seed_unwind_frame_info(struct task_struct *tsk, struct pt_regs *regs,
4643 struct unwind_frame_info *frame_info)
4744 {
48
- /*
49
- * synchronous unwinding (e.g. dump_stack)
50
- * - uses current values of SP and friends
51
- */
52
- if (regs == NULL && (tsk == NULL || tsk == current)) {
45
+ if (regs) {
46
+ /*
47
+ * Asynchronous unwinding of intr/exception
48
+ * - Just uses the pt_regs passed
49
+ */
50
+ frame_info->task = tsk;
51
+
52
+ frame_info->regs.r27 = regs->fp;
53
+ frame_info->regs.r28 = regs->sp;
54
+ frame_info->regs.r31 = regs->blink;
55
+ frame_info->regs.r63 = regs->ret;
56
+ frame_info->call_frame = 0;
57
+ } else if (tsk == NULL || tsk == current) {
58
+ /*
59
+ * synchronous unwinding (e.g. dump_stack)
60
+ * - uses current values of SP and friends
61
+ */
5362 unsigned long fp, sp, blink, ret;
5463 frame_info->task = current;
5564
....@@ -66,7 +75,7 @@
6675 frame_info->regs.r31 = blink;
6776 frame_info->regs.r63 = ret;
6877 frame_info->call_frame = 0;
69
- } else if (regs == NULL) {
78
+ } else {
7079 /*
7180 * Asynchronous unwinding of a likely sleeping task
7281 * - first ensure it is actually sleeping
....@@ -97,20 +106,7 @@
97106 frame_info->regs.r28 += 60;
98107 frame_info->call_frame = 0;
99108
100
- } else {
101
- /*
102
- * Asynchronous unwinding of intr/exception
103
- * - Just uses the pt_regs passed
104
- */
105
- frame_info->task = tsk;
106
-
107
- frame_info->regs.r27 = regs->fp;
108
- frame_info->regs.r28 = regs->sp;
109
- frame_info->regs.r31 = regs->blink;
110
- frame_info->regs.r63 = regs->ret;
111
- frame_info->call_frame = 0;
112109 }
113
-
114110 return 0;
115111 }
116112
....@@ -173,9 +169,11 @@
173169 /* Call-back which plugs into unwinding core to dump the stack in
174170 * case of panic/OOPs/BUG etc
175171 */
176
-static int __print_sym(unsigned int address, void *unused)
172
+static int __print_sym(unsigned int address, void *arg)
177173 {
178
- printk(" %pS\n", (void *)address);
174
+ const char *loglvl = arg;
175
+
176
+ printk("%s %pS\n", loglvl, (void *)address);
179177 return 0;
180178 }
181179
....@@ -232,17 +230,18 @@
232230 *-------------------------------------------------------------------------
233231 */
234232
235
-noinline void show_stacktrace(struct task_struct *tsk, struct pt_regs *regs)
233
+noinline void show_stacktrace(struct task_struct *tsk, struct pt_regs *regs,
234
+ const char *loglvl)
236235 {
237
- pr_info("\nStack Trace:\n");
238
- arc_unwind_core(tsk, regs, __print_sym, NULL);
236
+ printk("%s\nStack Trace:\n", loglvl);
237
+ arc_unwind_core(tsk, regs, __print_sym, (void *)loglvl);
239238 }
240239 EXPORT_SYMBOL(show_stacktrace);
241240
242241 /* Expected by sched Code */
243
-void show_stack(struct task_struct *tsk, unsigned long *sp)
242
+void show_stack(struct task_struct *tsk, unsigned long *sp, const char *loglvl)
244243 {
245
- show_stacktrace(tsk, NULL);
244
+ show_stacktrace(tsk, NULL, loglvl);
246245 }
247246
248247 /* Another API expected by schedular, shows up in "ps" as Wait Channel