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 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/sched.h> |
| 16 | #include <linux/kernel.h> |
| 17 | #include <linux/string.h> |
| 18 | #include <linux/errno.h> |
Martin Schwidefsky | 73b7d40 | 2011-07-24 10:48:33 +0200 | [diff] [blame] | 19 | #include <linux/ptrace.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <linux/timer.h> |
| 21 | #include <linux/mm.h> |
| 22 | #include <linux/smp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include <linux/init.h> |
| 24 | #include <linux/interrupt.h> |
Eric W. Biederman | df5f831 | 2008-02-08 04:18:33 -0800 | [diff] [blame] | 25 | #include <linux/seq_file.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <linux/delay.h> |
| 27 | #include <linux/module.h> |
Christoph Hellwig | 1eeb66a | 2007-05-08 00:27:03 -0700 | [diff] [blame] | 28 | #include <linux/kdebug.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | #include <linux/kallsyms.h> |
Heiko Carstens | 5d3f229 | 2005-08-01 21:11:33 -0700 | [diff] [blame] | 30 | #include <linux/reboot.h> |
Michael Grundy | 4ba069b | 2006-09-20 15:58:39 +0200 | [diff] [blame] | 31 | #include <linux/kprobes.h> |
Heiko Carstens | c0007f1 | 2007-04-27 16:01:42 +0200 | [diff] [blame] | 32 | #include <linux/bug.h> |
Heiko Carstens | 5c69971 | 2008-01-26 14:11:01 +0100 | [diff] [blame] | 33 | #include <linux/utsname.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #include <asm/uaccess.h> |
| 35 | #include <asm/io.h> |
Arun Sharma | 60063497 | 2011-07-26 16:09:06 -0700 | [diff] [blame] | 36 | #include <linux/atomic.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | #include <asm/mathemu.h> |
| 38 | #include <asm/cpcmd.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | #include <asm/lowcore.h> |
| 40 | #include <asm/debug.h> |
Michael Holzheu | 3ab121a | 2012-03-11 11:59:32 -0400 | [diff] [blame] | 41 | #include <asm/ipl.h> |
Heiko Carstens | a806170 | 2008-04-17 07:46:26 +0200 | [diff] [blame] | 42 | #include "entry.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 44 | void (*pgm_check_table[128])(struct pt_regs *regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | |
Heiko Carstens | 02834ee | 2011-12-27 11:27:31 +0100 | [diff] [blame] | 46 | int show_unhandled_signals = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #define stack_pointer ({ void **sp; asm("la %0,0(15)" : "=&d" (sp)); sp; }) |
| 49 | |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 50 | #ifndef CONFIG_64BIT |
Christian Borntraeger | d7fd5f1 | 2009-03-26 15:23:42 +0100 | [diff] [blame] | 51 | #define LONG "%08lx " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | #define FOURLONG "%08lx %08lx %08lx %08lx\n" |
| 53 | static int kstack_depth_to_print = 12; |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 54 | #else /* CONFIG_64BIT */ |
Christian Borntraeger | d7fd5f1 | 2009-03-26 15:23:42 +0100 | [diff] [blame] | 55 | #define LONG "%016lx " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | #define FOURLONG "%016lx %016lx %016lx %016lx\n" |
| 57 | static int kstack_depth_to_print = 20; |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 58 | #endif /* CONFIG_64BIT */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
Martin Schwidefsky | d35339a | 2012-07-31 11:03:04 +0200 | [diff] [blame^] | 60 | static inline void __user *get_trap_ip(struct pt_regs *regs) |
| 61 | { |
| 62 | #ifdef CONFIG_64BIT |
| 63 | unsigned long address; |
| 64 | |
| 65 | if (regs->int_code & 0x200) |
| 66 | address = *(unsigned long *)(current->thread.trap_tdb + 24); |
| 67 | else |
| 68 | address = regs->psw.addr; |
| 69 | return (void __user *) |
| 70 | ((address - (regs->int_code >> 16)) & PSW_ADDR_INSN); |
| 71 | #else |
| 72 | return (void __user *) |
| 73 | ((regs->psw.addr - (regs->int_code >> 16)) & PSW_ADDR_INSN); |
| 74 | #endif |
| 75 | } |
| 76 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | /* |
| 78 | * For show_trace we have tree different stack to consider: |
| 79 | * - the panic stack which is used if the kernel stack has overflown |
| 80 | * - the asynchronous interrupt stack (cpu related) |
| 81 | * - the synchronous kernel stack (process related) |
| 82 | * The stack trace can start at any of the three stack and can potentially |
| 83 | * touch all of them. The order is: panic stack, async stack, sync stack. |
| 84 | */ |
| 85 | static unsigned long |
| 86 | __show_trace(unsigned long sp, unsigned long low, unsigned long high) |
| 87 | { |
| 88 | struct stack_frame *sf; |
| 89 | struct pt_regs *regs; |
| 90 | |
| 91 | while (1) { |
| 92 | sp = sp & PSW_ADDR_INSN; |
| 93 | if (sp < low || sp > high - sizeof(*sf)) |
| 94 | return sp; |
| 95 | sf = (struct stack_frame *) sp; |
| 96 | printk("([<%016lx>] ", sf->gprs[8] & PSW_ADDR_INSN); |
| 97 | print_symbol("%s)\n", sf->gprs[8] & PSW_ADDR_INSN); |
| 98 | /* Follow the backchain. */ |
| 99 | while (1) { |
| 100 | low = sp; |
| 101 | sp = sf->back_chain & PSW_ADDR_INSN; |
| 102 | if (!sp) |
| 103 | break; |
| 104 | if (sp <= low || sp > high - sizeof(*sf)) |
| 105 | return sp; |
| 106 | sf = (struct stack_frame *) sp; |
| 107 | printk(" [<%016lx>] ", sf->gprs[8] & PSW_ADDR_INSN); |
| 108 | print_symbol("%s\n", sf->gprs[8] & PSW_ADDR_INSN); |
| 109 | } |
| 110 | /* Zero backchain detected, check for interrupt frame. */ |
| 111 | sp = (unsigned long) (sf + 1); |
| 112 | if (sp <= low || sp > high - sizeof(*regs)) |
| 113 | return sp; |
| 114 | regs = (struct pt_regs *) sp; |
| 115 | printk(" [<%016lx>] ", regs->psw.addr & PSW_ADDR_INSN); |
| 116 | print_symbol("%s\n", regs->psw.addr & PSW_ADDR_INSN); |
| 117 | low = sp; |
| 118 | sp = regs->gprs[15]; |
| 119 | } |
| 120 | } |
| 121 | |
Heiko Carstens | 4e83be7 | 2008-04-30 13:38:34 +0200 | [diff] [blame] | 122 | static void show_trace(struct task_struct *task, unsigned long *stack) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | { |
| 124 | register unsigned long __r15 asm ("15"); |
| 125 | unsigned long sp; |
| 126 | |
| 127 | sp = (unsigned long) stack; |
| 128 | if (!sp) |
| 129 | sp = task ? task->thread.ksp : __r15; |
| 130 | printk("Call Trace:\n"); |
| 131 | #ifdef CONFIG_CHECK_STACK |
| 132 | sp = __show_trace(sp, S390_lowcore.panic_stack - 4096, |
| 133 | S390_lowcore.panic_stack); |
| 134 | #endif |
| 135 | sp = __show_trace(sp, S390_lowcore.async_stack - ASYNC_SIZE, |
| 136 | S390_lowcore.async_stack); |
| 137 | if (task) |
Al Viro | 30af712 | 2006-01-12 01:05:50 -0800 | [diff] [blame] | 138 | __show_trace(sp, (unsigned long) task_stack_page(task), |
| 139 | (unsigned long) task_stack_page(task) + THREAD_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | else |
| 141 | __show_trace(sp, S390_lowcore.thread_info, |
| 142 | S390_lowcore.thread_info + THREAD_SIZE); |
Heiko Carstens | 236257e | 2006-12-04 15:40:47 +0100 | [diff] [blame] | 143 | if (!task) |
| 144 | task = current; |
| 145 | debug_show_held_locks(task); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | void show_stack(struct task_struct *task, unsigned long *sp) |
| 149 | { |
| 150 | register unsigned long * __r15 asm ("15"); |
| 151 | unsigned long *stack; |
| 152 | int i; |
| 153 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | if (!sp) |
Heiko Carstens | 7380534 | 2006-06-29 14:56:23 +0200 | [diff] [blame] | 155 | stack = task ? (unsigned long *) task->thread.ksp : __r15; |
| 156 | else |
| 157 | stack = sp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | for (i = 0; i < kstack_depth_to_print; i++) { |
| 160 | if (((addr_t) stack & (THREAD_SIZE-1)) == 0) |
| 161 | break; |
Heiko Carstens | ddadfa8 | 2012-03-11 11:59:35 -0400 | [diff] [blame] | 162 | if ((i * sizeof(long) % 32) == 0) |
| 163 | printk("%s ", i == 0 ? "" : "\n"); |
Christian Borntraeger | d7fd5f1 | 2009-03-26 15:23:42 +0100 | [diff] [blame] | 164 | printk(LONG, *stack++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | } |
| 166 | printk("\n"); |
| 167 | show_trace(task, sp); |
| 168 | } |
| 169 | |
Heiko Carstens | 4e83be7 | 2008-04-30 13:38:34 +0200 | [diff] [blame] | 170 | static void show_last_breaking_event(struct pt_regs *regs) |
Christian Borntraeger | 9e74a6b8 | 2008-04-17 07:46:30 +0200 | [diff] [blame] | 171 | { |
Heiko Carstens | 4e83be7 | 2008-04-30 13:38:34 +0200 | [diff] [blame] | 172 | #ifdef CONFIG_64BIT |
Christian Borntraeger | 9e74a6b8 | 2008-04-17 07:46:30 +0200 | [diff] [blame] | 173 | printk("Last Breaking-Event-Address:\n"); |
| 174 | printk(" [<%016lx>] ", regs->args[0] & PSW_ADDR_INSN); |
| 175 | print_symbol("%s\n", regs->args[0] & PSW_ADDR_INSN); |
Christian Borntraeger | 9e74a6b8 | 2008-04-17 07:46:30 +0200 | [diff] [blame] | 176 | #endif |
Heiko Carstens | 4e83be7 | 2008-04-30 13:38:34 +0200 | [diff] [blame] | 177 | } |
Christian Borntraeger | 9e74a6b8 | 2008-04-17 07:46:30 +0200 | [diff] [blame] | 178 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | /* |
| 180 | * The architecture-independent dump_stack generator |
| 181 | */ |
| 182 | void dump_stack(void) |
| 183 | { |
Heiko Carstens | 5c69971 | 2008-01-26 14:11:01 +0100 | [diff] [blame] | 184 | printk("CPU: %d %s %s %.*s\n", |
| 185 | task_thread_info(current)->cpu, print_tainted(), |
| 186 | init_utsname()->release, |
| 187 | (int)strcspn(init_utsname()->version, " "), |
| 188 | init_utsname()->version); |
| 189 | printk("Process %s (pid: %d, task: %p, ksp: %p)\n", |
| 190 | current->comm, current->pid, current, |
| 191 | (void *) current->thread.ksp); |
Heiko Carstens | d2c993d | 2006-07-12 16:41:55 +0200 | [diff] [blame] | 192 | show_stack(NULL, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | EXPORT_SYMBOL(dump_stack); |
| 195 | |
Martin Schwidefsky | bb11e3b | 2007-04-27 16:01:41 +0200 | [diff] [blame] | 196 | static inline int mask_bits(struct pt_regs *regs, unsigned long bits) |
| 197 | { |
| 198 | return (regs->psw.mask & bits) / ((~bits + 1) & bits); |
| 199 | } |
| 200 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | void show_registers(struct pt_regs *regs) |
| 202 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | char *mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | |
Heiko Carstens | 7d25617 | 2012-07-27 10:31:12 +0200 | [diff] [blame] | 205 | mode = user_mode(regs) ? "User" : "Krnl"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | printk("%s PSW : %p %p", |
| 207 | mode, (void *) regs->psw.mask, |
| 208 | (void *) regs->psw.addr); |
| 209 | print_symbol(" (%s)\n", regs->psw.addr & PSW_ADDR_INSN); |
Martin Schwidefsky | bb11e3b | 2007-04-27 16:01:41 +0200 | [diff] [blame] | 210 | printk(" R:%x T:%x IO:%x EX:%x Key:%x M:%x W:%x " |
| 211 | "P:%x AS:%x CC:%x PM:%x", mask_bits(regs, PSW_MASK_PER), |
| 212 | mask_bits(regs, PSW_MASK_DAT), mask_bits(regs, PSW_MASK_IO), |
| 213 | mask_bits(regs, PSW_MASK_EXT), mask_bits(regs, PSW_MASK_KEY), |
| 214 | mask_bits(regs, PSW_MASK_MCHECK), mask_bits(regs, PSW_MASK_WAIT), |
| 215 | mask_bits(regs, PSW_MASK_PSTATE), mask_bits(regs, PSW_MASK_ASC), |
| 216 | mask_bits(regs, PSW_MASK_CC), mask_bits(regs, PSW_MASK_PM)); |
| 217 | #ifdef CONFIG_64BIT |
Martin Schwidefsky | b50511e | 2011-10-30 15:16:50 +0100 | [diff] [blame] | 218 | printk(" EA:%x", mask_bits(regs, PSW_MASK_EA | PSW_MASK_BA)); |
Martin Schwidefsky | bb11e3b | 2007-04-27 16:01:41 +0200 | [diff] [blame] | 219 | #endif |
| 220 | printk("\n%s GPRS: " FOURLONG, mode, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | regs->gprs[0], regs->gprs[1], regs->gprs[2], regs->gprs[3]); |
| 222 | printk(" " FOURLONG, |
| 223 | regs->gprs[4], regs->gprs[5], regs->gprs[6], regs->gprs[7]); |
| 224 | printk(" " FOURLONG, |
| 225 | regs->gprs[8], regs->gprs[9], regs->gprs[10], regs->gprs[11]); |
| 226 | printk(" " FOURLONG, |
| 227 | regs->gprs[12], regs->gprs[13], regs->gprs[14], regs->gprs[15]); |
| 228 | |
Martin Schwidefsky | bb11e3b | 2007-04-27 16:01:41 +0200 | [diff] [blame] | 229 | show_code(regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | } |
| 231 | |
Heiko Carstens | 4e83be7 | 2008-04-30 13:38:34 +0200 | [diff] [blame] | 232 | void show_regs(struct pt_regs *regs) |
| 233 | { |
| 234 | print_modules(); |
| 235 | printk("CPU: %d %s %s %.*s\n", |
| 236 | task_thread_info(current)->cpu, print_tainted(), |
| 237 | init_utsname()->release, |
| 238 | (int)strcspn(init_utsname()->version, " "), |
| 239 | init_utsname()->version); |
| 240 | printk("Process %s (pid: %d, task: %p, ksp: %p)\n", |
| 241 | current->comm, current->pid, current, |
| 242 | (void *) current->thread.ksp); |
| 243 | show_registers(regs); |
| 244 | /* Show stack backtrace if pt_regs is from kernel mode */ |
Heiko Carstens | 7d25617 | 2012-07-27 10:31:12 +0200 | [diff] [blame] | 245 | if (!user_mode(regs)) |
Heiko Carstens | 4e83be7 | 2008-04-30 13:38:34 +0200 | [diff] [blame] | 246 | show_trace(NULL, (unsigned long *) regs->gprs[15]); |
| 247 | show_last_breaking_event(regs); |
| 248 | } |
| 249 | |
Heiko Carstens | 2b67fc4 | 2007-02-05 21:16:47 +0100 | [diff] [blame] | 250 | static DEFINE_SPINLOCK(die_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 252 | void die(struct pt_regs *regs, const char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | { |
| 254 | static int die_counter; |
| 255 | |
Heiko Carstens | bca0fb86 | 2007-06-19 13:10:05 +0200 | [diff] [blame] | 256 | oops_enter(); |
Michael Holzheu | 3ab121a | 2012-03-11 11:59:32 -0400 | [diff] [blame] | 257 | lgr_info_log(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | debug_stop_all(); |
| 259 | console_verbose(); |
| 260 | spin_lock_irq(&die_lock); |
| 261 | bust_spinlocks(1); |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 262 | printk("%s: %04x [#%d] ", str, regs->int_code & 0xffff, ++die_counter); |
Heiko Carstens | 5c69971 | 2008-01-26 14:11:01 +0100 | [diff] [blame] | 263 | #ifdef CONFIG_PREEMPT |
| 264 | printk("PREEMPT "); |
| 265 | #endif |
| 266 | #ifdef CONFIG_SMP |
Heiko Carstens | 2485579 | 2008-02-05 16:50:37 +0100 | [diff] [blame] | 267 | printk("SMP "); |
| 268 | #endif |
| 269 | #ifdef CONFIG_DEBUG_PAGEALLOC |
| 270 | printk("DEBUG_PAGEALLOC"); |
Heiko Carstens | 5c69971 | 2008-01-26 14:11:01 +0100 | [diff] [blame] | 271 | #endif |
| 272 | printk("\n"); |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 273 | notify_die(DIE_OOPS, str, regs, 0, regs->int_code & 0xffff, SIGSEGV); |
Heiko Carstens | bca0fb86 | 2007-06-19 13:10:05 +0200 | [diff] [blame] | 274 | show_regs(regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | bust_spinlocks(0); |
Pavel Emelianov | bcdcd8e | 2007-07-17 04:03:42 -0700 | [diff] [blame] | 276 | add_taint(TAINT_DIE); |
Heiko Carstens | bca0fb86 | 2007-06-19 13:10:05 +0200 | [diff] [blame] | 277 | spin_unlock_irq(&die_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | if (in_interrupt()) |
| 279 | panic("Fatal exception in interrupt"); |
| 280 | if (panic_on_oops) |
| 281 | panic("Fatal exception: panic_on_oops"); |
Heiko Carstens | bca0fb86 | 2007-06-19 13:10:05 +0200 | [diff] [blame] | 282 | oops_exit(); |
| 283 | do_exit(SIGSEGV); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | } |
| 285 | |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 286 | static inline void report_user_fault(struct pt_regs *regs, int signr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | { |
Heiko Carstens | ab3c68e | 2010-05-17 10:00:21 +0200 | [diff] [blame] | 288 | if ((task_pid_nr(current) > 1) && !show_unhandled_signals) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | return; |
Heiko Carstens | ab3c68e | 2010-05-17 10:00:21 +0200 | [diff] [blame] | 290 | if (!unhandled_signal(current, signr)) |
| 291 | return; |
| 292 | if (!printk_ratelimit()) |
| 293 | return; |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 294 | printk("User process fault: interruption code 0x%X ", regs->int_code); |
Heiko Carstens | ab3c68e | 2010-05-17 10:00:21 +0200 | [diff] [blame] | 295 | print_vma_addr("in ", regs->psw.addr & PSW_ADDR_INSN); |
| 296 | printk("\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | show_regs(regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | } |
| 299 | |
Heiko Carstens | c0007f1 | 2007-04-27 16:01:42 +0200 | [diff] [blame] | 300 | int is_valid_bugaddr(unsigned long addr) |
| 301 | { |
| 302 | return 1; |
| 303 | } |
| 304 | |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 305 | static void __kprobes do_trap(struct pt_regs *regs, |
| 306 | int si_signo, int si_code, char *str) |
| 307 | { |
| 308 | siginfo_t info; |
| 309 | |
| 310 | if (notify_die(DIE_TRAP, str, regs, 0, |
| 311 | regs->int_code, si_signo) == NOTIFY_STOP) |
Michael Grundy | 4ba069b | 2006-09-20 15:58:39 +0200 | [diff] [blame] | 312 | return; |
| 313 | |
Heiko Carstens | 7d25617 | 2012-07-27 10:31:12 +0200 | [diff] [blame] | 314 | if (user_mode(regs)) { |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 315 | info.si_signo = si_signo; |
| 316 | info.si_errno = 0; |
| 317 | info.si_code = si_code; |
Martin Schwidefsky | d35339a | 2012-07-31 11:03:04 +0200 | [diff] [blame^] | 318 | info.si_addr = get_trap_ip(regs); |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 319 | force_sig_info(si_signo, &info, current); |
| 320 | report_user_fault(regs, si_signo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | } else { |
| 322 | const struct exception_table_entry *fixup; |
| 323 | fixup = search_exception_tables(regs->psw.addr & PSW_ADDR_INSN); |
| 324 | if (fixup) |
| 325 | regs->psw.addr = fixup->fixup | PSW_ADDR_AMODE; |
Heiko Carstens | c0007f1 | 2007-04-27 16:01:42 +0200 | [diff] [blame] | 326 | else { |
| 327 | enum bug_trap_type btt; |
| 328 | |
Heiko Carstens | 608e261 | 2007-07-15 23:41:39 -0700 | [diff] [blame] | 329 | btt = report_bug(regs->psw.addr & PSW_ADDR_INSN, regs); |
Heiko Carstens | c0007f1 | 2007-04-27 16:01:42 +0200 | [diff] [blame] | 330 | if (btt == BUG_TRAP_TYPE_WARN) |
| 331 | return; |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 332 | die(regs, str); |
Heiko Carstens | c0007f1 | 2007-04-27 16:01:42 +0200 | [diff] [blame] | 333 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | } |
| 335 | } |
| 336 | |
Martin Schwidefsky | 5e9a269 | 2011-01-05 12:48:10 +0100 | [diff] [blame] | 337 | void __kprobes do_per_trap(struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | { |
Martin Schwidefsky | 73b7d40 | 2011-07-24 10:48:33 +0200 | [diff] [blame] | 339 | siginfo_t info; |
| 340 | |
Martin Schwidefsky | 5e9a269 | 2011-01-05 12:48:10 +0100 | [diff] [blame] | 341 | if (notify_die(DIE_SSTEP, "sstep", regs, 0, 0, SIGTRAP) == NOTIFY_STOP) |
Michael Grundy | 4ba069b | 2006-09-20 15:58:39 +0200 | [diff] [blame] | 342 | return; |
Martin Schwidefsky | 73b7d40 | 2011-07-24 10:48:33 +0200 | [diff] [blame] | 343 | if (!current->ptrace) |
| 344 | return; |
| 345 | info.si_signo = SIGTRAP; |
| 346 | info.si_errno = 0; |
| 347 | info.si_code = TRAP_HWBKPT; |
Martin Schwidefsky | 3c52e49 | 2011-10-30 15:17:15 +0100 | [diff] [blame] | 348 | info.si_addr = |
| 349 | (void __force __user *) current->thread.per_event.address; |
Martin Schwidefsky | 73b7d40 | 2011-07-24 10:48:33 +0200 | [diff] [blame] | 350 | force_sig_info(SIGTRAP, &info, current); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | } |
| 352 | |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 353 | static void default_trap_handler(struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | { |
Heiko Carstens | 7d25617 | 2012-07-27 10:31:12 +0200 | [diff] [blame] | 355 | if (user_mode(regs)) { |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 356 | report_user_fault(regs, SIGSEGV); |
Heiko Carstens | 6ea5096 | 2010-05-17 10:00:13 +0200 | [diff] [blame] | 357 | do_exit(SIGSEGV); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | } else |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 359 | die(regs, "Unknown program exception"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | } |
| 361 | |
Martin Schwidefsky | 1e54622 | 2010-10-25 16:10:37 +0200 | [diff] [blame] | 362 | #define DO_ERROR_INFO(name, signr, sicode, str) \ |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 363 | static void name(struct pt_regs *regs) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | { \ |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 365 | do_trap(regs, signr, sicode, str); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | } |
| 367 | |
Martin Schwidefsky | 1e54622 | 2010-10-25 16:10:37 +0200 | [diff] [blame] | 368 | DO_ERROR_INFO(addressing_exception, SIGILL, ILL_ILLADR, |
| 369 | "addressing exception") |
| 370 | DO_ERROR_INFO(execute_exception, SIGILL, ILL_ILLOPN, |
| 371 | "execute exception") |
| 372 | DO_ERROR_INFO(divide_exception, SIGFPE, FPE_INTDIV, |
| 373 | "fixpoint divide exception") |
| 374 | DO_ERROR_INFO(overflow_exception, SIGFPE, FPE_INTOVF, |
| 375 | "fixpoint overflow exception") |
| 376 | DO_ERROR_INFO(hfp_overflow_exception, SIGFPE, FPE_FLTOVF, |
| 377 | "HFP overflow exception") |
| 378 | DO_ERROR_INFO(hfp_underflow_exception, SIGFPE, FPE_FLTUND, |
| 379 | "HFP underflow exception") |
| 380 | DO_ERROR_INFO(hfp_significance_exception, SIGFPE, FPE_FLTRES, |
| 381 | "HFP significance exception") |
| 382 | DO_ERROR_INFO(hfp_divide_exception, SIGFPE, FPE_FLTDIV, |
| 383 | "HFP divide exception") |
| 384 | DO_ERROR_INFO(hfp_sqrt_exception, SIGFPE, FPE_FLTINV, |
| 385 | "HFP square root exception") |
| 386 | DO_ERROR_INFO(operand_exception, SIGILL, ILL_ILLOPN, |
| 387 | "operand exception") |
| 388 | DO_ERROR_INFO(privileged_op, SIGILL, ILL_PRVOPC, |
| 389 | "privileged operation") |
| 390 | DO_ERROR_INFO(special_op_exception, SIGILL, ILL_ILLOPN, |
| 391 | "special operation exception") |
| 392 | DO_ERROR_INFO(translation_exception, SIGILL, ILL_ILLOPN, |
| 393 | "translation exception") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | |
Martin Schwidefsky | d35339a | 2012-07-31 11:03:04 +0200 | [diff] [blame^] | 395 | #ifdef CONFIG_64BIT |
| 396 | DO_ERROR_INFO(transaction_exception, SIGILL, ILL_ILLOPN, |
| 397 | "transaction constraint exception") |
| 398 | #endif |
| 399 | |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 400 | static inline void do_fp_trap(struct pt_regs *regs, int fpc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | { |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 402 | int si_code = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | /* FPC[2] is Data Exception Code */ |
| 404 | if ((fpc & 0x00000300) == 0) { |
| 405 | /* bits 6 and 7 of DXC are 0 iff IEEE exception */ |
| 406 | if (fpc & 0x8000) /* invalid fp operation */ |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 407 | si_code = FPE_FLTINV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | else if (fpc & 0x4000) /* div by 0 */ |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 409 | si_code = FPE_FLTDIV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | else if (fpc & 0x2000) /* overflow */ |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 411 | si_code = FPE_FLTOVF; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | else if (fpc & 0x1000) /* underflow */ |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 413 | si_code = FPE_FLTUND; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | else if (fpc & 0x0800) /* inexact */ |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 415 | si_code = FPE_FLTRES; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | } |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 417 | do_trap(regs, SIGFPE, si_code, "floating point exception"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | } |
| 419 | |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 420 | static void __kprobes illegal_op(struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | { |
| 422 | siginfo_t info; |
| 423 | __u8 opcode[6]; |
Heiko Carstens | d2c993d | 2006-07-12 16:41:55 +0200 | [diff] [blame] | 424 | __u16 __user *location; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | int signal = 0; |
| 426 | |
Martin Schwidefsky | d35339a | 2012-07-31 11:03:04 +0200 | [diff] [blame^] | 427 | location = get_trap_ip(regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | |
Heiko Carstens | 7d25617 | 2012-07-27 10:31:12 +0200 | [diff] [blame] | 429 | if (user_mode(regs)) { |
Heiko Carstens | 12bae23 | 2006-10-27 12:39:22 +0200 | [diff] [blame] | 430 | if (get_user(*((__u16 *) opcode), (__u16 __user *) location)) |
| 431 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | if (*((__u16 *) opcode) == S390_BREAKPOINT_U16) { |
Martin Schwidefsky | 73b7d40 | 2011-07-24 10:48:33 +0200 | [diff] [blame] | 433 | if (current->ptrace) { |
| 434 | info.si_signo = SIGTRAP; |
| 435 | info.si_errno = 0; |
| 436 | info.si_code = TRAP_BRKPT; |
| 437 | info.si_addr = location; |
| 438 | force_sig_info(SIGTRAP, &info, current); |
| 439 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | signal = SIGILL; |
| 441 | #ifdef CONFIG_MATHEMU |
| 442 | } else if (opcode[0] == 0xb3) { |
Heiko Carstens | 12bae23 | 2006-10-27 12:39:22 +0200 | [diff] [blame] | 443 | if (get_user(*((__u16 *) (opcode+2)), location+1)) |
| 444 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | signal = math_emu_b3(opcode, regs); |
| 446 | } else if (opcode[0] == 0xed) { |
Heiko Carstens | 12bae23 | 2006-10-27 12:39:22 +0200 | [diff] [blame] | 447 | if (get_user(*((__u32 *) (opcode+2)), |
| 448 | (__u32 __user *)(location+1))) |
| 449 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | signal = math_emu_ed(opcode, regs); |
| 451 | } else if (*((__u16 *) opcode) == 0xb299) { |
Heiko Carstens | 12bae23 | 2006-10-27 12:39:22 +0200 | [diff] [blame] | 452 | if (get_user(*((__u16 *) (opcode+2)), location+1)) |
| 453 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | signal = math_emu_srnm(opcode, regs); |
| 455 | } else if (*((__u16 *) opcode) == 0xb29c) { |
Heiko Carstens | 12bae23 | 2006-10-27 12:39:22 +0200 | [diff] [blame] | 456 | if (get_user(*((__u16 *) (opcode+2)), location+1)) |
| 457 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | signal = math_emu_stfpc(opcode, regs); |
| 459 | } else if (*((__u16 *) opcode) == 0xb29d) { |
Heiko Carstens | 12bae23 | 2006-10-27 12:39:22 +0200 | [diff] [blame] | 460 | if (get_user(*((__u16 *) (opcode+2)), location+1)) |
| 461 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | signal = math_emu_lfpc(opcode, regs); |
| 463 | #endif |
| 464 | } else |
| 465 | signal = SIGILL; |
Heiko Carstens | 35df8d5 | 2007-02-05 21:17:29 +0100 | [diff] [blame] | 466 | } else { |
| 467 | /* |
| 468 | * If we get an illegal op in kernel mode, send it through the |
| 469 | * kprobes notifier. If kprobes doesn't pick it up, SIGILL |
| 470 | */ |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 471 | if (notify_die(DIE_BPT, "bpt", regs, 0, |
Heiko Carstens | 35df8d5 | 2007-02-05 21:17:29 +0100 | [diff] [blame] | 472 | 3, SIGTRAP) != NOTIFY_STOP) |
| 473 | signal = SIGILL; |
| 474 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | |
| 476 | #ifdef CONFIG_MATHEMU |
| 477 | if (signal == SIGFPE) |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 478 | do_fp_trap(regs, current->thread.fp_regs.fpc); |
| 479 | else if (signal == SIGSEGV) |
| 480 | do_trap(regs, signal, SEGV_MAPERR, "user address fault"); |
| 481 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | #endif |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 483 | if (signal) |
| 484 | do_trap(regs, signal, ILL_ILLOPC, "illegal operation"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | |
| 488 | #ifdef CONFIG_MATHEMU |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 489 | void specification_exception(struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | { |
| 491 | __u8 opcode[6]; |
Al Viro | 5a42b81 | 2006-10-09 20:28:03 +0100 | [diff] [blame] | 492 | __u16 __user *location = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | int signal = 0; |
| 494 | |
Martin Schwidefsky | d35339a | 2012-07-31 11:03:04 +0200 | [diff] [blame^] | 495 | location = (__u16 __user *) get_trap_ip(regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | |
Heiko Carstens | 7d25617 | 2012-07-27 10:31:12 +0200 | [diff] [blame] | 497 | if (user_mode(regs)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | get_user(*((__u16 *) opcode), location); |
| 499 | switch (opcode[0]) { |
| 500 | case 0x28: /* LDR Rx,Ry */ |
| 501 | signal = math_emu_ldr(opcode); |
| 502 | break; |
| 503 | case 0x38: /* LER Rx,Ry */ |
| 504 | signal = math_emu_ler(opcode); |
| 505 | break; |
| 506 | case 0x60: /* STD R,D(X,B) */ |
| 507 | get_user(*((__u16 *) (opcode+2)), location+1); |
| 508 | signal = math_emu_std(opcode, regs); |
| 509 | break; |
| 510 | case 0x68: /* LD R,D(X,B) */ |
| 511 | get_user(*((__u16 *) (opcode+2)), location+1); |
| 512 | signal = math_emu_ld(opcode, regs); |
| 513 | break; |
| 514 | case 0x70: /* STE R,D(X,B) */ |
| 515 | get_user(*((__u16 *) (opcode+2)), location+1); |
| 516 | signal = math_emu_ste(opcode, regs); |
| 517 | break; |
| 518 | case 0x78: /* LE R,D(X,B) */ |
| 519 | get_user(*((__u16 *) (opcode+2)), location+1); |
| 520 | signal = math_emu_le(opcode, regs); |
| 521 | break; |
| 522 | default: |
| 523 | signal = SIGILL; |
| 524 | break; |
| 525 | } |
| 526 | } else |
| 527 | signal = SIGILL; |
| 528 | |
| 529 | if (signal == SIGFPE) |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 530 | do_fp_trap(regs, current->thread.fp_regs.fpc); |
| 531 | else if (signal) |
| 532 | do_trap(regs, signal, ILL_ILLOPN, "specification exception"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | } |
| 534 | #else |
Martin Schwidefsky | 1e54622 | 2010-10-25 16:10:37 +0200 | [diff] [blame] | 535 | DO_ERROR_INFO(specification_exception, SIGILL, ILL_ILLOPN, |
| 536 | "specification exception"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | #endif |
| 538 | |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 539 | static void data_exception(struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | { |
Heiko Carstens | d2c993d | 2006-07-12 16:41:55 +0200 | [diff] [blame] | 541 | __u16 __user *location; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | int signal = 0; |
| 543 | |
Martin Schwidefsky | d35339a | 2012-07-31 11:03:04 +0200 | [diff] [blame^] | 544 | location = get_trap_ip(regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | |
| 546 | if (MACHINE_HAS_IEEE) |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 547 | asm volatile("stfpc %0" : "=m" (current->thread.fp_regs.fpc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | |
| 549 | #ifdef CONFIG_MATHEMU |
Heiko Carstens | 7d25617 | 2012-07-27 10:31:12 +0200 | [diff] [blame] | 550 | else if (user_mode(regs)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | __u8 opcode[6]; |
| 552 | get_user(*((__u16 *) opcode), location); |
| 553 | switch (opcode[0]) { |
| 554 | case 0x28: /* LDR Rx,Ry */ |
| 555 | signal = math_emu_ldr(opcode); |
| 556 | break; |
| 557 | case 0x38: /* LER Rx,Ry */ |
| 558 | signal = math_emu_ler(opcode); |
| 559 | break; |
| 560 | case 0x60: /* STD R,D(X,B) */ |
| 561 | get_user(*((__u16 *) (opcode+2)), location+1); |
| 562 | signal = math_emu_std(opcode, regs); |
| 563 | break; |
| 564 | case 0x68: /* LD R,D(X,B) */ |
| 565 | get_user(*((__u16 *) (opcode+2)), location+1); |
| 566 | signal = math_emu_ld(opcode, regs); |
| 567 | break; |
| 568 | case 0x70: /* STE R,D(X,B) */ |
| 569 | get_user(*((__u16 *) (opcode+2)), location+1); |
| 570 | signal = math_emu_ste(opcode, regs); |
| 571 | break; |
| 572 | case 0x78: /* LE R,D(X,B) */ |
| 573 | get_user(*((__u16 *) (opcode+2)), location+1); |
| 574 | signal = math_emu_le(opcode, regs); |
| 575 | break; |
| 576 | case 0xb3: |
| 577 | get_user(*((__u16 *) (opcode+2)), location+1); |
| 578 | signal = math_emu_b3(opcode, regs); |
| 579 | break; |
| 580 | case 0xed: |
| 581 | get_user(*((__u32 *) (opcode+2)), |
Al Viro | 5a42b81 | 2006-10-09 20:28:03 +0100 | [diff] [blame] | 582 | (__u32 __user *)(location+1)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | signal = math_emu_ed(opcode, regs); |
| 584 | break; |
| 585 | case 0xb2: |
| 586 | if (opcode[1] == 0x99) { |
| 587 | get_user(*((__u16 *) (opcode+2)), location+1); |
| 588 | signal = math_emu_srnm(opcode, regs); |
| 589 | } else if (opcode[1] == 0x9c) { |
| 590 | get_user(*((__u16 *) (opcode+2)), location+1); |
| 591 | signal = math_emu_stfpc(opcode, regs); |
| 592 | } else if (opcode[1] == 0x9d) { |
| 593 | get_user(*((__u16 *) (opcode+2)), location+1); |
| 594 | signal = math_emu_lfpc(opcode, regs); |
| 595 | } else |
| 596 | signal = SIGILL; |
| 597 | break; |
| 598 | default: |
| 599 | signal = SIGILL; |
| 600 | break; |
| 601 | } |
| 602 | } |
| 603 | #endif |
| 604 | if (current->thread.fp_regs.fpc & FPC_DXC_MASK) |
| 605 | signal = SIGFPE; |
| 606 | else |
| 607 | signal = SIGILL; |
| 608 | if (signal == SIGFPE) |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 609 | do_fp_trap(regs, current->thread.fp_regs.fpc); |
| 610 | else if (signal) |
| 611 | do_trap(regs, signal, ILL_ILLOPN, "data exception"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | } |
| 613 | |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 614 | static void space_switch_exception(struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | /* Set user psw back to home space mode. */ |
Heiko Carstens | 7d25617 | 2012-07-27 10:31:12 +0200 | [diff] [blame] | 617 | if (user_mode(regs)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | regs->psw.mask |= PSW_ASC_HOME; |
| 619 | /* Send SIGILL. */ |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 620 | do_trap(regs, SIGILL, ILL_PRVOPC, "space switch event"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | } |
| 622 | |
Martin Schwidefsky | fdb204d | 2011-07-24 10:48:24 +0200 | [diff] [blame] | 623 | void __kprobes kernel_stack_overflow(struct pt_regs * regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | { |
Heiko Carstens | 77eb65c | 2005-06-21 17:16:28 -0700 | [diff] [blame] | 625 | bust_spinlocks(1); |
| 626 | printk("Kernel stack overflow.\n"); |
| 627 | show_regs(regs); |
| 628 | bust_spinlocks(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | panic("Corrupt kernel stack, can't continue."); |
| 630 | } |
| 631 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | /* init is done in lowcore.S and head.S */ |
| 633 | |
| 634 | void __init trap_init(void) |
| 635 | { |
| 636 | int i; |
| 637 | |
| 638 | for (i = 0; i < 128; i++) |
| 639 | pgm_check_table[i] = &default_trap_handler; |
| 640 | pgm_check_table[1] = &illegal_op; |
| 641 | pgm_check_table[2] = &privileged_op; |
| 642 | pgm_check_table[3] = &execute_exception; |
| 643 | pgm_check_table[4] = &do_protection_exception; |
| 644 | pgm_check_table[5] = &addressing_exception; |
| 645 | pgm_check_table[6] = &specification_exception; |
| 646 | pgm_check_table[7] = &data_exception; |
| 647 | pgm_check_table[8] = &overflow_exception; |
| 648 | pgm_check_table[9] = ÷_exception; |
| 649 | pgm_check_table[0x0A] = &overflow_exception; |
| 650 | pgm_check_table[0x0B] = ÷_exception; |
| 651 | pgm_check_table[0x0C] = &hfp_overflow_exception; |
| 652 | pgm_check_table[0x0D] = &hfp_underflow_exception; |
| 653 | pgm_check_table[0x0E] = &hfp_significance_exception; |
| 654 | pgm_check_table[0x0F] = &hfp_divide_exception; |
| 655 | pgm_check_table[0x10] = &do_dat_exception; |
| 656 | pgm_check_table[0x11] = &do_dat_exception; |
| 657 | pgm_check_table[0x12] = &translation_exception; |
| 658 | pgm_check_table[0x13] = &special_op_exception; |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 659 | #ifdef CONFIG_64BIT |
Martin Schwidefsky | d35339a | 2012-07-31 11:03:04 +0200 | [diff] [blame^] | 660 | pgm_check_table[0x18] = &transaction_exception; |
Martin Schwidefsky | 6252d70 | 2008-02-09 18:24:37 +0100 | [diff] [blame] | 661 | pgm_check_table[0x38] = &do_asce_exception; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | pgm_check_table[0x39] = &do_dat_exception; |
| 663 | pgm_check_table[0x3A] = &do_dat_exception; |
| 664 | pgm_check_table[0x3B] = &do_dat_exception; |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 665 | #endif /* CONFIG_64BIT */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | pgm_check_table[0x15] = &operand_exception; |
| 667 | pgm_check_table[0x1C] = &space_switch_exception; |
| 668 | pgm_check_table[0x1D] = &hfp_sqrt_exception; |
Heiko Carstens | f3e1a27 | 2011-01-05 12:48:00 +0100 | [diff] [blame] | 669 | /* Enable machine checks early. */ |
| 670 | local_mcck_enable(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | } |