c6396b48fcd2d8ea124ac7ae1d252a2896e0b2f9
2 * Traps/Non-MMU Exception handling for ARC
4 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
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 as
8 * published by the Free Software Foundation.
10 * Rahul Trivedi: Codito Technologies 2004
13 #include <linux/sched.h>
14 #include <linux/kdebug.h>
15 #include <linux/uaccess.h>
16 #include <asm/ptrace.h>
17 #include <asm/setup.h>
18 #include <asm/kprobes.h>
20 void __init
trap_init(void)
25 void die(const char *str
, struct pt_regs
*regs
, unsigned long address
,
26 unsigned long cause_reg
)
28 show_kernel_fault_diag(str
, regs
, address
, cause_reg
);
35 * Helper called for bulk of exceptions NOT needing specific handling
36 * -for user faults enqueues requested signal
37 * -for kernel, chk if due to copy_(to|from)_user, otherwise die()
39 static noinline
int handle_exception(unsigned long cause
, char *str
,
40 struct pt_regs
*regs
, siginfo_t
*info
)
42 if (user_mode(regs
)) {
43 struct task_struct
*tsk
= current
;
45 tsk
->thread
.fault_address
= (__force
unsigned int)info
->si_addr
;
46 tsk
->thread
.cause_code
= cause
;
48 force_sig_info(info
->si_signo
, info
, tsk
);
51 /* If not due to copy_(to|from)_user, we are doomed */
52 if (fixup_exception(regs
))
55 die(str
, regs
, (unsigned long)info
->si_addr
, cause
);
61 #define DO_ERROR_INFO(signr, str, name, sicode) \
62 int name(unsigned long cause, unsigned long address, struct pt_regs *regs) \
68 .si_addr = (void __user *)address, \
70 return handle_exception(cause, str, regs, &info);\
74 * Entry points for exceptions NOT needing specific handling
76 DO_ERROR_INFO(SIGILL
, "Priv Op/Disabled Extn", do_privilege_fault
, ILL_PRVOPC
)
77 DO_ERROR_INFO(SIGILL
, "Invalid Extn Insn", do_extension_fault
, ILL_ILLOPC
)
78 DO_ERROR_INFO(SIGILL
, "Illegal Insn (or Seq)", insterror_is_error
, ILL_ILLOPC
)
79 DO_ERROR_INFO(SIGBUS
, "Invalid Mem Access", do_memory_error
, BUS_ADRERR
)
80 DO_ERROR_INFO(SIGTRAP
, "Breakpoint Set", trap_is_brkpt
, TRAP_BRKPT
)
82 DO_ERROR_INFO(SIGSEGV
, "Misaligned Access", do_misaligned_access
, SEGV_ACCERR
)
85 * Entry point for miscll errors such as Nested Exceptions
86 * -Duplicate TLB entry is handled seperately though
88 void do_machine_check_fault(unsigned long cause
, unsigned long address
,
91 die("Machine Check Exception", regs
, address
, cause
);
96 * Entry point for traps induced by ARCompact TRAP_S <n> insn
97 * This is same family as TRAP0/SWI insn (use the same vector).
98 * The only difference being SWI insn take no operand, while TRAP_S does
99 * which reflects in ECR Reg as 8 bit param.
100 * Thus TRAP_S <n> can be used for specific purpose
101 * -1 used for software breakpointing (gdb)
104 void do_non_swi_trap(unsigned long cause
, unsigned long address
,
105 struct pt_regs
*regs
)
107 unsigned int param
= cause
& 0xff;
111 trap_is_brkpt(cause
, address
, regs
);
115 trap_is_kprobe(param
, address
, regs
);
124 * Entry point for Instruction Error Exception
125 * -For a corner case, ARC kprobes implementation resorts to using
126 * this exception, hence the check
128 void do_insterror_or_kprobe(unsigned long cause
,
129 unsigned long address
,
130 struct pt_regs
*regs
)
132 /* Check if this exception is caused by kprobes */
133 if (notify_die(DIE_IERR
, "kprobe_ierr", regs
, address
,
134 cause
, SIGILL
) == NOTIFY_STOP
)
137 insterror_is_error(cause
, address
, regs
);
This page took 0.06476 seconds and 4 git commands to generate.