Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * S390 version |
Heiko Carstens | a53c8fa | 2012-07-20 11:15:04 +0200 | [diff] [blame] | 3 | * Copyright IBM Corp. 1999, 2000 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), |
| 5 | * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com), |
| 6 | * |
| 7 | * Derived from "arch/i386/kernel/traps.c" |
| 8 | * Copyright (C) 1991, 1992 Linus Torvalds |
| 9 | */ |
| 10 | |
| 11 | /* |
| 12 | * 'Traps.c' handles hardware traps and faults after we have saved some |
| 13 | * state in 'asm.s'. |
| 14 | */ |
Michael Grundy | 4ba069b | 2006-09-20 15:58:39 +0200 | [diff] [blame] | 15 | #include <linux/kprobes.h> |
Heiko Carstens | 1bca09f | 2013-03-14 13:44:25 +0100 | [diff] [blame] | 16 | #include <linux/kdebug.h> |
| 17 | #include <linux/module.h> |
| 18 | #include <linux/ptrace.h> |
| 19 | #include <linux/sched.h> |
| 20 | #include <linux/mm.h> |
Martin Schwidefsky | 8070361 | 2014-10-06 17:53:53 +0200 | [diff] [blame] | 21 | #include <linux/slab.h> |
Hendrik Brueckner | b075390 | 2015-10-06 12:25:59 +0200 | [diff] [blame] | 22 | #include <asm/fpu/api.h> |
Heiko Carstens | a806170 | 2008-04-17 07:46:26 +0200 | [diff] [blame] | 23 | #include "entry.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
Martin Schwidefsky | d35339a | 2012-07-31 11:03:04 +0200 | [diff] [blame] | 25 | static inline void __user *get_trap_ip(struct pt_regs *regs) |
| 26 | { |
Martin Schwidefsky | d35339a | 2012-07-31 11:03:04 +0200 | [diff] [blame] | 27 | unsigned long address; |
| 28 | |
| 29 | if (regs->int_code & 0x200) |
| 30 | address = *(unsigned long *)(current->thread.trap_tdb + 24); |
| 31 | else |
| 32 | address = regs->psw.addr; |
Heiko Carstens | 9cb1cce | 2016-01-18 13:12:19 +0100 | [diff] [blame] | 33 | return (void __user *) (address - (regs->int_code >> 16)); |
Martin Schwidefsky | d35339a | 2012-07-31 11:03:04 +0200 | [diff] [blame] | 34 | } |
| 35 | |
Heiko Carstens | c0007f1 | 2007-04-27 16:01:42 +0200 | [diff] [blame] | 36 | int is_valid_bugaddr(unsigned long addr) |
| 37 | { |
| 38 | return 1; |
| 39 | } |
| 40 | |
Jan Willeke | 2a0a5b2 | 2014-09-22 16:39:06 +0200 | [diff] [blame] | 41 | void do_report_trap(struct pt_regs *regs, int si_signo, int si_code, char *str) |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 42 | { |
| 43 | siginfo_t info; |
| 44 | |
Heiko Carstens | 7d25617 | 2012-07-27 10:31:12 +0200 | [diff] [blame] | 45 | if (user_mode(regs)) { |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 46 | info.si_signo = si_signo; |
| 47 | info.si_errno = 0; |
| 48 | info.si_code = si_code; |
Martin Schwidefsky | d35339a | 2012-07-31 11:03:04 +0200 | [diff] [blame] | 49 | info.si_addr = get_trap_ip(regs); |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 50 | force_sig_info(si_signo, &info, current); |
Heiko Carstens | 5d7ecce | 2016-02-24 14:27:46 +0100 | [diff] [blame] | 51 | report_user_fault(regs, si_signo, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | } else { |
| 53 | const struct exception_table_entry *fixup; |
Heiko Carstens | 9cb1cce | 2016-01-18 13:12:19 +0100 | [diff] [blame] | 54 | fixup = search_exception_tables(regs->psw.addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | if (fixup) |
Heiko Carstens | fecc868 | 2016-01-18 12:49:44 +0100 | [diff] [blame] | 56 | regs->psw.addr = extable_fixup(fixup); |
Heiko Carstens | c0007f1 | 2007-04-27 16:01:42 +0200 | [diff] [blame] | 57 | else { |
| 58 | enum bug_trap_type btt; |
| 59 | |
Heiko Carstens | 9cb1cce | 2016-01-18 13:12:19 +0100 | [diff] [blame] | 60 | btt = report_bug(regs->psw.addr, regs); |
Heiko Carstens | c0007f1 | 2007-04-27 16:01:42 +0200 | [diff] [blame] | 61 | if (btt == BUG_TRAP_TYPE_WARN) |
| 62 | return; |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 63 | die(regs, str); |
Heiko Carstens | c0007f1 | 2007-04-27 16:01:42 +0200 | [diff] [blame] | 64 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | } |
| 66 | } |
| 67 | |
Heiko Carstens | 7a5388d | 2014-10-22 12:42:38 +0200 | [diff] [blame] | 68 | static void do_trap(struct pt_regs *regs, int si_signo, int si_code, char *str) |
Jan Willeke | 2a0a5b2 | 2014-09-22 16:39:06 +0200 | [diff] [blame] | 69 | { |
| 70 | if (notify_die(DIE_TRAP, str, regs, 0, |
| 71 | regs->int_code, si_signo) == NOTIFY_STOP) |
| 72 | return; |
| 73 | do_report_trap(regs, si_signo, si_code, str); |
| 74 | } |
Heiko Carstens | 7a5388d | 2014-10-22 12:42:38 +0200 | [diff] [blame] | 75 | NOKPROBE_SYMBOL(do_trap); |
Jan Willeke | 2a0a5b2 | 2014-09-22 16:39:06 +0200 | [diff] [blame] | 76 | |
Heiko Carstens | 7a5388d | 2014-10-22 12:42:38 +0200 | [diff] [blame] | 77 | void do_per_trap(struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | { |
Martin Schwidefsky | 73b7d40 | 2011-07-24 10:48:33 +0200 | [diff] [blame] | 79 | siginfo_t info; |
| 80 | |
Martin Schwidefsky | 5e9a269 | 2011-01-05 12:48:10 +0100 | [diff] [blame] | 81 | if (notify_die(DIE_SSTEP, "sstep", regs, 0, 0, SIGTRAP) == NOTIFY_STOP) |
Michael Grundy | 4ba069b | 2006-09-20 15:58:39 +0200 | [diff] [blame] | 82 | return; |
Martin Schwidefsky | 73b7d40 | 2011-07-24 10:48:33 +0200 | [diff] [blame] | 83 | if (!current->ptrace) |
| 84 | return; |
| 85 | info.si_signo = SIGTRAP; |
| 86 | info.si_errno = 0; |
| 87 | info.si_code = TRAP_HWBKPT; |
Martin Schwidefsky | 3c52e49 | 2011-10-30 15:17:15 +0100 | [diff] [blame] | 88 | info.si_addr = |
| 89 | (void __force __user *) current->thread.per_event.address; |
Martin Schwidefsky | 73b7d40 | 2011-07-24 10:48:33 +0200 | [diff] [blame] | 90 | force_sig_info(SIGTRAP, &info, current); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | } |
Heiko Carstens | 7a5388d | 2014-10-22 12:42:38 +0200 | [diff] [blame] | 92 | NOKPROBE_SYMBOL(do_per_trap); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | |
Heiko Carstens | b01a37a | 2012-10-18 18:10:06 +0200 | [diff] [blame] | 94 | void default_trap_handler(struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | { |
Heiko Carstens | 7d25617 | 2012-07-27 10:31:12 +0200 | [diff] [blame] | 96 | if (user_mode(regs)) { |
Heiko Carstens | 5d7ecce | 2016-02-24 14:27:46 +0100 | [diff] [blame] | 97 | report_user_fault(regs, SIGSEGV, 0); |
Heiko Carstens | 6ea5096 | 2010-05-17 10:00:13 +0200 | [diff] [blame] | 98 | do_exit(SIGSEGV); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | } else |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 100 | die(regs, "Unknown program exception"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | } |
| 102 | |
Martin Schwidefsky | 1e54622 | 2010-10-25 16:10:37 +0200 | [diff] [blame] | 103 | #define DO_ERROR_INFO(name, signr, sicode, str) \ |
Heiko Carstens | b01a37a | 2012-10-18 18:10:06 +0200 | [diff] [blame] | 104 | void name(struct pt_regs *regs) \ |
| 105 | { \ |
| 106 | do_trap(regs, signr, sicode, str); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | } |
| 108 | |
Martin Schwidefsky | 1e54622 | 2010-10-25 16:10:37 +0200 | [diff] [blame] | 109 | DO_ERROR_INFO(addressing_exception, SIGILL, ILL_ILLADR, |
| 110 | "addressing exception") |
| 111 | DO_ERROR_INFO(execute_exception, SIGILL, ILL_ILLOPN, |
| 112 | "execute exception") |
| 113 | DO_ERROR_INFO(divide_exception, SIGFPE, FPE_INTDIV, |
| 114 | "fixpoint divide exception") |
| 115 | DO_ERROR_INFO(overflow_exception, SIGFPE, FPE_INTOVF, |
| 116 | "fixpoint overflow exception") |
| 117 | DO_ERROR_INFO(hfp_overflow_exception, SIGFPE, FPE_FLTOVF, |
| 118 | "HFP overflow exception") |
| 119 | DO_ERROR_INFO(hfp_underflow_exception, SIGFPE, FPE_FLTUND, |
| 120 | "HFP underflow exception") |
| 121 | DO_ERROR_INFO(hfp_significance_exception, SIGFPE, FPE_FLTRES, |
| 122 | "HFP significance exception") |
| 123 | DO_ERROR_INFO(hfp_divide_exception, SIGFPE, FPE_FLTDIV, |
| 124 | "HFP divide exception") |
| 125 | DO_ERROR_INFO(hfp_sqrt_exception, SIGFPE, FPE_FLTINV, |
| 126 | "HFP square root exception") |
| 127 | DO_ERROR_INFO(operand_exception, SIGILL, ILL_ILLOPN, |
| 128 | "operand exception") |
| 129 | DO_ERROR_INFO(privileged_op, SIGILL, ILL_PRVOPC, |
| 130 | "privileged operation") |
| 131 | DO_ERROR_INFO(special_op_exception, SIGILL, ILL_ILLOPN, |
| 132 | "special operation exception") |
Martin Schwidefsky | d35339a | 2012-07-31 11:03:04 +0200 | [diff] [blame] | 133 | DO_ERROR_INFO(transaction_exception, SIGILL, ILL_ILLOPN, |
| 134 | "transaction constraint exception") |
Martin Schwidefsky | d35339a | 2012-07-31 11:03:04 +0200 | [diff] [blame] | 135 | |
Hendrik Brueckner | 9977e88 | 2015-06-10 12:53:42 +0200 | [diff] [blame] | 136 | static inline void do_fp_trap(struct pt_regs *regs, __u32 fpc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | { |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 138 | int si_code = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | /* FPC[2] is Data Exception Code */ |
| 140 | if ((fpc & 0x00000300) == 0) { |
| 141 | /* bits 6 and 7 of DXC are 0 iff IEEE exception */ |
| 142 | if (fpc & 0x8000) /* invalid fp operation */ |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 143 | si_code = FPE_FLTINV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | else if (fpc & 0x4000) /* div by 0 */ |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 145 | si_code = FPE_FLTDIV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | else if (fpc & 0x2000) /* overflow */ |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 147 | si_code = FPE_FLTOVF; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | else if (fpc & 0x1000) /* underflow */ |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 149 | si_code = FPE_FLTUND; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | else if (fpc & 0x0800) /* inexact */ |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 151 | si_code = FPE_FLTRES; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | } |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 153 | do_trap(regs, SIGFPE, si_code, "floating point exception"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | } |
| 155 | |
Heiko Carstens | e56da34 | 2014-11-19 14:05:52 +0100 | [diff] [blame] | 156 | void translation_exception(struct pt_regs *regs) |
| 157 | { |
| 158 | /* May never happen. */ |
Heiko Carstens | e1d12d7 | 2015-02-18 14:17:14 +0100 | [diff] [blame] | 159 | panic("Translation exception"); |
Heiko Carstens | e56da34 | 2014-11-19 14:05:52 +0100 | [diff] [blame] | 160 | } |
| 161 | |
Heiko Carstens | 7a5388d | 2014-10-22 12:42:38 +0200 | [diff] [blame] | 162 | void illegal_op(struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | { |
| 164 | siginfo_t info; |
| 165 | __u8 opcode[6]; |
Heiko Carstens | d2c993d | 2006-07-12 16:41:55 +0200 | [diff] [blame] | 166 | __u16 __user *location; |
Jan Willeke | 2a0a5b2 | 2014-09-22 16:39:06 +0200 | [diff] [blame] | 167 | int is_uprobe_insn = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | int signal = 0; |
| 169 | |
Martin Schwidefsky | d35339a | 2012-07-31 11:03:04 +0200 | [diff] [blame] | 170 | location = get_trap_ip(regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | |
Heiko Carstens | 7d25617 | 2012-07-27 10:31:12 +0200 | [diff] [blame] | 172 | if (user_mode(regs)) { |
Heiko Carstens | 12bae23 | 2006-10-27 12:39:22 +0200 | [diff] [blame] | 173 | if (get_user(*((__u16 *) opcode), (__u16 __user *) location)) |
| 174 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | if (*((__u16 *) opcode) == S390_BREAKPOINT_U16) { |
Martin Schwidefsky | 73b7d40 | 2011-07-24 10:48:33 +0200 | [diff] [blame] | 176 | if (current->ptrace) { |
| 177 | info.si_signo = SIGTRAP; |
| 178 | info.si_errno = 0; |
| 179 | info.si_code = TRAP_BRKPT; |
| 180 | info.si_addr = location; |
| 181 | force_sig_info(SIGTRAP, &info, current); |
| 182 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | signal = SIGILL; |
Jan Willeke | 2a0a5b2 | 2014-09-22 16:39:06 +0200 | [diff] [blame] | 184 | #ifdef CONFIG_UPROBES |
| 185 | } else if (*((__u16 *) opcode) == UPROBE_SWBP_INSN) { |
| 186 | is_uprobe_insn = 1; |
| 187 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | } else |
| 189 | signal = SIGILL; |
Jan Willeke | 2a0a5b2 | 2014-09-22 16:39:06 +0200 | [diff] [blame] | 190 | } |
| 191 | /* |
| 192 | * We got either an illegal op in kernel mode, or user space trapped |
| 193 | * on a uprobes illegal instruction. See if kprobes or uprobes picks |
| 194 | * it up. If not, SIGILL. |
| 195 | */ |
| 196 | if (is_uprobe_insn || !user_mode(regs)) { |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 197 | if (notify_die(DIE_BPT, "bpt", regs, 0, |
Heiko Carstens | 35df8d5 | 2007-02-05 21:17:29 +0100 | [diff] [blame] | 198 | 3, SIGTRAP) != NOTIFY_STOP) |
| 199 | signal = SIGILL; |
| 200 | } |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 201 | if (signal) |
| 202 | do_trap(regs, signal, ILL_ILLOPC, "illegal operation"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | } |
Heiko Carstens | 7a5388d | 2014-10-22 12:42:38 +0200 | [diff] [blame] | 204 | NOKPROBE_SYMBOL(illegal_op); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | |
Martin Schwidefsky | 1e54622 | 2010-10-25 16:10:37 +0200 | [diff] [blame] | 206 | DO_ERROR_INFO(specification_exception, SIGILL, ILL_ILLOPN, |
| 207 | "specification exception"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | |
Martin Schwidefsky | 8070361 | 2014-10-06 17:53:53 +0200 | [diff] [blame] | 209 | void vector_exception(struct pt_regs *regs) |
| 210 | { |
| 211 | int si_code, vic; |
| 212 | |
| 213 | if (!MACHINE_HAS_VX) { |
| 214 | do_trap(regs, SIGILL, ILL_ILLOPN, "illegal operation"); |
| 215 | return; |
| 216 | } |
| 217 | |
| 218 | /* get vector interrupt code from fpc */ |
Hendrik Brueckner | d0164ee | 2015-06-29 16:43:06 +0200 | [diff] [blame] | 219 | save_fpu_regs(); |
Hendrik Brueckner | 904818e | 2015-06-11 15:33:54 +0200 | [diff] [blame] | 220 | vic = (current->thread.fpu.fpc & 0xf00) >> 8; |
Martin Schwidefsky | 8070361 | 2014-10-06 17:53:53 +0200 | [diff] [blame] | 221 | switch (vic) { |
| 222 | case 1: /* invalid vector operation */ |
| 223 | si_code = FPE_FLTINV; |
| 224 | break; |
| 225 | case 2: /* division by zero */ |
| 226 | si_code = FPE_FLTDIV; |
| 227 | break; |
| 228 | case 3: /* overflow */ |
| 229 | si_code = FPE_FLTOVF; |
| 230 | break; |
| 231 | case 4: /* underflow */ |
| 232 | si_code = FPE_FLTUND; |
| 233 | break; |
| 234 | case 5: /* inexact */ |
| 235 | si_code = FPE_FLTRES; |
| 236 | break; |
| 237 | default: /* unknown cause */ |
| 238 | si_code = 0; |
| 239 | } |
| 240 | do_trap(regs, SIGFPE, si_code, "vector exception"); |
| 241 | } |
| 242 | |
Heiko Carstens | b01a37a | 2012-10-18 18:10:06 +0200 | [diff] [blame] | 243 | void data_exception(struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | int signal = 0; |
| 246 | |
Hendrik Brueckner | d0164ee | 2015-06-29 16:43:06 +0200 | [diff] [blame] | 247 | save_fpu_regs(); |
Hendrik Brueckner | 904818e | 2015-06-11 15:33:54 +0200 | [diff] [blame] | 248 | if (current->thread.fpu.fpc & FPC_DXC_MASK) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | signal = SIGFPE; |
| 250 | else |
| 251 | signal = SIGILL; |
Heiko Carstens | 5a79859 | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 252 | if (signal == SIGFPE) |
Hendrik Brueckner | 904818e | 2015-06-11 15:33:54 +0200 | [diff] [blame] | 253 | do_fp_trap(regs, current->thread.fpu.fpc); |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 254 | else if (signal) |
| 255 | do_trap(regs, signal, ILL_ILLOPN, "data exception"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | } |
| 257 | |
Heiko Carstens | b01a37a | 2012-10-18 18:10:06 +0200 | [diff] [blame] | 258 | void space_switch_exception(struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | /* Set user psw back to home space mode. */ |
Heiko Carstens | 7d25617 | 2012-07-27 10:31:12 +0200 | [diff] [blame] | 261 | if (user_mode(regs)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | regs->psw.mask |= PSW_ASC_HOME; |
| 263 | /* Send SIGILL. */ |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 264 | do_trap(regs, SIGILL, ILL_PRVOPC, "space switch event"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | } |
| 266 | |
Heiko Carstens | 7a5388d | 2014-10-22 12:42:38 +0200 | [diff] [blame] | 267 | void kernel_stack_overflow(struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | { |
Heiko Carstens | 77eb65c | 2005-06-21 17:16:28 -0700 | [diff] [blame] | 269 | bust_spinlocks(1); |
| 270 | printk("Kernel stack overflow.\n"); |
| 271 | show_regs(regs); |
| 272 | bust_spinlocks(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | panic("Corrupt kernel stack, can't continue."); |
| 274 | } |
Heiko Carstens | 7a5388d | 2014-10-22 12:42:38 +0200 | [diff] [blame] | 275 | NOKPROBE_SYMBOL(kernel_stack_overflow); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | void __init trap_init(void) |
| 278 | { |
Heiko Carstens | f3e1a27 | 2011-01-05 12:48:00 +0100 | [diff] [blame] | 279 | local_mcck_enable(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | } |