diff options
author | Vineet Gupta <vgupta@synopsys.com> | 2013-01-18 04:42:18 -0500 |
---|---|---|
committer | Vineet Gupta <vgupta@synopsys.com> | 2013-02-11 09:30:37 -0500 |
commit | 054419ed8405da7aa93f88f698d696980efd3e37 (patch) | |
tree | 16b0376000cd0383eb8c5c064984c5c414042551 /arch/arc/kernel | |
parent | bacdf4809afade180a8f2171adb4cf7ec715d139 (diff) |
ARC: Non-MMU Exception Handling
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Diffstat (limited to 'arch/arc/kernel')
-rw-r--r-- | arch/arc/kernel/traps.c | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/arch/arc/kernel/traps.c b/arch/arc/kernel/traps.c new file mode 100644 index 000000000000..fd2457cec226 --- /dev/null +++ b/arch/arc/kernel/traps.c | |||
@@ -0,0 +1,125 @@ | |||
1 | /* | ||
2 | * Traps/Non-MMU Exception handling for ARC | ||
3 | * | ||
4 | * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) | ||
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 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | * Rahul Trivedi: Codito Technologies 2004 | ||
11 | */ | ||
12 | |||
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 | |||
19 | void __init trap_init(void) | ||
20 | { | ||
21 | return; | ||
22 | } | ||
23 | |||
24 | void die(const char *str, struct pt_regs *regs, unsigned long address, | ||
25 | unsigned long cause_reg) | ||
26 | { | ||
27 | show_kernel_fault_diag(str, regs, address, cause_reg); | ||
28 | |||
29 | /* DEAD END */ | ||
30 | __asm__("flag 1"); | ||
31 | } | ||
32 | |||
33 | /* | ||
34 | * Helper called for bulk of exceptions NOT needing specific handling | ||
35 | * -for user faults enqueues requested signal | ||
36 | * -for kernel, chk if due to copy_(to|from)_user, otherwise die() | ||
37 | */ | ||
38 | static noinline int handle_exception(unsigned long cause, char *str, | ||
39 | struct pt_regs *regs, siginfo_t *info) | ||
40 | { | ||
41 | if (user_mode(regs)) { | ||
42 | struct task_struct *tsk = current; | ||
43 | |||
44 | tsk->thread.fault_address = (__force unsigned int)info->si_addr; | ||
45 | tsk->thread.cause_code = cause; | ||
46 | |||
47 | force_sig_info(info->si_signo, info, tsk); | ||
48 | |||
49 | } else { | ||
50 | /* If not due to copy_(to|from)_user, we are doomed */ | ||
51 | if (fixup_exception(regs)) | ||
52 | return 0; | ||
53 | |||
54 | die(str, regs, (unsigned long)info->si_addr, cause); | ||
55 | } | ||
56 | |||
57 | return 1; | ||
58 | } | ||
59 | |||
60 | #define DO_ERROR_INFO(signr, str, name, sicode) \ | ||
61 | int name(unsigned long cause, unsigned long address, struct pt_regs *regs) \ | ||
62 | { \ | ||
63 | siginfo_t info = { \ | ||
64 | .si_signo = signr, \ | ||
65 | .si_errno = 0, \ | ||
66 | .si_code = sicode, \ | ||
67 | .si_addr = (void __user *)address, \ | ||
68 | }; \ | ||
69 | return handle_exception(cause, str, regs, &info);\ | ||
70 | } | ||
71 | |||
72 | /* | ||
73 | * Entry points for exceptions NOT needing specific handling | ||
74 | */ | ||
75 | DO_ERROR_INFO(SIGILL, "Priv Op/Disabled Extn", do_privilege_fault, ILL_PRVOPC) | ||
76 | DO_ERROR_INFO(SIGILL, "Invalid Extn Insn", do_extension_fault, ILL_ILLOPC) | ||
77 | DO_ERROR_INFO(SIGILL, "Illegal Insn (or Seq)", insterror_is_error, ILL_ILLOPC) | ||
78 | DO_ERROR_INFO(SIGBUS, "Invalid Mem Access", do_memory_error, BUS_ADRERR) | ||
79 | DO_ERROR_INFO(SIGTRAP, "Breakpoint Set", trap_is_brkpt, TRAP_BRKPT) | ||
80 | |||
81 | DO_ERROR_INFO(SIGSEGV, "Misaligned Access", do_misaligned_access, SEGV_ACCERR) | ||
82 | |||
83 | /* | ||
84 | * Entry point for miscll errors such as Nested Exceptions | ||
85 | * -Duplicate TLB entry is handled seperately though | ||
86 | */ | ||
87 | void do_machine_check_fault(unsigned long cause, unsigned long address, | ||
88 | struct pt_regs *regs) | ||
89 | { | ||
90 | die("Machine Check Exception", regs, address, cause); | ||
91 | } | ||
92 | |||
93 | /* | ||
94 | * Entry point for traps induced by ARCompact TRAP_S <n> insn | ||
95 | * This is same family as TRAP0/SWI insn (use the same vector). | ||
96 | * The only difference being SWI insn take no operand, while TRAP_S does | ||
97 | * which reflects in ECR Reg as 8 bit param. | ||
98 | * Thus TRAP_S <n> can be used for specific purpose | ||
99 | * -1 used for software breakpointing (gdb) | ||
100 | * -2 used by kprobes | ||
101 | */ | ||
102 | void do_non_swi_trap(unsigned long cause, unsigned long address, | ||
103 | struct pt_regs *regs) | ||
104 | { | ||
105 | unsigned int param = cause & 0xff; | ||
106 | |||
107 | switch (param) { | ||
108 | case 1: | ||
109 | trap_is_brkpt(cause, address, regs); | ||
110 | break; | ||
111 | |||
112 | default: | ||
113 | break; | ||
114 | } | ||
115 | } | ||
116 | |||
117 | /* | ||
118 | * Entry point for Instruction Error Exception | ||
119 | */ | ||
120 | void do_insterror_or_kprobe(unsigned long cause, | ||
121 | unsigned long address, | ||
122 | struct pt_regs *regs) | ||
123 | { | ||
124 | insterror_is_error(cause, address, regs); | ||
125 | } | ||