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