hc
2024-05-10 61598093bbdd283a7edc367d900f223070ead8d2
kernel/arch/hexagon/kernel/traps.c
....@@ -1,21 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Kernel traps/events for Hexagon processor
34 *
45 * Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2 and
8
- * only version 2 as published by the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program; if not, write to the Free Software
17
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
- * 02110-1301, USA.
196 */
207
218 #include <linux/init.h>
....@@ -92,7 +79,7 @@
9279 }
9380
9481 static void do_show_stack(struct task_struct *task, unsigned long *fp,
95
- unsigned long ip)
82
+ unsigned long ip, const char *loglvl)
9683 {
9784 int kstack_depth_to_print = 24;
9885 unsigned long offset, size;
....@@ -106,9 +93,8 @@
10693 if (task == NULL)
10794 task = current;
10895
109
- printk(KERN_INFO "CPU#%d, %s/%d, Call Trace:\n",
110
- raw_smp_processor_id(), task->comm,
111
- task_pid_nr(task));
96
+ printk("%sCPU#%d, %s/%d, Call Trace:\n", loglvl, raw_smp_processor_id(),
97
+ task->comm, task_pid_nr(task));
11298
11399 if (fp == NULL) {
114100 if (task == current) {
....@@ -121,7 +107,7 @@
121107 }
122108
123109 if ((((unsigned long) fp) & 0x3) || ((unsigned long) fp < 0x1000)) {
124
- printk(KERN_INFO "-- Corrupt frame pointer %p\n", fp);
110
+ printk("%s-- Corrupt frame pointer %p\n", loglvl, fp);
125111 return;
126112 }
127113
....@@ -138,8 +124,7 @@
138124
139125 name = kallsyms_lookup(ip, &size, &offset, &modname, tmpstr);
140126
141
- printk(KERN_INFO "[%p] 0x%lx: %s + 0x%lx", fp, ip, name,
142
- offset);
127
+ printk("%s[%p] 0x%lx: %s + 0x%lx", loglvl, fp, ip, name, offset);
143128 if (((unsigned long) fp < low) || (high < (unsigned long) fp))
144129 printk(KERN_CONT " (FP out of bounds!)");
145130 if (modname)
....@@ -149,8 +134,7 @@
149134 newfp = (unsigned long *) *fp;
150135
151136 if (((unsigned long) newfp) & 0x3) {
152
- printk(KERN_INFO "-- Corrupt frame pointer %p\n",
153
- newfp);
137
+ printk("%s-- Corrupt frame pointer %p\n", loglvl, newfp);
154138 break;
155139 }
156140
....@@ -160,7 +144,7 @@
160144 + 8);
161145
162146 if (regs->syscall_nr != -1) {
163
- printk(KERN_INFO "-- trap0 -- syscall_nr: %ld",
147
+ printk("%s-- trap0 -- syscall_nr: %ld", loglvl,
164148 regs->syscall_nr);
165149 printk(KERN_CONT " psp: %lx elr: %lx\n",
166150 pt_psp(regs), pt_elr(regs));
....@@ -168,7 +152,7 @@
168152 } else {
169153 /* really want to see more ... */
170154 kstack_depth_to_print += 6;
171
- printk(KERN_INFO "-- %s (0x%lx) badva: %lx\n",
155
+ printk("%s-- %s (0x%lx) badva: %lx\n", loglvl,
172156 ex_name(pt_cause(regs)), pt_cause(regs),
173157 pt_badva(regs));
174158 }
....@@ -191,10 +175,10 @@
191175 }
192176 }
193177
194
-void show_stack(struct task_struct *task, unsigned long *fp)
178
+void show_stack(struct task_struct *task, unsigned long *fp, const char *loglvl)
195179 {
196180 /* Saved link reg is one word above FP */
197
- do_show_stack(task, fp, 0);
181
+ do_show_stack(task, fp, 0, loglvl);
198182 }
199183
200184 int die(const char *str, struct pt_regs *regs, long err)
....@@ -220,7 +204,7 @@
220204
221205 print_modules();
222206 show_regs(regs);
223
- do_show_stack(current, &regs->r30, pt_elr(regs));
207
+ do_show_stack(current, &regs->r30, pt_elr(regs), KERN_EMERG);
224208
225209 bust_spinlocks(0);
226210 add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
....@@ -234,7 +218,7 @@
234218 panic("Fatal exception");
235219
236220 oops_exit();
237
- do_exit(err);
221
+ make_task_dead(err);
238222 return 0;
239223 }
240224
....@@ -252,7 +236,7 @@
252236 static void misaligned_instruction(struct pt_regs *regs)
253237 {
254238 die_if_kernel("Misaligned Instruction", regs, 0);
255
- force_sig(SIGBUS, current);
239
+ force_sig(SIGBUS);
256240 }
257241
258242 /*
....@@ -263,19 +247,19 @@
263247 static void misaligned_data_load(struct pt_regs *regs)
264248 {
265249 die_if_kernel("Misaligned Data Load", regs, 0);
266
- force_sig(SIGBUS, current);
250
+ force_sig(SIGBUS);
267251 }
268252
269253 static void misaligned_data_store(struct pt_regs *regs)
270254 {
271255 die_if_kernel("Misaligned Data Store", regs, 0);
272
- force_sig(SIGBUS, current);
256
+ force_sig(SIGBUS);
273257 }
274258
275259 static void illegal_instruction(struct pt_regs *regs)
276260 {
277261 die_if_kernel("Illegal Instruction", regs, 0);
278
- force_sig(SIGILL, current);
262
+ force_sig(SIGILL);
279263 }
280264
281265 /*
....@@ -285,7 +269,7 @@
285269 static void precise_bus_error(struct pt_regs *regs)
286270 {
287271 die_if_kernel("Precise Bus Error", regs, 0);
288
- force_sig(SIGBUS, current);
272
+ force_sig(SIGBUS);
289273 }
290274
291275 /*
....@@ -420,7 +404,7 @@
420404 * may want to use a different trap0 flavor.
421405 */
422406 force_sig_fault(SIGTRAP, TRAP_BRKPT,
423
- (void __user *) pt_elr(regs), current);
407
+ (void __user *) pt_elr(regs));
424408 } else {
425409 #ifdef CONFIG_KGDB
426410 kgdb_handle_exception(pt_cause(regs), SIGTRAP,