mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-18 19:07:03 +07:00
a43cb95d54
show_regs() is inherently arch-dependent but it does make sense to print generic debug information and some archs already do albeit in slightly different forms. This patch introduces a generic function to print debug information from show_regs() so that different archs print out the same information and it's much easier to modify what's printed. show_regs_print_info() prints out the same debug info as dump_stack() does plus task and thread_info pointers. * Archs which didn't print debug info now do. alpha, arc, blackfin, c6x, cris, frv, h8300, hexagon, ia64, m32r, metag, microblaze, mn10300, openrisc, parisc, score, sh64, sparc, um, xtensa * Already prints debug info. Replaced with show_regs_print_info(). The printed information is superset of what used to be there. arm, arm64, avr32, mips, powerpc, sh32, tile, unicore32, x86 * s390 is special in that it used to print arch-specific information along with generic debug info. Heiko and Martin think that the arch-specific extra isn't worth keeping s390 specfic implementation. Converted to use the generic version. Note that now all archs print the debug info before actual register dumps. An example BUG() dump follows. kernel BUG at /work/os/work/kernel/workqueue.c:4841! invalid opcode: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC Modules linked in: CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.9.0-rc1-work+ #7 Hardware name: empty empty/S3992, BIOS 080011 10/26/2007 task: ffff88007c85e040 ti: ffff88007c860000 task.ti: ffff88007c860000 RIP: 0010:[<ffffffff8234a07e>] [<ffffffff8234a07e>] init_workqueues+0x4/0x6 RSP: 0000:ffff88007c861ec8 EFLAGS: 00010246 RAX: ffff88007c861fd8 RBX: ffffffff824466a8 RCX: 0000000000000001 RDX: 0000000000000046 RSI: 0000000000000001 RDI: ffffffff8234a07a RBP: ffff88007c861ec8 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000001 R11: 0000000000000000 R12: ffffffff8234a07a R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 FS: 0000000000000000(0000) GS:ffff88007dc00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b CR2: ffff88015f7ff000 CR3: 00000000021f1000 CR4: 00000000000007f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Stack: ffff88007c861ef8 ffffffff81000312 ffffffff824466a8 ffff88007c85e650 0000000000000003 0000000000000000 ffff88007c861f38 ffffffff82335e5d ffff88007c862080 ffffffff8223d8c0 ffff88007c862080 ffffffff81c47760 Call Trace: [<ffffffff81000312>] do_one_initcall+0x122/0x170 [<ffffffff82335e5d>] kernel_init_freeable+0x9b/0x1c8 [<ffffffff81c47760>] ? rest_init+0x140/0x140 [<ffffffff81c4776e>] kernel_init+0xe/0xf0 [<ffffffff81c6be9c>] ret_from_fork+0x7c/0xb0 [<ffffffff81c47760>] ? rest_init+0x140/0x140 ... v2: Typo fix in x86-32. v3: CPU number dropped from show_regs_print_info() as dump_stack_print_info() has been updated to print it. s390 specific implementation dropped as requested by s390 maintainers. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: David S. Miller <davem@davemloft.net> Acked-by: Jesper Nilsson <jesper.nilsson@axis.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Bjorn Helgaas <bhelgaas@google.com> Cc: Fengguang Wu <fengguang.wu@intel.com> Cc: Mike Frysinger <vapier@gentoo.org> Cc: Vineet Gupta <vgupta@synopsys.com> Cc: Sam Ravnborg <sam@ravnborg.org> Acked-by: Chris Metcalf <cmetcalf@tilera.com> [tile bits] Acked-by: Richard Kuo <rkuo@codeaurora.org> [hexagon bits] Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
342 lines
8.7 KiB
C
342 lines
8.7 KiB
C
/*
|
|
* arch/score/kernel/traps.c
|
|
*
|
|
* Score Processor version.
|
|
*
|
|
* Copyright (C) 2009 Sunplus Core Technology Co., Ltd.
|
|
* Chen Liqin <liqin.chen@sunplusct.com>
|
|
* Lennox Wu <lennox.wu@sunplusct.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, see the file COPYING, or write
|
|
* to the Free Software Foundation, Inc.,
|
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/sched.h>
|
|
|
|
#include <asm/cacheflush.h>
|
|
#include <asm/irq.h>
|
|
#include <asm/irq_regs.h>
|
|
|
|
unsigned long exception_handlers[32];
|
|
|
|
/*
|
|
* The architecture-independent show_stack generator
|
|
*/
|
|
void show_stack(struct task_struct *task, unsigned long *sp)
|
|
{
|
|
int i;
|
|
long stackdata;
|
|
|
|
sp = sp ? sp : (unsigned long *)&sp;
|
|
|
|
printk(KERN_NOTICE "Stack: ");
|
|
i = 1;
|
|
while ((long) sp & (PAGE_SIZE - 1)) {
|
|
if (i && ((i % 8) == 0))
|
|
printk(KERN_NOTICE "\n");
|
|
if (i > 40) {
|
|
printk(KERN_NOTICE " ...");
|
|
break;
|
|
}
|
|
|
|
if (__get_user(stackdata, sp++)) {
|
|
printk(KERN_NOTICE " (Bad stack address)");
|
|
break;
|
|
}
|
|
|
|
printk(KERN_NOTICE " %08lx", stackdata);
|
|
i++;
|
|
}
|
|
printk(KERN_NOTICE "\n");
|
|
}
|
|
|
|
static void show_trace(long *sp)
|
|
{
|
|
int i;
|
|
long addr;
|
|
|
|
sp = sp ? sp : (long *) &sp;
|
|
|
|
printk(KERN_NOTICE "Call Trace: ");
|
|
i = 1;
|
|
while ((long) sp & (PAGE_SIZE - 1)) {
|
|
if (__get_user(addr, sp++)) {
|
|
if (i && ((i % 6) == 0))
|
|
printk(KERN_NOTICE "\n");
|
|
printk(KERN_NOTICE " (Bad stack address)\n");
|
|
break;
|
|
}
|
|
|
|
if (kernel_text_address(addr)) {
|
|
if (i && ((i % 6) == 0))
|
|
printk(KERN_NOTICE "\n");
|
|
if (i > 40) {
|
|
printk(KERN_NOTICE " ...");
|
|
break;
|
|
}
|
|
|
|
printk(KERN_NOTICE " [<%08lx>]", addr);
|
|
i++;
|
|
}
|
|
}
|
|
printk(KERN_NOTICE "\n");
|
|
}
|
|
|
|
static void show_code(unsigned int *pc)
|
|
{
|
|
long i;
|
|
|
|
printk(KERN_NOTICE "\nCode:");
|
|
|
|
for (i = -3; i < 6; i++) {
|
|
unsigned long insn;
|
|
if (__get_user(insn, pc + i)) {
|
|
printk(KERN_NOTICE " (Bad address in epc)\n");
|
|
break;
|
|
}
|
|
printk(KERN_NOTICE "%c%08lx%c", (i ? ' ' : '<'),
|
|
insn, (i ? ' ' : '>'));
|
|
}
|
|
}
|
|
|
|
/*
|
|
* FIXME: really the generic show_regs should take a const pointer argument.
|
|
*/
|
|
void show_regs(struct pt_regs *regs)
|
|
{
|
|
show_regs_print_info(KERN_DEFAULT);
|
|
|
|
printk("r0 : %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
|
|
regs->regs[0], regs->regs[1], regs->regs[2], regs->regs[3],
|
|
regs->regs[4], regs->regs[5], regs->regs[6], regs->regs[7]);
|
|
printk("r8 : %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
|
|
regs->regs[8], regs->regs[9], regs->regs[10], regs->regs[11],
|
|
regs->regs[12], regs->regs[13], regs->regs[14], regs->regs[15]);
|
|
printk("r16: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
|
|
regs->regs[16], regs->regs[17], regs->regs[18], regs->regs[19],
|
|
regs->regs[20], regs->regs[21], regs->regs[22], regs->regs[23]);
|
|
printk("r24: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
|
|
regs->regs[24], regs->regs[25], regs->regs[26], regs->regs[27],
|
|
regs->regs[28], regs->regs[29], regs->regs[30], regs->regs[31]);
|
|
|
|
printk("CEH : %08lx\n", regs->ceh);
|
|
printk("CEL : %08lx\n", regs->cel);
|
|
|
|
printk("EMA:%08lx, epc:%08lx %s\nPSR: %08lx\nECR:%08lx\nCondition : %08lx\n",
|
|
regs->cp0_ema, regs->cp0_epc, print_tainted(), regs->cp0_psr,
|
|
regs->cp0_ecr, regs->cp0_condition);
|
|
}
|
|
|
|
static void show_registers(struct pt_regs *regs)
|
|
{
|
|
show_regs(regs);
|
|
printk(KERN_NOTICE "Process %s (pid: %d, stackpage=%08lx)\n",
|
|
current->comm, current->pid, (unsigned long) current);
|
|
show_stack(current_thread_info()->task, (long *) regs->regs[0]);
|
|
show_trace((long *) regs->regs[0]);
|
|
show_code((unsigned int *) regs->cp0_epc);
|
|
printk(KERN_NOTICE "\n");
|
|
}
|
|
|
|
void __die(const char *str, struct pt_regs *regs, const char *file,
|
|
const char *func, unsigned long line)
|
|
{
|
|
console_verbose();
|
|
printk("%s", str);
|
|
if (file && func)
|
|
printk(" in %s:%s, line %ld", file, func, line);
|
|
printk(":\n");
|
|
show_registers(regs);
|
|
do_exit(SIGSEGV);
|
|
}
|
|
|
|
void __die_if_kernel(const char *str, struct pt_regs *regs,
|
|
const char *file, const char *func, unsigned long line)
|
|
{
|
|
if (!user_mode(regs))
|
|
__die(str, regs, file, func, line);
|
|
}
|
|
|
|
asmlinkage void do_adelinsn(struct pt_regs *regs)
|
|
{
|
|
printk("do_ADE-linsn:ema:0x%08lx:epc:0x%08lx\n",
|
|
regs->cp0_ema, regs->cp0_epc);
|
|
die_if_kernel("do_ade execution Exception\n", regs);
|
|
force_sig(SIGBUS, current);
|
|
}
|
|
|
|
asmlinkage void do_adedata(struct pt_regs *regs)
|
|
{
|
|
const struct exception_table_entry *fixup;
|
|
fixup = search_exception_tables(regs->cp0_epc);
|
|
if (fixup) {
|
|
regs->cp0_epc = fixup->fixup;
|
|
return;
|
|
}
|
|
printk("do_ADE-data:ema:0x%08lx:epc:0x%08lx\n",
|
|
regs->cp0_ema, regs->cp0_epc);
|
|
die_if_kernel("do_ade execution Exception\n", regs);
|
|
force_sig(SIGBUS, current);
|
|
}
|
|
|
|
asmlinkage void do_pel(struct pt_regs *regs)
|
|
{
|
|
die_if_kernel("do_pel execution Exception", regs);
|
|
force_sig(SIGFPE, current);
|
|
}
|
|
|
|
asmlinkage void do_cee(struct pt_regs *regs)
|
|
{
|
|
die_if_kernel("do_cee execution Exception", regs);
|
|
force_sig(SIGFPE, current);
|
|
}
|
|
|
|
asmlinkage void do_cpe(struct pt_regs *regs)
|
|
{
|
|
die_if_kernel("do_cpe execution Exception", regs);
|
|
force_sig(SIGFPE, current);
|
|
}
|
|
|
|
asmlinkage void do_be(struct pt_regs *regs)
|
|
{
|
|
die_if_kernel("do_be execution Exception", regs);
|
|
force_sig(SIGBUS, current);
|
|
}
|
|
|
|
asmlinkage void do_ov(struct pt_regs *regs)
|
|
{
|
|
siginfo_t info;
|
|
|
|
die_if_kernel("do_ov execution Exception", regs);
|
|
|
|
info.si_code = FPE_INTOVF;
|
|
info.si_signo = SIGFPE;
|
|
info.si_errno = 0;
|
|
info.si_addr = (void *)regs->cp0_epc;
|
|
force_sig_info(SIGFPE, &info, current);
|
|
}
|
|
|
|
asmlinkage void do_tr(struct pt_regs *regs)
|
|
{
|
|
die_if_kernel("do_tr execution Exception", regs);
|
|
force_sig(SIGTRAP, current);
|
|
}
|
|
|
|
asmlinkage void do_ri(struct pt_regs *regs)
|
|
{
|
|
unsigned long epc_insn;
|
|
unsigned long epc = regs->cp0_epc;
|
|
|
|
read_tsk_long(current, epc, &epc_insn);
|
|
if (current->thread.single_step == 1) {
|
|
if ((epc == current->thread.addr1) ||
|
|
(epc == current->thread.addr2)) {
|
|
user_disable_single_step(current);
|
|
force_sig(SIGTRAP, current);
|
|
return;
|
|
} else
|
|
BUG();
|
|
} else if ((epc_insn == BREAKPOINT32_INSN) ||
|
|
((epc_insn & 0x0000FFFF) == 0x7002) ||
|
|
((epc_insn & 0xFFFF0000) == 0x70020000)) {
|
|
force_sig(SIGTRAP, current);
|
|
return;
|
|
} else {
|
|
die_if_kernel("do_ri execution Exception", regs);
|
|
force_sig(SIGILL, current);
|
|
}
|
|
}
|
|
|
|
asmlinkage void do_ccu(struct pt_regs *regs)
|
|
{
|
|
die_if_kernel("do_ccu execution Exception", regs);
|
|
force_sig(SIGILL, current);
|
|
}
|
|
|
|
asmlinkage void do_reserved(struct pt_regs *regs)
|
|
{
|
|
/*
|
|
* Game over - no way to handle this if it ever occurs. Most probably
|
|
* caused by a new unknown cpu type or after another deadly
|
|
* hard/software error.
|
|
*/
|
|
die_if_kernel("do_reserved execution Exception", regs);
|
|
show_regs(regs);
|
|
panic("Caught reserved exception - should not happen.");
|
|
}
|
|
|
|
/*
|
|
* NMI exception handler.
|
|
*/
|
|
void nmi_exception_handler(struct pt_regs *regs)
|
|
{
|
|
die_if_kernel("nmi_exception_handler execution Exception", regs);
|
|
die("NMI", regs);
|
|
}
|
|
|
|
/* Install CPU exception handler */
|
|
void *set_except_vector(int n, void *addr)
|
|
{
|
|
unsigned long handler = (unsigned long) addr;
|
|
unsigned long old_handler = exception_handlers[n];
|
|
|
|
exception_handlers[n] = handler;
|
|
return (void *)old_handler;
|
|
}
|
|
|
|
void __init trap_init(void)
|
|
{
|
|
int i;
|
|
|
|
pgd_current = (unsigned long)init_mm.pgd;
|
|
/* DEBUG EXCEPTION */
|
|
memcpy((void *)DEBUG_VECTOR_BASE_ADDR,
|
|
&debug_exception_vector, DEBUG_VECTOR_SIZE);
|
|
/* NMI EXCEPTION */
|
|
memcpy((void *)GENERAL_VECTOR_BASE_ADDR,
|
|
&general_exception_vector, GENERAL_VECTOR_SIZE);
|
|
|
|
/*
|
|
* Initialise exception handlers
|
|
*/
|
|
for (i = 0; i <= 31; i++)
|
|
set_except_vector(i, handle_reserved);
|
|
|
|
set_except_vector(1, handle_nmi);
|
|
set_except_vector(2, handle_adelinsn);
|
|
set_except_vector(3, handle_tlb_refill);
|
|
set_except_vector(4, handle_tlb_invaild);
|
|
set_except_vector(5, handle_ibe);
|
|
set_except_vector(6, handle_pel);
|
|
set_except_vector(7, handle_sys);
|
|
set_except_vector(8, handle_ccu);
|
|
set_except_vector(9, handle_ri);
|
|
set_except_vector(10, handle_tr);
|
|
set_except_vector(11, handle_adedata);
|
|
set_except_vector(12, handle_adedata);
|
|
set_except_vector(13, handle_tlb_refill);
|
|
set_except_vector(14, handle_tlb_invaild);
|
|
set_except_vector(15, handle_mod);
|
|
set_except_vector(16, handle_cee);
|
|
set_except_vector(17, handle_cpe);
|
|
set_except_vector(18, handle_dbe);
|
|
flush_icache_range(DEBUG_VECTOR_BASE_ADDR, IRQ_VECTOR_BASE_ADDR);
|
|
|
|
atomic_inc(&init_mm.mm_count);
|
|
current->active_mm = &init_mm;
|
|
cpu_cache_init();
|
|
}
|