| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Kernel traps/events for Hexagon processor |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * 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. |
|---|
| 19 | 6 | */ |
|---|
| 20 | 7 | |
|---|
| 21 | 8 | #include <linux/init.h> |
|---|
| .. | .. |
|---|
| 92 | 79 | } |
|---|
| 93 | 80 | |
|---|
| 94 | 81 | static void do_show_stack(struct task_struct *task, unsigned long *fp, |
|---|
| 95 | | - unsigned long ip) |
|---|
| 82 | + unsigned long ip, const char *loglvl) |
|---|
| 96 | 83 | { |
|---|
| 97 | 84 | int kstack_depth_to_print = 24; |
|---|
| 98 | 85 | unsigned long offset, size; |
|---|
| .. | .. |
|---|
| 106 | 93 | if (task == NULL) |
|---|
| 107 | 94 | task = current; |
|---|
| 108 | 95 | |
|---|
| 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)); |
|---|
| 112 | 98 | |
|---|
| 113 | 99 | if (fp == NULL) { |
|---|
| 114 | 100 | if (task == current) { |
|---|
| .. | .. |
|---|
| 121 | 107 | } |
|---|
| 122 | 108 | |
|---|
| 123 | 109 | 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); |
|---|
| 125 | 111 | return; |
|---|
| 126 | 112 | } |
|---|
| 127 | 113 | |
|---|
| .. | .. |
|---|
| 138 | 124 | |
|---|
| 139 | 125 | name = kallsyms_lookup(ip, &size, &offset, &modname, tmpstr); |
|---|
| 140 | 126 | |
|---|
| 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); |
|---|
| 143 | 128 | if (((unsigned long) fp < low) || (high < (unsigned long) fp)) |
|---|
| 144 | 129 | printk(KERN_CONT " (FP out of bounds!)"); |
|---|
| 145 | 130 | if (modname) |
|---|
| .. | .. |
|---|
| 149 | 134 | newfp = (unsigned long *) *fp; |
|---|
| 150 | 135 | |
|---|
| 151 | 136 | 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); |
|---|
| 154 | 138 | break; |
|---|
| 155 | 139 | } |
|---|
| 156 | 140 | |
|---|
| .. | .. |
|---|
| 160 | 144 | + 8); |
|---|
| 161 | 145 | |
|---|
| 162 | 146 | if (regs->syscall_nr != -1) { |
|---|
| 163 | | - printk(KERN_INFO "-- trap0 -- syscall_nr: %ld", |
|---|
| 147 | + printk("%s-- trap0 -- syscall_nr: %ld", loglvl, |
|---|
| 164 | 148 | regs->syscall_nr); |
|---|
| 165 | 149 | printk(KERN_CONT " psp: %lx elr: %lx\n", |
|---|
| 166 | 150 | pt_psp(regs), pt_elr(regs)); |
|---|
| .. | .. |
|---|
| 168 | 152 | } else { |
|---|
| 169 | 153 | /* really want to see more ... */ |
|---|
| 170 | 154 | 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, |
|---|
| 172 | 156 | ex_name(pt_cause(regs)), pt_cause(regs), |
|---|
| 173 | 157 | pt_badva(regs)); |
|---|
| 174 | 158 | } |
|---|
| .. | .. |
|---|
| 191 | 175 | } |
|---|
| 192 | 176 | } |
|---|
| 193 | 177 | |
|---|
| 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) |
|---|
| 195 | 179 | { |
|---|
| 196 | 180 | /* Saved link reg is one word above FP */ |
|---|
| 197 | | - do_show_stack(task, fp, 0); |
|---|
| 181 | + do_show_stack(task, fp, 0, loglvl); |
|---|
| 198 | 182 | } |
|---|
| 199 | 183 | |
|---|
| 200 | 184 | int die(const char *str, struct pt_regs *regs, long err) |
|---|
| .. | .. |
|---|
| 220 | 204 | |
|---|
| 221 | 205 | print_modules(); |
|---|
| 222 | 206 | show_regs(regs); |
|---|
| 223 | | - do_show_stack(current, ®s->r30, pt_elr(regs)); |
|---|
| 207 | + do_show_stack(current, ®s->r30, pt_elr(regs), KERN_EMERG); |
|---|
| 224 | 208 | |
|---|
| 225 | 209 | bust_spinlocks(0); |
|---|
| 226 | 210 | add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE); |
|---|
| .. | .. |
|---|
| 252 | 236 | static void misaligned_instruction(struct pt_regs *regs) |
|---|
| 253 | 237 | { |
|---|
| 254 | 238 | die_if_kernel("Misaligned Instruction", regs, 0); |
|---|
| 255 | | - force_sig(SIGBUS, current); |
|---|
| 239 | + force_sig(SIGBUS); |
|---|
| 256 | 240 | } |
|---|
| 257 | 241 | |
|---|
| 258 | 242 | /* |
|---|
| .. | .. |
|---|
| 263 | 247 | static void misaligned_data_load(struct pt_regs *regs) |
|---|
| 264 | 248 | { |
|---|
| 265 | 249 | die_if_kernel("Misaligned Data Load", regs, 0); |
|---|
| 266 | | - force_sig(SIGBUS, current); |
|---|
| 250 | + force_sig(SIGBUS); |
|---|
| 267 | 251 | } |
|---|
| 268 | 252 | |
|---|
| 269 | 253 | static void misaligned_data_store(struct pt_regs *regs) |
|---|
| 270 | 254 | { |
|---|
| 271 | 255 | die_if_kernel("Misaligned Data Store", regs, 0); |
|---|
| 272 | | - force_sig(SIGBUS, current); |
|---|
| 256 | + force_sig(SIGBUS); |
|---|
| 273 | 257 | } |
|---|
| 274 | 258 | |
|---|
| 275 | 259 | static void illegal_instruction(struct pt_regs *regs) |
|---|
| 276 | 260 | { |
|---|
| 277 | 261 | die_if_kernel("Illegal Instruction", regs, 0); |
|---|
| 278 | | - force_sig(SIGILL, current); |
|---|
| 262 | + force_sig(SIGILL); |
|---|
| 279 | 263 | } |
|---|
| 280 | 264 | |
|---|
| 281 | 265 | /* |
|---|
| .. | .. |
|---|
| 285 | 269 | static void precise_bus_error(struct pt_regs *regs) |
|---|
| 286 | 270 | { |
|---|
| 287 | 271 | die_if_kernel("Precise Bus Error", regs, 0); |
|---|
| 288 | | - force_sig(SIGBUS, current); |
|---|
| 272 | + force_sig(SIGBUS); |
|---|
| 289 | 273 | } |
|---|
| 290 | 274 | |
|---|
| 291 | 275 | /* |
|---|
| .. | .. |
|---|
| 420 | 404 | * may want to use a different trap0 flavor. |
|---|
| 421 | 405 | */ |
|---|
| 422 | 406 | force_sig_fault(SIGTRAP, TRAP_BRKPT, |
|---|
| 423 | | - (void __user *) pt_elr(regs), current); |
|---|
| 407 | + (void __user *) pt_elr(regs)); |
|---|
| 424 | 408 | } else { |
|---|
| 425 | 409 | #ifdef CONFIG_KGDB |
|---|
| 426 | 410 | kgdb_handle_exception(pt_cause(regs), SIGTRAP, |
|---|