2005-06-24 05:01:16 +00:00
|
|
|
/*
|
|
|
|
* arch/xtensa/kernel/traps.c
|
|
|
|
*
|
|
|
|
* Exception handling.
|
|
|
|
*
|
|
|
|
* Derived from code with the following copyrights:
|
|
|
|
* Copyright (C) 1994 - 1999 by Ralf Baechle
|
|
|
|
* Modified for R3000 by Paul M. Antoine, 1995, 1996
|
|
|
|
* Complete output from die() by Ulf Carlsson, 1998
|
|
|
|
* Copyright (C) 1999 Silicon Graphics, Inc.
|
|
|
|
*
|
|
|
|
* Essentially rewritten for the Xtensa architecture port.
|
|
|
|
*
|
2013-04-15 05:20:48 +00:00
|
|
|
* Copyright (C) 2001 - 2013 Tensilica Inc.
|
2005-06-24 05:01:16 +00:00
|
|
|
*
|
|
|
|
* Joe Taylor <joe@tensilica.com, joetylr@yahoo.com>
|
|
|
|
* Chris Zankel <chris@zankel.net>
|
|
|
|
* Marc Gauthier<marc@tensilica.com, marc@alumni.uwaterloo.ca>
|
|
|
|
* Kevin Chea
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/stringify.h>
|
|
|
|
#include <linux/kallsyms.h>
|
2005-07-12 20:58:26 +00:00
|
|
|
#include <linux/delay.h>
|
2009-03-10 19:55:49 +00:00
|
|
|
#include <linux/hardirq.h>
|
2005-06-24 05:01:16 +00:00
|
|
|
|
2013-04-15 05:20:48 +00:00
|
|
|
#include <asm/stacktrace.h>
|
2005-06-24 05:01:16 +00:00
|
|
|
#include <asm/ptrace.h>
|
|
|
|
#include <asm/timex.h>
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include <asm/pgtable.h>
|
|
|
|
#include <asm/processor.h>
|
2013-02-03 01:39:22 +00:00
|
|
|
#include <asm/traps.h>
|
2005-06-24 05:01:16 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_KGDB
|
|
|
|
extern int gdb_enter;
|
|
|
|
extern int return_from_debug_flag;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Machine specific interrupt handlers
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern void kernel_exception(void);
|
|
|
|
extern void user_exception(void);
|
|
|
|
|
|
|
|
extern void fast_syscall_kernel(void);
|
|
|
|
extern void fast_syscall_user(void);
|
|
|
|
extern void fast_alloca(void);
|
|
|
|
extern void fast_unaligned(void);
|
|
|
|
extern void fast_second_level_miss(void);
|
|
|
|
extern void fast_store_prohibited(void);
|
|
|
|
extern void fast_coprocessor(void);
|
|
|
|
|
|
|
|
extern void do_illegal_instruction (struct pt_regs*);
|
|
|
|
extern void do_interrupt (struct pt_regs*);
|
2015-07-16 07:37:31 +00:00
|
|
|
extern void do_nmi(struct pt_regs *);
|
2005-06-24 05:01:16 +00:00
|
|
|
extern void do_unaligned_user (struct pt_regs*);
|
|
|
|
extern void do_multihit (struct pt_regs*, unsigned long);
|
|
|
|
extern void do_page_fault (struct pt_regs*, unsigned long);
|
|
|
|
extern void do_debug (struct pt_regs*);
|
|
|
|
extern void system_call (struct pt_regs*);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The vector table must be preceded by a save area (which
|
|
|
|
* implies it must be in RAM, unless one places RAM immediately
|
|
|
|
* before a ROM and puts the vector at the start of the ROM (!))
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define KRNL 0x01
|
|
|
|
#define USER 0x02
|
|
|
|
|
|
|
|
#define COPROCESSOR(x) \
|
2006-12-10 10:18:48 +00:00
|
|
|
{ EXCCAUSE_COPROCESSOR ## x ## _DISABLED, USER, fast_coprocessor }
|
2005-06-24 05:01:16 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int cause;
|
|
|
|
int fast;
|
|
|
|
void* handler;
|
|
|
|
} dispatch_init_table_t;
|
|
|
|
|
2007-08-03 22:54:36 +00:00
|
|
|
static dispatch_init_table_t __initdata dispatch_init_table[] = {
|
2005-06-24 05:01:16 +00:00
|
|
|
|
2006-12-10 10:18:48 +00:00
|
|
|
{ EXCCAUSE_ILLEGAL_INSTRUCTION, 0, do_illegal_instruction},
|
|
|
|
{ EXCCAUSE_SYSTEM_CALL, KRNL, fast_syscall_kernel },
|
|
|
|
{ EXCCAUSE_SYSTEM_CALL, USER, fast_syscall_user },
|
|
|
|
{ EXCCAUSE_SYSTEM_CALL, 0, system_call },
|
|
|
|
/* EXCCAUSE_INSTRUCTION_FETCH unhandled */
|
|
|
|
/* EXCCAUSE_LOAD_STORE_ERROR unhandled*/
|
|
|
|
{ EXCCAUSE_LEVEL1_INTERRUPT, 0, do_interrupt },
|
|
|
|
{ EXCCAUSE_ALLOCA, USER|KRNL, fast_alloca },
|
|
|
|
/* EXCCAUSE_INTEGER_DIVIDE_BY_ZERO unhandled */
|
|
|
|
/* EXCCAUSE_PRIVILEGED unhandled */
|
2005-06-24 05:01:16 +00:00
|
|
|
#if XCHAL_UNALIGNED_LOAD_EXCEPTION || XCHAL_UNALIGNED_STORE_EXCEPTION
|
2012-10-15 17:23:02 +00:00
|
|
|
#ifdef CONFIG_XTENSA_UNALIGNED_USER
|
2006-12-10 10:18:48 +00:00
|
|
|
{ EXCCAUSE_UNALIGNED, USER, fast_unaligned },
|
2005-06-24 05:01:16 +00:00
|
|
|
#endif
|
2014-08-06 21:03:01 +00:00
|
|
|
{ EXCCAUSE_UNALIGNED, 0, do_unaligned_user },
|
2006-12-10 10:18:48 +00:00
|
|
|
{ EXCCAUSE_UNALIGNED, KRNL, fast_unaligned },
|
2005-06-24 05:01:16 +00:00
|
|
|
#endif
|
2009-03-04 15:21:31 +00:00
|
|
|
#ifdef CONFIG_MMU
|
2006-12-10 10:18:48 +00:00
|
|
|
{ EXCCAUSE_ITLB_MISS, 0, do_page_fault },
|
|
|
|
{ EXCCAUSE_ITLB_MISS, USER|KRNL, fast_second_level_miss},
|
|
|
|
{ EXCCAUSE_ITLB_MULTIHIT, 0, do_multihit },
|
|
|
|
{ EXCCAUSE_ITLB_PRIVILEGE, 0, do_page_fault },
|
|
|
|
/* EXCCAUSE_SIZE_RESTRICTION unhandled */
|
|
|
|
{ EXCCAUSE_FETCH_CACHE_ATTRIBUTE, 0, do_page_fault },
|
|
|
|
{ EXCCAUSE_DTLB_MISS, USER|KRNL, fast_second_level_miss},
|
|
|
|
{ EXCCAUSE_DTLB_MISS, 0, do_page_fault },
|
|
|
|
{ EXCCAUSE_DTLB_MULTIHIT, 0, do_multihit },
|
|
|
|
{ EXCCAUSE_DTLB_PRIVILEGE, 0, do_page_fault },
|
|
|
|
/* EXCCAUSE_DTLB_SIZE_RESTRICTION unhandled */
|
|
|
|
{ EXCCAUSE_STORE_CACHE_ATTRIBUTE, USER|KRNL, fast_store_prohibited },
|
|
|
|
{ EXCCAUSE_STORE_CACHE_ATTRIBUTE, 0, do_page_fault },
|
|
|
|
{ EXCCAUSE_LOAD_CACHE_ATTRIBUTE, 0, do_page_fault },
|
2009-03-04 15:21:31 +00:00
|
|
|
#endif /* CONFIG_MMU */
|
2005-06-24 05:01:16 +00:00
|
|
|
/* XCCHAL_EXCCAUSE_FLOATING_POINT unhandled */
|
2008-02-12 21:17:07 +00:00
|
|
|
#if XTENSA_HAVE_COPROCESSOR(0)
|
2005-06-24 05:01:16 +00:00
|
|
|
COPROCESSOR(0),
|
|
|
|
#endif
|
2008-02-12 21:17:07 +00:00
|
|
|
#if XTENSA_HAVE_COPROCESSOR(1)
|
2005-06-24 05:01:16 +00:00
|
|
|
COPROCESSOR(1),
|
|
|
|
#endif
|
2008-02-12 21:17:07 +00:00
|
|
|
#if XTENSA_HAVE_COPROCESSOR(2)
|
2005-06-24 05:01:16 +00:00
|
|
|
COPROCESSOR(2),
|
|
|
|
#endif
|
2008-02-12 21:17:07 +00:00
|
|
|
#if XTENSA_HAVE_COPROCESSOR(3)
|
2005-06-24 05:01:16 +00:00
|
|
|
COPROCESSOR(3),
|
|
|
|
#endif
|
2008-02-12 21:17:07 +00:00
|
|
|
#if XTENSA_HAVE_COPROCESSOR(4)
|
2005-06-24 05:01:16 +00:00
|
|
|
COPROCESSOR(4),
|
|
|
|
#endif
|
2008-02-12 21:17:07 +00:00
|
|
|
#if XTENSA_HAVE_COPROCESSOR(5)
|
2005-06-24 05:01:16 +00:00
|
|
|
COPROCESSOR(5),
|
|
|
|
#endif
|
2008-02-12 21:17:07 +00:00
|
|
|
#if XTENSA_HAVE_COPROCESSOR(6)
|
2005-06-24 05:01:16 +00:00
|
|
|
COPROCESSOR(6),
|
|
|
|
#endif
|
2008-02-12 21:17:07 +00:00
|
|
|
#if XTENSA_HAVE_COPROCESSOR(7)
|
2005-06-24 05:01:16 +00:00
|
|
|
COPROCESSOR(7),
|
|
|
|
#endif
|
2015-07-16 07:37:31 +00:00
|
|
|
#if XTENSA_FAKE_NMI
|
|
|
|
{ EXCCAUSE_MAPPED_NMI, 0, do_nmi },
|
|
|
|
#endif
|
2005-06-24 05:01:16 +00:00
|
|
|
{ EXCCAUSE_MAPPED_DEBUG, 0, do_debug },
|
|
|
|
{ -1, -1, 0 }
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/* The exception table <exc_table> serves two functions:
|
|
|
|
* 1. it contains three dispatch tables (fast_user, fast_kernel, default-c)
|
|
|
|
* 2. it is a temporary memory buffer for the exception handlers.
|
|
|
|
*/
|
|
|
|
|
2013-10-16 22:42:26 +00:00
|
|
|
DEFINE_PER_CPU(unsigned long, exc_table[EXC_TABLE_SIZE/4]);
|
2005-06-24 05:01:16 +00:00
|
|
|
|
|
|
|
void die(const char*, struct pt_regs*, long);
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
__die_if_kernel(const char *str, struct pt_regs *regs, long err)
|
|
|
|
{
|
|
|
|
if (!user_mode(regs))
|
|
|
|
die(str, regs, err);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Unhandled Exceptions. Kill user task or panic if in kernel space.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void do_unhandled(struct pt_regs *regs, unsigned long exccause)
|
|
|
|
{
|
|
|
|
__die_if_kernel("Caught unhandled exception - should not happen",
|
|
|
|
regs, SIGKILL);
|
|
|
|
|
|
|
|
/* If in user mode, send SIGILL signal to current process */
|
|
|
|
printk("Caught unhandled exception in '%s' "
|
|
|
|
"(pid = %d, pc = %#010lx) - should not happen\n"
|
|
|
|
"\tEXCCAUSE is %ld\n",
|
2007-10-19 06:40:41 +00:00
|
|
|
current->comm, task_pid_nr(current), regs->pc, exccause);
|
2005-06-24 05:01:16 +00:00
|
|
|
force_sig(SIGILL, current);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Multi-hit exception. This if fatal!
|
|
|
|
*/
|
|
|
|
|
|
|
|
void do_multihit(struct pt_regs *regs, unsigned long exccause)
|
|
|
|
{
|
|
|
|
die("Caught multihit exception", regs, SIGKILL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2013-01-05 00:57:17 +00:00
|
|
|
* IRQ handler.
|
2005-06-24 05:01:16 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
extern void do_IRQ(int, struct pt_regs *);
|
|
|
|
|
2015-07-16 07:37:31 +00:00
|
|
|
#if XTENSA_FAKE_NMI
|
|
|
|
|
|
|
|
irqreturn_t xtensa_pmu_irq_handler(int irq, void *dev_id);
|
|
|
|
|
|
|
|
DEFINE_PER_CPU(unsigned long, nmi_count);
|
|
|
|
|
|
|
|
void do_nmi(struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
struct pt_regs *old_regs;
|
|
|
|
|
|
|
|
if ((regs->ps & PS_INTLEVEL_MASK) < LOCKLEVEL)
|
|
|
|
trace_hardirqs_off();
|
|
|
|
|
|
|
|
old_regs = set_irq_regs(regs);
|
|
|
|
nmi_enter();
|
|
|
|
++*this_cpu_ptr(&nmi_count);
|
|
|
|
xtensa_pmu_irq_handler(0, NULL);
|
|
|
|
nmi_exit();
|
|
|
|
set_irq_regs(old_regs);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-01-05 00:57:17 +00:00
|
|
|
void do_interrupt(struct pt_regs *regs)
|
2005-06-24 05:01:16 +00:00
|
|
|
{
|
2013-01-05 00:57:17 +00:00
|
|
|
static const unsigned int_level_mask[] = {
|
|
|
|
0,
|
|
|
|
XCHAL_INTLEVEL1_MASK,
|
|
|
|
XCHAL_INTLEVEL2_MASK,
|
|
|
|
XCHAL_INTLEVEL3_MASK,
|
|
|
|
XCHAL_INTLEVEL4_MASK,
|
|
|
|
XCHAL_INTLEVEL5_MASK,
|
|
|
|
XCHAL_INTLEVEL6_MASK,
|
|
|
|
XCHAL_INTLEVEL7_MASK,
|
|
|
|
};
|
2015-07-16 03:18:46 +00:00
|
|
|
struct pt_regs *old_regs;
|
2013-10-16 22:42:23 +00:00
|
|
|
|
2015-07-16 03:18:46 +00:00
|
|
|
trace_hardirqs_off();
|
|
|
|
|
|
|
|
old_regs = set_irq_regs(regs);
|
2013-10-16 22:42:23 +00:00
|
|
|
irq_enter();
|
2005-06-24 05:01:16 +00:00
|
|
|
|
2013-01-05 00:57:17 +00:00
|
|
|
for (;;) {
|
|
|
|
unsigned intread = get_sr(interrupt);
|
|
|
|
unsigned intenable = get_sr(intenable);
|
2013-03-25 22:51:43 +00:00
|
|
|
unsigned int_at_level = intread & intenable;
|
|
|
|
unsigned level;
|
|
|
|
|
|
|
|
for (level = LOCKLEVEL; level > 0; --level) {
|
|
|
|
if (int_at_level & int_level_mask[level]) {
|
|
|
|
int_at_level &= int_level_mask[level];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-01-05 00:57:17 +00:00
|
|
|
|
2013-03-25 22:51:43 +00:00
|
|
|
if (level == 0)
|
2013-10-16 22:42:23 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
do_IRQ(__ffs(int_at_level), regs);
|
2005-06-24 05:01:16 +00:00
|
|
|
}
|
2013-10-16 22:42:23 +00:00
|
|
|
|
|
|
|
irq_exit();
|
|
|
|
set_irq_regs(old_regs);
|
2005-06-24 05:01:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Illegal instruction. Fatal if in kernel space.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
do_illegal_instruction(struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
__die_if_kernel("Illegal instruction in kernel", regs, SIGKILL);
|
|
|
|
|
|
|
|
/* If in user mode, send SIGILL signal to current process. */
|
|
|
|
|
|
|
|
printk("Illegal Instruction in '%s' (pid = %d, pc = %#010lx)\n",
|
2007-10-19 06:40:41 +00:00
|
|
|
current->comm, task_pid_nr(current), regs->pc);
|
2005-06-24 05:01:16 +00:00
|
|
|
force_sig(SIGILL, current);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle unaligned memory accesses from user space. Kill task.
|
|
|
|
*
|
|
|
|
* If CONFIG_UNALIGNED_USER is not set, we don't allow unaligned memory
|
|
|
|
* accesses causes from user space.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if XCHAL_UNALIGNED_LOAD_EXCEPTION || XCHAL_UNALIGNED_STORE_EXCEPTION
|
|
|
|
void
|
|
|
|
do_unaligned_user (struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
siginfo_t info;
|
|
|
|
|
|
|
|
__die_if_kernel("Unhandled unaligned exception in kernel",
|
|
|
|
regs, SIGKILL);
|
|
|
|
|
|
|
|
current->thread.bad_vaddr = regs->excvaddr;
|
|
|
|
current->thread.error_code = -3;
|
|
|
|
printk("Unaligned memory access to %08lx in '%s' "
|
|
|
|
"(pid = %d, pc = %#010lx)\n",
|
2007-10-19 06:40:41 +00:00
|
|
|
regs->excvaddr, current->comm, task_pid_nr(current), regs->pc);
|
2005-06-24 05:01:16 +00:00
|
|
|
info.si_signo = SIGBUS;
|
|
|
|
info.si_errno = 0;
|
|
|
|
info.si_code = BUS_ADRALN;
|
|
|
|
info.si_addr = (void *) regs->excvaddr;
|
|
|
|
force_sig_info(SIGSEGV, &info, current);
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void
|
|
|
|
do_debug(struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_KGDB
|
|
|
|
/* If remote debugging is configured AND enabled, we give control to
|
|
|
|
* kgdb. Otherwise, we fall through, perhaps giving control to the
|
|
|
|
* native debugger.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (gdb_enter) {
|
|
|
|
extern void gdb_handle_exception(struct pt_regs *);
|
|
|
|
gdb_handle_exception(regs);
|
|
|
|
return_from_debug_flag = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
__die_if_kernel("Breakpoint in kernel", regs, SIGKILL);
|
|
|
|
|
|
|
|
/* If in user mode, send SIGTRAP signal to current process */
|
|
|
|
|
|
|
|
force_sig(SIGTRAP, current);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-16 22:42:26 +00:00
|
|
|
static void set_handler(int idx, void *handler)
|
|
|
|
{
|
|
|
|
unsigned int cpu;
|
|
|
|
|
|
|
|
for_each_possible_cpu(cpu)
|
|
|
|
per_cpu(exc_table, cpu)[idx] = (unsigned long)handler;
|
|
|
|
}
|
|
|
|
|
2012-11-19 04:30:15 +00:00
|
|
|
/* Set exception C handler - for temporary use when probing exceptions */
|
|
|
|
|
|
|
|
void * __init trap_set_handler(int cause, void *handler)
|
|
|
|
{
|
2013-10-16 22:42:26 +00:00
|
|
|
void *previous = (void *)per_cpu(exc_table, 0)[
|
|
|
|
EXC_TABLE_DEFAULT / 4 + cause];
|
|
|
|
set_handler(EXC_TABLE_DEFAULT / 4 + cause, handler);
|
2012-11-19 04:30:15 +00:00
|
|
|
return previous;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-16 22:42:28 +00:00
|
|
|
static void trap_init_excsave(void)
|
2013-10-16 22:42:26 +00:00
|
|
|
{
|
|
|
|
unsigned long excsave1 = (unsigned long)this_cpu_ptr(exc_table);
|
|
|
|
__asm__ __volatile__("wsr %0, excsave1\n" : : "a" (excsave1));
|
|
|
|
}
|
|
|
|
|
2005-06-24 05:01:16 +00:00
|
|
|
/*
|
|
|
|
* Initialize dispatch tables.
|
|
|
|
*
|
|
|
|
* The exception vectors are stored compressed the __init section in the
|
|
|
|
* dispatch_init_table. This function initializes the following three tables
|
|
|
|
* from that compressed table:
|
|
|
|
* - fast user first dispatch table for user exceptions
|
|
|
|
* - fast kernel first dispatch table for kernel exceptions
|
|
|
|
* - default C-handler C-handler called by the default fast handler.
|
|
|
|
*
|
|
|
|
* See vectors.S for more details.
|
|
|
|
*/
|
|
|
|
|
2007-08-03 22:54:36 +00:00
|
|
|
void __init trap_init(void)
|
2005-06-24 05:01:16 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Setup default vectors. */
|
|
|
|
|
|
|
|
for(i = 0; i < 64; i++) {
|
|
|
|
set_handler(EXC_TABLE_FAST_USER/4 + i, user_exception);
|
|
|
|
set_handler(EXC_TABLE_FAST_KERNEL/4 + i, kernel_exception);
|
|
|
|
set_handler(EXC_TABLE_DEFAULT/4 + i, do_unhandled);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Setup specific handlers. */
|
|
|
|
|
|
|
|
for(i = 0; dispatch_init_table[i].cause >= 0; i++) {
|
|
|
|
|
|
|
|
int fast = dispatch_init_table[i].fast;
|
|
|
|
int cause = dispatch_init_table[i].cause;
|
|
|
|
void *handler = dispatch_init_table[i].handler;
|
|
|
|
|
|
|
|
if (fast == 0)
|
|
|
|
set_handler (EXC_TABLE_DEFAULT/4 + cause, handler);
|
|
|
|
if (fast && fast & USER)
|
|
|
|
set_handler (EXC_TABLE_FAST_USER/4 + cause, handler);
|
|
|
|
if (fast && fast & KRNL)
|
|
|
|
set_handler (EXC_TABLE_FAST_KERNEL/4 + cause, handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize EXCSAVE_1 to hold the address of the exception table. */
|
2013-10-16 22:42:26 +00:00
|
|
|
trap_init_excsave();
|
|
|
|
}
|
2005-06-24 05:01:16 +00:00
|
|
|
|
2013-10-16 22:42:26 +00:00
|
|
|
#ifdef CONFIG_SMP
|
2013-10-16 22:42:28 +00:00
|
|
|
void secondary_trap_init(void)
|
2013-10-16 22:42:26 +00:00
|
|
|
{
|
|
|
|
trap_init_excsave();
|
2005-06-24 05:01:16 +00:00
|
|
|
}
|
2013-10-16 22:42:26 +00:00
|
|
|
#endif
|
2005-06-24 05:01:16 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This function dumps the current valid window frame and other base registers.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void show_regs(struct pt_regs * regs)
|
|
|
|
{
|
|
|
|
int i, wmask;
|
|
|
|
|
dump_stack: unify debug information printed by show_regs()
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>
2013-04-30 22:27:17 +00:00
|
|
|
show_regs_print_info(KERN_DEFAULT);
|
|
|
|
|
2005-06-24 05:01:16 +00:00
|
|
|
wmask = regs->wmask & ~1;
|
|
|
|
|
2008-02-12 19:55:32 +00:00
|
|
|
for (i = 0; i < 16; i++) {
|
2005-06-24 05:01:16 +00:00
|
|
|
if ((i % 8) == 0)
|
2009-07-06 20:05:40 +00:00
|
|
|
printk(KERN_INFO "a%02d:", i);
|
|
|
|
printk(KERN_CONT " %08lx", regs->areg[i]);
|
2005-06-24 05:01:16 +00:00
|
|
|
}
|
2009-07-06 20:05:40 +00:00
|
|
|
printk(KERN_CONT "\n");
|
2005-06-24 05:01:16 +00:00
|
|
|
|
|
|
|
printk("pc: %08lx, ps: %08lx, depc: %08lx, excvaddr: %08lx\n",
|
|
|
|
regs->pc, regs->ps, regs->depc, regs->excvaddr);
|
|
|
|
printk("lbeg: %08lx, lend: %08lx lcount: %08lx, sar: %08lx\n",
|
|
|
|
regs->lbeg, regs->lend, regs->lcount, regs->sar);
|
|
|
|
if (user_mode(regs))
|
|
|
|
printk("wb: %08lx, ws: %08lx, wmask: %08lx, syscall: %ld\n",
|
|
|
|
regs->windowbase, regs->windowstart, regs->wmask,
|
|
|
|
regs->syscall);
|
|
|
|
}
|
|
|
|
|
2013-04-15 05:20:48 +00:00
|
|
|
static int show_trace_cb(struct stackframe *frame, void *data)
|
2009-05-11 13:43:33 +00:00
|
|
|
{
|
2013-04-15 05:20:48 +00:00
|
|
|
if (kernel_text_address(frame->pc)) {
|
|
|
|
printk(" [<%08lx>] ", frame->pc);
|
|
|
|
print_symbol("%s\n", frame->pc);
|
|
|
|
}
|
|
|
|
return 0;
|
2009-05-11 13:43:33 +00:00
|
|
|
}
|
|
|
|
|
2005-06-24 05:01:16 +00:00
|
|
|
void show_trace(struct task_struct *task, unsigned long *sp)
|
|
|
|
{
|
2013-04-15 05:20:48 +00:00
|
|
|
if (!sp)
|
|
|
|
sp = stack_pointer(task);
|
2005-06-24 05:01:16 +00:00
|
|
|
|
|
|
|
printk("Call Trace:");
|
|
|
|
#ifdef CONFIG_KALLSYMS
|
|
|
|
printk("\n");
|
|
|
|
#endif
|
2013-04-15 05:20:48 +00:00
|
|
|
walk_stackframe(sp, show_trace_cb, NULL);
|
2005-06-24 05:01:16 +00:00
|
|
|
printk("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This routine abuses get_user()/put_user() to reference pointers
|
|
|
|
* with at least a bit of error checking ...
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int kstack_depth_to_print = 24;
|
|
|
|
|
|
|
|
void show_stack(struct task_struct *task, unsigned long *sp)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
unsigned long *stack;
|
|
|
|
|
2009-03-04 15:21:29 +00:00
|
|
|
if (!sp)
|
2009-05-11 13:43:33 +00:00
|
|
|
sp = stack_pointer(task);
|
2012-11-29 00:53:51 +00:00
|
|
|
stack = sp;
|
2005-06-24 05:01:16 +00:00
|
|
|
|
|
|
|
printk("\nStack: ");
|
|
|
|
|
|
|
|
for (i = 0; i < kstack_depth_to_print; i++) {
|
|
|
|
if (kstack_end(sp))
|
|
|
|
break;
|
|
|
|
if (i && ((i % 8) == 0))
|
|
|
|
printk("\n ");
|
|
|
|
printk("%08lx ", *sp++);
|
|
|
|
}
|
|
|
|
printk("\n");
|
|
|
|
show_trace(task, stack);
|
|
|
|
}
|
|
|
|
|
|
|
|
void show_code(unsigned int *pc)
|
|
|
|
{
|
|
|
|
long i;
|
|
|
|
|
|
|
|
printk("\nCode:");
|
|
|
|
|
|
|
|
for(i = -3 ; i < 6 ; i++) {
|
|
|
|
unsigned long insn;
|
|
|
|
if (__get_user(insn, pc + i)) {
|
|
|
|
printk(" (Bad address in pc)\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
printk("%c%08lx%c",(i?' ':'<'),insn,(i?' ':'>'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-27 09:53:55 +00:00
|
|
|
DEFINE_SPINLOCK(die_lock);
|
2005-06-24 05:01:16 +00:00
|
|
|
|
|
|
|
void die(const char * str, struct pt_regs * regs, long err)
|
|
|
|
{
|
|
|
|
static int die_counter;
|
|
|
|
int nl = 0;
|
|
|
|
|
|
|
|
console_verbose();
|
|
|
|
spin_lock_irq(&die_lock);
|
|
|
|
|
|
|
|
printk("%s: sig: %ld [#%d]\n", str, err, ++die_counter);
|
|
|
|
#ifdef CONFIG_PREEMPT
|
|
|
|
printk("PREEMPT ");
|
|
|
|
nl = 1;
|
|
|
|
#endif
|
|
|
|
if (nl)
|
|
|
|
printk("\n");
|
|
|
|
show_regs(regs);
|
|
|
|
if (!user_mode(regs))
|
|
|
|
show_stack(NULL, (unsigned long*)regs->areg[1]);
|
|
|
|
|
2013-01-21 06:47:39 +00:00
|
|
|
add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
|
2005-06-24 05:01:16 +00:00
|
|
|
spin_unlock_irq(&die_lock);
|
|
|
|
|
|
|
|
if (in_interrupt())
|
|
|
|
panic("Fatal exception in interrupt");
|
|
|
|
|
2006-07-30 10:03:34 +00:00
|
|
|
if (panic_on_oops)
|
2006-08-14 06:24:22 +00:00
|
|
|
panic("Fatal exception");
|
2006-07-30 10:03:34 +00:00
|
|
|
|
2005-06-24 05:01:16 +00:00
|
|
|
do_exit(err);
|
|
|
|
}
|