hc
2024-09-20 a36159eec6ca17402b0e146b86efaf76568dc353
kernel/arch/sh/kernel/dumpstack.c
....@@ -1,12 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Copyright (C) 1991, 1992 Linus Torvalds
34 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
45 * Copyright (C) 2009 Matt Fleming
56 * Copyright (C) 2002 - 2012 Paul Mundt
6
- *
7
- * This file is subject to the terms and conditions of the GNU General Public
8
- * License. See the file "COPYING" in the main directory of this archive
9
- * for more details.
107 */
118 #include <linux/kallsyms.h>
129 #include <linux/ftrace.h>
....@@ -19,37 +16,38 @@
1916 #include <asm/unwinder.h>
2017 #include <asm/stacktrace.h>
2118
22
-void dump_mem(const char *str, unsigned long bottom, unsigned long top)
19
+void dump_mem(const char *str, const char *loglvl, unsigned long bottom,
20
+ unsigned long top)
2321 {
2422 unsigned long p;
2523 int i;
2624
27
- printk("%s(0x%08lx to 0x%08lx)\n", str, bottom, top);
25
+ printk("%s%s(0x%08lx to 0x%08lx)\n", loglvl, str, bottom, top);
2826
2927 for (p = bottom & ~31; p < top; ) {
30
- printk("%04lx: ", p & 0xffff);
28
+ printk("%s%04lx: ", loglvl, p & 0xffff);
3129
3230 for (i = 0; i < 8; i++, p += 4) {
3331 unsigned int val;
3432
3533 if (p < bottom || p >= top)
36
- printk(" ");
34
+ pr_cont(" ");
3735 else {
3836 if (__get_user(val, (unsigned int __user *)p)) {
39
- printk("\n");
37
+ pr_cont("\n");
4038 return;
4139 }
42
- printk("%08x ", val);
40
+ pr_cont("%08x ", val);
4341 }
4442 }
45
- printk("\n");
43
+ pr_cont("\n");
4644 }
4745 }
4846
4947 void printk_address(unsigned long address, int reliable)
5048 {
51
- printk(" [<%p>] %s%pS\n", (void *) address,
52
- reliable ? "" : "? ", (void *) address);
49
+ pr_cont(" [<%px>] %s%pS\n", (void *) address,
50
+ reliable ? "" : "? ", (void *) address);
5351 }
5452
5553 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
....@@ -59,17 +57,20 @@
5957 struct thread_info *tinfo, int *graph)
6058 {
6159 struct task_struct *task = tinfo->task;
60
+ struct ftrace_ret_stack *ret_stack;
6261 unsigned long ret_addr;
63
- int index = task->curr_ret_stack;
6462
6563 if (addr != (unsigned long)return_to_handler)
6664 return;
6765
68
- if (!task->ret_stack || index < *graph)
66
+ if (!task->ret_stack)
6967 return;
7068
71
- index -= *graph;
72
- ret_addr = task->ret_stack[index].ret;
69
+ ret_stack = ftrace_graph_get_ret_stack(task, *graph);
70
+ if (!ret_stack)
71
+ return;
72
+
73
+ ret_addr = ret_stack->ret;
7374
7475 ops->address(data, ret_addr, 1);
7576
....@@ -106,12 +107,6 @@
106107 }
107108 }
108109
109
-static int print_trace_stack(void *data, char *name)
110
-{
111
- printk("%s <%s> ", (char *)data, name);
112
- return 0;
113
-}
114
-
115110 /*
116111 * Print one address/symbol entries per line.
117112 */
....@@ -122,21 +117,20 @@
122117 }
123118
124119 static const struct stacktrace_ops print_trace_ops = {
125
- .stack = print_trace_stack,
126120 .address = print_trace_address,
127121 };
128122
129123 void show_trace(struct task_struct *tsk, unsigned long *sp,
130
- struct pt_regs *regs)
124
+ struct pt_regs *regs, const char *loglvl)
131125 {
132126 if (regs && user_mode(regs))
133127 return;
134128
135
- printk("\nCall trace:\n");
129
+ printk("%s\nCall trace:\n", loglvl);
136130
137
- unwind_stack(tsk, regs, sp, &print_trace_ops, "");
131
+ unwind_stack(tsk, regs, sp, &print_trace_ops, (void *)loglvl);
138132
139
- printk("\n");
133
+ pr_cont("\n");
140134
141135 if (!tsk)
142136 tsk = current;
....@@ -144,7 +138,7 @@
144138 debug_show_held_locks(tsk);
145139 }
146140
147
-void show_stack(struct task_struct *tsk, unsigned long *sp)
141
+void show_stack(struct task_struct *tsk, unsigned long *sp, const char *loglvl)
148142 {
149143 unsigned long stack;
150144
....@@ -156,7 +150,7 @@
156150 sp = (unsigned long *)tsk->thread.sp;
157151
158152 stack = (unsigned long)sp;
159
- dump_mem("Stack: ", stack, THREAD_SIZE +
153
+ dump_mem("Stack: ", loglvl, stack, THREAD_SIZE +
160154 (unsigned long)task_stack_page(tsk));
161
- show_trace(tsk, sp, NULL);
155
+ show_trace(tsk, sp, NULL, loglvl);
162156 }