Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2010 Tilera Corporation. All Rights Reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation, version 2. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, but |
| 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or |
| 11 | * NON INFRINGEMENT. See the GNU General Public License for |
| 12 | * more details. |
| 13 | */ |
| 14 | |
| 15 | #include <linux/sched.h> |
| 16 | #include <linux/kernel.h> |
| 17 | #include <linux/kprobes.h> |
Tony Lu | 3fa17c3 | 2013-08-09 15:08:57 -0400 | [diff] [blame] | 18 | #include <linux/kdebug.h> |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 19 | #include <linux/module.h> |
| 20 | #include <linux/reboot.h> |
| 21 | #include <linux/uaccess.h> |
| 22 | #include <linux/ptrace.h> |
Chris Metcalf | 0707ad3 | 2010-06-25 17:04:17 -0400 | [diff] [blame] | 23 | #include <asm/stack.h> |
| 24 | #include <asm/traps.h> |
David Howells | bd119c69 | 2012-03-28 18:30:03 +0100 | [diff] [blame] | 25 | #include <asm/setup.h> |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 26 | |
| 27 | #include <arch/interrupts.h> |
| 28 | #include <arch/spr_def.h> |
Chris Metcalf | eb7c792 | 2011-11-02 23:02:17 -0400 | [diff] [blame] | 29 | #include <arch/opcode.h> |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 30 | |
| 31 | void __init trap_init(void) |
| 32 | { |
Chris Metcalf | acbde1d | 2013-09-03 14:41:36 -0400 | [diff] [blame] | 33 | /* Nothing needed here since we link code at .intrpt */ |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | int unaligned_fixup = 1; |
| 37 | |
| 38 | static int __init setup_unaligned_fixup(char *str) |
| 39 | { |
| 40 | /* |
| 41 | * Say "=-1" to completely disable it. If you just do "=0", we |
| 42 | * will still parse the instruction, then fire a SIGBUS with |
| 43 | * the correct address from inside the single_step code. |
| 44 | */ |
Daniel Walter | b2dfa04 | 2014-05-26 22:59:32 +0100 | [diff] [blame] | 45 | if (kstrtoint(str, 0, &unaligned_fixup) != 0) |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 46 | return 0; |
Daniel Walter | b2dfa04 | 2014-05-26 22:59:32 +0100 | [diff] [blame] | 47 | |
Chris Metcalf | 0707ad3 | 2010-06-25 17:04:17 -0400 | [diff] [blame] | 48 | pr_info("Fixups for unaligned data accesses are %s\n", |
Joe Perches | f474367 | 2014-10-31 10:50:46 -0700 | [diff] [blame] | 49 | unaligned_fixup >= 0 ? |
| 50 | (unaligned_fixup ? "enabled" : "disabled") : |
| 51 | "completely disabled"); |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 52 | return 1; |
| 53 | } |
| 54 | __setup("unaligned_fixup=", setup_unaligned_fixup); |
| 55 | |
| 56 | #if CHIP_HAS_TILE_DMA() |
| 57 | |
| 58 | static int dma_disabled; |
| 59 | |
| 60 | static int __init nodma(char *str) |
| 61 | { |
Chris Metcalf | 0707ad3 | 2010-06-25 17:04:17 -0400 | [diff] [blame] | 62 | pr_info("User-space DMA is disabled\n"); |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 63 | dma_disabled = 1; |
| 64 | return 1; |
| 65 | } |
| 66 | __setup("nodma", nodma); |
| 67 | |
| 68 | /* How to decode SPR_GPV_REASON */ |
| 69 | #define IRET_ERROR (1U << 31) |
| 70 | #define MT_ERROR (1U << 30) |
| 71 | #define MF_ERROR (1U << 29) |
| 72 | #define SPR_INDEX ((1U << 15) - 1) |
| 73 | #define SPR_MPL_SHIFT 9 /* starting bit position for MPL encoded in SPR */ |
| 74 | |
| 75 | /* |
| 76 | * See if this GPV is just to notify the kernel of SPR use and we can |
| 77 | * retry the user instruction after adjusting some MPLs suitably. |
| 78 | */ |
| 79 | static int retry_gpv(unsigned int gpv_reason) |
| 80 | { |
| 81 | int mpl; |
| 82 | |
| 83 | if (gpv_reason & IRET_ERROR) |
| 84 | return 0; |
| 85 | |
| 86 | BUG_ON((gpv_reason & (MT_ERROR|MF_ERROR)) == 0); |
| 87 | mpl = (gpv_reason & SPR_INDEX) >> SPR_MPL_SHIFT; |
| 88 | if (mpl == INT_DMA_NOTIFY && !dma_disabled) { |
| 89 | /* User is turning on DMA. Allow it and retry. */ |
| 90 | printk(KERN_DEBUG "Process %d/%s is now enabled for DMA\n", |
| 91 | current->pid, current->comm); |
| 92 | BUG_ON(current->thread.tile_dma_state.enabled); |
| 93 | current->thread.tile_dma_state.enabled = 1; |
| 94 | grant_dma_mpls(); |
| 95 | return 1; |
| 96 | } |
| 97 | |
| 98 | return 0; |
| 99 | } |
| 100 | |
| 101 | #endif /* CHIP_HAS_TILE_DMA() */ |
| 102 | |
Chris Metcalf | a009930 | 2013-08-13 15:33:53 -0400 | [diff] [blame] | 103 | extern tile_bundle_bits bpt_code; |
Chris Metcalf | 0707ad3 | 2010-06-25 17:04:17 -0400 | [diff] [blame] | 104 | |
| 105 | asm(".pushsection .rodata.bpt_code,\"a\";" |
| 106 | ".align 8;" |
| 107 | "bpt_code: bpt;" |
| 108 | ".size bpt_code,.-bpt_code;" |
| 109 | ".popsection"); |
| 110 | |
Chris Metcalf | a009930 | 2013-08-13 15:33:53 -0400 | [diff] [blame] | 111 | static int special_ill(tile_bundle_bits bundle, int *sigp, int *codep) |
Chris Metcalf | 0707ad3 | 2010-06-25 17:04:17 -0400 | [diff] [blame] | 112 | { |
| 113 | int sig, code, maxcode; |
| 114 | |
| 115 | if (bundle == bpt_code) { |
| 116 | *sigp = SIGTRAP; |
| 117 | *codep = TRAP_BRKPT; |
| 118 | return 1; |
| 119 | } |
| 120 | |
| 121 | /* If it's a "raise" bundle, then "ill" must be in pipe X1. */ |
| 122 | #ifdef __tilegx__ |
| 123 | if ((bundle & TILEGX_BUNDLE_MODE_MASK) != 0) |
| 124 | return 0; |
Chris Metcalf | 1fcbe02 | 2010-08-13 08:40:57 -0400 | [diff] [blame] | 125 | if (get_Opcode_X1(bundle) != RRR_0_OPCODE_X1) |
| 126 | return 0; |
| 127 | if (get_RRROpcodeExtension_X1(bundle) != UNARY_RRR_0_OPCODE_X1) |
Chris Metcalf | 0707ad3 | 2010-06-25 17:04:17 -0400 | [diff] [blame] | 128 | return 0; |
| 129 | if (get_UnaryOpcodeExtension_X1(bundle) != ILL_UNARY_OPCODE_X1) |
| 130 | return 0; |
| 131 | #else |
Chris Metcalf | eb7c792 | 2011-11-02 23:02:17 -0400 | [diff] [blame] | 132 | if (bundle & TILEPRO_BUNDLE_Y_ENCODING_MASK) |
Chris Metcalf | 0707ad3 | 2010-06-25 17:04:17 -0400 | [diff] [blame] | 133 | return 0; |
| 134 | if (get_Opcode_X1(bundle) != SHUN_0_OPCODE_X1) |
| 135 | return 0; |
| 136 | if (get_UnShOpcodeExtension_X1(bundle) != UN_0_SHUN_0_OPCODE_X1) |
| 137 | return 0; |
| 138 | if (get_UnOpcodeExtension_X1(bundle) != ILL_UN_0_SHUN_0_OPCODE_X1) |
| 139 | return 0; |
| 140 | #endif |
| 141 | |
| 142 | /* Check that the magic distinguishers are set to mean "raise". */ |
| 143 | if (get_Dest_X1(bundle) != 29 || get_SrcA_X1(bundle) != 37) |
| 144 | return 0; |
| 145 | |
| 146 | /* There must be an "addli zero, zero, VAL" in X0. */ |
| 147 | if (get_Opcode_X0(bundle) != ADDLI_OPCODE_X0) |
| 148 | return 0; |
| 149 | if (get_Dest_X0(bundle) != TREG_ZERO) |
| 150 | return 0; |
| 151 | if (get_SrcA_X0(bundle) != TREG_ZERO) |
| 152 | return 0; |
| 153 | |
| 154 | /* |
| 155 | * Validate the proposed signal number and si_code value. |
| 156 | * Note that we embed these in the static instruction itself |
| 157 | * so that we perturb the register state as little as possible |
| 158 | * at the time of the actual fault; it's unlikely you'd ever |
| 159 | * need to dynamically choose which kind of fault to raise |
| 160 | * from user space. |
| 161 | */ |
| 162 | sig = get_Imm16_X0(bundle) & 0x3f; |
| 163 | switch (sig) { |
| 164 | case SIGILL: |
| 165 | maxcode = NSIGILL; |
| 166 | break; |
| 167 | case SIGFPE: |
| 168 | maxcode = NSIGFPE; |
| 169 | break; |
| 170 | case SIGSEGV: |
| 171 | maxcode = NSIGSEGV; |
| 172 | break; |
| 173 | case SIGBUS: |
| 174 | maxcode = NSIGBUS; |
| 175 | break; |
| 176 | case SIGTRAP: |
| 177 | maxcode = NSIGTRAP; |
| 178 | break; |
| 179 | default: |
| 180 | return 0; |
| 181 | } |
| 182 | code = (get_Imm16_X0(bundle) >> 6) & 0xf; |
| 183 | if (code <= 0 || code > maxcode) |
| 184 | return 0; |
| 185 | |
| 186 | /* Make it the requested signal. */ |
| 187 | *sigp = sig; |
| 188 | *codep = code | __SI_FAULT; |
| 189 | return 1; |
| 190 | } |
| 191 | |
Chris Metcalf | c6f696f | 2012-03-30 16:31:08 -0400 | [diff] [blame] | 192 | static const char *const int_name[] = { |
| 193 | [INT_MEM_ERROR] = "Memory error", |
| 194 | [INT_ILL] = "Illegal instruction", |
| 195 | [INT_GPV] = "General protection violation", |
| 196 | [INT_UDN_ACCESS] = "UDN access", |
| 197 | [INT_IDN_ACCESS] = "IDN access", |
| 198 | #if CHIP_HAS_SN() |
| 199 | [INT_SN_ACCESS] = "SN access", |
| 200 | #endif |
| 201 | [INT_SWINT_3] = "Software interrupt 3", |
| 202 | [INT_SWINT_2] = "Software interrupt 2", |
| 203 | [INT_SWINT_0] = "Software interrupt 0", |
| 204 | [INT_UNALIGN_DATA] = "Unaligned data", |
| 205 | [INT_DOUBLE_FAULT] = "Double fault", |
| 206 | #ifdef __tilegx__ |
| 207 | [INT_ILL_TRANS] = "Illegal virtual address", |
| 208 | #endif |
| 209 | }; |
| 210 | |
Tony Lu | 3fa17c3 | 2013-08-09 15:08:57 -0400 | [diff] [blame] | 211 | static int do_bpt(struct pt_regs *regs) |
| 212 | { |
| 213 | unsigned long bundle, bcode, bpt; |
| 214 | |
| 215 | bundle = *(unsigned long *)instruction_pointer(regs); |
| 216 | |
| 217 | /* |
| 218 | * bpt shoule be { bpt; nop }, which is 0x286a44ae51485000ULL. |
| 219 | * we encode the unused least significant bits for other purpose. |
| 220 | */ |
| 221 | bpt = bundle & ~((1ULL << 12) - 1); |
| 222 | if (bpt != TILE_BPT_BUNDLE) |
| 223 | return 0; |
| 224 | |
| 225 | bcode = bundle & ((1ULL << 12) - 1); |
| 226 | /* |
| 227 | * notify the kprobe handlers, if instruction is likely to |
| 228 | * pertain to them. |
| 229 | */ |
| 230 | switch (bcode) { |
| 231 | /* breakpoint_insn */ |
| 232 | case 0: |
| 233 | notify_die(DIE_BREAK, "debug", regs, bundle, |
| 234 | INT_ILL, SIGTRAP); |
| 235 | break; |
Chris Metcalf | 8157107 | 2013-08-28 19:53:17 -0400 | [diff] [blame] | 236 | /* compiled_bpt */ |
| 237 | case DIE_COMPILED_BPT: |
| 238 | notify_die(DIE_COMPILED_BPT, "debug", regs, bundle, |
| 239 | INT_ILL, SIGTRAP); |
| 240 | break; |
Tony Lu | 3fa17c3 | 2013-08-09 15:08:57 -0400 | [diff] [blame] | 241 | /* breakpoint2_insn */ |
| 242 | case DIE_SSTEPBP: |
| 243 | notify_die(DIE_SSTEPBP, "single_step", regs, bundle, |
| 244 | INT_ILL, SIGTRAP); |
| 245 | break; |
| 246 | default: |
| 247 | return 0; |
| 248 | } |
| 249 | |
| 250 | return 1; |
| 251 | } |
| 252 | |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 253 | void __kprobes do_trap(struct pt_regs *regs, int fault_num, |
| 254 | unsigned long reason) |
| 255 | { |
| 256 | siginfo_t info = { 0 }; |
| 257 | int signo, code; |
Chris Metcalf | a714fff | 2012-03-29 15:23:54 -0400 | [diff] [blame] | 258 | unsigned long address = 0; |
Chris Metcalf | a009930 | 2013-08-13 15:33:53 -0400 | [diff] [blame] | 259 | tile_bundle_bits instr; |
Tony Lu | 3fa17c3 | 2013-08-09 15:08:57 -0400 | [diff] [blame] | 260 | int is_kernel = !user_mode(regs); |
| 261 | |
| 262 | /* Handle breakpoints, etc. */ |
| 263 | if (is_kernel && fault_num == INT_ILL && do_bpt(regs)) |
Chris Metcalf | 1bb50ca | 2015-12-23 17:13:04 -0500 | [diff] [blame] | 264 | return; |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 265 | |
Chris Metcalf | 70d2b59 | 2013-08-07 12:11:56 -0400 | [diff] [blame] | 266 | /* Re-enable interrupts, if they were previously enabled. */ |
| 267 | if (!(regs->flags & PT_FLAGS_DISABLE_IRQ)) |
| 268 | local_irq_enable(); |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 269 | |
| 270 | /* |
| 271 | * If it hits in kernel mode and we can't fix it up, just exit the |
| 272 | * current process and hope for the best. |
| 273 | */ |
Tony Lu | 3fa17c3 | 2013-08-09 15:08:57 -0400 | [diff] [blame] | 274 | if (is_kernel) { |
Chris Metcalf | c6f696f | 2012-03-30 16:31:08 -0400 | [diff] [blame] | 275 | const char *name; |
Chris Metcalf | 70d2b59 | 2013-08-07 12:11:56 -0400 | [diff] [blame] | 276 | char buf[100]; |
| 277 | if (fixup_exception(regs)) /* ILL_TRANS or UNALIGN_DATA */ |
Chris Metcalf | 1bb50ca | 2015-12-23 17:13:04 -0500 | [diff] [blame] | 278 | return; |
Chris Metcalf | c6f696f | 2012-03-30 16:31:08 -0400 | [diff] [blame] | 279 | if (fault_num >= 0 && |
Himangi Saraogi | 367b938 | 2014-06-17 01:42:24 +0530 | [diff] [blame] | 280 | fault_num < ARRAY_SIZE(int_name) && |
Chris Metcalf | c6f696f | 2012-03-30 16:31:08 -0400 | [diff] [blame] | 281 | int_name[fault_num] != NULL) |
| 282 | name = int_name[fault_num]; |
| 283 | else |
| 284 | name = "Unknown interrupt"; |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 285 | if (fault_num == INT_GPV) |
Chris Metcalf | 70d2b59 | 2013-08-07 12:11:56 -0400 | [diff] [blame] | 286 | snprintf(buf, sizeof(buf), "; GPV_REASON %#lx", reason); |
| 287 | #ifdef __tilegx__ |
| 288 | else if (fault_num == INT_ILL_TRANS) |
| 289 | snprintf(buf, sizeof(buf), "; address %#lx", reason); |
| 290 | #endif |
| 291 | else |
| 292 | buf[0] = '\0'; |
| 293 | pr_alert("Kernel took bad trap %d (%s) at PC %#lx%s\n", |
| 294 | fault_num, name, regs->pc, buf); |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 295 | show_regs(regs); |
| 296 | do_exit(SIGKILL); /* FIXME: implement i386 die() */ |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | switch (fault_num) { |
Chris Metcalf | a714fff | 2012-03-29 15:23:54 -0400 | [diff] [blame] | 300 | case INT_MEM_ERROR: |
| 301 | signo = SIGBUS; |
| 302 | code = BUS_OBJERR; |
| 303 | break; |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 304 | case INT_ILL: |
Chris Metcalf | 0707ad3 | 2010-06-25 17:04:17 -0400 | [diff] [blame] | 305 | if (copy_from_user(&instr, (void __user *)regs->pc, |
| 306 | sizeof(instr))) { |
Joe Perches | f474367 | 2014-10-31 10:50:46 -0700 | [diff] [blame] | 307 | pr_err("Unreadable instruction for INT_ILL: %#lx\n", |
| 308 | regs->pc); |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 309 | do_exit(SIGKILL); |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 310 | } |
Chris Metcalf | 0707ad3 | 2010-06-25 17:04:17 -0400 | [diff] [blame] | 311 | if (!special_ill(instr, &signo, &code)) { |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 312 | signo = SIGILL; |
| 313 | code = ILL_ILLOPC; |
| 314 | } |
| 315 | address = regs->pc; |
| 316 | break; |
| 317 | case INT_GPV: |
| 318 | #if CHIP_HAS_TILE_DMA() |
| 319 | if (retry_gpv(reason)) |
Chris Metcalf | 1bb50ca | 2015-12-23 17:13:04 -0500 | [diff] [blame] | 320 | return; |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 321 | #endif |
| 322 | /*FALLTHROUGH*/ |
| 323 | case INT_UDN_ACCESS: |
| 324 | case INT_IDN_ACCESS: |
| 325 | #if CHIP_HAS_SN() |
| 326 | case INT_SN_ACCESS: |
| 327 | #endif |
| 328 | signo = SIGILL; |
| 329 | code = ILL_PRVREG; |
| 330 | address = regs->pc; |
| 331 | break; |
| 332 | case INT_SWINT_3: |
| 333 | case INT_SWINT_2: |
| 334 | case INT_SWINT_0: |
| 335 | signo = SIGILL; |
| 336 | code = ILL_ILLTRP; |
| 337 | address = regs->pc; |
| 338 | break; |
| 339 | case INT_UNALIGN_DATA: |
Chris Metcalf | 233325b | 2010-10-14 16:32:41 -0400 | [diff] [blame] | 340 | #ifndef __tilegx__ /* Emulated support for single step debugging */ |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 341 | if (unaligned_fixup >= 0) { |
| 342 | struct single_step_state *state = |
| 343 | current_thread_info()->step_state; |
Chris Metcalf | 0707ad3 | 2010-06-25 17:04:17 -0400 | [diff] [blame] | 344 | if (!state || |
| 345 | (void __user *)(regs->pc) != state->buffer) { |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 346 | single_step_once(regs); |
Chris Metcalf | 1bb50ca | 2015-12-23 17:13:04 -0500 | [diff] [blame] | 347 | return; |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 348 | } |
| 349 | } |
| 350 | #endif |
| 351 | signo = SIGBUS; |
| 352 | code = BUS_ADRALN; |
| 353 | address = 0; |
| 354 | break; |
| 355 | case INT_DOUBLE_FAULT: |
| 356 | /* |
| 357 | * For double fault, "reason" is actually passed as |
Chris Metcalf | a78c942 | 2010-10-14 16:23:03 -0400 | [diff] [blame] | 358 | * SYSTEM_SAVE_K_2, the hypervisor's double-fault info, so |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 359 | * we can provide the original fault number rather than |
| 360 | * the uninteresting "INT_DOUBLE_FAULT" so the user can |
| 361 | * learn what actually struck while PL0 ICS was set. |
| 362 | */ |
| 363 | fault_num = reason; |
| 364 | signo = SIGILL; |
| 365 | code = ILL_DBLFLT; |
| 366 | address = regs->pc; |
| 367 | break; |
| 368 | #ifdef __tilegx__ |
Chris Metcalf | e172353 | 2012-03-29 14:52:00 -0400 | [diff] [blame] | 369 | case INT_ILL_TRANS: { |
| 370 | /* Avoid a hardware erratum with the return address stack. */ |
| 371 | fill_ra_stack(); |
| 372 | |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 373 | signo = SIGSEGV; |
Chris Metcalf | 70d2b59 | 2013-08-07 12:11:56 -0400 | [diff] [blame] | 374 | address = reason; |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 375 | code = SEGV_MAPERR; |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 376 | break; |
Chris Metcalf | e172353 | 2012-03-29 14:52:00 -0400 | [diff] [blame] | 377 | } |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 378 | #endif |
| 379 | default: |
| 380 | panic("Unexpected do_trap interrupt number %d", fault_num); |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | info.si_signo = signo; |
| 384 | info.si_code = code; |
Chris Metcalf | 0707ad3 | 2010-06-25 17:04:17 -0400 | [diff] [blame] | 385 | info.si_addr = (void __user *)address; |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 386 | if (signo == SIGILL) |
| 387 | info.si_trapno = fault_num; |
Chris Metcalf | a714fff | 2012-03-29 15:23:54 -0400 | [diff] [blame] | 388 | if (signo != SIGTRAP) |
| 389 | trace_unhandled_signal("trap", regs, address, signo); |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 390 | force_sig_info(signo, &info, current); |
| 391 | } |
| 392 | |
Chris Metcalf | e5701b7 | 2015-05-04 17:26:35 -0400 | [diff] [blame] | 393 | void do_nmi(struct pt_regs *regs, int fault_num, unsigned long reason) |
| 394 | { |
| 395 | switch (reason) { |
| 396 | case TILE_NMI_DUMP_STACK: |
| 397 | do_nmi_dump_stack(regs); |
| 398 | break; |
| 399 | default: |
| 400 | panic("Unexpected do_nmi type %ld", reason); |
| 401 | return; |
| 402 | } |
| 403 | } |
| 404 | |
Chris Metcalf | 47ad7b9 | 2015-05-08 10:27:35 -0400 | [diff] [blame] | 405 | /* Deprecated function currently only used here. */ |
| 406 | extern void _dump_stack(int dummy, ulong pc, ulong lr, ulong sp, ulong r52); |
| 407 | |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 408 | void kernel_double_fault(int dummy, ulong pc, ulong lr, ulong sp, ulong r52) |
| 409 | { |
| 410 | _dump_stack(dummy, pc, lr, sp, r52); |
Chris Metcalf | 0707ad3 | 2010-06-25 17:04:17 -0400 | [diff] [blame] | 411 | pr_emerg("Double fault: exiting\n"); |
Chris Metcalf | 867e359 | 2010-05-28 23:09:12 -0400 | [diff] [blame] | 412 | machine_halt(); |
| 413 | } |