1 |
1275 |
phoenix |
/*
|
2 |
|
|
* arch/s390/kernel/traps.c
|
3 |
|
|
*
|
4 |
|
|
* S390 version
|
5 |
|
|
* Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
|
6 |
|
|
* Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
|
7 |
|
|
* Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
|
8 |
|
|
*
|
9 |
|
|
* Derived from "arch/i386/kernel/traps.c"
|
10 |
|
|
* Copyright (C) 1991, 1992 Linus Torvalds
|
11 |
|
|
*/
|
12 |
|
|
|
13 |
|
|
/*
|
14 |
|
|
* 'Traps.c' handles hardware traps and faults after we have saved some
|
15 |
|
|
* state in 'asm.s'.
|
16 |
|
|
*/
|
17 |
|
|
#include <linux/config.h>
|
18 |
|
|
#include <linux/sched.h>
|
19 |
|
|
#include <linux/kernel.h>
|
20 |
|
|
#include <linux/string.h>
|
21 |
|
|
#include <linux/errno.h>
|
22 |
|
|
#include <linux/ptrace.h>
|
23 |
|
|
#include <linux/timer.h>
|
24 |
|
|
#include <linux/mm.h>
|
25 |
|
|
#include <linux/smp.h>
|
26 |
|
|
#include <linux/smp_lock.h>
|
27 |
|
|
#include <linux/init.h>
|
28 |
|
|
#include <linux/delay.h>
|
29 |
|
|
#include <linux/module.h>
|
30 |
|
|
|
31 |
|
|
#include <asm/system.h>
|
32 |
|
|
#include <asm/uaccess.h>
|
33 |
|
|
#include <asm/io.h>
|
34 |
|
|
#include <asm/atomic.h>
|
35 |
|
|
#if CONFIG_REMOTE_DEBUG
|
36 |
|
|
#include <asm/gdb-stub.h>
|
37 |
|
|
#endif
|
38 |
|
|
#include <asm/cpcmd.h>
|
39 |
|
|
#include <asm/s390_ext.h>
|
40 |
|
|
|
41 |
|
|
/* Called from entry.S only */
|
42 |
|
|
extern void handle_per_exception(struct pt_regs *regs);
|
43 |
|
|
|
44 |
|
|
typedef void pgm_check_handler_t(struct pt_regs *, long);
|
45 |
|
|
pgm_check_handler_t *pgm_check_table[128];
|
46 |
|
|
|
47 |
|
|
#ifdef CONFIG_SYSCTL
|
48 |
|
|
#ifdef CONFIG_PROCESS_DEBUG
|
49 |
|
|
int sysctl_userprocess_debug = 1;
|
50 |
|
|
#else
|
51 |
|
|
int sysctl_userprocess_debug = 0;
|
52 |
|
|
#endif
|
53 |
|
|
#endif
|
54 |
|
|
|
55 |
|
|
extern pgm_check_handler_t do_protection_exception;
|
56 |
|
|
extern pgm_check_handler_t do_segment_exception;
|
57 |
|
|
extern pgm_check_handler_t do_region_exception;
|
58 |
|
|
extern pgm_check_handler_t do_page_exception;
|
59 |
|
|
#ifdef CONFIG_PFAULT
|
60 |
|
|
extern int pfault_init(void);
|
61 |
|
|
extern void pfault_fini(void);
|
62 |
|
|
extern void pfault_interrupt(struct pt_regs *regs, __u16 error_code);
|
63 |
|
|
static ext_int_info_t ext_int_pfault;
|
64 |
|
|
#endif
|
65 |
|
|
|
66 |
|
|
int kstack_depth_to_print = 20;
|
67 |
|
|
|
68 |
|
|
/*
|
69 |
|
|
* If the address is either in the .text section of the
|
70 |
|
|
* kernel, or in the vmalloc'ed module regions, it *may*
|
71 |
|
|
* be the address of a calling routine
|
72 |
|
|
*/
|
73 |
|
|
extern char _stext, _etext;
|
74 |
|
|
|
75 |
|
|
#ifdef CONFIG_MODULES
|
76 |
|
|
|
77 |
|
|
extern struct module *module_list;
|
78 |
|
|
extern struct module kernel_module;
|
79 |
|
|
|
80 |
|
|
static inline int kernel_text_address(unsigned long addr)
|
81 |
|
|
{
|
82 |
|
|
int retval = 0;
|
83 |
|
|
struct module *mod;
|
84 |
|
|
|
85 |
|
|
if (addr >= (unsigned long) &_stext &&
|
86 |
|
|
addr <= (unsigned long) &_etext)
|
87 |
|
|
return 1;
|
88 |
|
|
|
89 |
|
|
for (mod = module_list; mod != &kernel_module; mod = mod->next) {
|
90 |
|
|
/* mod_bound tests for addr being inside the vmalloc'ed
|
91 |
|
|
* module area. Of course it'd be better to test only
|
92 |
|
|
* for the .text subset... */
|
93 |
|
|
if (mod_bound(addr, 0, mod)) {
|
94 |
|
|
retval = 1;
|
95 |
|
|
break;
|
96 |
|
|
}
|
97 |
|
|
}
|
98 |
|
|
|
99 |
|
|
return retval;
|
100 |
|
|
}
|
101 |
|
|
|
102 |
|
|
#else
|
103 |
|
|
|
104 |
|
|
static inline int kernel_text_address(unsigned long addr)
|
105 |
|
|
{
|
106 |
|
|
return (addr >= (unsigned long) &_stext &&
|
107 |
|
|
addr <= (unsigned long) &_etext);
|
108 |
|
|
}
|
109 |
|
|
|
110 |
|
|
#endif
|
111 |
|
|
|
112 |
|
|
void show_trace(unsigned long * stack)
|
113 |
|
|
{
|
114 |
|
|
unsigned long backchain, low_addr, high_addr, ret_addr;
|
115 |
|
|
int i;
|
116 |
|
|
|
117 |
|
|
if (!stack)
|
118 |
|
|
stack = (unsigned long*)&stack;
|
119 |
|
|
|
120 |
|
|
printk("Call Trace: ");
|
121 |
|
|
low_addr = ((unsigned long) stack) & PSW_ADDR_MASK;
|
122 |
|
|
high_addr = (low_addr & (-THREAD_SIZE)) + THREAD_SIZE;
|
123 |
|
|
/* Skip the first frame (biased stack) */
|
124 |
|
|
backchain = *((unsigned long *) low_addr) & PSW_ADDR_MASK;
|
125 |
|
|
/* Print up to 8 lines */
|
126 |
|
|
for (i = 0; i < 8; i++) {
|
127 |
|
|
if (backchain < low_addr || backchain >= high_addr)
|
128 |
|
|
break;
|
129 |
|
|
ret_addr = *((unsigned long *) (backchain+112)) & PSW_ADDR_MASK;
|
130 |
|
|
if (!kernel_text_address(ret_addr))
|
131 |
|
|
break;
|
132 |
|
|
if (i && ((i % 3) == 0))
|
133 |
|
|
printk("\n ");
|
134 |
|
|
printk("[<%016lx>] ", ret_addr);
|
135 |
|
|
low_addr = backchain;
|
136 |
|
|
backchain = *((unsigned long *) backchain) & PSW_ADDR_MASK;
|
137 |
|
|
}
|
138 |
|
|
printk("\n");
|
139 |
|
|
}
|
140 |
|
|
|
141 |
|
|
void show_trace_task(struct task_struct *tsk)
|
142 |
|
|
{
|
143 |
|
|
/*
|
144 |
|
|
* We can't print the backtrace of a running process. It is
|
145 |
|
|
* unreliable at best and can cause kernel oopses.
|
146 |
|
|
*/
|
147 |
|
|
if (task_has_cpu(tsk))
|
148 |
|
|
return;
|
149 |
|
|
show_trace((unsigned long *) tsk->thread.ksp);
|
150 |
|
|
}
|
151 |
|
|
|
152 |
|
|
void show_stack(unsigned long *sp)
|
153 |
|
|
{
|
154 |
|
|
unsigned long *stack;
|
155 |
|
|
int i;
|
156 |
|
|
|
157 |
|
|
// debugging aid: "show_stack(NULL);" prints the
|
158 |
|
|
// back trace for this cpu.
|
159 |
|
|
|
160 |
|
|
if (sp == NULL)
|
161 |
|
|
sp = (unsigned long*) &sp;
|
162 |
|
|
|
163 |
|
|
stack = sp;
|
164 |
|
|
for (i = 0; i < kstack_depth_to_print; i++) {
|
165 |
|
|
if (((addr_t) stack & (THREAD_SIZE-1)) == 0)
|
166 |
|
|
break;
|
167 |
|
|
if (i && ((i % 4) == 0))
|
168 |
|
|
printk("\n ");
|
169 |
|
|
printk("%016lx ", *stack++);
|
170 |
|
|
}
|
171 |
|
|
printk("\n");
|
172 |
|
|
show_trace(sp);
|
173 |
|
|
}
|
174 |
|
|
|
175 |
|
|
void show_registers(struct pt_regs *regs)
|
176 |
|
|
{
|
177 |
|
|
mm_segment_t old_fs;
|
178 |
|
|
char *mode;
|
179 |
|
|
int i;
|
180 |
|
|
|
181 |
|
|
mode = (regs->psw.mask & PSW_PROBLEM_STATE) ? "User" : "Krnl";
|
182 |
|
|
printk("%s PSW : %016lx %016lx\n",
|
183 |
|
|
mode, (unsigned long) regs->psw.mask,
|
184 |
|
|
(unsigned long) regs->psw.addr);
|
185 |
|
|
printk("%s GPRS: %016lx %016lx %016lx %016lx\n", mode,
|
186 |
|
|
regs->gprs[0], regs->gprs[1], regs->gprs[2], regs->gprs[3]);
|
187 |
|
|
printk(" %016lx %016lx %016lx %016lx\n",
|
188 |
|
|
regs->gprs[4], regs->gprs[5], regs->gprs[6], regs->gprs[7]);
|
189 |
|
|
printk(" %016lx %016lx %016lx %016lx\n",
|
190 |
|
|
regs->gprs[8], regs->gprs[9], regs->gprs[10], regs->gprs[11]);
|
191 |
|
|
printk(" %016lx %016lx %016lx %016lx\n",
|
192 |
|
|
regs->gprs[12], regs->gprs[13], regs->gprs[14], regs->gprs[15]);
|
193 |
|
|
printk("%s ACRS: %08x %08x %08x %08x\n", mode,
|
194 |
|
|
regs->acrs[0], regs->acrs[1], regs->acrs[2], regs->acrs[3]);
|
195 |
|
|
printk(" %08x %08x %08x %08x\n",
|
196 |
|
|
regs->acrs[4], regs->acrs[5], regs->acrs[6], regs->acrs[7]);
|
197 |
|
|
printk(" %08x %08x %08x %08x\n",
|
198 |
|
|
regs->acrs[8], regs->acrs[9], regs->acrs[10], regs->acrs[11]);
|
199 |
|
|
printk(" %08x %08x %08x %08x\n",
|
200 |
|
|
regs->acrs[12], regs->acrs[13], regs->acrs[14], regs->acrs[15]);
|
201 |
|
|
|
202 |
|
|
/*
|
203 |
|
|
* Print the first 20 byte of the instruction stream at the
|
204 |
|
|
* time of the fault.
|
205 |
|
|
*/
|
206 |
|
|
old_fs = get_fs();
|
207 |
|
|
if (regs->psw.mask & PSW_PROBLEM_STATE)
|
208 |
|
|
set_fs(USER_DS);
|
209 |
|
|
else
|
210 |
|
|
set_fs(KERNEL_DS);
|
211 |
|
|
printk("%s Code: ", mode);
|
212 |
|
|
for (i = 0; i < 20; i++) {
|
213 |
|
|
unsigned char c;
|
214 |
|
|
if (__get_user(c, (char *)(regs->psw.addr + i))) {
|
215 |
|
|
printk(" Bad PSW.");
|
216 |
|
|
break;
|
217 |
|
|
}
|
218 |
|
|
printk("%02x ", c);
|
219 |
|
|
}
|
220 |
|
|
set_fs(old_fs);
|
221 |
|
|
|
222 |
|
|
printk("\n");
|
223 |
|
|
}
|
224 |
|
|
|
225 |
|
|
/* This is called from fs/proc/array.c */
|
226 |
|
|
char *task_show_regs(struct task_struct *task, char *buf)
|
227 |
|
|
{
|
228 |
|
|
struct pt_regs *regs;
|
229 |
|
|
|
230 |
|
|
regs = __KSTK_PTREGS(task);
|
231 |
|
|
buf += sprintf(buf, "task: %016lx, ksp: %016lx\n",
|
232 |
|
|
(unsigned long) task, task->thread.ksp);
|
233 |
|
|
buf += sprintf(buf, "User PSW : %016lx %016lx\n",
|
234 |
|
|
(unsigned long) regs->psw.mask,
|
235 |
|
|
(unsigned long) regs->psw.addr);
|
236 |
|
|
buf += sprintf(buf, "User GPRS: %016lx %016lx %016lx %016lx\n",
|
237 |
|
|
regs->gprs[0], regs->gprs[1],
|
238 |
|
|
regs->gprs[2], regs->gprs[3]);
|
239 |
|
|
buf += sprintf(buf, " %016lx %016lx %016lx %016lx\n",
|
240 |
|
|
regs->gprs[4], regs->gprs[5],
|
241 |
|
|
regs->gprs[6], regs->gprs[7]);
|
242 |
|
|
buf += sprintf(buf, " %016lx %016lx %016lx %016lx\n",
|
243 |
|
|
regs->gprs[8], regs->gprs[9],
|
244 |
|
|
regs->gprs[10], regs->gprs[11]);
|
245 |
|
|
buf += sprintf(buf, " %016lx %016lx %016lx %016lx\n",
|
246 |
|
|
regs->gprs[12], regs->gprs[13],
|
247 |
|
|
regs->gprs[14], regs->gprs[15]);
|
248 |
|
|
buf += sprintf(buf, "User ACRS: %08x %08x %08x %08x\n",
|
249 |
|
|
regs->acrs[0], regs->acrs[1],
|
250 |
|
|
regs->acrs[2], regs->acrs[3]);
|
251 |
|
|
buf += sprintf(buf, " %08x %08x %08x %08x\n",
|
252 |
|
|
regs->acrs[4], regs->acrs[5],
|
253 |
|
|
regs->acrs[6], regs->acrs[7]);
|
254 |
|
|
buf += sprintf(buf, " %08x %08x %08x %08x\n",
|
255 |
|
|
regs->acrs[8], regs->acrs[9],
|
256 |
|
|
regs->acrs[10], regs->acrs[11]);
|
257 |
|
|
buf += sprintf(buf, " %08x %08x %08x %08x\n",
|
258 |
|
|
regs->acrs[12], regs->acrs[13],
|
259 |
|
|
regs->acrs[14], regs->acrs[15]);
|
260 |
|
|
return buf;
|
261 |
|
|
}
|
262 |
|
|
|
263 |
|
|
spinlock_t die_lock = SPIN_LOCK_UNLOCKED;
|
264 |
|
|
|
265 |
|
|
void die(const char * str, struct pt_regs * regs, long err)
|
266 |
|
|
{
|
267 |
|
|
console_verbose();
|
268 |
|
|
spin_lock_irq(&die_lock);
|
269 |
|
|
bust_spinlocks(1);
|
270 |
|
|
printk("%s: %04lx\n", str, err & 0xffff);
|
271 |
|
|
show_regs(regs);
|
272 |
|
|
bust_spinlocks(0);
|
273 |
|
|
spin_unlock_irq(&die_lock);
|
274 |
|
|
do_exit(SIGSEGV);
|
275 |
|
|
}
|
276 |
|
|
|
277 |
|
|
static void inline do_trap(long interruption_code, int signr, char *str,
|
278 |
|
|
struct pt_regs *regs, siginfo_t *info)
|
279 |
|
|
{
|
280 |
|
|
/*
|
281 |
|
|
* We got all needed information from the lowcore and can
|
282 |
|
|
* now safely switch on interrupts.
|
283 |
|
|
*/
|
284 |
|
|
if (regs->psw.mask & PSW_PROBLEM_STATE)
|
285 |
|
|
__sti();
|
286 |
|
|
|
287 |
|
|
if (regs->psw.mask & PSW_PROBLEM_STATE) {
|
288 |
|
|
struct task_struct *tsk = current;
|
289 |
|
|
tsk->thread.trap_no = interruption_code & 0xffff;
|
290 |
|
|
if (info)
|
291 |
|
|
force_sig_info(signr, info, tsk);
|
292 |
|
|
else
|
293 |
|
|
force_sig(signr, tsk);
|
294 |
|
|
#ifndef CONFIG_SYSCTL
|
295 |
|
|
#ifdef CONFIG_PROCESS_DEBUG
|
296 |
|
|
printk("User process fault: interruption code 0x%lX\n",
|
297 |
|
|
interruption_code);
|
298 |
|
|
show_regs(regs);
|
299 |
|
|
#endif
|
300 |
|
|
#else
|
301 |
|
|
if (sysctl_userprocess_debug) {
|
302 |
|
|
printk("User process fault: interruption code 0x%lX\n",
|
303 |
|
|
interruption_code);
|
304 |
|
|
show_regs(regs);
|
305 |
|
|
}
|
306 |
|
|
#endif
|
307 |
|
|
} else {
|
308 |
|
|
unsigned long fixup = search_exception_table(regs->psw.addr);
|
309 |
|
|
if (fixup)
|
310 |
|
|
regs->psw.addr = fixup;
|
311 |
|
|
else
|
312 |
|
|
die(str, regs, interruption_code);
|
313 |
|
|
}
|
314 |
|
|
}
|
315 |
|
|
|
316 |
|
|
static inline void *get_check_address(struct pt_regs *regs)
|
317 |
|
|
{
|
318 |
|
|
return (void *) ADDR_BITS_REMOVE(regs->psw.addr-S390_lowcore.pgm_ilc);
|
319 |
|
|
}
|
320 |
|
|
|
321 |
|
|
int do_debugger_trap(struct pt_regs *regs,int signal)
|
322 |
|
|
{
|
323 |
|
|
if(regs->psw.mask&PSW_PROBLEM_STATE)
|
324 |
|
|
{
|
325 |
|
|
if(current->ptrace & PT_PTRACED)
|
326 |
|
|
force_sig(signal,current);
|
327 |
|
|
else
|
328 |
|
|
return 1;
|
329 |
|
|
}
|
330 |
|
|
else
|
331 |
|
|
{
|
332 |
|
|
#if CONFIG_REMOTE_DEBUG
|
333 |
|
|
if(gdb_stub_initialised)
|
334 |
|
|
{
|
335 |
|
|
gdb_stub_handle_exception(regs, signal);
|
336 |
|
|
return 0;
|
337 |
|
|
}
|
338 |
|
|
#endif
|
339 |
|
|
return 1;
|
340 |
|
|
}
|
341 |
|
|
return 0;
|
342 |
|
|
}
|
343 |
|
|
|
344 |
|
|
#define DO_ERROR(signr, str, name) \
|
345 |
|
|
asmlinkage void name(struct pt_regs * regs, long interruption_code) \
|
346 |
|
|
{ \
|
347 |
|
|
do_trap(interruption_code, signr, str, regs, NULL); \
|
348 |
|
|
}
|
349 |
|
|
|
350 |
|
|
#define DO_ERROR_INFO(signr, str, name, sicode, siaddr) \
|
351 |
|
|
asmlinkage void name(struct pt_regs * regs, long interruption_code) \
|
352 |
|
|
{ \
|
353 |
|
|
siginfo_t info; \
|
354 |
|
|
info.si_signo = signr; \
|
355 |
|
|
info.si_errno = 0; \
|
356 |
|
|
info.si_code = sicode; \
|
357 |
|
|
info.si_addr = (void *)siaddr; \
|
358 |
|
|
do_trap(interruption_code, signr, str, regs, &info); \
|
359 |
|
|
}
|
360 |
|
|
|
361 |
|
|
DO_ERROR(SIGSEGV, "Unknown program exception", default_trap_handler)
|
362 |
|
|
|
363 |
|
|
DO_ERROR_INFO(SIGBUS, "addressing exception", addressing_exception,
|
364 |
|
|
BUS_ADRERR, get_check_address(regs))
|
365 |
|
|
DO_ERROR_INFO(SIGILL, "execute exception", execute_exception,
|
366 |
|
|
ILL_ILLOPN, get_check_address(regs))
|
367 |
|
|
DO_ERROR_INFO(SIGFPE, "fixpoint divide exception", divide_exception,
|
368 |
|
|
FPE_INTDIV, get_check_address(regs))
|
369 |
|
|
DO_ERROR_INFO(SIGILL, "operand exception", operand_exception,
|
370 |
|
|
ILL_ILLOPN, get_check_address(regs))
|
371 |
|
|
DO_ERROR_INFO(SIGILL, "privileged operation", privileged_op,
|
372 |
|
|
ILL_PRVOPC, get_check_address(regs))
|
373 |
|
|
DO_ERROR_INFO(SIGILL, "special operation exception", special_op_exception,
|
374 |
|
|
ILL_ILLOPN, get_check_address(regs))
|
375 |
|
|
DO_ERROR_INFO(SIGILL, "specification exception", specification_exception,
|
376 |
|
|
ILL_ILLOPN, get_check_address(regs))
|
377 |
|
|
DO_ERROR_INFO(SIGILL, "translation exception", translation_exception,
|
378 |
|
|
ILL_ILLOPN, get_check_address(regs))
|
379 |
|
|
|
380 |
|
|
static inline void
|
381 |
|
|
do_fp_trap(struct pt_regs *regs, void *location,
|
382 |
|
|
int fpc, long interruption_code)
|
383 |
|
|
{
|
384 |
|
|
siginfo_t si;
|
385 |
|
|
|
386 |
|
|
si.si_signo = SIGFPE;
|
387 |
|
|
si.si_errno = 0;
|
388 |
|
|
si.si_addr = location;
|
389 |
|
|
si.si_code = 0;
|
390 |
|
|
/* FPC[2] is Data Exception Code */
|
391 |
|
|
if ((fpc & 0x00000300) == 0) {
|
392 |
|
|
/* bits 6 and 7 of DXC are 0 iff IEEE exception */
|
393 |
|
|
if (fpc & 0x8000) /* invalid fp operation */
|
394 |
|
|
si.si_code = FPE_FLTINV;
|
395 |
|
|
else if (fpc & 0x4000) /* div by 0 */
|
396 |
|
|
si.si_code = FPE_FLTDIV;
|
397 |
|
|
else if (fpc & 0x2000) /* overflow */
|
398 |
|
|
si.si_code = FPE_FLTOVF;
|
399 |
|
|
else if (fpc & 0x1000) /* underflow */
|
400 |
|
|
si.si_code = FPE_FLTUND;
|
401 |
|
|
else if (fpc & 0x0800) /* inexact */
|
402 |
|
|
si.si_code = FPE_FLTRES;
|
403 |
|
|
}
|
404 |
|
|
current->thread.ieee_instruction_pointer = (addr_t) location;
|
405 |
|
|
do_trap(interruption_code, SIGFPE,
|
406 |
|
|
"floating point exception", regs, &si);
|
407 |
|
|
}
|
408 |
|
|
|
409 |
|
|
asmlinkage void illegal_op(struct pt_regs * regs, long interruption_code)
|
410 |
|
|
{
|
411 |
|
|
__u8 opcode[6];
|
412 |
|
|
__u16 *location;
|
413 |
|
|
int do_sig = 0;
|
414 |
|
|
|
415 |
|
|
location = (__u16 *) get_check_address(regs);
|
416 |
|
|
|
417 |
|
|
/*
|
418 |
|
|
* We got all needed information from the lowcore and can
|
419 |
|
|
* now safely switch on interrupts.
|
420 |
|
|
*/
|
421 |
|
|
if (regs->psw.mask & PSW_PROBLEM_STATE)
|
422 |
|
|
__sti();
|
423 |
|
|
|
424 |
|
|
/* WARNING don't change this check back to */
|
425 |
|
|
/* int problem_state=(regs->psw.mask & PSW_PROBLEM_STATE); */
|
426 |
|
|
/* & then doing if(problem_state) an int is too small for this */
|
427 |
|
|
/* check on 64 bit. */
|
428 |
|
|
if(regs->psw.mask & PSW_PROBLEM_STATE)
|
429 |
|
|
get_user(*((__u16 *) opcode), location);
|
430 |
|
|
else
|
431 |
|
|
*((__u16 *)opcode)=*((__u16 *)location);
|
432 |
|
|
if(*((__u16 *)opcode)==S390_BREAKPOINT_U16)
|
433 |
|
|
{
|
434 |
|
|
if(do_debugger_trap(regs,SIGTRAP))
|
435 |
|
|
do_sig=1;
|
436 |
|
|
}
|
437 |
|
|
else
|
438 |
|
|
do_sig = 1;
|
439 |
|
|
if (do_sig)
|
440 |
|
|
do_trap(interruption_code, SIGILL,
|
441 |
|
|
"illegal operation", regs, NULL);
|
442 |
|
|
}
|
443 |
|
|
|
444 |
|
|
asmlinkage void data_exception(struct pt_regs * regs, long interruption_code)
|
445 |
|
|
{
|
446 |
|
|
__u16 *location;
|
447 |
|
|
|
448 |
|
|
location = (__u16 *) get_check_address(regs);
|
449 |
|
|
|
450 |
|
|
/*
|
451 |
|
|
* We got all needed information from the lowcore and can
|
452 |
|
|
* now safely switch on interrupts.
|
453 |
|
|
*/
|
454 |
|
|
if (regs->psw.mask & PSW_PROBLEM_STATE)
|
455 |
|
|
__sti();
|
456 |
|
|
|
457 |
|
|
__asm__ volatile ("stfpc %0\n\t"
|
458 |
|
|
: "=m" (current->thread.fp_regs.fpc));
|
459 |
|
|
|
460 |
|
|
if (current->thread.fp_regs.fpc & FPC_DXC_MASK)
|
461 |
|
|
do_fp_trap(regs, location,
|
462 |
|
|
current->thread.fp_regs.fpc, interruption_code);
|
463 |
|
|
else {
|
464 |
|
|
siginfo_t info;
|
465 |
|
|
info.si_signo = SIGILL;
|
466 |
|
|
info.si_errno = 0;
|
467 |
|
|
info.si_code = ILL_ILLOPN;
|
468 |
|
|
info.si_addr = location;
|
469 |
|
|
do_trap(interruption_code, SIGILL,
|
470 |
|
|
"data exception", regs, &info);
|
471 |
|
|
}
|
472 |
|
|
}
|
473 |
|
|
|
474 |
|
|
|
475 |
|
|
|
476 |
|
|
/* init is done in lowcore.S and head.S */
|
477 |
|
|
|
478 |
|
|
void __init trap_init(void)
|
479 |
|
|
{
|
480 |
|
|
int i;
|
481 |
|
|
|
482 |
|
|
for (i = 0; i < 128; i++)
|
483 |
|
|
pgm_check_table[i] = &default_trap_handler;
|
484 |
|
|
pgm_check_table[1] = &illegal_op;
|
485 |
|
|
pgm_check_table[2] = &privileged_op;
|
486 |
|
|
pgm_check_table[3] = &execute_exception;
|
487 |
|
|
pgm_check_table[4] = &do_protection_exception;
|
488 |
|
|
pgm_check_table[5] = &addressing_exception;
|
489 |
|
|
pgm_check_table[6] = &specification_exception;
|
490 |
|
|
pgm_check_table[7] = &data_exception;
|
491 |
|
|
pgm_check_table[9] = ÷_exception;
|
492 |
|
|
pgm_check_table[0x12] = &translation_exception;
|
493 |
|
|
pgm_check_table[0x13] = &special_op_exception;
|
494 |
|
|
pgm_check_table[0x15] = &operand_exception;
|
495 |
|
|
pgm_check_table[0x10] = &do_segment_exception;
|
496 |
|
|
pgm_check_table[0x11] = &do_page_exception;
|
497 |
|
|
pgm_check_table[0x1C] = &privileged_op;
|
498 |
|
|
pgm_check_table[0x38] = &addressing_exception;
|
499 |
|
|
pgm_check_table[0x3B] = &do_region_exception;
|
500 |
|
|
#ifdef CONFIG_PFAULT
|
501 |
|
|
if (MACHINE_IS_VM) {
|
502 |
|
|
/* request the 0x2603 external interrupt */
|
503 |
|
|
if (register_early_external_interrupt(0x2603, pfault_interrupt,
|
504 |
|
|
&ext_int_pfault) != 0)
|
505 |
|
|
panic("Couldn't request external interrupt 0x2603");
|
506 |
|
|
/*
|
507 |
|
|
* Try to get pfault pseudo page faults going.
|
508 |
|
|
*/
|
509 |
|
|
if (pfault_init() != 0) {
|
510 |
|
|
/* Tough luck, no pfault. */
|
511 |
|
|
unregister_early_external_interrupt(0x2603,
|
512 |
|
|
pfault_interrupt,
|
513 |
|
|
&ext_int_pfault);
|
514 |
|
|
}
|
515 |
|
|
}
|
516 |
|
|
#endif
|
517 |
|
|
}
|
518 |
|
|
|
519 |
|
|
|
520 |
|
|
void handle_per_exception(struct pt_regs *regs)
|
521 |
|
|
{
|
522 |
|
|
if(regs->psw.mask&PSW_PROBLEM_STATE)
|
523 |
|
|
{
|
524 |
|
|
per_struct *per_info=¤t->thread.per_info;
|
525 |
|
|
per_info->lowcore.words.perc_atmid=S390_lowcore.per_perc_atmid;
|
526 |
|
|
per_info->lowcore.words.address=S390_lowcore.per_address;
|
527 |
|
|
per_info->lowcore.words.access_id=S390_lowcore.per_access_id;
|
528 |
|
|
}
|
529 |
|
|
if(do_debugger_trap(regs,SIGTRAP))
|
530 |
|
|
{
|
531 |
|
|
/* I've seen this possibly a task structure being reused ? */
|
532 |
|
|
printk("Spurious per exception detected\n");
|
533 |
|
|
printk("switching off per tracing for this task.\n");
|
534 |
|
|
show_regs(regs);
|
535 |
|
|
/* Hopefully switching off per tracing will help us survive */
|
536 |
|
|
regs->psw.mask &= ~PSW_PER_MASK;
|
537 |
|
|
}
|
538 |
|
|
}
|
539 |
|
|
|