| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * OpenRISC traps.c |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 9 | 10 | * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> |
|---|
| 10 | 11 | * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se> |
|---|
| 11 | 12 | * |
|---|
| 12 | | - * This program is free software; you can redistribute it and/or |
|---|
| 13 | | - * modify it under the terms of the GNU General Public License |
|---|
| 14 | | - * as published by the Free Software Foundation; either version |
|---|
| 15 | | - * 2 of the License, or (at your option) any later version. |
|---|
| 16 | | - * |
|---|
| 17 | 13 | * Here we handle the break vectors not used by the system call |
|---|
| 18 | 14 | * mechanism, as well as some general stack/register dumping |
|---|
| 19 | 15 | * things. |
|---|
| 20 | | - * |
|---|
| 21 | 16 | */ |
|---|
| 22 | 17 | |
|---|
| 23 | 18 | #include <linux/init.h> |
|---|
| .. | .. |
|---|
| 35 | 30 | #include <linux/kallsyms.h> |
|---|
| 36 | 31 | #include <linux/uaccess.h> |
|---|
| 37 | 32 | |
|---|
| 38 | | -#include <asm/segment.h> |
|---|
| 39 | 33 | #include <asm/io.h> |
|---|
| 40 | | -#include <asm/pgtable.h> |
|---|
| 41 | 34 | #include <asm/unwinder.h> |
|---|
| 42 | 35 | #include <asm/sections.h> |
|---|
| 43 | 36 | |
|---|
| .. | .. |
|---|
| 47 | 40 | |
|---|
| 48 | 41 | void print_trace(void *data, unsigned long addr, int reliable) |
|---|
| 49 | 42 | { |
|---|
| 50 | | - pr_emerg("[<%p>] %s%pS\n", (void *) addr, reliable ? "" : "? ", |
|---|
| 43 | + const char *loglvl = data; |
|---|
| 44 | + |
|---|
| 45 | + printk("%s[<%p>] %s%pS\n", loglvl, (void *) addr, reliable ? "" : "? ", |
|---|
| 51 | 46 | (void *) addr); |
|---|
| 52 | 47 | } |
|---|
| 53 | 48 | |
|---|
| 54 | 49 | /* displays a short stack trace */ |
|---|
| 55 | | -void show_stack(struct task_struct *task, unsigned long *esp) |
|---|
| 50 | +void show_stack(struct task_struct *task, unsigned long *esp, const char *loglvl) |
|---|
| 56 | 51 | { |
|---|
| 57 | 52 | if (esp == NULL) |
|---|
| 58 | 53 | esp = (unsigned long *)&esp; |
|---|
| 59 | 54 | |
|---|
| 60 | | - pr_emerg("Call trace:\n"); |
|---|
| 61 | | - unwind_stack(NULL, esp, print_trace); |
|---|
| 62 | | -} |
|---|
| 63 | | - |
|---|
| 64 | | -void show_trace_task(struct task_struct *tsk) |
|---|
| 65 | | -{ |
|---|
| 66 | | - /* |
|---|
| 67 | | - * TODO: SysRq-T trace dump... |
|---|
| 68 | | - */ |
|---|
| 55 | + printk("%sCall trace:\n", loglvl); |
|---|
| 56 | + unwind_stack((void *)loglvl, esp, print_trace); |
|---|
| 69 | 57 | } |
|---|
| 70 | 58 | |
|---|
| 71 | 59 | void show_registers(struct pt_regs *regs) |
|---|
| .. | .. |
|---|
| 109 | 97 | if (in_kernel) { |
|---|
| 110 | 98 | |
|---|
| 111 | 99 | printk("\nStack: "); |
|---|
| 112 | | - show_stack(NULL, (unsigned long *)esp); |
|---|
| 100 | + show_stack(NULL, (unsigned long *)esp, KERN_EMERG); |
|---|
| 113 | 101 | |
|---|
| 114 | 102 | printk("\nCode: "); |
|---|
| 115 | 103 | if (regs->pc < PAGE_OFFSET) |
|---|
| .. | .. |
|---|
| 250 | 238 | |
|---|
| 251 | 239 | asmlinkage void do_trap(struct pt_regs *regs, unsigned long address) |
|---|
| 252 | 240 | { |
|---|
| 253 | | - force_sig_fault(SIGTRAP, TRAP_TRACE, (void __user *)address, current); |
|---|
| 241 | + force_sig_fault(SIGTRAP, TRAP_TRACE, (void __user *)address); |
|---|
| 254 | 242 | |
|---|
| 255 | 243 | regs->pc += 4; |
|---|
| 256 | 244 | } |
|---|
| .. | .. |
|---|
| 259 | 247 | { |
|---|
| 260 | 248 | if (user_mode(regs)) { |
|---|
| 261 | 249 | /* Send a SIGBUS */ |
|---|
| 262 | | - force_sig_fault(SIGBUS, BUS_ADRALN, (void __user *)address, current); |
|---|
| 250 | + force_sig_fault(SIGBUS, BUS_ADRALN, (void __user *)address); |
|---|
| 263 | 251 | } else { |
|---|
| 264 | 252 | printk("KERNEL: Unaligned Access 0x%.8lx\n", address); |
|---|
| 265 | 253 | show_registers(regs); |
|---|
| .. | .. |
|---|
| 272 | 260 | { |
|---|
| 273 | 261 | if (user_mode(regs)) { |
|---|
| 274 | 262 | /* Send a SIGBUS */ |
|---|
| 275 | | - force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *)address, current); |
|---|
| 263 | + force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *)address); |
|---|
| 276 | 264 | } else { /* Kernel mode */ |
|---|
| 277 | 265 | printk("KERNEL: Bus error (SIGBUS) 0x%.8lx\n", address); |
|---|
| 278 | 266 | show_registers(regs); |
|---|
| .. | .. |
|---|
| 377 | 365 | |
|---|
| 378 | 366 | if (get_user(value, lwa_addr)) { |
|---|
| 379 | 367 | if (user_mode(regs)) { |
|---|
| 380 | | - force_sig(SIGSEGV, current); |
|---|
| 368 | + force_sig(SIGSEGV); |
|---|
| 381 | 369 | return; |
|---|
| 382 | 370 | } |
|---|
| 383 | 371 | |
|---|
| .. | .. |
|---|
| 424 | 412 | |
|---|
| 425 | 413 | if (put_user(regs->gpr[rb], vaddr)) { |
|---|
| 426 | 414 | if (user_mode(regs)) { |
|---|
| 427 | | - force_sig(SIGSEGV, current); |
|---|
| 415 | + force_sig(SIGSEGV); |
|---|
| 428 | 416 | return; |
|---|
| 429 | 417 | } |
|---|
| 430 | 418 | |
|---|
| .. | .. |
|---|
| 467 | 455 | |
|---|
| 468 | 456 | if (user_mode(regs)) { |
|---|
| 469 | 457 | /* Send a SIGILL */ |
|---|
| 470 | | - force_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)address, current); |
|---|
| 458 | + force_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)address); |
|---|
| 471 | 459 | } else { /* Kernel mode */ |
|---|
| 472 | 460 | printk("KERNEL: Illegal instruction (SIGILL) 0x%.8lx\n", |
|---|
| 473 | 461 | address); |
|---|