2
* linux/arch/m68k/kernel/traps.c
4
* Copyright (C) 1993, 1994 by Hamish Macdonald
6
* 68040 fixes by Michael Rausch
7
* 68040 fixes by Martin Apel
8
* 68040 fixes and writeback by Richard Zidlicky
9
* 68060 fixes by Roman Hodek
10
* 68060 fixes by Jesper Skov
12
* This file is subject to the terms and conditions of the GNU General Public
13
* License. See the file COPYING in the main directory of this archive
18
* Sets up all exception vectors
21
#include <linux/sched.h>
22
#include <linux/signal.h>
23
#include <linux/kernel.h>
25
#include <linux/module.h>
26
#include <linux/user.h>
27
#include <linux/string.h>
28
#include <linux/linkage.h>
29
#include <linux/init.h>
30
#include <linux/ptrace.h>
31
#include <linux/kallsyms.h>
33
#include <asm/setup.h>
35
#include <asm/system.h>
36
#include <asm/uaccess.h>
37
#include <asm/traps.h>
38
#include <asm/pgalloc.h>
39
#include <asm/machdep.h>
40
#include <asm/siginfo.h>
42
/* assembler routines */
43
asmlinkage void system_call(void);
44
asmlinkage void buserr(void);
45
asmlinkage void trap(void);
46
asmlinkage void nmihandler(void);
47
#ifdef CONFIG_M68KFPU_EMU
48
asmlinkage void fpu_emu(void);
51
e_vector vectors[256];
53
/* nmi handler for the Amiga */
59
* this must be called very early as the kernel might
60
* use some instruction that are emulated on the 060
61
* and so we're prepared for early probe attempts (e.g. nf_init).
63
void __init base_trap_init(void)
66
extern e_vector *sun3x_prom_vbr;
68
__asm__ volatile ("movec %%vbr, %0" : "=r" (sun3x_prom_vbr));
71
/* setup the exception vector table */
72
__asm__ volatile ("movec %0,%%vbr" : : "r" ((void*)vectors));
75
/* set up ISP entry points */
76
asmlinkage void unimp_vec(void) asm ("_060_isp_unimp");
78
vectors[VEC_UNIMPII] = unimp_vec;
81
vectors[VEC_BUSERR] = buserr;
82
vectors[VEC_ILLEGAL] = trap;
83
vectors[VEC_SYS] = system_call;
86
void __init trap_init (void)
90
for (i = VEC_SPUR; i <= VEC_INT7; i++)
91
vectors[i] = bad_inthandler;
93
for (i = 0; i < VEC_USER; i++)
97
for (i = VEC_USER; i < 256; i++)
98
vectors[i] = bad_inthandler;
100
#ifdef CONFIG_M68KFPU_EMU
102
vectors[VEC_LINE11] = fpu_emu;
105
if (CPU_IS_040 && !FPU_IS_EMU) {
106
/* set up FPSP entry points */
107
asmlinkage void dz_vec(void) asm ("dz");
108
asmlinkage void inex_vec(void) asm ("inex");
109
asmlinkage void ovfl_vec(void) asm ("ovfl");
110
asmlinkage void unfl_vec(void) asm ("unfl");
111
asmlinkage void snan_vec(void) asm ("snan");
112
asmlinkage void operr_vec(void) asm ("operr");
113
asmlinkage void bsun_vec(void) asm ("bsun");
114
asmlinkage void fline_vec(void) asm ("fline");
115
asmlinkage void unsupp_vec(void) asm ("unsupp");
117
vectors[VEC_FPDIVZ] = dz_vec;
118
vectors[VEC_FPIR] = inex_vec;
119
vectors[VEC_FPOVER] = ovfl_vec;
120
vectors[VEC_FPUNDER] = unfl_vec;
121
vectors[VEC_FPNAN] = snan_vec;
122
vectors[VEC_FPOE] = operr_vec;
123
vectors[VEC_FPBRUC] = bsun_vec;
124
vectors[VEC_LINE11] = fline_vec;
125
vectors[VEC_FPUNSUP] = unsupp_vec;
128
if (CPU_IS_060 && !FPU_IS_EMU) {
129
/* set up IFPSP entry points */
130
asmlinkage void snan_vec6(void) asm ("_060_fpsp_snan");
131
asmlinkage void operr_vec6(void) asm ("_060_fpsp_operr");
132
asmlinkage void ovfl_vec6(void) asm ("_060_fpsp_ovfl");
133
asmlinkage void unfl_vec6(void) asm ("_060_fpsp_unfl");
134
asmlinkage void dz_vec6(void) asm ("_060_fpsp_dz");
135
asmlinkage void inex_vec6(void) asm ("_060_fpsp_inex");
136
asmlinkage void fline_vec6(void) asm ("_060_fpsp_fline");
137
asmlinkage void unsupp_vec6(void) asm ("_060_fpsp_unsupp");
138
asmlinkage void effadd_vec6(void) asm ("_060_fpsp_effadd");
140
vectors[VEC_FPNAN] = snan_vec6;
141
vectors[VEC_FPOE] = operr_vec6;
142
vectors[VEC_FPOVER] = ovfl_vec6;
143
vectors[VEC_FPUNDER] = unfl_vec6;
144
vectors[VEC_FPDIVZ] = dz_vec6;
145
vectors[VEC_FPIR] = inex_vec6;
146
vectors[VEC_LINE11] = fline_vec6;
147
vectors[VEC_FPUNSUP] = unsupp_vec6;
148
vectors[VEC_UNIMPEA] = effadd_vec6;
151
/* if running on an amiga, make the NMI interrupt do nothing */
153
vectors[VEC_INT7] = nmihandler;
158
static const char *vec_names[] = {
159
[VEC_RESETSP] = "RESET SP",
160
[VEC_RESETPC] = "RESET PC",
161
[VEC_BUSERR] = "BUS ERROR",
162
[VEC_ADDRERR] = "ADDRESS ERROR",
163
[VEC_ILLEGAL] = "ILLEGAL INSTRUCTION",
164
[VEC_ZERODIV] = "ZERO DIVIDE",
166
[VEC_TRAP] = "TRAPcc",
167
[VEC_PRIV] = "PRIVILEGE VIOLATION",
168
[VEC_TRACE] = "TRACE",
169
[VEC_LINE10] = "LINE 1010",
170
[VEC_LINE11] = "LINE 1111",
171
[VEC_RESV12] = "UNASSIGNED RESERVED 12",
172
[VEC_COPROC] = "COPROCESSOR PROTOCOL VIOLATION",
173
[VEC_FORMAT] = "FORMAT ERROR",
174
[VEC_UNINT] = "UNINITIALIZED INTERRUPT",
175
[VEC_RESV16] = "UNASSIGNED RESERVED 16",
176
[VEC_RESV17] = "UNASSIGNED RESERVED 17",
177
[VEC_RESV18] = "UNASSIGNED RESERVED 18",
178
[VEC_RESV19] = "UNASSIGNED RESERVED 19",
179
[VEC_RESV20] = "UNASSIGNED RESERVED 20",
180
[VEC_RESV21] = "UNASSIGNED RESERVED 21",
181
[VEC_RESV22] = "UNASSIGNED RESERVED 22",
182
[VEC_RESV23] = "UNASSIGNED RESERVED 23",
183
[VEC_SPUR] = "SPURIOUS INTERRUPT",
184
[VEC_INT1] = "LEVEL 1 INT",
185
[VEC_INT2] = "LEVEL 2 INT",
186
[VEC_INT3] = "LEVEL 3 INT",
187
[VEC_INT4] = "LEVEL 4 INT",
188
[VEC_INT5] = "LEVEL 5 INT",
189
[VEC_INT6] = "LEVEL 6 INT",
190
[VEC_INT7] = "LEVEL 7 INT",
191
[VEC_SYS] = "SYSCALL",
192
[VEC_TRAP1] = "TRAP #1",
193
[VEC_TRAP2] = "TRAP #2",
194
[VEC_TRAP3] = "TRAP #3",
195
[VEC_TRAP4] = "TRAP #4",
196
[VEC_TRAP5] = "TRAP #5",
197
[VEC_TRAP6] = "TRAP #6",
198
[VEC_TRAP7] = "TRAP #7",
199
[VEC_TRAP8] = "TRAP #8",
200
[VEC_TRAP9] = "TRAP #9",
201
[VEC_TRAP10] = "TRAP #10",
202
[VEC_TRAP11] = "TRAP #11",
203
[VEC_TRAP12] = "TRAP #12",
204
[VEC_TRAP13] = "TRAP #13",
205
[VEC_TRAP14] = "TRAP #14",
206
[VEC_TRAP15] = "TRAP #15",
207
[VEC_FPBRUC] = "FPCP BSUN",
208
[VEC_FPIR] = "FPCP INEXACT",
209
[VEC_FPDIVZ] = "FPCP DIV BY 0",
210
[VEC_FPUNDER] = "FPCP UNDERFLOW",
211
[VEC_FPOE] = "FPCP OPERAND ERROR",
212
[VEC_FPOVER] = "FPCP OVERFLOW",
213
[VEC_FPNAN] = "FPCP SNAN",
214
[VEC_FPUNSUP] = "FPCP UNSUPPORTED OPERATION",
215
[VEC_MMUCFG] = "MMU CONFIGURATION ERROR",
216
[VEC_MMUILL] = "MMU ILLEGAL OPERATION ERROR",
217
[VEC_MMUACC] = "MMU ACCESS LEVEL VIOLATION ERROR",
218
[VEC_RESV59] = "UNASSIGNED RESERVED 59",
219
[VEC_UNIMPEA] = "UNASSIGNED RESERVED 60",
220
[VEC_UNIMPII] = "UNASSIGNED RESERVED 61",
221
[VEC_RESV62] = "UNASSIGNED RESERVED 62",
222
[VEC_RESV63] = "UNASSIGNED RESERVED 63",
225
static const char *space_names[] = {
227
[USER_DATA] = "User Data",
228
[USER_PROGRAM] = "User Program",
232
[FC_CONTROL] = "Control",
235
[SUPER_DATA] = "Super Data",
236
[SUPER_PROGRAM] = "Super Program",
240
void die_if_kernel(char *,struct pt_regs *,int);
241
asmlinkage int do_page_fault(struct pt_regs *regs, unsigned long address,
242
unsigned long error_code);
243
int send_fault_sig(struct pt_regs *regs);
245
asmlinkage void trap_c(struct frame *fp);
247
#if defined (CONFIG_M68060)
248
static inline void access_error060 (struct frame *fp)
250
unsigned long fslw = fp->un.fmt4.pc; /* is really FSLW for access error */
253
printk("fslw=%#lx, fa=%#lx\n", fslw, fp->un.fmt4.effaddr);
256
if (fslw & MMU060_BPE) {
257
/* branch prediction error -> clear branch cache */
258
__asm__ __volatile__ ("movec %/cacr,%/d0\n\t"
259
"orl #0x00400000,%/d0\n\t"
262
/* return if there's no other error */
263
if (!(fslw & MMU060_ERR_BITS) && !(fslw & MMU060_SEE))
267
if (fslw & (MMU060_DESC_ERR | MMU060_WP | MMU060_SP)) {
268
unsigned long errorcode;
269
unsigned long addr = fp->un.fmt4.effaddr;
271
if (fslw & MMU060_MA)
272
addr = (addr + PAGE_SIZE - 1) & PAGE_MASK;
275
if (fslw & MMU060_DESC_ERR) {
276
__flush_tlb040_one(addr);
282
printk("errorcode = %d\n", errorcode );
284
do_page_fault(&fp->ptregs, addr, errorcode);
285
} else if (fslw & (MMU060_SEE)){
286
/* Software Emulation Error.
287
* fault during mem_read/mem_write in ifpsp060/os.S
289
send_fault_sig(&fp->ptregs);
290
} else if (!(fslw & (MMU060_RE|MMU060_WE)) ||
291
send_fault_sig(&fp->ptregs) > 0) {
292
printk("pc=%#lx, fa=%#lx\n", fp->ptregs.pc, fp->un.fmt4.effaddr);
293
printk( "68060 access error, fslw=%lx\n", fslw );
297
#endif /* CONFIG_M68060 */
299
#if defined (CONFIG_M68040)
300
static inline unsigned long probe040(int iswrite, unsigned long addr, int wbs)
303
mm_segment_t old_fs = get_fs();
305
set_fs(MAKE_MM_SEG(wbs));
308
asm volatile (".chip 68040; ptestw (%0); .chip 68k" : : "a" (addr));
310
asm volatile (".chip 68040; ptestr (%0); .chip 68k" : : "a" (addr));
312
asm volatile (".chip 68040; movec %%mmusr,%0; .chip 68k" : "=r" (mmusr));
319
static inline int do_040writeback1(unsigned short wbs, unsigned long wba,
323
mm_segment_t old_fs = get_fs();
325
/* set_fs can not be moved, otherwise put_user() may oops */
326
set_fs(MAKE_MM_SEG(wbs));
328
switch (wbs & WBSIZ_040) {
330
res = put_user(wbd & 0xff, (char __user *)wba);
333
res = put_user(wbd & 0xffff, (short __user *)wba);
336
res = put_user(wbd, (int __user *)wba);
340
/* set_fs can not be moved, otherwise put_user() may oops */
345
printk("do_040writeback1, res=%d\n",res);
351
/* after an exception in a writeback the stack frame corresponding
352
* to that exception is discarded, set a few bits in the old frame
353
* to simulate what it should look like
355
static inline void fix_xframe040(struct frame *fp, unsigned long wba, unsigned short wbs)
357
fp->un.fmt7.faddr = wba;
358
fp->un.fmt7.ssw = wbs & 0xff;
359
if (wba != current->thread.faddr)
360
fp->un.fmt7.ssw |= MA_040;
363
static inline void do_040writebacks(struct frame *fp)
367
if (fp->un.fmt7.wb1s & WBV_040)
368
printk("access_error040: cannot handle 1st writeback. oops.\n");
371
if ((fp->un.fmt7.wb2s & WBV_040) &&
372
!(fp->un.fmt7.wb2s & WBTT_040)) {
373
res = do_040writeback1(fp->un.fmt7.wb2s, fp->un.fmt7.wb2a,
376
fix_xframe040(fp, fp->un.fmt7.wb2a, fp->un.fmt7.wb2s);
378
fp->un.fmt7.wb2s = 0;
381
/* do the 2nd wb only if the first one was successful (except for a kernel wb) */
382
if (fp->un.fmt7.wb3s & WBV_040 && (!res || fp->un.fmt7.wb3s & 4)) {
383
res = do_040writeback1(fp->un.fmt7.wb3s, fp->un.fmt7.wb3a,
387
fix_xframe040(fp, fp->un.fmt7.wb3a, fp->un.fmt7.wb3s);
389
fp->un.fmt7.wb2s = fp->un.fmt7.wb3s;
390
fp->un.fmt7.wb3s &= (~WBV_040);
391
fp->un.fmt7.wb2a = fp->un.fmt7.wb3a;
392
fp->un.fmt7.wb2d = fp->un.fmt7.wb3d;
395
fp->un.fmt7.wb3s = 0;
399
send_fault_sig(&fp->ptregs);
403
* called from sigreturn(), must ensure userspace code didn't
404
* manipulate exception frame to circumvent protection, then complete
406
* we just clear TM2 to turn it into a userspace access
408
asmlinkage void berr_040cleanup(struct frame *fp)
410
fp->un.fmt7.wb2s &= ~4;
411
fp->un.fmt7.wb3s &= ~4;
413
do_040writebacks(fp);
416
static inline void access_error040(struct frame *fp)
418
unsigned short ssw = fp->un.fmt7.ssw;
422
printk("ssw=%#x, fa=%#lx\n", ssw, fp->un.fmt7.faddr);
423
printk("wb1s=%#x, wb2s=%#x, wb3s=%#x\n", fp->un.fmt7.wb1s,
424
fp->un.fmt7.wb2s, fp->un.fmt7.wb3s);
425
printk ("wb2a=%lx, wb3a=%lx, wb2d=%lx, wb3d=%lx\n",
426
fp->un.fmt7.wb2a, fp->un.fmt7.wb3a,
427
fp->un.fmt7.wb2d, fp->un.fmt7.wb3d);
431
unsigned long addr = fp->un.fmt7.faddr;
432
unsigned long errorcode;
435
* The MMU status has to be determined AFTER the address
436
* has been corrected if there was a misaligned access (MA).
439
addr = (addr + 7) & -8;
441
/* MMU error, get the MMUSR info for this access */
442
mmusr = probe040(!(ssw & RW_040), addr, ssw);
444
printk("mmusr = %lx\n", mmusr);
447
if (!(mmusr & MMU_R_040)) {
448
/* clear the invalid atc entry */
449
__flush_tlb040_one(addr);
453
/* despite what documentation seems to say, RMW
454
* accesses have always both the LK and RW bits set */
455
if (!(ssw & RW_040) || (ssw & LK_040))
458
if (do_page_fault(&fp->ptregs, addr, errorcode)) {
460
printk("do_page_fault() !=0\n");
462
if (user_mode(&fp->ptregs)){
463
/* delay writebacks after signal delivery */
465
printk(".. was usermode - return\n");
469
/* disable writeback into user space from kernel
470
* (if do_page_fault didn't fix the mapping,
471
* the writeback won't do good)
475
printk(".. disabling wb2\n");
477
if (fp->un.fmt7.wb2a == fp->un.fmt7.faddr)
478
fp->un.fmt7.wb2s &= ~WBV_040;
479
if (fp->un.fmt7.wb3a == fp->un.fmt7.faddr)
480
fp->un.fmt7.wb3s &= ~WBV_040;
483
/* In case of a bus error we either kill the process or expect
484
* the kernel to catch the fault, which then is also responsible
485
* for cleaning up the mess.
487
current->thread.signo = SIGBUS;
488
current->thread.faddr = fp->un.fmt7.faddr;
489
if (send_fault_sig(&fp->ptregs) >= 0)
490
printk("68040 bus error (ssw=%x, faddr=%lx)\n", ssw,
495
do_040writebacks(fp);
497
#endif /* CONFIG_M68040 */
499
#if defined(CONFIG_SUN3)
500
#include <asm/sun3mmu.h>
502
extern int mmu_emu_handle_fault (unsigned long, int, int);
504
/* sun3 version of bus_error030 */
506
static inline void bus_error030 (struct frame *fp)
508
unsigned char buserr_type = sun3_get_buserr ();
509
unsigned long addr, errorcode;
510
unsigned short ssw = fp->un.fmtb.ssw;
511
extern unsigned long _sun3_map_test_start, _sun3_map_test_end;
515
printk ("Instruction fault at %#010lx\n",
517
fp->ptregs.format == 0xa ? fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2
519
fp->ptregs.format == 0xa ? fp->ptregs.pc + 4 : fp->un.fmtb.baddr);
521
printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
522
ssw & RW ? "read" : "write",
524
space_names[ssw & DFC], fp->ptregs.pc);
528
* Check if this page should be demand-mapped. This needs to go before
529
* the testing for a bad kernel-space access (demand-mapping applies
530
* to kernel accesses too).
534
&& (buserr_type & (SUN3_BUSERR_PROTERR | SUN3_BUSERR_INVALID))) {
535
if (mmu_emu_handle_fault (fp->un.fmtb.daddr, ssw & RW, 0))
539
/* Check for kernel-space pagefault (BAD). */
540
if (fp->ptregs.sr & PS_S) {
541
/* kernel fault must be a data fault to user space */
542
if (! ((ssw & DF) && ((ssw & DFC) == USER_DATA))) {
543
// try checking the kernel mappings before surrender
544
if (mmu_emu_handle_fault (fp->un.fmtb.daddr, ssw & RW, 1))
546
/* instruction fault or kernel data fault! */
548
printk ("Instruction fault at %#010lx\n",
551
/* was this fault incurred testing bus mappings? */
552
if((fp->ptregs.pc >= (unsigned long)&_sun3_map_test_start) &&
553
(fp->ptregs.pc <= (unsigned long)&_sun3_map_test_end)) {
554
send_fault_sig(&fp->ptregs);
558
printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
559
ssw & RW ? "read" : "write",
561
space_names[ssw & DFC], fp->ptregs.pc);
563
printk ("BAD KERNEL BUSERR\n");
565
die_if_kernel("Oops", &fp->ptregs,0);
566
force_sig(SIGKILL, current);
571
if (!(ssw & (FC | FB)) && !(ssw & DF))
572
/* not an instruction fault or data fault! BAD */
573
panic ("USER BUSERR w/o instruction or data fault");
577
/* First handle the data fault, if any. */
579
addr = fp->un.fmtb.daddr;
581
// errorcode bit 0: 0 -> no page 1 -> protection fault
582
// errorcode bit 1: 0 -> read fault 1 -> write fault
584
// (buserr_type & SUN3_BUSERR_PROTERR) -> protection fault
585
// (buserr_type & SUN3_BUSERR_INVALID) -> invalid page fault
587
if (buserr_type & SUN3_BUSERR_PROTERR)
589
else if (buserr_type & SUN3_BUSERR_INVALID)
593
printk ("*** unexpected busfault type=%#04x\n", buserr_type);
594
printk ("invalid %s access at %#lx from pc %#lx\n",
595
!(ssw & RW) ? "write" : "read", addr,
598
die_if_kernel ("Oops", &fp->ptregs, buserr_type);
599
force_sig (SIGBUS, current);
603
//todo: wtf is RM bit? --m
604
if (!(ssw & RW) || ssw & RM)
607
/* Handle page fault. */
608
do_page_fault (&fp->ptregs, addr, errorcode);
610
/* Retry the data fault now. */
614
/* Now handle the instruction fault. */
616
/* Get the fault address. */
617
if (fp->ptregs.format == 0xA)
618
addr = fp->ptregs.pc + 4;
620
addr = fp->un.fmtb.baddr;
624
if (buserr_type & SUN3_BUSERR_INVALID) {
625
if (!mmu_emu_handle_fault (fp->un.fmtb.daddr, 1, 0))
626
do_page_fault (&fp->ptregs, addr, 0);
629
printk ("protection fault on insn access (segv).\n");
631
force_sig (SIGSEGV, current);
635
#if defined(CPU_M68020_OR_M68030)
636
static inline void bus_error030 (struct frame *fp)
638
volatile unsigned short temp;
639
unsigned short mmusr;
640
unsigned long addr, errorcode;
641
unsigned short ssw = fp->un.fmtb.ssw;
645
printk ("pid = %x ", current->pid);
646
printk ("SSW=%#06x ", ssw);
649
printk ("Instruction fault at %#010lx\n",
651
fp->ptregs.format == 0xa ? fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2
653
fp->ptregs.format == 0xa ? fp->ptregs.pc + 4 : fp->un.fmtb.baddr);
655
printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
656
ssw & RW ? "read" : "write",
658
space_names[ssw & DFC], fp->ptregs.pc);
661
/* ++andreas: If a data fault and an instruction fault happen
662
at the same time map in both pages. */
664
/* First handle the data fault, if any. */
666
addr = fp->un.fmtb.daddr;
669
asm volatile ("ptestr %3,%2@,#7,%0\n\t"
672
: "a" (&temp), "a" (addr), "d" (ssw));
674
asm volatile ("ptestr %2,%1@,#7\n\t"
676
: : "a" (&temp), "a" (addr), "d" (ssw));
681
printk("mmusr is %#x for addr %#lx in task %p\n",
682
mmusr, addr, current);
683
printk("descriptor address is %#lx, contents %#lx\n",
684
__va(desc), *(unsigned long *)__va(desc));
687
errorcode = (mmusr & MMU_I) ? 0 : 1;
688
if (!(ssw & RW) || (ssw & RM))
691
if (mmusr & (MMU_I | MMU_WP)) {
693
printk("Data %s fault at %#010lx in %s (pc=%#lx)\n",
694
ssw & RW ? "read" : "write",
696
space_names[ssw & DFC], fp->ptregs.pc);
699
/* Don't try to do anything further if an exception was
701
if (do_page_fault (&fp->ptregs, addr, errorcode) < 0)
703
} else if (!(mmusr & MMU_I)) {
704
/* probably a 020 cas fault */
705
if (!(ssw & RM) && send_fault_sig(&fp->ptregs) > 0)
706
printk("unexpected bus error (%#x,%#x)\n", ssw, mmusr);
707
} else if (mmusr & (MMU_B|MMU_L|MMU_S)) {
708
printk("invalid %s access at %#lx from pc %#lx\n",
709
!(ssw & RW) ? "write" : "read", addr,
711
die_if_kernel("Oops",&fp->ptregs,mmusr);
712
force_sig(SIGSEGV, current);
716
static volatile long tlong;
719
printk("weird %s access at %#lx from pc %#lx (ssw is %#x)\n",
720
!(ssw & RW) ? "write" : "read", addr,
722
asm volatile ("ptestr #1,%1@,#0\n\t"
725
: "a" (&temp), "a" (addr));
728
printk ("level 0 mmusr is %#x\n", mmusr);
730
asm volatile ("pmove %%tt0,%0@"
733
printk("tt0 is %#lx, ", tlong);
734
asm volatile ("pmove %%tt1,%0@"
737
printk("tt1 is %#lx\n", tlong);
740
printk("Unknown SIGSEGV - 1\n");
742
die_if_kernel("Oops",&fp->ptregs,mmusr);
743
force_sig(SIGSEGV, current);
747
/* setup an ATC entry for the access about to be retried */
748
if (!(ssw & RW) || (ssw & RM))
749
asm volatile ("ploadw %1,%0@" : /* no outputs */
750
: "a" (addr), "d" (ssw));
752
asm volatile ("ploadr %1,%0@" : /* no outputs */
753
: "a" (addr), "d" (ssw));
756
/* Now handle the instruction fault. */
758
if (!(ssw & (FC|FB)))
761
if (fp->ptregs.sr & PS_S) {
762
printk("Instruction fault at %#010lx\n",
765
printk ("BAD KERNEL BUSERR\n");
766
die_if_kernel("Oops",&fp->ptregs,0);
767
force_sig(SIGKILL, current);
771
/* get the fault address */
772
if (fp->ptregs.format == 10)
773
addr = fp->ptregs.pc + 4;
775
addr = fp->un.fmtb.baddr;
779
if ((ssw & DF) && ((addr ^ fp->un.fmtb.daddr) & PAGE_MASK) == 0)
780
/* Insn fault on same page as data fault. But we
781
should still create the ATC entry. */
782
goto create_atc_entry;
785
asm volatile ("ptestr #1,%2@,#7,%0\n\t"
788
: "a" (&temp), "a" (addr));
790
asm volatile ("ptestr #1,%1@,#7\n\t"
792
: : "a" (&temp), "a" (addr));
797
printk ("mmusr is %#x for addr %#lx in task %p\n",
798
mmusr, addr, current);
799
printk ("descriptor address is %#lx, contents %#lx\n",
800
__va(desc), *(unsigned long *)__va(desc));
804
do_page_fault (&fp->ptregs, addr, 0);
805
else if (mmusr & (MMU_B|MMU_L|MMU_S)) {
806
printk ("invalid insn access at %#lx from pc %#lx\n",
807
addr, fp->ptregs.pc);
809
printk("Unknown SIGSEGV - 2\n");
811
die_if_kernel("Oops",&fp->ptregs,mmusr);
812
force_sig(SIGSEGV, current);
817
/* setup an ATC entry for the access about to be retried */
818
asm volatile ("ploadr #2,%0@" : /* no outputs */
821
#endif /* CPU_M68020_OR_M68030 */
822
#endif /* !CONFIG_SUN3 */
824
asmlinkage void buserr_c(struct frame *fp)
826
/* Only set esp0 if coming from user mode */
827
if (user_mode(&fp->ptregs))
828
current->thread.esp0 = (unsigned long) fp;
831
printk ("*** Bus Error *** Format is %x\n", fp->ptregs.format);
834
switch (fp->ptregs.format) {
835
#if defined (CONFIG_M68060)
836
case 4: /* 68060 access error */
837
access_error060 (fp);
840
#if defined (CONFIG_M68040)
841
case 0x7: /* 68040 access error */
842
access_error040 (fp);
845
#if defined (CPU_M68020_OR_M68030)
852
die_if_kernel("bad frame format",&fp->ptregs,0);
854
printk("Unknown SIGSEGV - 4\n");
856
force_sig(SIGSEGV, current);
861
static int kstack_depth_to_print = 48;
863
void show_trace(unsigned long *stack)
865
unsigned long *endstack;
869
printk("Call Trace:");
870
addr = (unsigned long)stack + THREAD_SIZE - 1;
871
endstack = (unsigned long *)(addr & -THREAD_SIZE);
873
while (stack + 1 <= endstack) {
876
* If the address is either in the text segment of the
877
* kernel, or in the region which contains vmalloc'ed
878
* memory, it *may* be the address of a calling
879
* routine; if so, print it so that someone tracing
880
* down the cause of the crash will be able to figure
881
* out the call path that was taken.
883
if (__kernel_text_address(addr)) {
884
#ifndef CONFIG_KALLSYMS
888
printk(" [<%08lx>] %pS\n", addr, (void *)addr);
895
void show_registers(struct pt_regs *regs)
897
struct frame *fp = (struct frame *)regs;
898
mm_segment_t old_fs = get_fs();
904
printk("PC: [<%08lx>] %pS\n", regs->pc, (void *)regs->pc);
905
printk("SR: %04x SP: %p a2: %08lx\n", regs->sr, regs, regs->a2);
906
printk("d0: %08lx d1: %08lx d2: %08lx d3: %08lx\n",
907
regs->d0, regs->d1, regs->d2, regs->d3);
908
printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
909
regs->d4, regs->d5, regs->a0, regs->a1);
911
printk("Process %s (pid: %d, task=%p)\n",
912
current->comm, task_pid_nr(current), current);
913
addr = (unsigned long)&fp->un;
914
printk("Frame format=%X ", regs->format);
915
switch (regs->format) {
917
printk("instr addr=%08lx\n", fp->un.fmt2.iaddr);
918
addr += sizeof(fp->un.fmt2);
921
printk("eff addr=%08lx\n", fp->un.fmt3.effaddr);
922
addr += sizeof(fp->un.fmt3);
925
printk((CPU_IS_060 ? "fault addr=%08lx fslw=%08lx\n"
926
: "eff addr=%08lx pc=%08lx\n"),
927
fp->un.fmt4.effaddr, fp->un.fmt4.pc);
928
addr += sizeof(fp->un.fmt4);
931
printk("eff addr=%08lx ssw=%04x faddr=%08lx\n",
932
fp->un.fmt7.effaddr, fp->un.fmt7.ssw, fp->un.fmt7.faddr);
933
printk("wb 1 stat/addr/data: %04x %08lx %08lx\n",
934
fp->un.fmt7.wb1s, fp->un.fmt7.wb1a, fp->un.fmt7.wb1dpd0);
935
printk("wb 2 stat/addr/data: %04x %08lx %08lx\n",
936
fp->un.fmt7.wb2s, fp->un.fmt7.wb2a, fp->un.fmt7.wb2d);
937
printk("wb 3 stat/addr/data: %04x %08lx %08lx\n",
938
fp->un.fmt7.wb3s, fp->un.fmt7.wb3a, fp->un.fmt7.wb3d);
939
printk("push data: %08lx %08lx %08lx %08lx\n",
940
fp->un.fmt7.wb1dpd0, fp->un.fmt7.pd1, fp->un.fmt7.pd2,
942
addr += sizeof(fp->un.fmt7);
945
printk("instr addr=%08lx\n", fp->un.fmt9.iaddr);
946
addr += sizeof(fp->un.fmt9);
949
printk("ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n",
950
fp->un.fmta.ssw, fp->un.fmta.isc, fp->un.fmta.isb,
951
fp->un.fmta.daddr, fp->un.fmta.dobuf);
952
addr += sizeof(fp->un.fmta);
955
printk("ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n",
956
fp->un.fmtb.ssw, fp->un.fmtb.isc, fp->un.fmtb.isb,
957
fp->un.fmtb.daddr, fp->un.fmtb.dobuf);
958
printk("baddr=%08lx dibuf=%08lx ver=%x\n",
959
fp->un.fmtb.baddr, fp->un.fmtb.dibuf, fp->un.fmtb.ver);
960
addr += sizeof(fp->un.fmtb);
965
show_stack(NULL, (unsigned long *)addr);
969
cp = (u16 *)regs->pc;
970
for (i = -8; i < 16; i++) {
971
if (get_user(c, cp + i) && i >= 0) {
972
printk(" Bad PC value.");
975
printk(i ? " %04x" : " <%04x>", c);
981
void show_stack(struct task_struct *task, unsigned long *stack)
984
unsigned long *endstack;
989
stack = (unsigned long *)task->thread.esp0;
991
stack = (unsigned long *)&stack;
993
endstack = (unsigned long *)(((unsigned long)stack + THREAD_SIZE - 1) & -THREAD_SIZE);
995
printk("Stack from %08lx:", (unsigned long)stack);
997
for (i = 0; i < kstack_depth_to_print; i++) {
998
if (p + 1 > endstack)
1002
printk(" %08lx", *p++);
1009
* The architecture-independent backtrace generator
1011
void dump_stack(void)
1013
unsigned long stack;
1018
EXPORT_SYMBOL(dump_stack);
1020
void bad_super_trap (struct frame *fp)
1023
if (fp->ptregs.vector < 4 * ARRAY_SIZE(vec_names))
1024
printk ("*** %s *** FORMAT=%X\n",
1025
vec_names[(fp->ptregs.vector) >> 2],
1028
printk ("*** Exception %d *** FORMAT=%X\n",
1029
(fp->ptregs.vector) >> 2,
1031
if (fp->ptregs.vector >> 2 == VEC_ADDRERR && CPU_IS_020_OR_030) {
1032
unsigned short ssw = fp->un.fmtb.ssw;
1034
printk ("SSW=%#06x ", ssw);
1037
printk ("Pipe stage C instruction fault at %#010lx\n",
1038
(fp->ptregs.format) == 0xA ?
1039
fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2);
1041
printk ("Pipe stage B instruction fault at %#010lx\n",
1042
(fp->ptregs.format) == 0xA ?
1043
fp->ptregs.pc + 4 : fp->un.fmtb.baddr);
1045
printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
1046
ssw & RW ? "read" : "write",
1047
fp->un.fmtb.daddr, space_names[ssw & DFC],
1050
printk ("Current process id is %d\n", task_pid_nr(current));
1051
die_if_kernel("BAD KERNEL TRAP", &fp->ptregs, 0);
1054
asmlinkage void trap_c(struct frame *fp)
1059
if (fp->ptregs.sr & PS_S) {
1060
if (fp->ptregs.vector == VEC_TRACE << 2) {
1061
/* traced a trapping instruction on a 68020/30,
1062
* real exception will be executed afterwards.
1064
} else if (!handle_kernel_fault(&fp->ptregs))
1069
/* send the appropriate signal to the user program */
1070
switch ((fp->ptregs.vector) >> 2) {
1072
info.si_code = BUS_ADRALN;
1078
info.si_code = ILL_ILLOPC;
1082
info.si_code = ILL_PRVOPC;
1086
info.si_code = ILL_COPROC;
1103
info.si_code = ILL_ILLTRP;
1109
info.si_code = FPE_FLTINV;
1113
info.si_code = FPE_FLTRES;
1117
info.si_code = FPE_FLTDIV;
1121
info.si_code = FPE_FLTUND;
1125
info.si_code = FPE_FLTOVF;
1129
info.si_code = FPE_INTDIV;
1134
info.si_code = FPE_INTOVF;
1137
case VEC_TRACE: /* ptrace single step */
1138
info.si_code = TRAP_TRACE;
1141
case VEC_TRAP15: /* breakpoint */
1142
info.si_code = TRAP_BRKPT;
1146
info.si_code = ILL_ILLOPC;
1150
info.si_signo = sig;
1152
switch (fp->ptregs.format) {
1154
info.si_addr = (void *) fp->ptregs.pc;
1157
info.si_addr = (void *) fp->un.fmt2.iaddr;
1160
info.si_addr = (void *) fp->un.fmt7.effaddr;
1163
info.si_addr = (void *) fp->un.fmt9.iaddr;
1166
info.si_addr = (void *) fp->un.fmta.daddr;
1169
info.si_addr = (void *) fp->un.fmtb.daddr;
1172
force_sig_info (sig, &info, current);
1175
void die_if_kernel (char *str, struct pt_regs *fp, int nr)
1177
if (!(fp->sr & PS_S))
1181
printk("%s: %08x\n",str,nr);
1183
add_taint(TAINT_DIE);
1188
* This function is called if an error occur while accessing
1189
* user-space from the fpsp040 code.
1191
asmlinkage void fpsp040_die(void)
1196
#ifdef CONFIG_M68KFPU_EMU
1197
asmlinkage void fpemu_signal(int signal, int code, void *addr)
1201
info.si_signo = signal;
1203
info.si_code = code;
1204
info.si_addr = addr;
1205
force_sig_info(signal, &info, current);