diff options
Diffstat (limited to 'arch/m68k/kernel')
| -rw-r--r-- | arch/m68k/kernel/Makefile | 23 | ||||
| -rw-r--r-- | arch/m68k/kernel/Makefile_mm | 17 | ||||
| -rw-r--r-- | arch/m68k/kernel/Makefile_no | 10 | ||||
| -rw-r--r-- | arch/m68k/kernel/dma_mm.c | 1 | ||||
| -rw-r--r-- | arch/m68k/kernel/dma_no.c | 1 | ||||
| -rw-r--r-- | arch/m68k/kernel/entry_mm.S | 7 | ||||
| -rw-r--r-- | arch/m68k/kernel/entry_no.S | 6 | ||||
| -rw-r--r-- | arch/m68k/kernel/ints.c | 323 | ||||
| -rw-r--r-- | arch/m68k/kernel/setup_no.c | 4 | ||||
| -rw-r--r-- | arch/m68k/kernel/traps.c | 1108 | ||||
| -rw-r--r-- | arch/m68k/kernel/traps_mm.c | 1207 | ||||
| -rw-r--r-- | arch/m68k/kernel/traps_no.c | 361 | ||||
| -rw-r--r-- | arch/m68k/kernel/vectors.c | 145 | ||||
| -rw-r--r-- | arch/m68k/kernel/vmlinux.lds_no.S | 1 |
14 files changed, 1309 insertions, 1905 deletions
diff --git a/arch/m68k/kernel/Makefile b/arch/m68k/kernel/Makefile index c482ebc9dd54..c5696193281a 100644 --- a/arch/m68k/kernel/Makefile +++ b/arch/m68k/kernel/Makefile | |||
| @@ -1,5 +1,20 @@ | |||
| 1 | ifdef CONFIG_MMU | 1 | # |
| 2 | include arch/m68k/kernel/Makefile_mm | 2 | # Makefile for the linux kernel. |
| 3 | else | 3 | # |
| 4 | include arch/m68k/kernel/Makefile_no | 4 | |
| 5 | extra-$(CONFIG_MMU) := head.o | ||
| 6 | extra-$(CONFIG_SUN3) := sun3-head.o | ||
| 7 | extra-y += vmlinux.lds | ||
| 8 | |||
| 9 | obj-y := entry.o irq.o m68k_ksyms.o module.o process.o ptrace.o setup.o \ | ||
| 10 | signal.o sys_m68k.o syscalltable.o time.o traps.o | ||
| 11 | |||
| 12 | obj-$(CONFIG_MMU) += ints.o vectors.o | ||
| 13 | |||
| 14 | ifndef CONFIG_MMU_SUN3 | ||
| 15 | obj-y += dma.o | ||
| 5 | endif | 16 | endif |
| 17 | ifndef CONFIG_MMU | ||
| 18 | obj-y += init_task.o | ||
| 19 | endif | ||
| 20 | |||
diff --git a/arch/m68k/kernel/Makefile_mm b/arch/m68k/kernel/Makefile_mm deleted file mode 100644 index aced67804579..000000000000 --- a/arch/m68k/kernel/Makefile_mm +++ /dev/null | |||
| @@ -1,17 +0,0 @@ | |||
| 1 | # | ||
| 2 | # Makefile for the linux kernel. | ||
| 3 | # | ||
| 4 | |||
| 5 | ifndef CONFIG_SUN3 | ||
| 6 | extra-y := head.o | ||
| 7 | else | ||
| 8 | extra-y := sun3-head.o | ||
| 9 | endif | ||
| 10 | extra-y += vmlinux.lds | ||
| 11 | |||
| 12 | obj-y := entry.o process.o traps.o ints.o signal.o ptrace.o module.o \ | ||
| 13 | sys_m68k.o time.o setup.o m68k_ksyms.o devres.o syscalltable.o | ||
| 14 | |||
| 15 | devres-y = ../../../kernel/irq/devres.o | ||
| 16 | |||
| 17 | obj-y$(CONFIG_MMU_SUN3) += dma.o # no, it's not a typo | ||
diff --git a/arch/m68k/kernel/Makefile_no b/arch/m68k/kernel/Makefile_no deleted file mode 100644 index 37c3fc074c0a..000000000000 --- a/arch/m68k/kernel/Makefile_no +++ /dev/null | |||
| @@ -1,10 +0,0 @@ | |||
| 1 | # | ||
| 2 | # Makefile for arch/m68knommu/kernel. | ||
| 3 | # | ||
| 4 | |||
| 5 | extra-y := vmlinux.lds | ||
| 6 | |||
| 7 | obj-y += dma.o entry.o init_task.o irq.o m68k_ksyms.o process.o ptrace.o \ | ||
| 8 | setup.o signal.o syscalltable.o sys_m68k.o time.o traps.o | ||
| 9 | |||
| 10 | obj-$(CONFIG_MODULES) += module.o | ||
diff --git a/arch/m68k/kernel/dma_mm.c b/arch/m68k/kernel/dma_mm.c index 4bbb3c2a8880..a3c471b523f2 100644 --- a/arch/m68k/kernel/dma_mm.c +++ b/arch/m68k/kernel/dma_mm.c | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include <linux/scatterlist.h> | 12 | #include <linux/scatterlist.h> |
| 13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
| 14 | #include <linux/vmalloc.h> | 14 | #include <linux/vmalloc.h> |
| 15 | #include <linux/export.h> | ||
| 15 | 16 | ||
| 16 | #include <asm/pgalloc.h> | 17 | #include <asm/pgalloc.h> |
| 17 | 18 | ||
diff --git a/arch/m68k/kernel/dma_no.c b/arch/m68k/kernel/dma_no.c index fc61541aeb71..f1dc3fc71bc2 100644 --- a/arch/m68k/kernel/dma_no.c +++ b/arch/m68k/kernel/dma_no.c | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include <linux/mm.h> | 10 | #include <linux/mm.h> |
| 11 | #include <linux/device.h> | 11 | #include <linux/device.h> |
| 12 | #include <linux/dma-mapping.h> | 12 | #include <linux/dma-mapping.h> |
| 13 | #include <linux/export.h> | ||
| 13 | #include <asm/cacheflush.h> | 14 | #include <asm/cacheflush.h> |
| 14 | 15 | ||
| 15 | void *dma_alloc_coherent(struct device *dev, size_t size, | 16 | void *dma_alloc_coherent(struct device *dev, size_t size, |
diff --git a/arch/m68k/kernel/entry_mm.S b/arch/m68k/kernel/entry_mm.S index bd0ec05263b2..c713f514843d 100644 --- a/arch/m68k/kernel/entry_mm.S +++ b/arch/m68k/kernel/entry_mm.S | |||
| @@ -48,7 +48,7 @@ | |||
| 48 | .globl sys_fork, sys_clone, sys_vfork | 48 | .globl sys_fork, sys_clone, sys_vfork |
| 49 | .globl ret_from_interrupt, bad_interrupt | 49 | .globl ret_from_interrupt, bad_interrupt |
| 50 | .globl auto_irqhandler_fixup | 50 | .globl auto_irqhandler_fixup |
| 51 | .globl user_irqvec_fixup, user_irqhandler_fixup | 51 | .globl user_irqvec_fixup |
| 52 | 52 | ||
| 53 | .text | 53 | .text |
| 54 | ENTRY(buserr) | 54 | ENTRY(buserr) |
| @@ -207,7 +207,7 @@ ENTRY(auto_inthandler) | |||
| 207 | movel %sp,%sp@- | 207 | movel %sp,%sp@- |
| 208 | movel %d0,%sp@- | put vector # on stack | 208 | movel %d0,%sp@- | put vector # on stack |
| 209 | auto_irqhandler_fixup = . + 2 | 209 | auto_irqhandler_fixup = . + 2 |
| 210 | jsr __m68k_handle_int | process the IRQ | 210 | jsr do_IRQ | process the IRQ |
| 211 | addql #8,%sp | pop parameters off stack | 211 | addql #8,%sp | pop parameters off stack |
| 212 | 212 | ||
| 213 | ret_from_interrupt: | 213 | ret_from_interrupt: |
| @@ -240,8 +240,7 @@ user_irqvec_fixup = . + 2 | |||
| 240 | 240 | ||
| 241 | movel %sp,%sp@- | 241 | movel %sp,%sp@- |
| 242 | movel %d0,%sp@- | put vector # on stack | 242 | movel %d0,%sp@- | put vector # on stack |
| 243 | user_irqhandler_fixup = . + 2 | 243 | jsr do_IRQ | process the IRQ |
| 244 | jsr __m68k_handle_int | process the IRQ | ||
| 245 | addql #8,%sp | pop parameters off stack | 244 | addql #8,%sp | pop parameters off stack |
| 246 | 245 | ||
| 247 | subqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1) | 246 | subqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1) |
diff --git a/arch/m68k/kernel/entry_no.S b/arch/m68k/kernel/entry_no.S index 5f0f6b598b5a..1b4289061a64 100644 --- a/arch/m68k/kernel/entry_no.S +++ b/arch/m68k/kernel/entry_no.S | |||
| @@ -43,7 +43,7 @@ | |||
| 43 | .globl sys_vfork | 43 | .globl sys_vfork |
| 44 | 44 | ||
| 45 | ENTRY(buserr) | 45 | ENTRY(buserr) |
| 46 | SAVE_ALL | 46 | SAVE_ALL_INT |
| 47 | moveq #-1,%d0 | 47 | moveq #-1,%d0 |
| 48 | movel %d0,%sp@(PT_OFF_ORIG_D0) | 48 | movel %d0,%sp@(PT_OFF_ORIG_D0) |
| 49 | movel %sp,%sp@- /* stack frame pointer argument */ | 49 | movel %sp,%sp@- /* stack frame pointer argument */ |
| @@ -52,7 +52,7 @@ ENTRY(buserr) | |||
| 52 | jra ret_from_exception | 52 | jra ret_from_exception |
| 53 | 53 | ||
| 54 | ENTRY(trap) | 54 | ENTRY(trap) |
| 55 | SAVE_ALL | 55 | SAVE_ALL_INT |
| 56 | moveq #-1,%d0 | 56 | moveq #-1,%d0 |
| 57 | movel %d0,%sp@(PT_OFF_ORIG_D0) | 57 | movel %d0,%sp@(PT_OFF_ORIG_D0) |
| 58 | movel %sp,%sp@- /* stack frame pointer argument */ | 58 | movel %sp,%sp@- /* stack frame pointer argument */ |
| @@ -64,7 +64,7 @@ ENTRY(trap) | |||
| 64 | 64 | ||
| 65 | .globl dbginterrupt | 65 | .globl dbginterrupt |
| 66 | ENTRY(dbginterrupt) | 66 | ENTRY(dbginterrupt) |
| 67 | SAVE_ALL | 67 | SAVE_ALL_INT |
| 68 | moveq #-1,%d0 | 68 | moveq #-1,%d0 |
| 69 | movel %d0,%sp@(PT_OFF_ORIG_D0) | 69 | movel %d0,%sp@(PT_OFF_ORIG_D0) |
| 70 | movel %sp,%sp@- /* stack frame pointer argument */ | 70 | movel %sp,%sp@- /* stack frame pointer argument */ |
diff --git a/arch/m68k/kernel/ints.c b/arch/m68k/kernel/ints.c index 761ee0440c99..74fefac00899 100644 --- a/arch/m68k/kernel/ints.c +++ b/arch/m68k/kernel/ints.c | |||
| @@ -4,25 +4,6 @@ | |||
| 4 | * This file is subject to the terms and conditions of the GNU General Public | 4 | * This file is subject to the terms and conditions of the GNU General Public |
| 5 | * License. See the file COPYING in the main directory of this archive | 5 | * License. See the file COPYING in the main directory of this archive |
| 6 | * for more details. | 6 | * for more details. |
| 7 | * | ||
| 8 | * 07/03/96: Timer initialization, and thus mach_sched_init(), | ||
| 9 | * removed from request_irq() and moved to init_time(). | ||
| 10 | * We should therefore consider renaming our add_isr() and | ||
| 11 | * remove_isr() to request_irq() and free_irq() | ||
| 12 | * respectively, so they are compliant with the other | ||
| 13 | * architectures. /Jes | ||
| 14 | * 11/07/96: Changed all add_/remove_isr() to request_/free_irq() calls. | ||
| 15 | * Removed irq list support, if any machine needs an irq server | ||
| 16 | * it must implement this itself (as it's already done), instead | ||
| 17 | * only default handler are used with mach_default_handler. | ||
| 18 | * request_irq got some flags different from other architectures: | ||
| 19 | * - IRQ_FLG_REPLACE : Replace an existing handler (the default one | ||
| 20 | * can be replaced without this flag) | ||
| 21 | * - IRQ_FLG_LOCK : handler can't be replaced | ||
| 22 | * There are other machine depending flags, see there | ||
| 23 | * If you want to replace a default handler you should know what | ||
| 24 | * you're doing, since it might handle different other irq sources | ||
| 25 | * which must be served /Roman Zippel | ||
| 26 | */ | 7 | */ |
| 27 | 8 | ||
| 28 | #include <linux/module.h> | 9 | #include <linux/module.h> |
| @@ -47,33 +28,22 @@ | |||
| 47 | #endif | 28 | #endif |
| 48 | 29 | ||
| 49 | extern u32 auto_irqhandler_fixup[]; | 30 | extern u32 auto_irqhandler_fixup[]; |
| 50 | extern u32 user_irqhandler_fixup[]; | ||
| 51 | extern u16 user_irqvec_fixup[]; | 31 | extern u16 user_irqvec_fixup[]; |
| 52 | 32 | ||
| 53 | /* table for system interrupt handlers */ | ||
| 54 | static struct irq_node *irq_list[NR_IRQS]; | ||
| 55 | static struct irq_controller *irq_controller[NR_IRQS]; | ||
| 56 | static int irq_depth[NR_IRQS]; | ||
| 57 | |||
| 58 | static int m68k_first_user_vec; | 33 | static int m68k_first_user_vec; |
| 59 | 34 | ||
| 60 | static struct irq_controller auto_irq_controller = { | 35 | static struct irq_chip auto_irq_chip = { |
| 61 | .name = "auto", | 36 | .name = "auto", |
| 62 | .lock = __SPIN_LOCK_UNLOCKED(auto_irq_controller.lock), | 37 | .irq_startup = m68k_irq_startup, |
| 63 | .startup = m68k_irq_startup, | 38 | .irq_shutdown = m68k_irq_shutdown, |
| 64 | .shutdown = m68k_irq_shutdown, | ||
| 65 | }; | 39 | }; |
| 66 | 40 | ||
| 67 | static struct irq_controller user_irq_controller = { | 41 | static struct irq_chip user_irq_chip = { |
| 68 | .name = "user", | 42 | .name = "user", |
| 69 | .lock = __SPIN_LOCK_UNLOCKED(user_irq_controller.lock), | 43 | .irq_startup = m68k_irq_startup, |
| 70 | .startup = m68k_irq_startup, | 44 | .irq_shutdown = m68k_irq_shutdown, |
| 71 | .shutdown = m68k_irq_shutdown, | ||
| 72 | }; | 45 | }; |
| 73 | 46 | ||
| 74 | #define NUM_IRQ_NODES 100 | ||
| 75 | static irq_node_t nodes[NUM_IRQ_NODES]; | ||
| 76 | |||
| 77 | /* | 47 | /* |
| 78 | * void init_IRQ(void) | 48 | * void init_IRQ(void) |
| 79 | * | 49 | * |
| @@ -96,7 +66,7 @@ void __init init_IRQ(void) | |||
| 96 | } | 66 | } |
| 97 | 67 | ||
| 98 | for (i = IRQ_AUTO_1; i <= IRQ_AUTO_7; i++) | 68 | for (i = IRQ_AUTO_1; i <= IRQ_AUTO_7; i++) |
| 99 | irq_controller[i] = &auto_irq_controller; | 69 | irq_set_chip_and_handler(i, &auto_irq_chip, handle_simple_irq); |
| 100 | 70 | ||
| 101 | mach_init_IRQ(); | 71 | mach_init_IRQ(); |
| 102 | } | 72 | } |
| @@ -106,7 +76,7 @@ void __init init_IRQ(void) | |||
| 106 | * @handler: called from auto vector interrupts | 76 | * @handler: called from auto vector interrupts |
| 107 | * | 77 | * |
| 108 | * setup the handler to be called from auto vector interrupts instead of the | 78 | * setup the handler to be called from auto vector interrupts instead of the |
| 109 | * standard __m68k_handle_int(), it will be called with irq numbers in the range | 79 | * standard do_IRQ(), it will be called with irq numbers in the range |
| 110 | * from IRQ_AUTO_1 - IRQ_AUTO_7. | 80 | * from IRQ_AUTO_1 - IRQ_AUTO_7. |
| 111 | */ | 81 | */ |
| 112 | void __init m68k_setup_auto_interrupt(void (*handler)(unsigned int, struct pt_regs *)) | 82 | void __init m68k_setup_auto_interrupt(void (*handler)(unsigned int, struct pt_regs *)) |
| @@ -120,217 +90,49 @@ void __init m68k_setup_auto_interrupt(void (*handler)(unsigned int, struct pt_re | |||
| 120 | * m68k_setup_user_interrupt | 90 | * m68k_setup_user_interrupt |
| 121 | * @vec: first user vector interrupt to handle | 91 | * @vec: first user vector interrupt to handle |
| 122 | * @cnt: number of active user vector interrupts | 92 | * @cnt: number of active user vector interrupts |
| 123 | * @handler: called from user vector interrupts | ||
| 124 | * | 93 | * |
| 125 | * setup user vector interrupts, this includes activating the specified range | 94 | * setup user vector interrupts, this includes activating the specified range |
| 126 | * of interrupts, only then these interrupts can be requested (note: this is | 95 | * of interrupts, only then these interrupts can be requested (note: this is |
| 127 | * different from auto vector interrupts). An optional handler can be installed | 96 | * different from auto vector interrupts). |
| 128 | * to be called instead of the default __m68k_handle_int(), it will be called | ||
| 129 | * with irq numbers starting from IRQ_USER. | ||
| 130 | */ | 97 | */ |
| 131 | void __init m68k_setup_user_interrupt(unsigned int vec, unsigned int cnt, | 98 | void __init m68k_setup_user_interrupt(unsigned int vec, unsigned int cnt) |
| 132 | void (*handler)(unsigned int, struct pt_regs *)) | ||
| 133 | { | 99 | { |
| 134 | int i; | 100 | int i; |
| 135 | 101 | ||
| 136 | BUG_ON(IRQ_USER + cnt > NR_IRQS); | 102 | BUG_ON(IRQ_USER + cnt > NR_IRQS); |
| 137 | m68k_first_user_vec = vec; | 103 | m68k_first_user_vec = vec; |
| 138 | for (i = 0; i < cnt; i++) | 104 | for (i = 0; i < cnt; i++) |
| 139 | irq_controller[IRQ_USER + i] = &user_irq_controller; | 105 | irq_set_chip(IRQ_USER + i, &user_irq_chip); |
| 140 | *user_irqvec_fixup = vec - IRQ_USER; | 106 | *user_irqvec_fixup = vec - IRQ_USER; |
| 141 | if (handler) | ||
| 142 | *user_irqhandler_fixup = (u32)handler; | ||
| 143 | flush_icache(); | 107 | flush_icache(); |
| 144 | } | 108 | } |
| 145 | 109 | ||
| 146 | /** | 110 | /** |
| 147 | * m68k_setup_irq_controller | 111 | * m68k_setup_irq_controller |
| 148 | * @contr: irq controller which controls specified irq | 112 | * @chip: irq chip which controls specified irq |
| 113 | * @handle: flow handler which handles specified irq | ||
| 149 | * @irq: first irq to be managed by the controller | 114 | * @irq: first irq to be managed by the controller |
| 115 | * @cnt: number of irqs to be managed by the controller | ||
| 150 | * | 116 | * |
| 151 | * Change the controller for the specified range of irq, which will be used to | 117 | * Change the controller for the specified range of irq, which will be used to |
| 152 | * manage these irq. auto/user irq already have a default controller, which can | 118 | * manage these irq. auto/user irq already have a default controller, which can |
| 153 | * be changed as well, but the controller probably should use m68k_irq_startup/ | 119 | * be changed as well, but the controller probably should use m68k_irq_startup/ |
| 154 | * m68k_irq_shutdown. | 120 | * m68k_irq_shutdown. |
| 155 | */ | 121 | */ |
| 156 | void m68k_setup_irq_controller(struct irq_controller *contr, unsigned int irq, | 122 | void m68k_setup_irq_controller(struct irq_chip *chip, |
| 123 | irq_flow_handler_t handle, unsigned int irq, | ||
| 157 | unsigned int cnt) | 124 | unsigned int cnt) |
| 158 | { | 125 | { |
| 159 | int i; | 126 | int i; |
| 160 | 127 | ||
| 161 | for (i = 0; i < cnt; i++) | 128 | for (i = 0; i < cnt; i++) { |
| 162 | irq_controller[irq + i] = contr; | 129 | irq_set_chip(irq + i, chip); |
| 163 | } | 130 | if (handle) |
| 164 | 131 | irq_set_handler(irq + i, handle); | |
| 165 | irq_node_t *new_irq_node(void) | ||
| 166 | { | ||
| 167 | irq_node_t *node; | ||
| 168 | short i; | ||
| 169 | |||
| 170 | for (node = nodes, i = NUM_IRQ_NODES-1; i >= 0; node++, i--) { | ||
| 171 | if (!node->handler) { | ||
| 172 | memset(node, 0, sizeof(*node)); | ||
| 173 | return node; | ||
| 174 | } | ||
| 175 | } | 132 | } |
| 176 | |||
| 177 | printk ("new_irq_node: out of nodes\n"); | ||
| 178 | return NULL; | ||
| 179 | } | 133 | } |
| 180 | 134 | ||
| 181 | int setup_irq(unsigned int irq, struct irq_node *node) | 135 | unsigned int m68k_irq_startup_irq(unsigned int irq) |
| 182 | { | ||
| 183 | struct irq_controller *contr; | ||
| 184 | struct irq_node **prev; | ||
| 185 | unsigned long flags; | ||
| 186 | |||
| 187 | if (irq >= NR_IRQS || !(contr = irq_controller[irq])) { | ||
| 188 | printk("%s: Incorrect IRQ %d from %s\n", | ||
| 189 | __func__, irq, node->devname); | ||
| 190 | return -ENXIO; | ||
| 191 | } | ||
| 192 | |||
| 193 | spin_lock_irqsave(&contr->lock, flags); | ||
| 194 | |||
| 195 | prev = irq_list + irq; | ||
| 196 | if (*prev) { | ||
| 197 | /* Can't share interrupts unless both agree to */ | ||
| 198 | if (!((*prev)->flags & node->flags & IRQF_SHARED)) { | ||
| 199 | spin_unlock_irqrestore(&contr->lock, flags); | ||
| 200 | return -EBUSY; | ||
| 201 | } | ||
| 202 | while (*prev) | ||
| 203 | prev = &(*prev)->next; | ||
| 204 | } | ||
| 205 | |||
| 206 | if (!irq_list[irq]) { | ||
| 207 | if (contr->startup) | ||
| 208 | contr->startup(irq); | ||
| 209 | else | ||
| 210 | contr->enable(irq); | ||
| 211 | } | ||
| 212 | node->next = NULL; | ||
| 213 | *prev = node; | ||
| 214 | |||
| 215 | spin_unlock_irqrestore(&contr->lock, flags); | ||
| 216 | |||
| 217 | return 0; | ||
| 218 | } | ||
| 219 | |||
| 220 | int request_irq(unsigned int irq, | ||
| 221 | irq_handler_t handler, | ||
| 222 | unsigned long flags, const char *devname, void *dev_id) | ||
| 223 | { | ||
| 224 | struct irq_node *node; | ||
| 225 | int res; | ||
| 226 | |||
| 227 | node = new_irq_node(); | ||
| 228 | if (!node) | ||
| 229 | return -ENOMEM; | ||
| 230 | |||
| 231 | node->handler = handler; | ||
| 232 | node->flags = flags; | ||
| 233 | node->dev_id = dev_id; | ||
| 234 | node->devname = devname; | ||
| 235 | |||
| 236 | res = setup_irq(irq, node); | ||
| 237 | if (res) | ||
| 238 | node->handler = NULL; | ||
| 239 | |||
| 240 | return res; | ||
| 241 | } | ||
| 242 | |||
| 243 | EXPORT_SYMBOL(request_irq); | ||
| 244 | |||
| 245 | void free_irq(unsigned int irq, void *dev_id) | ||
| 246 | { | ||
| 247 | struct irq_controller *contr; | ||
| 248 | struct irq_node **p, *node; | ||
| 249 | unsigned long flags; | ||
| 250 | |||
| 251 | if (irq >= NR_IRQS || !(contr = irq_controller[irq])) { | ||
| 252 | printk("%s: Incorrect IRQ %d\n", __func__, irq); | ||
| 253 | return; | ||
| 254 | } | ||
| 255 | |||
| 256 | spin_lock_irqsave(&contr->lock, flags); | ||
| 257 | |||
| 258 | p = irq_list + irq; | ||
| 259 | while ((node = *p)) { | ||
| 260 | if (node->dev_id == dev_id) | ||
| 261 | break; | ||
| 262 | p = &node->next; | ||
| 263 | } | ||
| 264 | |||
| 265 | if (node) { | ||
| 266 | *p = node->next; | ||
| 267 | node->handler = NULL; | ||
| 268 | } else | ||
| 269 | printk("%s: Removing probably wrong IRQ %d\n", | ||
| 270 | __func__, irq); | ||
| 271 | |||
| 272 | if (!irq_list[irq]) { | ||
| 273 | if (contr->shutdown) | ||
| 274 | contr->shutdown(irq); | ||
| 275 | else | ||
| 276 | contr->disable(irq); | ||
| 277 | } | ||
| 278 | |||
| 279 | spin_unlock_irqrestore(&contr->lock, flags); | ||
| 280 | } | ||
| 281 | |||
| 282 | EXPORT_SYMBOL(free_irq); | ||
| 283 | |||
| 284 | void enable_irq(unsigned int irq) | ||
| 285 | { | ||
| 286 | struct irq_controller *contr; | ||
| 287 | unsigned long flags; | ||
| 288 | |||
| 289 | if (irq >= NR_IRQS || !(contr = irq_controller[irq])) { | ||
| 290 | printk("%s: Incorrect IRQ %d\n", | ||
| 291 | __func__, irq); | ||
| 292 | return; | ||
| 293 | } | ||
| 294 | |||
| 295 | spin_lock_irqsave(&contr->lock, flags); | ||
| 296 | if (irq_depth[irq]) { | ||
| 297 | if (!--irq_depth[irq]) { | ||
| 298 | if (contr->enable) | ||
| 299 | contr->enable(irq); | ||
| 300 | } | ||
| 301 | } else | ||
| 302 | WARN_ON(1); | ||
| 303 | spin_unlock_irqrestore(&contr->lock, flags); | ||
| 304 | } | ||
| 305 | |||
| 306 | EXPORT_SYMBOL(enable_irq); | ||
| 307 | |||
| 308 | void disable_irq(unsigned int irq) | ||
| 309 | { | ||
| 310 | struct irq_controller *contr; | ||
| 311 | unsigned long flags; | ||
| 312 | |||
| 313 | if (irq >= NR_IRQS || !(contr = irq_controller[irq])) { | ||
| 314 | printk("%s: Incorrect IRQ %d\n", | ||
| 315 | __func__, irq); | ||
| 316 | return; | ||
| 317 | } | ||
| 318 | |||
| 319 | spin_lock_irqsave(&contr->lock, flags); | ||
| 320 | if (!irq_depth[irq]++) { | ||
| 321 | if (contr->disable) | ||
| 322 | contr->disable(irq); | ||
| 323 | } | ||
| 324 | spin_unlock_irqrestore(&contr->lock, flags); | ||
| 325 | } | ||
| 326 | |||
| 327 | EXPORT_SYMBOL(disable_irq); | ||
| 328 | |||
| 329 | void disable_irq_nosync(unsigned int irq) __attribute__((alias("disable_irq"))); | ||
| 330 | |||
| 331 | EXPORT_SYMBOL(disable_irq_nosync); | ||
| 332 | |||
| 333 | int m68k_irq_startup(unsigned int irq) | ||
| 334 | { | 136 | { |
| 335 | if (irq <= IRQ_AUTO_7) | 137 | if (irq <= IRQ_AUTO_7) |
| 336 | vectors[VEC_SPUR + irq] = auto_inthandler; | 138 | vectors[VEC_SPUR + irq] = auto_inthandler; |
| @@ -339,41 +141,21 @@ int m68k_irq_startup(unsigned int irq) | |||
| 339 | return 0; | 141 | return 0; |
| 340 | } | 142 | } |
| 341 | 143 | ||
| 342 | void m68k_irq_shutdown(unsigned int irq) | 144 | unsigned int m68k_irq_startup(struct irq_data *data) |
| 343 | { | 145 | { |
| 344 | if (irq <= IRQ_AUTO_7) | 146 | return m68k_irq_startup_irq(data->irq); |
| 345 | vectors[VEC_SPUR + irq] = bad_inthandler; | ||
| 346 | else | ||
| 347 | vectors[m68k_first_user_vec + irq - IRQ_USER] = bad_inthandler; | ||
| 348 | } | 147 | } |
| 349 | 148 | ||
| 350 | 149 | void m68k_irq_shutdown(struct irq_data *data) | |
| 351 | /* | ||
| 352 | * Do we need these probe functions on the m68k? | ||
| 353 | * | ||
| 354 | * ... may be useful with ISA devices | ||
| 355 | */ | ||
| 356 | unsigned long probe_irq_on (void) | ||
| 357 | { | 150 | { |
| 358 | #ifdef CONFIG_Q40 | 151 | unsigned int irq = data->irq; |
| 359 | if (MACH_IS_Q40) | ||
| 360 | return q40_probe_irq_on(); | ||
| 361 | #endif | ||
| 362 | return 0; | ||
| 363 | } | ||
| 364 | 152 | ||
| 365 | EXPORT_SYMBOL(probe_irq_on); | 153 | if (irq <= IRQ_AUTO_7) |
| 366 | 154 | vectors[VEC_SPUR + irq] = bad_inthandler; | |
| 367 | int probe_irq_off (unsigned long irqs) | 155 | else |
| 368 | { | 156 | vectors[m68k_first_user_vec + irq - IRQ_USER] = bad_inthandler; |
| 369 | #ifdef CONFIG_Q40 | ||
| 370 | if (MACH_IS_Q40) | ||
| 371 | return q40_probe_irq_off(irqs); | ||
| 372 | #endif | ||
| 373 | return 0; | ||
| 374 | } | 157 | } |
| 375 | 158 | ||
| 376 | EXPORT_SYMBOL(probe_irq_off); | ||
| 377 | 159 | ||
| 378 | unsigned int irq_canonicalize(unsigned int irq) | 160 | unsigned int irq_canonicalize(unsigned int irq) |
| 379 | { | 161 | { |
| @@ -386,52 +168,9 @@ unsigned int irq_canonicalize(unsigned int irq) | |||
| 386 | 168 | ||
| 387 | EXPORT_SYMBOL(irq_canonicalize); | 169 | EXPORT_SYMBOL(irq_canonicalize); |
| 388 | 170 | ||
| 389 | asmlinkage void m68k_handle_int(unsigned int irq) | ||
| 390 | { | ||
| 391 | struct irq_node *node; | ||
| 392 | kstat_cpu(0).irqs[irq]++; | ||
| 393 | node = irq_list[irq]; | ||
| 394 | do { | ||
| 395 | node->handler(irq, node->dev_id); | ||
| 396 | node = node->next; | ||
| 397 | } while (node); | ||
| 398 | } | ||
| 399 | |||
| 400 | asmlinkage void __m68k_handle_int(unsigned int irq, struct pt_regs *regs) | ||
| 401 | { | ||
| 402 | struct pt_regs *old_regs; | ||
| 403 | old_regs = set_irq_regs(regs); | ||
| 404 | m68k_handle_int(irq); | ||
| 405 | set_irq_regs(old_regs); | ||
| 406 | } | ||
| 407 | 171 | ||
| 408 | asmlinkage void handle_badint(struct pt_regs *regs) | 172 | asmlinkage void handle_badint(struct pt_regs *regs) |
| 409 | { | 173 | { |
| 410 | kstat_cpu(0).irqs[0]++; | 174 | atomic_inc(&irq_err_count); |
| 411 | printk("unexpected interrupt from %u\n", regs->vector); | 175 | pr_warn("unexpected interrupt from %u\n", regs->vector); |
| 412 | } | ||
| 413 | |||
| 414 | int show_interrupts(struct seq_file *p, void *v) | ||
| 415 | { | ||
| 416 | struct irq_controller *contr; | ||
| 417 | struct irq_node *node; | ||
| 418 | int i = *(loff_t *) v; | ||
| 419 | |||
| 420 | /* autovector interrupts */ | ||
| 421 | if (irq_list[i]) { | ||
| 422 | contr = irq_controller[i]; | ||
| 423 | node = irq_list[i]; | ||
| 424 | seq_printf(p, "%-8s %3u: %10u %s", contr->name, i, kstat_cpu(0).irqs[i], node->devname); | ||
| 425 | while ((node = node->next)) | ||
| 426 | seq_printf(p, ", %s", node->devname); | ||
| 427 | seq_puts(p, "\n"); | ||
| 428 | } | ||
| 429 | return 0; | ||
| 430 | } | ||
| 431 | |||
| 432 | #ifdef CONFIG_PROC_FS | ||
| 433 | void init_irq_proc(void) | ||
| 434 | { | ||
| 435 | /* Insert /proc/irq driver here */ | ||
| 436 | } | 176 | } |
| 437 | #endif | ||
diff --git a/arch/m68k/kernel/setup_no.c b/arch/m68k/kernel/setup_no.c index 16b2de7f5101..2ed8c0fb1517 100644 --- a/arch/m68k/kernel/setup_no.c +++ b/arch/m68k/kernel/setup_no.c | |||
| @@ -36,6 +36,7 @@ | |||
| 36 | #include <asm/irq.h> | 36 | #include <asm/irq.h> |
| 37 | #include <asm/machdep.h> | 37 | #include <asm/machdep.h> |
| 38 | #include <asm/pgtable.h> | 38 | #include <asm/pgtable.h> |
| 39 | #include <asm/sections.h> | ||
| 39 | 40 | ||
| 40 | unsigned long memory_start; | 41 | unsigned long memory_start; |
| 41 | unsigned long memory_end; | 42 | unsigned long memory_end; |
| @@ -80,9 +81,6 @@ void (*mach_power_off)(void); | |||
| 80 | #define CPU_INSTR_PER_JIFFY 16 | 81 | #define CPU_INSTR_PER_JIFFY 16 |
| 81 | #endif | 82 | #endif |
| 82 | 83 | ||
| 83 | extern int _stext, _etext, _sdata, _edata, _sbss, _ebss, _end; | ||
| 84 | extern int _ramstart, _ramend; | ||
| 85 | |||
| 86 | #if defined(CONFIG_UBOOT) | 84 | #if defined(CONFIG_UBOOT) |
| 87 | /* | 85 | /* |
| 88 | * parse_uboot_commandline | 86 | * parse_uboot_commandline |
diff --git a/arch/m68k/kernel/traps.c b/arch/m68k/kernel/traps.c index c98add3f5f0f..89362f2bb56a 100644 --- a/arch/m68k/kernel/traps.c +++ b/arch/m68k/kernel/traps.c | |||
| @@ -1,5 +1,1107 @@ | |||
| 1 | #ifdef CONFIG_MMU | 1 | /* |
| 2 | #include "traps_mm.c" | 2 | * linux/arch/m68k/kernel/traps.c |
| 3 | * | ||
| 4 | * Copyright (C) 1993, 1994 by Hamish Macdonald | ||
| 5 | * | ||
| 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 | ||
| 11 | * | ||
| 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 | ||
| 14 | * for more details. | ||
| 15 | */ | ||
| 16 | |||
| 17 | /* | ||
| 18 | * Sets up all exception vectors | ||
| 19 | */ | ||
| 20 | |||
| 21 | #include <linux/sched.h> | ||
| 22 | #include <linux/signal.h> | ||
| 23 | #include <linux/kernel.h> | ||
| 24 | #include <linux/mm.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> | ||
| 32 | |||
| 33 | #include <asm/setup.h> | ||
| 34 | #include <asm/fpu.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> | ||
| 41 | |||
| 42 | |||
| 43 | static const char *vec_names[] = { | ||
| 44 | [VEC_RESETSP] = "RESET SP", | ||
| 45 | [VEC_RESETPC] = "RESET PC", | ||
| 46 | [VEC_BUSERR] = "BUS ERROR", | ||
| 47 | [VEC_ADDRERR] = "ADDRESS ERROR", | ||
| 48 | [VEC_ILLEGAL] = "ILLEGAL INSTRUCTION", | ||
| 49 | [VEC_ZERODIV] = "ZERO DIVIDE", | ||
| 50 | [VEC_CHK] = "CHK", | ||
| 51 | [VEC_TRAP] = "TRAPcc", | ||
| 52 | [VEC_PRIV] = "PRIVILEGE VIOLATION", | ||
| 53 | [VEC_TRACE] = "TRACE", | ||
| 54 | [VEC_LINE10] = "LINE 1010", | ||
| 55 | [VEC_LINE11] = "LINE 1111", | ||
| 56 | [VEC_RESV12] = "UNASSIGNED RESERVED 12", | ||
| 57 | [VEC_COPROC] = "COPROCESSOR PROTOCOL VIOLATION", | ||
| 58 | [VEC_FORMAT] = "FORMAT ERROR", | ||
| 59 | [VEC_UNINT] = "UNINITIALIZED INTERRUPT", | ||
| 60 | [VEC_RESV16] = "UNASSIGNED RESERVED 16", | ||
| 61 | [VEC_RESV17] = "UNASSIGNED RESERVED 17", | ||
| 62 | [VEC_RESV18] = "UNASSIGNED RESERVED 18", | ||
| 63 | [VEC_RESV19] = "UNASSIGNED RESERVED 19", | ||
| 64 | [VEC_RESV20] = "UNASSIGNED RESERVED 20", | ||
| 65 | [VEC_RESV21] = "UNASSIGNED RESERVED 21", | ||
| 66 | [VEC_RESV22] = "UNASSIGNED RESERVED 22", | ||
| 67 | [VEC_RESV23] = "UNASSIGNED RESERVED 23", | ||
| 68 | [VEC_SPUR] = "SPURIOUS INTERRUPT", | ||
| 69 | [VEC_INT1] = "LEVEL 1 INT", | ||
| 70 | [VEC_INT2] = "LEVEL 2 INT", | ||
| 71 | [VEC_INT3] = "LEVEL 3 INT", | ||
| 72 | [VEC_INT4] = "LEVEL 4 INT", | ||
| 73 | [VEC_INT5] = "LEVEL 5 INT", | ||
| 74 | [VEC_INT6] = "LEVEL 6 INT", | ||
| 75 | [VEC_INT7] = "LEVEL 7 INT", | ||
| 76 | [VEC_SYS] = "SYSCALL", | ||
| 77 | [VEC_TRAP1] = "TRAP #1", | ||
| 78 | [VEC_TRAP2] = "TRAP #2", | ||
| 79 | [VEC_TRAP3] = "TRAP #3", | ||
| 80 | [VEC_TRAP4] = "TRAP #4", | ||
| 81 | [VEC_TRAP5] = "TRAP #5", | ||
| 82 | [VEC_TRAP6] = "TRAP #6", | ||
| 83 | [VEC_TRAP7] = "TRAP #7", | ||
| 84 | [VEC_TRAP8] = "TRAP #8", | ||
| 85 | [VEC_TRAP9] = "TRAP #9", | ||
| 86 | [VEC_TRAP10] = "TRAP #10", | ||
| 87 | [VEC_TRAP11] = "TRAP #11", | ||
| 88 | [VEC_TRAP12] = "TRAP #12", | ||
| 89 | [VEC_TRAP13] = "TRAP #13", | ||
| 90 | [VEC_TRAP14] = "TRAP #14", | ||
| 91 | [VEC_TRAP15] = "TRAP #15", | ||
| 92 | [VEC_FPBRUC] = "FPCP BSUN", | ||
| 93 | [VEC_FPIR] = "FPCP INEXACT", | ||
| 94 | [VEC_FPDIVZ] = "FPCP DIV BY 0", | ||
| 95 | [VEC_FPUNDER] = "FPCP UNDERFLOW", | ||
| 96 | [VEC_FPOE] = "FPCP OPERAND ERROR", | ||
| 97 | [VEC_FPOVER] = "FPCP OVERFLOW", | ||
| 98 | [VEC_FPNAN] = "FPCP SNAN", | ||
| 99 | [VEC_FPUNSUP] = "FPCP UNSUPPORTED OPERATION", | ||
| 100 | [VEC_MMUCFG] = "MMU CONFIGURATION ERROR", | ||
| 101 | [VEC_MMUILL] = "MMU ILLEGAL OPERATION ERROR", | ||
| 102 | [VEC_MMUACC] = "MMU ACCESS LEVEL VIOLATION ERROR", | ||
| 103 | [VEC_RESV59] = "UNASSIGNED RESERVED 59", | ||
| 104 | [VEC_UNIMPEA] = "UNASSIGNED RESERVED 60", | ||
| 105 | [VEC_UNIMPII] = "UNASSIGNED RESERVED 61", | ||
| 106 | [VEC_RESV62] = "UNASSIGNED RESERVED 62", | ||
| 107 | [VEC_RESV63] = "UNASSIGNED RESERVED 63", | ||
| 108 | }; | ||
| 109 | |||
| 110 | static const char *space_names[] = { | ||
| 111 | [0] = "Space 0", | ||
| 112 | [USER_DATA] = "User Data", | ||
| 113 | [USER_PROGRAM] = "User Program", | ||
| 114 | #ifndef CONFIG_SUN3 | ||
| 115 | [3] = "Space 3", | ||
| 3 | #else | 116 | #else |
| 4 | #include "traps_no.c" | 117 | [FC_CONTROL] = "Control", |
| 118 | #endif | ||
| 119 | [4] = "Space 4", | ||
| 120 | [SUPER_DATA] = "Super Data", | ||
| 121 | [SUPER_PROGRAM] = "Super Program", | ||
| 122 | [CPU_SPACE] = "CPU" | ||
| 123 | }; | ||
| 124 | |||
| 125 | void die_if_kernel(char *,struct pt_regs *,int); | ||
| 126 | asmlinkage int do_page_fault(struct pt_regs *regs, unsigned long address, | ||
| 127 | unsigned long error_code); | ||
| 128 | int send_fault_sig(struct pt_regs *regs); | ||
| 129 | |||
| 130 | asmlinkage void trap_c(struct frame *fp); | ||
| 131 | |||
| 132 | #if defined (CONFIG_M68060) | ||
| 133 | static inline void access_error060 (struct frame *fp) | ||
| 134 | { | ||
| 135 | unsigned long fslw = fp->un.fmt4.pc; /* is really FSLW for access error */ | ||
| 136 | |||
| 137 | #ifdef DEBUG | ||
| 138 | printk("fslw=%#lx, fa=%#lx\n", fslw, fp->un.fmt4.effaddr); | ||
| 139 | #endif | ||
| 140 | |||
| 141 | if (fslw & MMU060_BPE) { | ||
| 142 | /* branch prediction error -> clear branch cache */ | ||
| 143 | __asm__ __volatile__ ("movec %/cacr,%/d0\n\t" | ||
| 144 | "orl #0x00400000,%/d0\n\t" | ||
| 145 | "movec %/d0,%/cacr" | ||
| 146 | : : : "d0" ); | ||
| 147 | /* return if there's no other error */ | ||
| 148 | if (!(fslw & MMU060_ERR_BITS) && !(fslw & MMU060_SEE)) | ||
| 149 | return; | ||
| 150 | } | ||
| 151 | |||
| 152 | if (fslw & (MMU060_DESC_ERR | MMU060_WP | MMU060_SP)) { | ||
| 153 | unsigned long errorcode; | ||
| 154 | unsigned long addr = fp->un.fmt4.effaddr; | ||
| 155 | |||
| 156 | if (fslw & MMU060_MA) | ||
| 157 | addr = (addr + PAGE_SIZE - 1) & PAGE_MASK; | ||
| 158 | |||
| 159 | errorcode = 1; | ||
| 160 | if (fslw & MMU060_DESC_ERR) { | ||
| 161 | __flush_tlb040_one(addr); | ||
| 162 | errorcode = 0; | ||
| 163 | } | ||
| 164 | if (fslw & MMU060_W) | ||
| 165 | errorcode |= 2; | ||
| 166 | #ifdef DEBUG | ||
| 167 | printk("errorcode = %d\n", errorcode ); | ||
| 168 | #endif | ||
| 169 | do_page_fault(&fp->ptregs, addr, errorcode); | ||
| 170 | } else if (fslw & (MMU060_SEE)){ | ||
| 171 | /* Software Emulation Error. | ||
| 172 | * fault during mem_read/mem_write in ifpsp060/os.S | ||
| 173 | */ | ||
| 174 | send_fault_sig(&fp->ptregs); | ||
| 175 | } else if (!(fslw & (MMU060_RE|MMU060_WE)) || | ||
| 176 | send_fault_sig(&fp->ptregs) > 0) { | ||
| 177 | printk("pc=%#lx, fa=%#lx\n", fp->ptregs.pc, fp->un.fmt4.effaddr); | ||
| 178 | printk( "68060 access error, fslw=%lx\n", fslw ); | ||
| 179 | trap_c( fp ); | ||
| 180 | } | ||
| 181 | } | ||
| 182 | #endif /* CONFIG_M68060 */ | ||
| 183 | |||
| 184 | #if defined (CONFIG_M68040) | ||
| 185 | static inline unsigned long probe040(int iswrite, unsigned long addr, int wbs) | ||
| 186 | { | ||
| 187 | unsigned long mmusr; | ||
| 188 | mm_segment_t old_fs = get_fs(); | ||
| 189 | |||
| 190 | set_fs(MAKE_MM_SEG(wbs)); | ||
| 191 | |||
| 192 | if (iswrite) | ||
| 193 | asm volatile (".chip 68040; ptestw (%0); .chip 68k" : : "a" (addr)); | ||
| 194 | else | ||
| 195 | asm volatile (".chip 68040; ptestr (%0); .chip 68k" : : "a" (addr)); | ||
| 196 | |||
| 197 | asm volatile (".chip 68040; movec %%mmusr,%0; .chip 68k" : "=r" (mmusr)); | ||
| 198 | |||
| 199 | set_fs(old_fs); | ||
| 200 | |||
| 201 | return mmusr; | ||
| 202 | } | ||
| 203 | |||
| 204 | static inline int do_040writeback1(unsigned short wbs, unsigned long wba, | ||
| 205 | unsigned long wbd) | ||
| 206 | { | ||
| 207 | int res = 0; | ||
| 208 | mm_segment_t old_fs = get_fs(); | ||
| 209 | |||
| 210 | /* set_fs can not be moved, otherwise put_user() may oops */ | ||
| 211 | set_fs(MAKE_MM_SEG(wbs)); | ||
| 212 | |||
| 213 | switch (wbs & WBSIZ_040) { | ||
| 214 | case BA_SIZE_BYTE: | ||
| 215 | res = put_user(wbd & 0xff, (char __user *)wba); | ||
| 216 | break; | ||
| 217 | case BA_SIZE_WORD: | ||
| 218 | res = put_user(wbd & 0xffff, (short __user *)wba); | ||
| 219 | break; | ||
| 220 | case BA_SIZE_LONG: | ||
| 221 | res = put_user(wbd, (int __user *)wba); | ||
| 222 | break; | ||
| 223 | } | ||
| 224 | |||
| 225 | /* set_fs can not be moved, otherwise put_user() may oops */ | ||
| 226 | set_fs(old_fs); | ||
| 227 | |||
| 228 | |||
| 229 | #ifdef DEBUG | ||
| 230 | printk("do_040writeback1, res=%d\n",res); | ||
| 231 | #endif | ||
| 232 | |||
| 233 | return res; | ||
| 234 | } | ||
| 235 | |||
| 236 | /* after an exception in a writeback the stack frame corresponding | ||
| 237 | * to that exception is discarded, set a few bits in the old frame | ||
| 238 | * to simulate what it should look like | ||
| 239 | */ | ||
| 240 | static inline void fix_xframe040(struct frame *fp, unsigned long wba, unsigned short wbs) | ||
| 241 | { | ||
| 242 | fp->un.fmt7.faddr = wba; | ||
| 243 | fp->un.fmt7.ssw = wbs & 0xff; | ||
| 244 | if (wba != current->thread.faddr) | ||
| 245 | fp->un.fmt7.ssw |= MA_040; | ||
| 246 | } | ||
| 247 | |||
| 248 | static inline void do_040writebacks(struct frame *fp) | ||
| 249 | { | ||
| 250 | int res = 0; | ||
| 251 | #if 0 | ||
| 252 | if (fp->un.fmt7.wb1s & WBV_040) | ||
| 253 | printk("access_error040: cannot handle 1st writeback. oops.\n"); | ||
| 254 | #endif | ||
| 255 | |||
| 256 | if ((fp->un.fmt7.wb2s & WBV_040) && | ||
| 257 | !(fp->un.fmt7.wb2s & WBTT_040)) { | ||
| 258 | res = do_040writeback1(fp->un.fmt7.wb2s, fp->un.fmt7.wb2a, | ||
| 259 | fp->un.fmt7.wb2d); | ||
| 260 | if (res) | ||
| 261 | fix_xframe040(fp, fp->un.fmt7.wb2a, fp->un.fmt7.wb2s); | ||
| 262 | else | ||
| 263 | fp->un.fmt7.wb2s = 0; | ||
| 264 | } | ||
| 265 | |||
| 266 | /* do the 2nd wb only if the first one was successful (except for a kernel wb) */ | ||
| 267 | if (fp->un.fmt7.wb3s & WBV_040 && (!res || fp->un.fmt7.wb3s & 4)) { | ||
| 268 | res = do_040writeback1(fp->un.fmt7.wb3s, fp->un.fmt7.wb3a, | ||
| 269 | fp->un.fmt7.wb3d); | ||
| 270 | if (res) | ||
| 271 | { | ||
| 272 | fix_xframe040(fp, fp->un.fmt7.wb3a, fp->un.fmt7.wb3s); | ||
| 273 | |||
| 274 | fp->un.fmt7.wb2s = fp->un.fmt7.wb3s; | ||
| 275 | fp->un.fmt7.wb3s &= (~WBV_040); | ||
| 276 | fp->un.fmt7.wb2a = fp->un.fmt7.wb3a; | ||
| 277 | fp->un.fmt7.wb2d = fp->un.fmt7.wb3d; | ||
| 278 | } | ||
| 279 | else | ||
| 280 | fp->un.fmt7.wb3s = 0; | ||
| 281 | } | ||
| 282 | |||
| 283 | if (res) | ||
| 284 | send_fault_sig(&fp->ptregs); | ||
| 285 | } | ||
| 286 | |||
| 287 | /* | ||
| 288 | * called from sigreturn(), must ensure userspace code didn't | ||
| 289 | * manipulate exception frame to circumvent protection, then complete | ||
| 290 | * pending writebacks | ||
| 291 | * we just clear TM2 to turn it into a userspace access | ||
| 292 | */ | ||
| 293 | asmlinkage void berr_040cleanup(struct frame *fp) | ||
| 294 | { | ||
| 295 | fp->un.fmt7.wb2s &= ~4; | ||
| 296 | fp->un.fmt7.wb3s &= ~4; | ||
| 297 | |||
| 298 | do_040writebacks(fp); | ||
| 299 | } | ||
| 300 | |||
| 301 | static inline void access_error040(struct frame *fp) | ||
| 302 | { | ||
| 303 | unsigned short ssw = fp->un.fmt7.ssw; | ||
| 304 | unsigned long mmusr; | ||
| 305 | |||
| 306 | #ifdef DEBUG | ||
| 307 | printk("ssw=%#x, fa=%#lx\n", ssw, fp->un.fmt7.faddr); | ||
| 308 | printk("wb1s=%#x, wb2s=%#x, wb3s=%#x\n", fp->un.fmt7.wb1s, | ||
| 309 | fp->un.fmt7.wb2s, fp->un.fmt7.wb3s); | ||
| 310 | printk ("wb2a=%lx, wb3a=%lx, wb2d=%lx, wb3d=%lx\n", | ||
| 311 | fp->un.fmt7.wb2a, fp->un.fmt7.wb3a, | ||
| 312 | fp->un.fmt7.wb2d, fp->un.fmt7.wb3d); | ||
| 313 | #endif | ||
| 314 | |||
| 315 | if (ssw & ATC_040) { | ||
| 316 | unsigned long addr = fp->un.fmt7.faddr; | ||
| 317 | unsigned long errorcode; | ||
| 318 | |||
| 319 | /* | ||
| 320 | * The MMU status has to be determined AFTER the address | ||
| 321 | * has been corrected if there was a misaligned access (MA). | ||
| 322 | */ | ||
| 323 | if (ssw & MA_040) | ||
| 324 | addr = (addr + 7) & -8; | ||
| 325 | |||
| 326 | /* MMU error, get the MMUSR info for this access */ | ||
| 327 | mmusr = probe040(!(ssw & RW_040), addr, ssw); | ||
| 328 | #ifdef DEBUG | ||
| 329 | printk("mmusr = %lx\n", mmusr); | ||
| 330 | #endif | ||
| 331 | errorcode = 1; | ||
| 332 | if (!(mmusr & MMU_R_040)) { | ||
| 333 | /* clear the invalid atc entry */ | ||
| 334 | __flush_tlb040_one(addr); | ||
| 335 | errorcode = 0; | ||
| 336 | } | ||
| 337 | |||
| 338 | /* despite what documentation seems to say, RMW | ||
| 339 | * accesses have always both the LK and RW bits set */ | ||
| 340 | if (!(ssw & RW_040) || (ssw & LK_040)) | ||
| 341 | errorcode |= 2; | ||
| 342 | |||
| 343 | if (do_page_fault(&fp->ptregs, addr, errorcode)) { | ||
| 344 | #ifdef DEBUG | ||
| 345 | printk("do_page_fault() !=0\n"); | ||
| 346 | #endif | ||
| 347 | if (user_mode(&fp->ptregs)){ | ||
| 348 | /* delay writebacks after signal delivery */ | ||
| 349 | #ifdef DEBUG | ||
| 350 | printk(".. was usermode - return\n"); | ||
| 351 | #endif | ||
| 352 | return; | ||
| 353 | } | ||
| 354 | /* disable writeback into user space from kernel | ||
| 355 | * (if do_page_fault didn't fix the mapping, | ||
| 356 | * the writeback won't do good) | ||
| 357 | */ | ||
| 358 | disable_wb: | ||
| 359 | #ifdef DEBUG | ||
| 360 | printk(".. disabling wb2\n"); | ||
| 361 | #endif | ||
| 362 | if (fp->un.fmt7.wb2a == fp->un.fmt7.faddr) | ||
| 363 | fp->un.fmt7.wb2s &= ~WBV_040; | ||
| 364 | if (fp->un.fmt7.wb3a == fp->un.fmt7.faddr) | ||
| 365 | fp->un.fmt7.wb3s &= ~WBV_040; | ||
| 366 | } | ||
| 367 | } else { | ||
| 368 | /* In case of a bus error we either kill the process or expect | ||
| 369 | * the kernel to catch the fault, which then is also responsible | ||
| 370 | * for cleaning up the mess. | ||
| 371 | */ | ||
| 372 | current->thread.signo = SIGBUS; | ||
| 373 | current->thread.faddr = fp->un.fmt7.faddr; | ||
| 374 | if (send_fault_sig(&fp->ptregs) >= 0) | ||
| 375 | printk("68040 bus error (ssw=%x, faddr=%lx)\n", ssw, | ||
| 376 | fp->un.fmt7.faddr); | ||
| 377 | goto disable_wb; | ||
| 378 | } | ||
| 379 | |||
| 380 | do_040writebacks(fp); | ||
| 381 | } | ||
| 382 | #endif /* CONFIG_M68040 */ | ||
| 383 | |||
| 384 | #if defined(CONFIG_SUN3) | ||
| 385 | #include <asm/sun3mmu.h> | ||
| 386 | |||
| 387 | extern int mmu_emu_handle_fault (unsigned long, int, int); | ||
| 388 | |||
| 389 | /* sun3 version of bus_error030 */ | ||
| 390 | |||
| 391 | static inline void bus_error030 (struct frame *fp) | ||
| 392 | { | ||
| 393 | unsigned char buserr_type = sun3_get_buserr (); | ||
| 394 | unsigned long addr, errorcode; | ||
| 395 | unsigned short ssw = fp->un.fmtb.ssw; | ||
| 396 | extern unsigned long _sun3_map_test_start, _sun3_map_test_end; | ||
| 397 | |||
| 398 | #ifdef DEBUG | ||
| 399 | if (ssw & (FC | FB)) | ||
| 400 | printk ("Instruction fault at %#010lx\n", | ||
| 401 | ssw & FC ? | ||
| 402 | fp->ptregs.format == 0xa ? fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2 | ||
| 403 | : | ||
| 404 | fp->ptregs.format == 0xa ? fp->ptregs.pc + 4 : fp->un.fmtb.baddr); | ||
| 405 | if (ssw & DF) | ||
| 406 | printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n", | ||
| 407 | ssw & RW ? "read" : "write", | ||
| 408 | fp->un.fmtb.daddr, | ||
| 409 | space_names[ssw & DFC], fp->ptregs.pc); | ||
| 410 | #endif | ||
| 411 | |||
| 412 | /* | ||
| 413 | * Check if this page should be demand-mapped. This needs to go before | ||
| 414 | * the testing for a bad kernel-space access (demand-mapping applies | ||
| 415 | * to kernel accesses too). | ||
| 416 | */ | ||
| 417 | |||
| 418 | if ((ssw & DF) | ||
| 419 | && (buserr_type & (SUN3_BUSERR_PROTERR | SUN3_BUSERR_INVALID))) { | ||
| 420 | if (mmu_emu_handle_fault (fp->un.fmtb.daddr, ssw & RW, 0)) | ||
| 421 | return; | ||
| 422 | } | ||
| 423 | |||
| 424 | /* Check for kernel-space pagefault (BAD). */ | ||
| 425 | if (fp->ptregs.sr & PS_S) { | ||
| 426 | /* kernel fault must be a data fault to user space */ | ||
| 427 | if (! ((ssw & DF) && ((ssw & DFC) == USER_DATA))) { | ||
| 428 | // try checking the kernel mappings before surrender | ||
| 429 | if (mmu_emu_handle_fault (fp->un.fmtb.daddr, ssw & RW, 1)) | ||
| 430 | return; | ||
| 431 | /* instruction fault or kernel data fault! */ | ||
| 432 | if (ssw & (FC | FB)) | ||
| 433 | printk ("Instruction fault at %#010lx\n", | ||
| 434 | fp->ptregs.pc); | ||
| 435 | if (ssw & DF) { | ||
| 436 | /* was this fault incurred testing bus mappings? */ | ||
| 437 | if((fp->ptregs.pc >= (unsigned long)&_sun3_map_test_start) && | ||
| 438 | (fp->ptregs.pc <= (unsigned long)&_sun3_map_test_end)) { | ||
| 439 | send_fault_sig(&fp->ptregs); | ||
| 440 | return; | ||
| 441 | } | ||
| 442 | |||
| 443 | printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n", | ||
| 444 | ssw & RW ? "read" : "write", | ||
| 445 | fp->un.fmtb.daddr, | ||
| 446 | space_names[ssw & DFC], fp->ptregs.pc); | ||
| 447 | } | ||
| 448 | printk ("BAD KERNEL BUSERR\n"); | ||
| 449 | |||
| 450 | die_if_kernel("Oops", &fp->ptregs,0); | ||
| 451 | force_sig(SIGKILL, current); | ||
| 452 | return; | ||
| 453 | } | ||
| 454 | } else { | ||
| 455 | /* user fault */ | ||
| 456 | if (!(ssw & (FC | FB)) && !(ssw & DF)) | ||
| 457 | /* not an instruction fault or data fault! BAD */ | ||
| 458 | panic ("USER BUSERR w/o instruction or data fault"); | ||
| 459 | } | ||
| 460 | |||
| 461 | |||
| 462 | /* First handle the data fault, if any. */ | ||
| 463 | if (ssw & DF) { | ||
| 464 | addr = fp->un.fmtb.daddr; | ||
| 465 | |||
| 466 | // errorcode bit 0: 0 -> no page 1 -> protection fault | ||
| 467 | // errorcode bit 1: 0 -> read fault 1 -> write fault | ||
| 468 | |||
| 469 | // (buserr_type & SUN3_BUSERR_PROTERR) -> protection fault | ||
| 470 | // (buserr_type & SUN3_BUSERR_INVALID) -> invalid page fault | ||
| 471 | |||
| 472 | if (buserr_type & SUN3_BUSERR_PROTERR) | ||
| 473 | errorcode = 0x01; | ||
| 474 | else if (buserr_type & SUN3_BUSERR_INVALID) | ||
| 475 | errorcode = 0x00; | ||
| 476 | else { | ||
| 477 | #ifdef DEBUG | ||
| 478 | printk ("*** unexpected busfault type=%#04x\n", buserr_type); | ||
| 479 | printk ("invalid %s access at %#lx from pc %#lx\n", | ||
| 480 | !(ssw & RW) ? "write" : "read", addr, | ||
| 481 | fp->ptregs.pc); | ||
| 482 | #endif | ||
| 483 | die_if_kernel ("Oops", &fp->ptregs, buserr_type); | ||
| 484 | force_sig (SIGBUS, current); | ||
| 485 | return; | ||
| 486 | } | ||
| 487 | |||
| 488 | //todo: wtf is RM bit? --m | ||
| 489 | if (!(ssw & RW) || ssw & RM) | ||
| 490 | errorcode |= 0x02; | ||
| 491 | |||
| 492 | /* Handle page fault. */ | ||
| 493 | do_page_fault (&fp->ptregs, addr, errorcode); | ||
| 494 | |||
| 495 | /* Retry the data fault now. */ | ||
| 496 | return; | ||
| 497 | } | ||
| 498 | |||
| 499 | /* Now handle the instruction fault. */ | ||
| 500 | |||
| 501 | /* Get the fault address. */ | ||
| 502 | if (fp->ptregs.format == 0xA) | ||
| 503 | addr = fp->ptregs.pc + 4; | ||
| 504 | else | ||
| 505 | addr = fp->un.fmtb.baddr; | ||
| 506 | if (ssw & FC) | ||
| 507 | addr -= 2; | ||
| 508 | |||
| 509 | if (buserr_type & SUN3_BUSERR_INVALID) { | ||
| 510 | if (!mmu_emu_handle_fault (fp->un.fmtb.daddr, 1, 0)) | ||
| 511 | do_page_fault (&fp->ptregs, addr, 0); | ||
| 512 | } else { | ||
| 513 | #ifdef DEBUG | ||
| 514 | printk ("protection fault on insn access (segv).\n"); | ||
| 515 | #endif | ||
| 516 | force_sig (SIGSEGV, current); | ||
| 517 | } | ||
| 518 | } | ||
| 519 | #else | ||
| 520 | #if defined(CPU_M68020_OR_M68030) | ||
| 521 | static inline void bus_error030 (struct frame *fp) | ||
| 522 | { | ||
| 523 | volatile unsigned short temp; | ||
| 524 | unsigned short mmusr; | ||
| 525 | unsigned long addr, errorcode; | ||
| 526 | unsigned short ssw = fp->un.fmtb.ssw; | ||
| 527 | #ifdef DEBUG | ||
| 528 | unsigned long desc; | ||
| 529 | |||
| 530 | printk ("pid = %x ", current->pid); | ||
| 531 | printk ("SSW=%#06x ", ssw); | ||
| 532 | |||
| 533 | if (ssw & (FC | FB)) | ||
| 534 | printk ("Instruction fault at %#010lx\n", | ||
| 535 | ssw & FC ? | ||
| 536 | fp->ptregs.format == 0xa ? fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2 | ||
| 537 | : | ||
| 538 | fp->ptregs.format == 0xa ? fp->ptregs.pc + 4 : fp->un.fmtb.baddr); | ||
| 539 | if (ssw & DF) | ||
| 540 | printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n", | ||
| 541 | ssw & RW ? "read" : "write", | ||
| 542 | fp->un.fmtb.daddr, | ||
| 543 | space_names[ssw & DFC], fp->ptregs.pc); | ||
| 544 | #endif | ||
| 545 | |||
| 546 | /* ++andreas: If a data fault and an instruction fault happen | ||
| 547 | at the same time map in both pages. */ | ||
| 548 | |||
| 549 | /* First handle the data fault, if any. */ | ||
| 550 | if (ssw & DF) { | ||
| 551 | addr = fp->un.fmtb.daddr; | ||
| 552 | |||
| 553 | #ifdef DEBUG | ||
| 554 | asm volatile ("ptestr %3,%2@,#7,%0\n\t" | ||
| 555 | "pmove %%psr,%1@" | ||
| 556 | : "=a&" (desc) | ||
| 557 | : "a" (&temp), "a" (addr), "d" (ssw)); | ||
| 558 | #else | ||
| 559 | asm volatile ("ptestr %2,%1@,#7\n\t" | ||
| 560 | "pmove %%psr,%0@" | ||
| 561 | : : "a" (&temp), "a" (addr), "d" (ssw)); | ||
| 562 | #endif | ||
| 563 | mmusr = temp; | ||
| 564 | |||
| 565 | #ifdef DEBUG | ||
| 566 | printk("mmusr is %#x for addr %#lx in task %p\n", | ||
| 567 | mmusr, addr, current); | ||
| 568 | printk("descriptor address is %#lx, contents %#lx\n", | ||
| 569 | __va(desc), *(unsigned long *)__va(desc)); | ||
| 570 | #endif | ||
| 571 | |||
| 572 | errorcode = (mmusr & MMU_I) ? 0 : 1; | ||
| 573 | if (!(ssw & RW) || (ssw & RM)) | ||
| 574 | errorcode |= 2; | ||
| 575 | |||
| 576 | if (mmusr & (MMU_I | MMU_WP)) { | ||
| 577 | if (ssw & 4) { | ||
| 578 | printk("Data %s fault at %#010lx in %s (pc=%#lx)\n", | ||
| 579 | ssw & RW ? "read" : "write", | ||
| 580 | fp->un.fmtb.daddr, | ||
| 581 | space_names[ssw & DFC], fp->ptregs.pc); | ||
| 582 | goto buserr; | ||
| 583 | } | ||
| 584 | /* Don't try to do anything further if an exception was | ||
| 585 | handled. */ | ||
| 586 | if (do_page_fault (&fp->ptregs, addr, errorcode) < 0) | ||
| 587 | return; | ||
| 588 | } else if (!(mmusr & MMU_I)) { | ||
| 589 | /* probably a 020 cas fault */ | ||
| 590 | if (!(ssw & RM) && send_fault_sig(&fp->ptregs) > 0) | ||
| 591 | printk("unexpected bus error (%#x,%#x)\n", ssw, mmusr); | ||
| 592 | } else if (mmusr & (MMU_B|MMU_L|MMU_S)) { | ||
| 593 | printk("invalid %s access at %#lx from pc %#lx\n", | ||
| 594 | !(ssw & RW) ? "write" : "read", addr, | ||
| 595 | fp->ptregs.pc); | ||
| 596 | die_if_kernel("Oops",&fp->ptregs,mmusr); | ||
| 597 | force_sig(SIGSEGV, current); | ||
| 598 | return; | ||
| 599 | } else { | ||
| 600 | #if 0 | ||
| 601 | static volatile long tlong; | ||
| 602 | #endif | ||
| 603 | |||
| 604 | printk("weird %s access at %#lx from pc %#lx (ssw is %#x)\n", | ||
| 605 | !(ssw & RW) ? "write" : "read", addr, | ||
| 606 | fp->ptregs.pc, ssw); | ||
| 607 | asm volatile ("ptestr #1,%1@,#0\n\t" | ||
| 608 | "pmove %%psr,%0@" | ||
| 609 | : /* no outputs */ | ||
| 610 | : "a" (&temp), "a" (addr)); | ||
| 611 | mmusr = temp; | ||
| 612 | |||
| 613 | printk ("level 0 mmusr is %#x\n", mmusr); | ||
| 614 | #if 0 | ||
| 615 | asm volatile ("pmove %%tt0,%0@" | ||
| 616 | : /* no outputs */ | ||
| 617 | : "a" (&tlong)); | ||
| 618 | printk("tt0 is %#lx, ", tlong); | ||
| 619 | asm volatile ("pmove %%tt1,%0@" | ||
| 620 | : /* no outputs */ | ||
| 621 | : "a" (&tlong)); | ||
| 622 | printk("tt1 is %#lx\n", tlong); | ||
| 623 | #endif | ||
| 624 | #ifdef DEBUG | ||
| 625 | printk("Unknown SIGSEGV - 1\n"); | ||
| 626 | #endif | ||
| 627 | die_if_kernel("Oops",&fp->ptregs,mmusr); | ||
| 628 | force_sig(SIGSEGV, current); | ||
| 629 | return; | ||
| 630 | } | ||
| 631 | |||
| 632 | /* setup an ATC entry for the access about to be retried */ | ||
| 633 | if (!(ssw & RW) || (ssw & RM)) | ||
| 634 | asm volatile ("ploadw %1,%0@" : /* no outputs */ | ||
| 635 | : "a" (addr), "d" (ssw)); | ||
| 636 | else | ||
| 637 | asm volatile ("ploadr %1,%0@" : /* no outputs */ | ||
| 638 | : "a" (addr), "d" (ssw)); | ||
| 639 | } | ||
| 640 | |||
| 641 | /* Now handle the instruction fault. */ | ||
| 642 | |||
| 643 | if (!(ssw & (FC|FB))) | ||
| 644 | return; | ||
| 645 | |||
| 646 | if (fp->ptregs.sr & PS_S) { | ||
| 647 | printk("Instruction fault at %#010lx\n", | ||
| 648 | fp->ptregs.pc); | ||
| 649 | buserr: | ||
| 650 | printk ("BAD KERNEL BUSERR\n"); | ||
| 651 | die_if_kernel("Oops",&fp->ptregs,0); | ||
| 652 | force_sig(SIGKILL, current); | ||
| 653 | return; | ||
| 654 | } | ||
| 655 | |||
| 656 | /* get the fault address */ | ||
| 657 | if (fp->ptregs.format == 10) | ||
| 658 | addr = fp->ptregs.pc + 4; | ||
| 659 | else | ||
| 660 | addr = fp->un.fmtb.baddr; | ||
| 661 | if (ssw & FC) | ||
| 662 | addr -= 2; | ||
| 663 | |||
| 664 | if ((ssw & DF) && ((addr ^ fp->un.fmtb.daddr) & PAGE_MASK) == 0) | ||
| 665 | /* Insn fault on same page as data fault. But we | ||
| 666 | should still create the ATC entry. */ | ||
| 667 | goto create_atc_entry; | ||
| 668 | |||
| 669 | #ifdef DEBUG | ||
| 670 | asm volatile ("ptestr #1,%2@,#7,%0\n\t" | ||
| 671 | "pmove %%psr,%1@" | ||
| 672 | : "=a&" (desc) | ||
| 673 | : "a" (&temp), "a" (addr)); | ||
| 674 | #else | ||
| 675 | asm volatile ("ptestr #1,%1@,#7\n\t" | ||
| 676 | "pmove %%psr,%0@" | ||
| 677 | : : "a" (&temp), "a" (addr)); | ||
| 678 | #endif | ||
| 679 | mmusr = temp; | ||
| 680 | |||
| 681 | #ifdef DEBUG | ||
| 682 | printk ("mmusr is %#x for addr %#lx in task %p\n", | ||
| 683 | mmusr, addr, current); | ||
| 684 | printk ("descriptor address is %#lx, contents %#lx\n", | ||
| 685 | __va(desc), *(unsigned long *)__va(desc)); | ||
| 686 | #endif | ||
| 687 | |||
| 688 | if (mmusr & MMU_I) | ||
| 689 | do_page_fault (&fp->ptregs, addr, 0); | ||
| 690 | else if (mmusr & (MMU_B|MMU_L|MMU_S)) { | ||
| 691 | printk ("invalid insn access at %#lx from pc %#lx\n", | ||
| 692 | addr, fp->ptregs.pc); | ||
| 693 | #ifdef DEBUG | ||
| 694 | printk("Unknown SIGSEGV - 2\n"); | ||
| 695 | #endif | ||
| 696 | die_if_kernel("Oops",&fp->ptregs,mmusr); | ||
| 697 | force_sig(SIGSEGV, current); | ||
| 698 | return; | ||
| 699 | } | ||
| 700 | |||
| 701 | create_atc_entry: | ||
| 702 | /* setup an ATC entry for the access about to be retried */ | ||
| 703 | asm volatile ("ploadr #2,%0@" : /* no outputs */ | ||
| 704 | : "a" (addr)); | ||
| 705 | } | ||
| 706 | #endif /* CPU_M68020_OR_M68030 */ | ||
| 707 | #endif /* !CONFIG_SUN3 */ | ||
| 708 | |||
| 709 | asmlinkage void buserr_c(struct frame *fp) | ||
| 710 | { | ||
| 711 | /* Only set esp0 if coming from user mode */ | ||
| 712 | if (user_mode(&fp->ptregs)) | ||
| 713 | current->thread.esp0 = (unsigned long) fp; | ||
| 714 | |||
| 715 | #ifdef DEBUG | ||
| 716 | printk ("*** Bus Error *** Format is %x\n", fp->ptregs.format); | ||
| 717 | #endif | ||
| 718 | |||
| 719 | switch (fp->ptregs.format) { | ||
| 720 | #if defined (CONFIG_M68060) | ||
| 721 | case 4: /* 68060 access error */ | ||
| 722 | access_error060 (fp); | ||
| 723 | break; | ||
| 724 | #endif | ||
| 725 | #if defined (CONFIG_M68040) | ||
| 726 | case 0x7: /* 68040 access error */ | ||
| 727 | access_error040 (fp); | ||
| 728 | break; | ||
| 729 | #endif | ||
| 730 | #if defined (CPU_M68020_OR_M68030) | ||
| 731 | case 0xa: | ||
| 732 | case 0xb: | ||
| 733 | bus_error030 (fp); | ||
| 734 | break; | ||
| 735 | #endif | ||
| 736 | default: | ||
| 737 | die_if_kernel("bad frame format",&fp->ptregs,0); | ||
| 738 | #ifdef DEBUG | ||
| 739 | printk("Unknown SIGSEGV - 4\n"); | ||
| 740 | #endif | ||
| 741 | force_sig(SIGSEGV, current); | ||
| 742 | } | ||
| 743 | } | ||
| 744 | |||
| 745 | |||
| 746 | static int kstack_depth_to_print = 48; | ||
| 747 | |||
| 748 | void show_trace(unsigned long *stack) | ||
| 749 | { | ||
| 750 | unsigned long *endstack; | ||
| 751 | unsigned long addr; | ||
| 752 | int i; | ||
| 753 | |||
| 754 | printk("Call Trace:"); | ||
| 755 | addr = (unsigned long)stack + THREAD_SIZE - 1; | ||
| 756 | endstack = (unsigned long *)(addr & -THREAD_SIZE); | ||
| 757 | i = 0; | ||
| 758 | while (stack + 1 <= endstack) { | ||
| 759 | addr = *stack++; | ||
| 760 | /* | ||
| 761 | * If the address is either in the text segment of the | ||
| 762 | * kernel, or in the region which contains vmalloc'ed | ||
| 763 | * memory, it *may* be the address of a calling | ||
| 764 | * routine; if so, print it so that someone tracing | ||
| 765 | * down the cause of the crash will be able to figure | ||
| 766 | * out the call path that was taken. | ||
| 767 | */ | ||
| 768 | if (__kernel_text_address(addr)) { | ||
| 769 | #ifndef CONFIG_KALLSYMS | ||
| 770 | if (i % 5 == 0) | ||
| 771 | printk("\n "); | ||
| 772 | #endif | ||
| 773 | printk(" [<%08lx>] %pS\n", addr, (void *)addr); | ||
| 774 | i++; | ||
| 775 | } | ||
| 776 | } | ||
| 777 | printk("\n"); | ||
| 778 | } | ||
| 779 | |||
| 780 | void show_registers(struct pt_regs *regs) | ||
| 781 | { | ||
| 782 | struct frame *fp = (struct frame *)regs; | ||
| 783 | mm_segment_t old_fs = get_fs(); | ||
| 784 | u16 c, *cp; | ||
| 785 | unsigned long addr; | ||
| 786 | int i; | ||
| 787 | |||
| 788 | print_modules(); | ||
| 789 | printk("PC: [<%08lx>] %pS\n", regs->pc, (void *)regs->pc); | ||
| 790 | printk("SR: %04x SP: %p a2: %08lx\n", regs->sr, regs, regs->a2); | ||
| 791 | printk("d0: %08lx d1: %08lx d2: %08lx d3: %08lx\n", | ||
| 792 | regs->d0, regs->d1, regs->d2, regs->d3); | ||
| 793 | printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n", | ||
| 794 | regs->d4, regs->d5, regs->a0, regs->a1); | ||
| 795 | |||
| 796 | printk("Process %s (pid: %d, task=%p)\n", | ||
| 797 | current->comm, task_pid_nr(current), current); | ||
| 798 | addr = (unsigned long)&fp->un; | ||
| 799 | printk("Frame format=%X ", regs->format); | ||
| 800 | switch (regs->format) { | ||
| 801 | case 0x2: | ||
| 802 | printk("instr addr=%08lx\n", fp->un.fmt2.iaddr); | ||
| 803 | addr += sizeof(fp->un.fmt2); | ||
| 804 | break; | ||
| 805 | case 0x3: | ||
| 806 | printk("eff addr=%08lx\n", fp->un.fmt3.effaddr); | ||
| 807 | addr += sizeof(fp->un.fmt3); | ||
| 808 | break; | ||
| 809 | case 0x4: | ||
| 810 | printk((CPU_IS_060 ? "fault addr=%08lx fslw=%08lx\n" | ||
| 811 | : "eff addr=%08lx pc=%08lx\n"), | ||
| 812 | fp->un.fmt4.effaddr, fp->un.fmt4.pc); | ||
| 813 | addr += sizeof(fp->un.fmt4); | ||
| 814 | break; | ||
| 815 | case 0x7: | ||
| 816 | printk("eff addr=%08lx ssw=%04x faddr=%08lx\n", | ||
| 817 | fp->un.fmt7.effaddr, fp->un.fmt7.ssw, fp->un.fmt7.faddr); | ||
| 818 | printk("wb 1 stat/addr/data: %04x %08lx %08lx\n", | ||
| 819 | fp->un.fmt7.wb1s, fp->un.fmt7.wb1a, fp->un.fmt7.wb1dpd0); | ||
| 820 | printk("wb 2 stat/addr/data: %04x %08lx %08lx\n", | ||
| 821 | fp->un.fmt7.wb2s, fp->un.fmt7.wb2a, fp->un.fmt7.wb2d); | ||
| 822 | printk("wb 3 stat/addr/data: %04x %08lx %08lx\n", | ||
| 823 | fp->un.fmt7.wb3s, fp->un.fmt7.wb3a, fp->un.fmt7.wb3d); | ||
| 824 | printk("push data: %08lx %08lx %08lx %08lx\n", | ||
| 825 | fp->un.fmt7.wb1dpd0, fp->un.fmt7.pd1, fp->un.fmt7.pd2, | ||
| 826 | fp->un.fmt7.pd3); | ||
| 827 | addr += sizeof(fp->un.fmt7); | ||
| 828 | break; | ||
| 829 | case 0x9: | ||
| 830 | printk("instr addr=%08lx\n", fp->un.fmt9.iaddr); | ||
| 831 | addr += sizeof(fp->un.fmt9); | ||
| 832 | break; | ||
| 833 | case 0xa: | ||
| 834 | printk("ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n", | ||
| 835 | fp->un.fmta.ssw, fp->un.fmta.isc, fp->un.fmta.isb, | ||
| 836 | fp->un.fmta.daddr, fp->un.fmta.dobuf); | ||
| 837 | addr += sizeof(fp->un.fmta); | ||
| 838 | break; | ||
| 839 | case 0xb: | ||
| 840 | printk("ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n", | ||
| 841 | fp->un.fmtb.ssw, fp->un.fmtb.isc, fp->un.fmtb.isb, | ||
| 842 | fp->un.fmtb.daddr, fp->un.fmtb.dobuf); | ||
| 843 | printk("baddr=%08lx dibuf=%08lx ver=%x\n", | ||
| 844 | fp->un.fmtb.baddr, fp->un.fmtb.dibuf, fp->un.fmtb.ver); | ||
| 845 | addr += sizeof(fp->un.fmtb); | ||
| 846 | break; | ||
| 847 | default: | ||
| 848 | printk("\n"); | ||
| 849 | } | ||
| 850 | show_stack(NULL, (unsigned long *)addr); | ||
| 851 | |||
| 852 | printk("Code:"); | ||
| 853 | set_fs(KERNEL_DS); | ||
| 854 | cp = (u16 *)regs->pc; | ||
| 855 | for (i = -8; i < 16; i++) { | ||
| 856 | if (get_user(c, cp + i) && i >= 0) { | ||
| 857 | printk(" Bad PC value."); | ||
| 858 | break; | ||
| 859 | } | ||
| 860 | printk(i ? " %04x" : " <%04x>", c); | ||
| 861 | } | ||
| 862 | set_fs(old_fs); | ||
| 863 | printk ("\n"); | ||
| 864 | } | ||
| 865 | |||
| 866 | void show_stack(struct task_struct *task, unsigned long *stack) | ||
| 867 | { | ||
| 868 | unsigned long *p; | ||
| 869 | unsigned long *endstack; | ||
| 870 | int i; | ||
| 871 | |||
| 872 | if (!stack) { | ||
| 873 | if (task) | ||
| 874 | stack = (unsigned long *)task->thread.esp0; | ||
| 875 | else | ||
| 876 | stack = (unsigned long *)&stack; | ||
| 877 | } | ||
| 878 | endstack = (unsigned long *)(((unsigned long)stack + THREAD_SIZE - 1) & -THREAD_SIZE); | ||
| 879 | |||
| 880 | printk("Stack from %08lx:", (unsigned long)stack); | ||
| 881 | p = stack; | ||
| 882 | for (i = 0; i < kstack_depth_to_print; i++) { | ||
| 883 | if (p + 1 > endstack) | ||
| 884 | break; | ||
| 885 | if (i % 8 == 0) | ||
| 886 | printk("\n "); | ||
| 887 | printk(" %08lx", *p++); | ||
| 888 | } | ||
| 889 | printk("\n"); | ||
| 890 | show_trace(stack); | ||
| 891 | } | ||
| 892 | |||
| 893 | /* | ||
| 894 | * The architecture-independent backtrace generator | ||
| 895 | */ | ||
| 896 | void dump_stack(void) | ||
| 897 | { | ||
| 898 | unsigned long stack; | ||
| 899 | |||
| 900 | show_trace(&stack); | ||
| 901 | } | ||
| 902 | |||
| 903 | EXPORT_SYMBOL(dump_stack); | ||
| 904 | |||
| 905 | /* | ||
| 906 | * The vector number returned in the frame pointer may also contain | ||
| 907 | * the "fs" (Fault Status) bits on ColdFire. These are in the bottom | ||
| 908 | * 2 bits, and upper 2 bits. So we need to mask out the real vector | ||
| 909 | * number before using it in comparisons. You don't need to do this on | ||
| 910 | * real 68k parts, but it won't hurt either. | ||
| 911 | */ | ||
| 912 | |||
| 913 | void bad_super_trap (struct frame *fp) | ||
| 914 | { | ||
| 915 | int vector = (fp->ptregs.vector >> 2) & 0xff; | ||
| 916 | |||
| 917 | console_verbose(); | ||
| 918 | if (vector < ARRAY_SIZE(vec_names)) | ||
| 919 | printk ("*** %s *** FORMAT=%X\n", | ||
| 920 | vec_names[vector], | ||
| 921 | fp->ptregs.format); | ||
| 922 | else | ||
| 923 | printk ("*** Exception %d *** FORMAT=%X\n", | ||
| 924 | vector, fp->ptregs.format); | ||
| 925 | if (vector == VEC_ADDRERR && CPU_IS_020_OR_030) { | ||
| 926 | unsigned short ssw = fp->un.fmtb.ssw; | ||
| 927 | |||
| 928 | printk ("SSW=%#06x ", ssw); | ||
| 929 | |||
| 930 | if (ssw & RC) | ||
| 931 | printk ("Pipe stage C instruction fault at %#010lx\n", | ||
| 932 | (fp->ptregs.format) == 0xA ? | ||
| 933 | fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2); | ||
| 934 | if (ssw & RB) | ||
| 935 | printk ("Pipe stage B instruction fault at %#010lx\n", | ||
| 936 | (fp->ptregs.format) == 0xA ? | ||
| 937 | fp->ptregs.pc + 4 : fp->un.fmtb.baddr); | ||
| 938 | if (ssw & DF) | ||
| 939 | printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n", | ||
| 940 | ssw & RW ? "read" : "write", | ||
| 941 | fp->un.fmtb.daddr, space_names[ssw & DFC], | ||
| 942 | fp->ptregs.pc); | ||
| 943 | } | ||
| 944 | printk ("Current process id is %d\n", task_pid_nr(current)); | ||
| 945 | die_if_kernel("BAD KERNEL TRAP", &fp->ptregs, 0); | ||
| 946 | } | ||
| 947 | |||
| 948 | asmlinkage void trap_c(struct frame *fp) | ||
| 949 | { | ||
| 950 | int sig; | ||
| 951 | int vector = (fp->ptregs.vector >> 2) & 0xff; | ||
| 952 | siginfo_t info; | ||
| 953 | |||
| 954 | if (fp->ptregs.sr & PS_S) { | ||
| 955 | if (vector == VEC_TRACE) { | ||
| 956 | /* traced a trapping instruction on a 68020/30, | ||
| 957 | * real exception will be executed afterwards. | ||
| 958 | */ | ||
| 959 | } else if (!handle_kernel_fault(&fp->ptregs)) | ||
| 960 | bad_super_trap(fp); | ||
| 961 | return; | ||
| 962 | } | ||
| 963 | |||
| 964 | /* send the appropriate signal to the user program */ | ||
| 965 | switch (vector) { | ||
| 966 | case VEC_ADDRERR: | ||
| 967 | info.si_code = BUS_ADRALN; | ||
| 968 | sig = SIGBUS; | ||
| 969 | break; | ||
| 970 | case VEC_ILLEGAL: | ||
| 971 | case VEC_LINE10: | ||
| 972 | case VEC_LINE11: | ||
| 973 | info.si_code = ILL_ILLOPC; | ||
| 974 | sig = SIGILL; | ||
| 975 | break; | ||
| 976 | case VEC_PRIV: | ||
| 977 | info.si_code = ILL_PRVOPC; | ||
| 978 | sig = SIGILL; | ||
| 979 | break; | ||
| 980 | case VEC_COPROC: | ||
| 981 | info.si_code = ILL_COPROC; | ||
| 982 | sig = SIGILL; | ||
| 983 | break; | ||
| 984 | case VEC_TRAP1: | ||
| 985 | case VEC_TRAP2: | ||
| 986 | case VEC_TRAP3: | ||
| 987 | case VEC_TRAP4: | ||
| 988 | case VEC_TRAP5: | ||
| 989 | case VEC_TRAP6: | ||
| 990 | case VEC_TRAP7: | ||
| 991 | case VEC_TRAP8: | ||
| 992 | case VEC_TRAP9: | ||
| 993 | case VEC_TRAP10: | ||
| 994 | case VEC_TRAP11: | ||
| 995 | case VEC_TRAP12: | ||
| 996 | case VEC_TRAP13: | ||
| 997 | case VEC_TRAP14: | ||
| 998 | info.si_code = ILL_ILLTRP; | ||
| 999 | sig = SIGILL; | ||
| 1000 | break; | ||
| 1001 | case VEC_FPBRUC: | ||
| 1002 | case VEC_FPOE: | ||
| 1003 | case VEC_FPNAN: | ||
| 1004 | info.si_code = FPE_FLTINV; | ||
| 1005 | sig = SIGFPE; | ||
| 1006 | break; | ||
| 1007 | case VEC_FPIR: | ||
| 1008 | info.si_code = FPE_FLTRES; | ||
| 1009 | sig = SIGFPE; | ||
| 1010 | break; | ||
| 1011 | case VEC_FPDIVZ: | ||
| 1012 | info.si_code = FPE_FLTDIV; | ||
| 1013 | sig = SIGFPE; | ||
| 1014 | break; | ||
| 1015 | case VEC_FPUNDER: | ||
| 1016 | info.si_code = FPE_FLTUND; | ||
| 1017 | sig = SIGFPE; | ||
| 1018 | break; | ||
| 1019 | case VEC_FPOVER: | ||
| 1020 | info.si_code = FPE_FLTOVF; | ||
| 1021 | sig = SIGFPE; | ||
| 1022 | break; | ||
| 1023 | case VEC_ZERODIV: | ||
| 1024 | info.si_code = FPE_INTDIV; | ||
| 1025 | sig = SIGFPE; | ||
| 1026 | break; | ||
| 1027 | case VEC_CHK: | ||
| 1028 | case VEC_TRAP: | ||
| 1029 | info.si_code = FPE_INTOVF; | ||
| 1030 | sig = SIGFPE; | ||
| 1031 | break; | ||
| 1032 | case VEC_TRACE: /* ptrace single step */ | ||
| 1033 | info.si_code = TRAP_TRACE; | ||
| 1034 | sig = SIGTRAP; | ||
| 1035 | break; | ||
| 1036 | case VEC_TRAP15: /* breakpoint */ | ||
| 1037 | info.si_code = TRAP_BRKPT; | ||
| 1038 | sig = SIGTRAP; | ||
| 1039 | break; | ||
| 1040 | default: | ||
| 1041 | info.si_code = ILL_ILLOPC; | ||
| 1042 | sig = SIGILL; | ||
| 1043 | break; | ||
| 1044 | } | ||
| 1045 | info.si_signo = sig; | ||
| 1046 | info.si_errno = 0; | ||
| 1047 | switch (fp->ptregs.format) { | ||
| 1048 | default: | ||
| 1049 | info.si_addr = (void *) fp->ptregs.pc; | ||
| 1050 | break; | ||
| 1051 | case 2: | ||
| 1052 | info.si_addr = (void *) fp->un.fmt2.iaddr; | ||
| 1053 | break; | ||
| 1054 | case 7: | ||
| 1055 | info.si_addr = (void *) fp->un.fmt7.effaddr; | ||
| 1056 | break; | ||
| 1057 | case 9: | ||
| 1058 | info.si_addr = (void *) fp->un.fmt9.iaddr; | ||
| 1059 | break; | ||
| 1060 | case 10: | ||
| 1061 | info.si_addr = (void *) fp->un.fmta.daddr; | ||
| 1062 | break; | ||
| 1063 | case 11: | ||
| 1064 | info.si_addr = (void *) fp->un.fmtb.daddr; | ||
| 1065 | break; | ||
| 1066 | } | ||
| 1067 | force_sig_info (sig, &info, current); | ||
| 1068 | } | ||
| 1069 | |||
| 1070 | void die_if_kernel (char *str, struct pt_regs *fp, int nr) | ||
| 1071 | { | ||
| 1072 | if (!(fp->sr & PS_S)) | ||
| 1073 | return; | ||
| 1074 | |||
| 1075 | console_verbose(); | ||
| 1076 | printk("%s: %08x\n",str,nr); | ||
| 1077 | show_registers(fp); | ||
| 1078 | add_taint(TAINT_DIE); | ||
| 1079 | do_exit(SIGSEGV); | ||
| 1080 | } | ||
| 1081 | |||
| 1082 | asmlinkage void set_esp0(unsigned long ssp) | ||
| 1083 | { | ||
| 1084 | current->thread.esp0 = ssp; | ||
| 1085 | } | ||
| 1086 | |||
| 1087 | /* | ||
| 1088 | * This function is called if an error occur while accessing | ||
| 1089 | * user-space from the fpsp040 code. | ||
| 1090 | */ | ||
| 1091 | asmlinkage void fpsp040_die(void) | ||
| 1092 | { | ||
| 1093 | do_exit(SIGSEGV); | ||
| 1094 | } | ||
| 1095 | |||
| 1096 | #ifdef CONFIG_M68KFPU_EMU | ||
| 1097 | asmlinkage void fpemu_signal(int signal, int code, void *addr) | ||
| 1098 | { | ||
| 1099 | siginfo_t info; | ||
| 1100 | |||
| 1101 | info.si_signo = signal; | ||
| 1102 | info.si_errno = 0; | ||
| 1103 | info.si_code = code; | ||
| 1104 | info.si_addr = addr; | ||
| 1105 | force_sig_info(signal, &info, current); | ||
| 1106 | } | ||
| 5 | #endif | 1107 | #endif |
diff --git a/arch/m68k/kernel/traps_mm.c b/arch/m68k/kernel/traps_mm.c deleted file mode 100644 index 4022bbc28878..000000000000 --- a/arch/m68k/kernel/traps_mm.c +++ /dev/null | |||
| @@ -1,1207 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * linux/arch/m68k/kernel/traps.c | ||
| 3 | * | ||
| 4 | * Copyright (C) 1993, 1994 by Hamish Macdonald | ||
| 5 | * | ||
| 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 | ||
| 11 | * | ||
| 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 | ||
| 14 | * for more details. | ||
| 15 | */ | ||
| 16 | |||
| 17 | /* | ||
| 18 | * Sets up all exception vectors | ||
| 19 | */ | ||
| 20 | |||
| 21 | #include <linux/sched.h> | ||
| 22 | #include <linux/signal.h> | ||
| 23 | #include <linux/kernel.h> | ||
| 24 | #include <linux/mm.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> | ||
| 32 | |||
| 33 | #include <asm/setup.h> | ||
| 34 | #include <asm/fpu.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> | ||
| 41 | |||
| 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); | ||
| 49 | #endif | ||
| 50 | |||
| 51 | e_vector vectors[256]; | ||
| 52 | |||
| 53 | /* nmi handler for the Amiga */ | ||
| 54 | asm(".text\n" | ||
| 55 | __ALIGN_STR "\n" | ||
| 56 | "nmihandler: rte"); | ||
| 57 | |||
| 58 | /* | ||
| 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). | ||
| 62 | */ | ||
| 63 | void __init base_trap_init(void) | ||
| 64 | { | ||
| 65 | if (MACH_IS_SUN3X) { | ||
| 66 | extern e_vector *sun3x_prom_vbr; | ||
| 67 | |||
| 68 | __asm__ volatile ("movec %%vbr, %0" : "=r" (sun3x_prom_vbr)); | ||
| 69 | } | ||
| 70 | |||
| 71 | /* setup the exception vector table */ | ||
| 72 | __asm__ volatile ("movec %0,%%vbr" : : "r" ((void*)vectors)); | ||
| 73 | |||
| 74 | if (CPU_IS_060) { | ||
| 75 | /* set up ISP entry points */ | ||
| 76 | asmlinkage void unimp_vec(void) asm ("_060_isp_unimp"); | ||
| 77 | |||
| 78 | vectors[VEC_UNIMPII] = unimp_vec; | ||
| 79 | } | ||
| 80 | |||
| 81 | vectors[VEC_BUSERR] = buserr; | ||
| 82 | vectors[VEC_ILLEGAL] = trap; | ||
| 83 | vectors[VEC_SYS] = system_call; | ||
| 84 | } | ||
| 85 | |||
| 86 | void __init trap_init (void) | ||
| 87 | { | ||
| 88 | int i; | ||
| 89 | |||
| 90 | for (i = VEC_SPUR; i <= VEC_INT7; i++) | ||
| 91 | vectors[i] = bad_inthandler; | ||
| 92 | |||
| 93 | for (i = 0; i < VEC_USER; i++) | ||
| 94 | if (!vectors[i]) | ||
| 95 | vectors[i] = trap; | ||
| 96 | |||
| 97 | for (i = VEC_USER; i < 256; i++) | ||
| 98 | vectors[i] = bad_inthandler; | ||
| 99 | |||
| 100 | #ifdef CONFIG_M68KFPU_EMU | ||
| 101 | if (FPU_IS_EMU) | ||
| 102 | vectors[VEC_LINE11] = fpu_emu; | ||
| 103 | #endif | ||
| 104 | |||
| 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"); | ||
| 116 | |||
| 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; | ||
| 126 | } | ||
| 127 | |||
| 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"); | ||
| 139 | |||
| 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; | ||
| 149 | } | ||
| 150 | |||
| 151 | /* if running on an amiga, make the NMI interrupt do nothing */ | ||
| 152 | if (MACH_IS_AMIGA) { | ||
| 153 | vectors[VEC_INT7] = nmihandler; | ||
| 154 | } | ||
| 155 | } | ||
| 156 | |||
| 157 | |||
| 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", | ||
| 165 | [VEC_CHK] = "CHK", | ||
| 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", | ||
| 223 | }; | ||
| 224 | |||
| 225 | static const char *space_names[] = { | ||
| 226 | [0] = "Space 0", | ||
| 227 | [USER_DATA] = "User Data", | ||
| 228 | [USER_PROGRAM] = "User Program", | ||
| 229 | #ifndef CONFIG_SUN3 | ||
| 230 | [3] = "Space 3", | ||
| 231 | #else | ||
| 232 | [FC_CONTROL] = "Control", | ||
| 233 | #endif | ||
| 234 | [4] = "Space 4", | ||
| 235 | [SUPER_DATA] = "Super Data", | ||
| 236 | [SUPER_PROGRAM] = "Super Program", | ||
| 237 | [CPU_SPACE] = "CPU" | ||
| 238 | }; | ||
| 239 | |||
| 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); | ||
| 244 | |||
| 245 | asmlinkage void trap_c(struct frame *fp); | ||
| 246 | |||
| 247 | #if defined (CONFIG_M68060) | ||
| 248 | static inline void access_error060 (struct frame *fp) | ||
| 249 | { | ||
| 250 | unsigned long fslw = fp->un.fmt4.pc; /* is really FSLW for access error */ | ||
| 251 | |||
| 252 | #ifdef DEBUG | ||
| 253 | printk("fslw=%#lx, fa=%#lx\n", fslw, fp->un.fmt4.effaddr); | ||
| 254 | #endif | ||
| 255 | |||
| 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" | ||
| 260 | "movec %/d0,%/cacr" | ||
| 261 | : : : "d0" ); | ||
| 262 | /* return if there's no other error */ | ||
| 263 | if (!(fslw & MMU060_ERR_BITS) && !(fslw & MMU060_SEE)) | ||
| 264 | return; | ||
| 265 | } | ||
| 266 | |||
| 267 | if (fslw & (MMU060_DESC_ERR | MMU060_WP | MMU060_SP)) { | ||
| 268 | unsigned long errorcode; | ||
| 269 | unsigned long addr = fp->un.fmt4.effaddr; | ||
| 270 | |||
| 271 | if (fslw & MMU060_MA) | ||
| 272 | addr = (addr + PAGE_SIZE - 1) & PAGE_MASK; | ||
| 273 | |||
| 274 | errorcode = 1; | ||
| 275 | if (fslw & MMU060_DESC_ERR) { | ||
| 276 | __flush_tlb040_one(addr); | ||
| 277 | errorcode = 0; | ||
| 278 | } | ||
| 279 | if (fslw & MMU060_W) | ||
| 280 | errorcode |= 2; | ||
| 281 | #ifdef DEBUG | ||
| 282 | printk("errorcode = %d\n", errorcode ); | ||
| 283 | #endif | ||
| 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 | ||
| 288 | */ | ||
| 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 ); | ||
| 294 | trap_c( fp ); | ||
| 295 | } | ||
| 296 | } | ||
| 297 | #endif /* CONFIG_M68060 */ | ||
| 298 | |||
| 299 | #if defined (CONFIG_M68040) | ||
| 300 | static inline unsigned long probe040(int iswrite, unsigned long addr, int wbs) | ||
| 301 | { | ||
| 302 | unsigned long mmusr; | ||
| 303 | mm_segment_t old_fs = get_fs(); | ||
| 304 | |||
| 305 | set_fs(MAKE_MM_SEG(wbs)); | ||
| 306 | |||
| 307 | if (iswrite) | ||
| 308 | asm volatile (".chip 68040; ptestw (%0); .chip 68k" : : "a" (addr)); | ||
| 309 | else | ||
| 310 | asm volatile (".chip 68040; ptestr (%0); .chip 68k" : : "a" (addr)); | ||
| 311 | |||
| 312 | asm volatile (".chip 68040; movec %%mmusr,%0; .chip 68k" : "=r" (mmusr)); | ||
| 313 | |||
| 314 | set_fs(old_fs); | ||
| 315 | |||
| 316 | return mmusr; | ||
| 317 | } | ||
| 318 | |||
| 319 | static inline int do_040writeback1(unsigned short wbs, unsigned long wba, | ||
| 320 | unsigned long wbd) | ||
| 321 | { | ||
| 322 | int res = 0; | ||
| 323 | mm_segment_t old_fs = get_fs(); | ||
| 324 | |||
| 325 | /* set_fs can not be moved, otherwise put_user() may oops */ | ||
| 326 | set_fs(MAKE_MM_SEG(wbs)); | ||
| 327 | |||
| 328 | switch (wbs & WBSIZ_040) { | ||
| 329 | case BA_SIZE_BYTE: | ||
| 330 | res = put_user(wbd & 0xff, (char __user *)wba); | ||
| 331 | break; | ||
| 332 | case BA_SIZE_WORD: | ||
| 333 | res = put_user(wbd & 0xffff, (short __user *)wba); | ||
| 334 | break; | ||
| 335 | case BA_SIZE_LONG: | ||
| 336 | res = put_user(wbd, (int __user *)wba); | ||
| 337 | break; | ||
| 338 | } | ||
| 339 | |||
| 340 | /* set_fs can not be moved, otherwise put_user() may oops */ | ||
| 341 | set_fs(old_fs); | ||
| 342 | |||
| 343 | |||
| 344 | #ifdef DEBUG | ||
| 345 | printk("do_040writeback1, res=%d\n",res); | ||
| 346 | #endif | ||
| 347 | |||
| 348 | return res; | ||
| 349 | } | ||
| 350 | |||
| 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 | ||
| 354 | */ | ||
| 355 | static inline void fix_xframe040(struct frame *fp, unsigned long wba, unsigned short wbs) | ||
| 356 | { | ||
| 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; | ||
| 361 | } | ||
| 362 | |||
| 363 | static inline void do_040writebacks(struct frame *fp) | ||
| 364 | { | ||
| 365 | int res = 0; | ||
| 366 | #if 0 | ||
| 367 | if (fp->un.fmt7.wb1s & WBV_040) | ||
| 368 | printk("access_error040: cannot handle 1st writeback. oops.\n"); | ||
| 369 | #endif | ||
| 370 | |||
| 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, | ||
| 374 | fp->un.fmt7.wb2d); | ||
| 375 | if (res) | ||
| 376 | fix_xframe040(fp, fp->un.fmt7.wb2a, fp->un.fmt7.wb2s); | ||
| 377 | else | ||
| 378 | fp->un.fmt7.wb2s = 0; | ||
| 379 | } | ||
| 380 | |||
| 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, | ||
| 384 | fp->un.fmt7.wb3d); | ||
| 385 | if (res) | ||
| 386 | { | ||
| 387 | fix_xframe040(fp, fp->un.fmt7.wb3a, fp->un.fmt7.wb3s); | ||
| 388 | |||
| 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; | ||
| 393 | } | ||
| 394 | else | ||
| 395 | fp->un.fmt7.wb3s = 0; | ||
| 396 | } | ||
| 397 | |||
| 398 | if (res) | ||
| 399 | send_fault_sig(&fp->ptregs); | ||
| 400 | } | ||
| 401 | |||
| 402 | /* | ||
| 403 | * called from sigreturn(), must ensure userspace code didn't | ||
| 404 | * manipulate exception frame to circumvent protection, then complete | ||
| 405 | * pending writebacks | ||
| 406 | * we just clear TM2 to turn it into a userspace access | ||
| 407 | */ | ||
| 408 | asmlinkage void berr_040cleanup(struct frame *fp) | ||
| 409 | { | ||
| 410 | fp->un.fmt7.wb2s &= ~4; | ||
| 411 | fp->un.fmt7.wb3s &= ~4; | ||
| 412 | |||
| 413 | do_040writebacks(fp); | ||
| 414 | } | ||
| 415 | |||
| 416 | static inline void access_error040(struct frame *fp) | ||
| 417 | { | ||
| 418 | unsigned short ssw = fp->un.fmt7.ssw; | ||
| 419 | unsigned long mmusr; | ||
| 420 | |||
| 421 | #ifdef DEBUG | ||
| 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); | ||
| 428 | #endif | ||
| 429 | |||
| 430 | if (ssw & ATC_040) { | ||
| 431 | unsigned long addr = fp->un.fmt7.faddr; | ||
| 432 | unsigned long errorcode; | ||
| 433 | |||
| 434 | /* | ||
| 435 | * The MMU status has to be determined AFTER the address | ||
| 436 | * has been corrected if there was a misaligned access (MA). | ||
| 437 | */ | ||
| 438 | if (ssw & MA_040) | ||
| 439 | addr = (addr + 7) & -8; | ||
| 440 | |||
| 441 | /* MMU error, get the MMUSR info for this access */ | ||
| 442 | mmusr = probe040(!(ssw & RW_040), addr, ssw); | ||
| 443 | #ifdef DEBUG | ||
| 444 | printk("mmusr = %lx\n", mmusr); | ||
| 445 | #endif | ||
| 446 | errorcode = 1; | ||
| 447 | if (!(mmusr & MMU_R_040)) { | ||
| 448 | /* clear the invalid atc entry */ | ||
| 449 | __flush_tlb040_one(addr); | ||
| 450 | errorcode = 0; | ||
| 451 | } | ||
| 452 | |||
| 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)) | ||
| 456 | errorcode |= 2; | ||
| 457 | |||
| 458 | if (do_page_fault(&fp->ptregs, addr, errorcode)) { | ||
| 459 | #ifdef DEBUG | ||
| 460 | printk("do_page_fault() !=0\n"); | ||
| 461 | #endif | ||
| 462 | if (user_mode(&fp->ptregs)){ | ||
| 463 | /* delay writebacks after signal delivery */ | ||
| 464 | #ifdef DEBUG | ||
| 465 | printk(".. was usermode - return\n"); | ||
| 466 | #endif | ||
| 467 | return; | ||
| 468 | } | ||
| 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) | ||
| 472 | */ | ||
| 473 | disable_wb: | ||
| 474 | #ifdef DEBUG | ||
| 475 | printk(".. disabling wb2\n"); | ||
| 476 | #endif | ||
| 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; | ||
| 481 | } | ||
| 482 | } else { | ||
| 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. | ||
| 486 | */ | ||
| 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, | ||
| 491 | fp->un.fmt7.faddr); | ||
| 492 | goto disable_wb; | ||
| 493 | } | ||
| 494 | |||
| 495 | do_040writebacks(fp); | ||
| 496 | } | ||
| 497 | #endif /* CONFIG_M68040 */ | ||
| 498 | |||
| 499 | #if defined(CONFIG_SUN3) | ||
| 500 | #include <asm/sun3mmu.h> | ||
| 501 | |||
| 502 | extern int mmu_emu_handle_fault (unsigned long, int, int); | ||
| 503 | |||
| 504 | /* sun3 version of bus_error030 */ | ||
| 505 | |||
| 506 | static inline void bus_error030 (struct frame *fp) | ||
| 507 | { | ||
| 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; | ||
| 512 | |||
| 513 | #ifdef DEBUG | ||
| 514 | if (ssw & (FC | FB)) | ||
| 515 | printk ("Instruction fault at %#010lx\n", | ||
| 516 | ssw & FC ? | ||
| 517 | fp->ptregs.format == 0xa ? fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2 | ||
| 518 | : | ||
| 519 | fp->ptregs.format == 0xa ? fp->ptregs.pc + 4 : fp->un.fmtb.baddr); | ||
| 520 | if (ssw & DF) | ||
| 521 | printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n", | ||
| 522 | ssw & RW ? "read" : "write", | ||
| 523 | fp->un.fmtb.daddr, | ||
| 524 | space_names[ssw & DFC], fp->ptregs.pc); | ||
| 525 | #endif | ||
| 526 | |||
| 527 | /* | ||
| 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). | ||
| 531 | */ | ||
| 532 | |||
| 533 | if ((ssw & DF) | ||
| 534 | && (buserr_type & (SUN3_BUSERR_PROTERR | SUN3_BUSERR_INVALID))) { | ||
| 535 | if (mmu_emu_handle_fault (fp->un.fmtb.daddr, ssw & RW, 0)) | ||
| 536 | return; | ||
| 537 | } | ||
| 538 | |||
| 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)) | ||
| 545 | return; | ||
| 546 | /* instruction fault or kernel data fault! */ | ||
| 547 | if (ssw & (FC | FB)) | ||
| 548 | printk ("Instruction fault at %#010lx\n", | ||
| 549 | fp->ptregs.pc); | ||
| 550 | if (ssw & DF) { | ||
| 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); | ||
| 555 | return; | ||
| 556 | } | ||
| 557 | |||
| 558 | printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n", | ||
| 559 | ssw & RW ? "read" : "write", | ||
| 560 | fp->un.fmtb.daddr, | ||
| 561 | space_names[ssw & DFC], fp->ptregs.pc); | ||
| 562 | } | ||
| 563 | printk ("BAD KERNEL BUSERR\n"); | ||
| 564 | |||
| 565 | die_if_kernel("Oops", &fp->ptregs,0); | ||
| 566 | force_sig(SIGKILL, current); | ||
| 567 | return; | ||
| 568 | } | ||
| 569 | } else { | ||
| 570 | /* user fault */ | ||
| 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"); | ||
| 574 | } | ||
| 575 | |||
| 576 | |||
| 577 | /* First handle the data fault, if any. */ | ||
| 578 | if (ssw & DF) { | ||
| 579 | addr = fp->un.fmtb.daddr; | ||
| 580 | |||
| 581 | // errorcode bit 0: 0 -> no page 1 -> protection fault | ||
| 582 | // errorcode bit 1: 0 -> read fault 1 -> write fault | ||
| 583 | |||
| 584 | // (buserr_type & SUN3_BUSERR_PROTERR) -> protection fault | ||
| 585 | // (buserr_type & SUN3_BUSERR_INVALID) -> invalid page fault | ||
| 586 | |||
| 587 | if (buserr_type & SUN3_BUSERR_PROTERR) | ||
| 588 | errorcode = 0x01; | ||
| 589 | else if (buserr_type & SUN3_BUSERR_INVALID) | ||
| 590 | errorcode = 0x00; | ||
| 591 | else { | ||
| 592 | #ifdef DEBUG | ||
| 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, | ||
| 596 | fp->ptregs.pc); | ||
| 597 | #endif | ||
| 598 | die_if_kernel ("Oops", &fp->ptregs, buserr_type); | ||
| 599 | force_sig (SIGBUS, current); | ||
| 600 | return; | ||
| 601 | } | ||
| 602 | |||
| 603 | //todo: wtf is RM bit? --m | ||
| 604 | if (!(ssw & RW) || ssw & RM) | ||
| 605 | errorcode |= 0x02; | ||
| 606 | |||
| 607 | /* Handle page fault. */ | ||
| 608 | do_page_fault (&fp->ptregs, addr, errorcode); | ||
| 609 | |||
| 610 | /* Retry the data fault now. */ | ||
| 611 | return; | ||
| 612 | } | ||
| 613 | |||
| 614 | /* Now handle the instruction fault. */ | ||
| 615 | |||
| 616 | /* Get the fault address. */ | ||
| 617 | if (fp->ptregs.format == 0xA) | ||
| 618 | addr = fp->ptregs.pc + 4; | ||
| 619 | else | ||
| 620 | addr = fp->un.fmtb.baddr; | ||
| 621 | if (ssw & FC) | ||
| 622 | addr -= 2; | ||
| 623 | |||
| 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); | ||
| 627 | } else { | ||
| 628 | #ifdef DEBUG | ||
| 629 | printk ("protection fault on insn access (segv).\n"); | ||
| 630 | #endif | ||
| 631 | force_sig (SIGSEGV, current); | ||
| 632 | } | ||
| 633 | } | ||
| 634 | #else | ||
| 635 | #if defined(CPU_M68020_OR_M68030) | ||
| 636 | static inline void bus_error030 (struct frame *fp) | ||
| 637 | { | ||
| 638 | volatile unsigned short temp; | ||
| 639 | unsigned short mmusr; | ||
| 640 | unsigned long addr, errorcode; | ||
| 641 | unsigned short ssw = fp->un.fmtb.ssw; | ||
| 642 | #ifdef DEBUG | ||
| 643 | unsigned long desc; | ||
| 644 | |||
| 645 | printk ("pid = %x ", current->pid); | ||
| 646 | printk ("SSW=%#06x ", ssw); | ||
| 647 | |||
| 648 | if (ssw & (FC | FB)) | ||
| 649 | printk ("Instruction fault at %#010lx\n", | ||
| 650 | ssw & FC ? | ||
| 651 | fp->ptregs.format == 0xa ? fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2 | ||
| 652 | : | ||
| 653 | fp->ptregs.format == 0xa ? fp->ptregs.pc + 4 : fp->un.fmtb.baddr); | ||
| 654 | if (ssw & DF) | ||
| 655 | printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n", | ||
| 656 | ssw & RW ? "read" : "write", | ||
| 657 | fp->un.fmtb.daddr, | ||
| 658 | space_names[ssw & DFC], fp->ptregs.pc); | ||
| 659 | #endif | ||
| 660 | |||
| 661 | /* ++andreas: If a data fault and an instruction fault happen | ||
| 662 | at the same time map in both pages. */ | ||
| 663 | |||
| 664 | /* First handle the data fault, if any. */ | ||
| 665 | if (ssw & DF) { | ||
| 666 | addr = fp->un.fmtb.daddr; | ||
| 667 | |||
| 668 | #ifdef DEBUG | ||
| 669 | asm volatile ("ptestr %3,%2@,#7,%0\n\t" | ||
| 670 | "pmove %%psr,%1@" | ||
| 671 | : "=a&" (desc) | ||
| 672 | : "a" (&temp), "a" (addr), "d" (ssw)); | ||
| 673 | #else | ||
| 674 | asm volatile ("ptestr %2,%1@,#7\n\t" | ||
| 675 | "pmove %%psr,%0@" | ||
| 676 | : : "a" (&temp), "a" (addr), "d" (ssw)); | ||
| 677 | #endif | ||
| 678 | mmusr = temp; | ||
| 679 | |||
| 680 | #ifdef DEBUG | ||
| 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)); | ||
| 685 | #endif | ||
| 686 | |||
| 687 | errorcode = (mmusr & MMU_I) ? 0 : 1; | ||
| 688 | if (!(ssw & RW) || (ssw & RM)) | ||
| 689 | errorcode |= 2; | ||
| 690 | |||
| 691 | if (mmusr & (MMU_I | MMU_WP)) { | ||
| 692 | if (ssw & 4) { | ||
| 693 | printk("Data %s fault at %#010lx in %s (pc=%#lx)\n", | ||
| 694 | ssw & RW ? "read" : "write", | ||
| 695 | fp->un.fmtb.daddr, | ||
| 696 | space_names[ssw & DFC], fp->ptregs.pc); | ||
| 697 | goto buserr; | ||
| 698 | } | ||
| 699 | /* Don't try to do anything further if an exception was | ||
| 700 | handled. */ | ||
| 701 | if (do_page_fault (&fp->ptregs, addr, errorcode) < 0) | ||
| 702 | return; | ||
| 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, | ||
| 710 | fp->ptregs.pc); | ||
| 711 | die_if_kernel("Oops",&fp->ptregs,mmusr); | ||
| 712 | force_sig(SIGSEGV, current); | ||
| 713 | return; | ||
| 714 | } else { | ||
| 715 | #if 0 | ||
| 716 | static volatile long tlong; | ||
| 717 | #endif | ||
| 718 | |||
| 719 | printk("weird %s access at %#lx from pc %#lx (ssw is %#x)\n", | ||
| 720 | !(ssw & RW) ? "write" : "read", addr, | ||
| 721 | fp->ptregs.pc, ssw); | ||
| 722 | asm volatile ("ptestr #1,%1@,#0\n\t" | ||
| 723 | "pmove %%psr,%0@" | ||
| 724 | : /* no outputs */ | ||
| 725 | : "a" (&temp), "a" (addr)); | ||
| 726 | mmusr = temp; | ||
| 727 | |||
| 728 | printk ("level 0 mmusr is %#x\n", mmusr); | ||
| 729 | #if 0 | ||
| 730 | asm volatile ("pmove %%tt0,%0@" | ||
| 731 | : /* no outputs */ | ||
| 732 | : "a" (&tlong)); | ||
| 733 | printk("tt0 is %#lx, ", tlong); | ||
| 734 | asm volatile ("pmove %%tt1,%0@" | ||
| 735 | : /* no outputs */ | ||
| 736 | : "a" (&tlong)); | ||
| 737 | printk("tt1 is %#lx\n", tlong); | ||
| 738 | #endif | ||
| 739 | #ifdef DEBUG | ||
| 740 | printk("Unknown SIGSEGV - 1\n"); | ||
| 741 | #endif | ||
| 742 | die_if_kernel("Oops",&fp->ptregs,mmusr); | ||
| 743 | force_sig(SIGSEGV, current); | ||
| 744 | return; | ||
| 745 | } | ||
| 746 | |||
| 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)); | ||
| 751 | else | ||
| 752 | asm volatile ("ploadr %1,%0@" : /* no outputs */ | ||
| 753 | : "a" (addr), "d" (ssw)); | ||
| 754 | } | ||
| 755 | |||
| 756 | /* Now handle the instruction fault. */ | ||
| 757 | |||
| 758 | if (!(ssw & (FC|FB))) | ||
| 759 | return; | ||
| 760 | |||
| 761 | if (fp->ptregs.sr & PS_S) { | ||
| 762 | printk("Instruction fault at %#010lx\n", | ||
| 763 | fp->ptregs.pc); | ||
| 764 | buserr: | ||
| 765 | printk ("BAD KERNEL BUSERR\n"); | ||
| 766 | die_if_kernel("Oops",&fp->ptregs,0); | ||
| 767 | force_sig(SIGKILL, current); | ||
| 768 | return; | ||
| 769 | } | ||
| 770 | |||
| 771 | /* get the fault address */ | ||
| 772 | if (fp->ptregs.format == 10) | ||
| 773 | addr = fp->ptregs.pc + 4; | ||
| 774 | else | ||
| 775 | addr = fp->un.fmtb.baddr; | ||
| 776 | if (ssw & FC) | ||
| 777 | addr -= 2; | ||
| 778 | |||
| 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; | ||
| 783 | |||
| 784 | #ifdef DEBUG | ||
| 785 | asm volatile ("ptestr #1,%2@,#7,%0\n\t" | ||
| 786 | "pmove %%psr,%1@" | ||
| 787 | : "=a&" (desc) | ||
| 788 | : "a" (&temp), "a" (addr)); | ||
| 789 | #else | ||
| 790 | asm volatile ("ptestr #1,%1@,#7\n\t" | ||
| 791 | "pmove %%psr,%0@" | ||
| 792 | : : "a" (&temp), "a" (addr)); | ||
| 793 | #endif | ||
| 794 | mmusr = temp; | ||
| 795 | |||
| 796 | #ifdef DEBUG | ||
| 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)); | ||
| 801 | #endif | ||
| 802 | |||
| 803 | if (mmusr & MMU_I) | ||
| 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); | ||
| 808 | #ifdef DEBUG | ||
| 809 | printk("Unknown SIGSEGV - 2\n"); | ||
| 810 | #endif | ||
| 811 | die_if_kernel("Oops",&fp->ptregs,mmusr); | ||
| 812 | force_sig(SIGSEGV, current); | ||
| 813 | return; | ||
| 814 | } | ||
| 815 | |||
| 816 | create_atc_entry: | ||
| 817 | /* setup an ATC entry for the access about to be retried */ | ||
| 818 | asm volatile ("ploadr #2,%0@" : /* no outputs */ | ||
| 819 | : "a" (addr)); | ||
| 820 | } | ||
| 821 | #endif /* CPU_M68020_OR_M68030 */ | ||
| 822 | #endif /* !CONFIG_SUN3 */ | ||
| 823 | |||
| 824 | asmlinkage void buserr_c(struct frame *fp) | ||
| 825 | { | ||
| 826 | /* Only set esp0 if coming from user mode */ | ||
| 827 | if (user_mode(&fp->ptregs)) | ||
| 828 | current->thread.esp0 = (unsigned long) fp; | ||
| 829 | |||
| 830 | #ifdef DEBUG | ||
| 831 | printk ("*** Bus Error *** Format is %x\n", fp->ptregs.format); | ||
| 832 | #endif | ||
| 833 | |||
| 834 | switch (fp->ptregs.format) { | ||
| 835 | #if defined (CONFIG_M68060) | ||
| 836 | case 4: /* 68060 access error */ | ||
| 837 | access_error060 (fp); | ||
| 838 | break; | ||
| 839 | #endif | ||
| 840 | #if defined (CONFIG_M68040) | ||
| 841 | case 0x7: /* 68040 access error */ | ||
| 842 | access_error040 (fp); | ||
| 843 | break; | ||
| 844 | #endif | ||
| 845 | #if defined (CPU_M68020_OR_M68030) | ||
| 846 | case 0xa: | ||
| 847 | case 0xb: | ||
| 848 | bus_error030 (fp); | ||
| 849 | break; | ||
| 850 | #endif | ||
| 851 | default: | ||
| 852 | die_if_kernel("bad frame format",&fp->ptregs,0); | ||
| 853 | #ifdef DEBUG | ||
| 854 | printk("Unknown SIGSEGV - 4\n"); | ||
| 855 | #endif | ||
| 856 | force_sig(SIGSEGV, current); | ||
| 857 | } | ||
| 858 | } | ||
| 859 | |||
| 860 | |||
| 861 | static int kstack_depth_to_print = 48; | ||
| 862 | |||
| 863 | void show_trace(unsigned long *stack) | ||
| 864 | { | ||
| 865 | unsigned long *endstack; | ||
| 866 | unsigned long addr; | ||
| 867 | int i; | ||
| 868 | |||
| 869 | printk("Call Trace:"); | ||
| 870 | addr = (unsigned long)stack + THREAD_SIZE - 1; | ||
| 871 | endstack = (unsigned long *)(addr & -THREAD_SIZE); | ||
| 872 | i = 0; | ||
| 873 | while (stack + 1 <= endstack) { | ||
| 874 | addr = *stack++; | ||
| 875 | /* | ||
| 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. | ||
| 882 | */ | ||
| 883 | if (__kernel_text_address(addr)) { | ||
| 884 | #ifndef CONFIG_KALLSYMS | ||
| 885 | if (i % 5 == 0) | ||
| 886 | printk("\n "); | ||
| 887 | #endif | ||
| 888 | printk(" [<%08lx>] %pS\n", addr, (void *)addr); | ||
| 889 | i++; | ||
| 890 | } | ||
| 891 | } | ||
| 892 | printk("\n"); | ||
| 893 | } | ||
| 894 | |||
| 895 | void show_registers(struct pt_regs *regs) | ||
| 896 | { | ||
| 897 | struct frame *fp = (struct frame *)regs; | ||
| 898 | mm_segment_t old_fs = get_fs(); | ||
| 899 | u16 c, *cp; | ||
| 900 | unsigned long addr; | ||
| 901 | int i; | ||
| 902 | |||
| 903 | print_modules(); | ||
| 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); | ||
| 910 | |||
| 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) { | ||
| 916 | case 0x2: | ||
| 917 | printk("instr addr=%08lx\n", fp->un.fmt2.iaddr); | ||
| 918 | addr += sizeof(fp->un.fmt2); | ||
| 919 | break; | ||
| 920 | case 0x3: | ||
| 921 | printk("eff addr=%08lx\n", fp->un.fmt3.effaddr); | ||
| 922 | addr += sizeof(fp->un.fmt3); | ||
| 923 | break; | ||
| 924 | case 0x4: | ||
| 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); | ||
| 929 | break; | ||
| 930 | case 0x7: | ||
| 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, | ||
| 941 | fp->un.fmt7.pd3); | ||
| 942 | addr += sizeof(fp->un.fmt7); | ||
| 943 | break; | ||
| 944 | case 0x9: | ||
| 945 | printk("instr addr=%08lx\n", fp->un.fmt9.iaddr); | ||
| 946 | addr += sizeof(fp->un.fmt9); | ||
| 947 | break; | ||
| 948 | case 0xa: | ||
| 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); | ||
| 953 | break; | ||
| 954 | case 0xb: | ||
| 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); | ||
| 961 | break; | ||
| 962 | default: | ||
| 963 | printk("\n"); | ||
| 964 | } | ||
| 965 | show_stack(NULL, (unsigned long *)addr); | ||
| 966 | |||
| 967 | printk("Code:"); | ||
| 968 | set_fs(KERNEL_DS); | ||
| 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."); | ||
| 973 | break; | ||
| 974 | } | ||
| 975 | printk(i ? " %04x" : " <%04x>", c); | ||
| 976 | } | ||
| 977 | set_fs(old_fs); | ||
| 978 | printk ("\n"); | ||
| 979 | } | ||
| 980 | |||
| 981 | void show_stack(struct task_struct *task, unsigned long *stack) | ||
| 982 | { | ||
| 983 | unsigned long *p; | ||
| 984 | unsigned long *endstack; | ||
| 985 | int i; | ||
| 986 | |||
| 987 | if (!stack) { | ||
| 988 | if (task) | ||
| 989 | stack = (unsigned long *)task->thread.esp0; | ||
| 990 | else | ||
| 991 | stack = (unsigned long *)&stack; | ||
| 992 | } | ||
| 993 | endstack = (unsigned long *)(((unsigned long)stack + THREAD_SIZE - 1) & -THREAD_SIZE); | ||
| 994 | |||
| 995 | printk("Stack from %08lx:", (unsigned long)stack); | ||
| 996 | p = stack; | ||
| 997 | for (i = 0; i < kstack_depth_to_print; i++) { | ||
| 998 | if (p + 1 > endstack) | ||
| 999 | break; | ||
| 1000 | if (i % 8 == 0) | ||
| 1001 | printk("\n "); | ||
| 1002 | printk(" %08lx", *p++); | ||
| 1003 | } | ||
| 1004 | printk("\n"); | ||
| 1005 | show_trace(stack); | ||
| 1006 | } | ||
| 1007 | |||
| 1008 | /* | ||
| 1009 | * The architecture-independent backtrace generator | ||
| 1010 | */ | ||
| 1011 | void dump_stack(void) | ||
| 1012 | { | ||
| 1013 | unsigned long stack; | ||
| 1014 | |||
| 1015 | show_trace(&stack); | ||
| 1016 | } | ||
| 1017 | |||
| 1018 | EXPORT_SYMBOL(dump_stack); | ||
| 1019 | |||
| 1020 | void bad_super_trap (struct frame *fp) | ||
| 1021 | { | ||
| 1022 | console_verbose(); | ||
| 1023 | if (fp->ptregs.vector < 4 * ARRAY_SIZE(vec_names)) | ||
| 1024 | printk ("*** %s *** FORMAT=%X\n", | ||
| 1025 | vec_names[(fp->ptregs.vector) >> 2], | ||
| 1026 | fp->ptregs.format); | ||
| 1027 | else | ||
| 1028 | printk ("*** Exception %d *** FORMAT=%X\n", | ||
| 1029 | (fp->ptregs.vector) >> 2, | ||
| 1030 | fp->ptregs.format); | ||
| 1031 | if (fp->ptregs.vector >> 2 == VEC_ADDRERR && CPU_IS_020_OR_030) { | ||
| 1032 | unsigned short ssw = fp->un.fmtb.ssw; | ||
| 1033 | |||
| 1034 | printk ("SSW=%#06x ", ssw); | ||
| 1035 | |||
| 1036 | if (ssw & RC) | ||
| 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); | ||
| 1040 | if (ssw & RB) | ||
| 1041 | printk ("Pipe stage B instruction fault at %#010lx\n", | ||
| 1042 | (fp->ptregs.format) == 0xA ? | ||
| 1043 | fp->ptregs.pc + 4 : fp->un.fmtb.baddr); | ||
| 1044 | if (ssw & DF) | ||
| 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], | ||
| 1048 | fp->ptregs.pc); | ||
| 1049 | } | ||
| 1050 | printk ("Current process id is %d\n", task_pid_nr(current)); | ||
| 1051 | die_if_kernel("BAD KERNEL TRAP", &fp->ptregs, 0); | ||
| 1052 | } | ||
| 1053 | |||
| 1054 | asmlinkage void trap_c(struct frame *fp) | ||
| 1055 | { | ||
| 1056 | int sig; | ||
| 1057 | siginfo_t info; | ||
| 1058 | |||
| 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. | ||
| 1063 | */ | ||
| 1064 | } else if (!handle_kernel_fault(&fp->ptregs)) | ||
| 1065 | bad_super_trap(fp); | ||
| 1066 | return; | ||
| 1067 | } | ||
| 1068 | |||
| 1069 | /* send the appropriate signal to the user program */ | ||
| 1070 | switch ((fp->ptregs.vector) >> 2) { | ||
| 1071 | case VEC_ADDRERR: | ||
| 1072 | info.si_code = BUS_ADRALN; | ||
| 1073 | sig = SIGBUS; | ||
| 1074 | break; | ||
| 1075 | case VEC_ILLEGAL: | ||
| 1076 | case VEC_LINE10: | ||
| 1077 | case VEC_LINE11: | ||
| 1078 | info.si_code = ILL_ILLOPC; | ||
| 1079 | sig = SIGILL; | ||
| 1080 | break; | ||
| 1081 | case VEC_PRIV: | ||
| 1082 | info.si_code = ILL_PRVOPC; | ||
| 1083 | sig = SIGILL; | ||
| 1084 | break; | ||
| 1085 | case VEC_COPROC: | ||
| 1086 | info.si_code = ILL_COPROC; | ||
| 1087 | sig = SIGILL; | ||
| 1088 | break; | ||
| 1089 | case VEC_TRAP1: | ||
| 1090 | case VEC_TRAP2: | ||
| 1091 | case VEC_TRAP3: | ||
| 1092 | case VEC_TRAP4: | ||
| 1093 | case VEC_TRAP5: | ||
| 1094 | case VEC_TRAP6: | ||
| 1095 | case VEC_TRAP7: | ||
| 1096 | case VEC_TRAP8: | ||
| 1097 | case VEC_TRAP9: | ||
| 1098 | case VEC_TRAP10: | ||
| 1099 | case VEC_TRAP11: | ||
| 1100 | case VEC_TRAP12: | ||
| 1101 | case VEC_TRAP13: | ||
| 1102 | case VEC_TRAP14: | ||
| 1103 | info.si_code = ILL_ILLTRP; | ||
| 1104 | sig = SIGILL; | ||
| 1105 | break; | ||
| 1106 | case VEC_FPBRUC: | ||
| 1107 | case VEC_FPOE: | ||
| 1108 | case VEC_FPNAN: | ||
| 1109 | info.si_code = FPE_FLTINV; | ||
| 1110 | sig = SIGFPE; | ||
| 1111 | break; | ||
| 1112 | case VEC_FPIR: | ||
| 1113 | info.si_code = FPE_FLTRES; | ||
| 1114 | sig = SIGFPE; | ||
| 1115 | break; | ||
| 1116 | case VEC_FPDIVZ: | ||
| 1117 | info.si_code = FPE_FLTDIV; | ||
| 1118 | sig = SIGFPE; | ||
| 1119 | break; | ||
| 1120 | case VEC_FPUNDER: | ||
| 1121 | info.si_code = FPE_FLTUND; | ||
| 1122 | sig = SIGFPE; | ||
| 1123 | break; | ||
| 1124 | case VEC_FPOVER: | ||
| 1125 | info.si_code = FPE_FLTOVF; | ||
| 1126 | sig = SIGFPE; | ||
| 1127 | break; | ||
| 1128 | case VEC_ZERODIV: | ||
| 1129 | info.si_code = FPE_INTDIV; | ||
| 1130 | sig = SIGFPE; | ||
| 1131 | break; | ||
| 1132 | case VEC_CHK: | ||
| 1133 | case VEC_TRAP: | ||
| 1134 | info.si_code = FPE_INTOVF; | ||
| 1135 | sig = SIGFPE; | ||
| 1136 | break; | ||
| 1137 | case VEC_TRACE: /* ptrace single step */ | ||
| 1138 | info.si_code = TRAP_TRACE; | ||
| 1139 | sig = SIGTRAP; | ||
| 1140 | break; | ||
| 1141 | case VEC_TRAP15: /* breakpoint */ | ||
| 1142 | info.si_code = TRAP_BRKPT; | ||
| 1143 | sig = SIGTRAP; | ||
| 1144 | break; | ||
| 1145 | default: | ||
| 1146 | info.si_code = ILL_ILLOPC; | ||
| 1147 | sig = SIGILL; | ||
| 1148 | break; | ||
| 1149 | } | ||
| 1150 | info.si_signo = sig; | ||
| 1151 | info.si_errno = 0; | ||
| 1152 | switch (fp->ptregs.format) { | ||
| 1153 | default: | ||
| 1154 | info.si_addr = (void *) fp->ptregs.pc; | ||
| 1155 | break; | ||
| 1156 | case 2: | ||
| 1157 | info.si_addr = (void *) fp->un.fmt2.iaddr; | ||
| 1158 | break; | ||
| 1159 | case 7: | ||
| 1160 | info.si_addr = (void *) fp->un.fmt7.effaddr; | ||
| 1161 | break; | ||
| 1162 | case 9: | ||
| 1163 | info.si_addr = (void *) fp->un.fmt9.iaddr; | ||
| 1164 | break; | ||
| 1165 | case 10: | ||
| 1166 | info.si_addr = (void *) fp->un.fmta.daddr; | ||
| 1167 | break; | ||
| 1168 | case 11: | ||
| 1169 | info.si_addr = (void *) fp->un.fmtb.daddr; | ||
| 1170 | break; | ||
| 1171 | } | ||
| 1172 | force_sig_info (sig, &info, current); | ||
| 1173 | } | ||
| 1174 | |||
| 1175 | void die_if_kernel (char *str, struct pt_regs *fp, int nr) | ||
| 1176 | { | ||
| 1177 | if (!(fp->sr & PS_S)) | ||
| 1178 | return; | ||
| 1179 | |||
| 1180 | console_verbose(); | ||
| 1181 | printk("%s: %08x\n",str,nr); | ||
| 1182 | show_registers(fp); | ||
| 1183 | add_taint(TAINT_DIE); | ||
| 1184 | do_exit(SIGSEGV); | ||
| 1185 | } | ||
| 1186 | |||
| 1187 | /* | ||
| 1188 | * This function is called if an error occur while accessing | ||
| 1189 | * user-space from the fpsp040 code. | ||
| 1190 | */ | ||
| 1191 | asmlinkage void fpsp040_die(void) | ||
| 1192 | { | ||
| 1193 | do_exit(SIGSEGV); | ||
| 1194 | } | ||
| 1195 | |||
| 1196 | #ifdef CONFIG_M68KFPU_EMU | ||
| 1197 | asmlinkage void fpemu_signal(int signal, int code, void *addr) | ||
| 1198 | { | ||
| 1199 | siginfo_t info; | ||
| 1200 | |||
| 1201 | info.si_signo = signal; | ||
| 1202 | info.si_errno = 0; | ||
| 1203 | info.si_code = code; | ||
| 1204 | info.si_addr = addr; | ||
| 1205 | force_sig_info(signal, &info, current); | ||
| 1206 | } | ||
| 1207 | #endif | ||
diff --git a/arch/m68k/kernel/traps_no.c b/arch/m68k/kernel/traps_no.c deleted file mode 100644 index e67b8c806959..000000000000 --- a/arch/m68k/kernel/traps_no.c +++ /dev/null | |||
| @@ -1,361 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * linux/arch/m68knommu/kernel/traps.c | ||
| 3 | * | ||
| 4 | * Copyright (C) 1993, 1994 by Hamish Macdonald | ||
| 5 | * | ||
| 6 | * 68040 fixes by Michael Rausch | ||
| 7 | * 68040 fixes by Martin Apel | ||
| 8 | * 68060 fixes by Roman Hodek | ||
| 9 | * 68060 fixes by Jesper Skov | ||
| 10 | * | ||
| 11 | * This file is subject to the terms and conditions of the GNU General Public | ||
| 12 | * License. See the file COPYING in the main directory of this archive | ||
| 13 | * for more details. | ||
| 14 | */ | ||
| 15 | |||
| 16 | /* | ||
| 17 | * Sets up all exception vectors | ||
| 18 | */ | ||
| 19 | #include <linux/sched.h> | ||
| 20 | #include <linux/signal.h> | ||
| 21 | #include <linux/kernel.h> | ||
| 22 | #include <linux/mm.h> | ||
| 23 | #include <linux/module.h> | ||
| 24 | #include <linux/types.h> | ||
| 25 | #include <linux/user.h> | ||
| 26 | #include <linux/string.h> | ||
| 27 | #include <linux/linkage.h> | ||
| 28 | #include <linux/init.h> | ||
| 29 | #include <linux/ptrace.h> | ||
| 30 | #include <linux/kallsyms.h> | ||
| 31 | |||
| 32 | #include <asm/setup.h> | ||
| 33 | #include <asm/fpu.h> | ||
| 34 | #include <asm/system.h> | ||
| 35 | #include <asm/uaccess.h> | ||
| 36 | #include <asm/traps.h> | ||
| 37 | #include <asm/pgtable.h> | ||
| 38 | #include <asm/machdep.h> | ||
| 39 | #include <asm/siginfo.h> | ||
| 40 | |||
| 41 | static char const * const vec_names[] = { | ||
| 42 | "RESET SP", "RESET PC", "BUS ERROR", "ADDRESS ERROR", | ||
| 43 | "ILLEGAL INSTRUCTION", "ZERO DIVIDE", "CHK", "TRAPcc", | ||
| 44 | "PRIVILEGE VIOLATION", "TRACE", "LINE 1010", "LINE 1111", | ||
| 45 | "UNASSIGNED RESERVED 12", "COPROCESSOR PROTOCOL VIOLATION", | ||
| 46 | "FORMAT ERROR", "UNINITIALIZED INTERRUPT", | ||
| 47 | "UNASSIGNED RESERVED 16", "UNASSIGNED RESERVED 17", | ||
| 48 | "UNASSIGNED RESERVED 18", "UNASSIGNED RESERVED 19", | ||
| 49 | "UNASSIGNED RESERVED 20", "UNASSIGNED RESERVED 21", | ||
| 50 | "UNASSIGNED RESERVED 22", "UNASSIGNED RESERVED 23", | ||
| 51 | "SPURIOUS INTERRUPT", "LEVEL 1 INT", "LEVEL 2 INT", "LEVEL 3 INT", | ||
| 52 | "LEVEL 4 INT", "LEVEL 5 INT", "LEVEL 6 INT", "LEVEL 7 INT", | ||
| 53 | "SYSCALL", "TRAP #1", "TRAP #2", "TRAP #3", | ||
| 54 | "TRAP #4", "TRAP #5", "TRAP #6", "TRAP #7", | ||
| 55 | "TRAP #8", "TRAP #9", "TRAP #10", "TRAP #11", | ||
| 56 | "TRAP #12", "TRAP #13", "TRAP #14", "TRAP #15", | ||
| 57 | "FPCP BSUN", "FPCP INEXACT", "FPCP DIV BY 0", "FPCP UNDERFLOW", | ||
| 58 | "FPCP OPERAND ERROR", "FPCP OVERFLOW", "FPCP SNAN", | ||
| 59 | "FPCP UNSUPPORTED OPERATION", | ||
| 60 | "MMU CONFIGURATION ERROR" | ||
| 61 | }; | ||
| 62 | |||
| 63 | void die_if_kernel(char *str, struct pt_regs *fp, int nr) | ||
| 64 | { | ||
| 65 | if (!(fp->sr & PS_S)) | ||
| 66 | return; | ||
| 67 | |||
| 68 | console_verbose(); | ||
| 69 | printk(KERN_EMERG "%s: %08x\n",str,nr); | ||
| 70 | printk(KERN_EMERG "PC: [<%08lx>]\nSR: %04x SP: %p a2: %08lx\n", | ||
| 71 | fp->pc, fp->sr, fp, fp->a2); | ||
| 72 | printk(KERN_EMERG "d0: %08lx d1: %08lx d2: %08lx d3: %08lx\n", | ||
| 73 | fp->d0, fp->d1, fp->d2, fp->d3); | ||
| 74 | printk(KERN_EMERG "d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n", | ||
| 75 | fp->d4, fp->d5, fp->a0, fp->a1); | ||
| 76 | |||
| 77 | printk(KERN_EMERG "Process %s (pid: %d, stackpage=%08lx)\n", | ||
| 78 | current->comm, current->pid, PAGE_SIZE+(unsigned long)current); | ||
| 79 | show_stack(NULL, (unsigned long *)(fp + 1)); | ||
| 80 | add_taint(TAINT_DIE); | ||
| 81 | do_exit(SIGSEGV); | ||
| 82 | } | ||
| 83 | |||
| 84 | asmlinkage void buserr_c(struct frame *fp) | ||
| 85 | { | ||
| 86 | /* Only set esp0 if coming from user mode */ | ||
| 87 | if (user_mode(&fp->ptregs)) | ||
| 88 | current->thread.esp0 = (unsigned long) fp; | ||
| 89 | |||
| 90 | #if defined(DEBUG) | ||
| 91 | printk (KERN_DEBUG "*** Bus Error *** Format is %x\n", fp->ptregs.format); | ||
| 92 | #endif | ||
| 93 | |||
| 94 | die_if_kernel("bad frame format",&fp->ptregs,0); | ||
| 95 | #if defined(DEBUG) | ||
| 96 | printk(KERN_DEBUG "Unknown SIGSEGV - 4\n"); | ||
| 97 | #endif | ||
| 98 | force_sig(SIGSEGV, current); | ||
| 99 | } | ||
| 100 | |||
| 101 | static void print_this_address(unsigned long addr, int i) | ||
| 102 | { | ||
| 103 | #ifdef CONFIG_KALLSYMS | ||
| 104 | printk(KERN_EMERG " [%08lx] ", addr); | ||
| 105 | print_symbol(KERN_CONT "%s\n", addr); | ||
| 106 | #else | ||
| 107 | if (i % 5) | ||
| 108 | printk(KERN_CONT " [%08lx] ", addr); | ||
| 109 | else | ||
| 110 | printk(KERN_EMERG " [%08lx] ", addr); | ||
| 111 | i++; | ||
| 112 | #endif | ||
| 113 | } | ||
| 114 | |||
| 115 | int kstack_depth_to_print = 48; | ||
| 116 | |||
| 117 | static void __show_stack(struct task_struct *task, unsigned long *stack) | ||
| 118 | { | ||
| 119 | unsigned long *endstack, addr; | ||
| 120 | #ifdef CONFIG_FRAME_POINTER | ||
| 121 | unsigned long *last_stack; | ||
| 122 | #endif | ||
| 123 | int i; | ||
| 124 | |||
| 125 | if (!stack) | ||
| 126 | stack = (unsigned long *)task->thread.ksp; | ||
| 127 | |||
| 128 | addr = (unsigned long) stack; | ||
| 129 | endstack = (unsigned long *) PAGE_ALIGN(addr); | ||
| 130 | |||
| 131 | printk(KERN_EMERG "Stack from %08lx:", (unsigned long)stack); | ||
| 132 | for (i = 0; i < kstack_depth_to_print; i++) { | ||
| 133 | if (stack + 1 + i > endstack) | ||
| 134 | break; | ||
| 135 | if (i % 8 == 0) | ||
| 136 | printk(KERN_EMERG " "); | ||
| 137 | printk(KERN_CONT " %08lx", *(stack + i)); | ||
| 138 | } | ||
| 139 | printk("\n"); | ||
| 140 | i = 0; | ||
| 141 | |||
| 142 | #ifdef CONFIG_FRAME_POINTER | ||
| 143 | printk(KERN_EMERG "Call Trace:\n"); | ||
| 144 | |||
| 145 | last_stack = stack - 1; | ||
| 146 | while (stack <= endstack && stack > last_stack) { | ||
| 147 | |||
| 148 | addr = *(stack + 1); | ||
| 149 | print_this_address(addr, i); | ||
| 150 | i++; | ||
| 151 | |||
| 152 | last_stack = stack; | ||
| 153 | stack = (unsigned long *)*stack; | ||
| 154 | } | ||
| 155 | printk("\n"); | ||
| 156 | #else | ||
| 157 | printk(KERN_EMERG "Call Trace with CONFIG_FRAME_POINTER disabled:\n"); | ||
| 158 | while (stack <= endstack) { | ||
| 159 | addr = *stack++; | ||
| 160 | /* | ||
| 161 | * If the address is either in the text segment of the kernel, | ||
| 162 | * or in a region which is occupied by a module then it *may* | ||
| 163 | * be the address of a calling routine; if so, print it so that | ||
| 164 | * someone tracing down the cause of the crash will be able to | ||
| 165 | * figure out the call path that was taken. | ||
| 166 | */ | ||
| 167 | if (__kernel_text_address(addr)) { | ||
| 168 | print_this_address(addr, i); | ||
| 169 | i++; | ||
| 170 | } | ||
| 171 | } | ||
| 172 | printk(KERN_CONT "\n"); | ||
| 173 | #endif | ||
| 174 | } | ||
| 175 | |||
| 176 | void bad_super_trap(struct frame *fp) | ||
| 177 | { | ||
| 178 | int vector = (fp->ptregs.vector >> 2) & 0xff; | ||
| 179 | |||
| 180 | console_verbose(); | ||
| 181 | if (vector < ARRAY_SIZE(vec_names)) | ||
| 182 | printk (KERN_WARNING "*** %s *** FORMAT=%X\n", | ||
| 183 | vec_names[vector], | ||
| 184 | fp->ptregs.format); | ||
| 185 | else | ||
| 186 | printk (KERN_WARNING "*** Exception %d *** FORMAT=%X\n", | ||
| 187 | vector, | ||
| 188 | fp->ptregs.format); | ||
| 189 | printk (KERN_WARNING "Current process id is %d\n", current->pid); | ||
| 190 | die_if_kernel("BAD KERNEL TRAP", &fp->ptregs, 0); | ||
| 191 | } | ||
| 192 | |||
| 193 | asmlinkage void trap_c(struct frame *fp) | ||
| 194 | { | ||
| 195 | int sig; | ||
| 196 | int vector = (fp->ptregs.vector >> 2) & 0xff; | ||
| 197 | siginfo_t info; | ||
| 198 | |||
| 199 | if (fp->ptregs.sr & PS_S) { | ||
| 200 | if (vector == VEC_TRACE) { | ||
| 201 | /* traced a trapping instruction */ | ||
| 202 | } else | ||
| 203 | bad_super_trap(fp); | ||
| 204 | return; | ||
| 205 | } | ||
| 206 | |||
| 207 | /* send the appropriate signal to the user program */ | ||
| 208 | switch (vector) { | ||
| 209 | case VEC_ADDRERR: | ||
| 210 | info.si_code = BUS_ADRALN; | ||
| 211 | sig = SIGBUS; | ||
| 212 | break; | ||
| 213 | case VEC_ILLEGAL: | ||
| 214 | case VEC_LINE10: | ||
| 215 | case VEC_LINE11: | ||
| 216 | info.si_code = ILL_ILLOPC; | ||
| 217 | sig = SIGILL; | ||
| 218 | break; | ||
| 219 | case VEC_PRIV: | ||
| 220 | info.si_code = ILL_PRVOPC; | ||
| 221 | sig = SIGILL; | ||
| 222 | break; | ||
| 223 | case VEC_COPROC: | ||
| 224 | info.si_code = ILL_COPROC; | ||
| 225 | sig = SIGILL; | ||
| 226 | break; | ||
| 227 | case VEC_TRAP1: /* gdbserver breakpoint */ | ||
| 228 | fp->ptregs.pc -= 2; | ||
| 229 | info.si_code = TRAP_TRACE; | ||
| 230 | sig = SIGTRAP; | ||
| 231 | break; | ||
| 232 | case VEC_TRAP2: | ||
| 233 | case VEC_TRAP3: | ||
| 234 | case VEC_TRAP4: | ||
| 235 | case VEC_TRAP5: | ||
| 236 | case VEC_TRAP6: | ||
| 237 | case VEC_TRAP7: | ||
| 238 | case VEC_TRAP8: | ||
| 239 | case VEC_TRAP9: | ||
| 240 | case VEC_TRAP10: | ||
| 241 | case VEC_TRAP11: | ||
| 242 | case VEC_TRAP12: | ||
| 243 | case VEC_TRAP13: | ||
| 244 | case VEC_TRAP14: | ||
| 245 | info.si_code = ILL_ILLTRP; | ||
| 246 | sig = SIGILL; | ||
| 247 | break; | ||
| 248 | case VEC_FPBRUC: | ||
| 249 | case VEC_FPOE: | ||
| 250 | case VEC_FPNAN: | ||
| 251 | info.si_code = FPE_FLTINV; | ||
| 252 | sig = SIGFPE; | ||
| 253 | break; | ||
| 254 | case VEC_FPIR: | ||
| 255 | info.si_code = FPE_FLTRES; | ||
| 256 | sig = SIGFPE; | ||
| 257 | break; | ||
| 258 | case VEC_FPDIVZ: | ||
| 259 | info.si_code = FPE_FLTDIV; | ||
| 260 | sig = SIGFPE; | ||
| 261 | break; | ||
| 262 | case VEC_FPUNDER: | ||
| 263 | info.si_code = FPE_FLTUND; | ||
| 264 | sig = SIGFPE; | ||
| 265 | break; | ||
| 266 | case VEC_FPOVER: | ||
| 267 | info.si_code = FPE_FLTOVF; | ||
| 268 | sig = SIGFPE; | ||
| 269 | break; | ||
| 270 | case VEC_ZERODIV: | ||
| 271 | info.si_code = FPE_INTDIV; | ||
| 272 | sig = SIGFPE; | ||
| 273 | break; | ||
| 274 | case VEC_CHK: | ||
| 275 | case VEC_TRAP: | ||
| 276 | info.si_code = FPE_INTOVF; | ||
| 277 | sig = SIGFPE; | ||
| 278 | break; | ||
| 279 | case VEC_TRACE: /* ptrace single step */ | ||
| 280 | info.si_code = TRAP_TRACE; | ||
| 281 | sig = SIGTRAP; | ||
| 282 | break; | ||
| 283 | case VEC_TRAP15: /* breakpoint */ | ||
| 284 | info.si_code = TRAP_BRKPT; | ||
| 285 | sig = SIGTRAP; | ||
| 286 | break; | ||
| 287 | default: | ||
| 288 | info.si_code = ILL_ILLOPC; | ||
| 289 | sig = SIGILL; | ||
| 290 | break; | ||
| 291 | } | ||
| 292 | info.si_signo = sig; | ||
| 293 | info.si_errno = 0; | ||
| 294 | switch (fp->ptregs.format) { | ||
| 295 | default: | ||
| 296 | info.si_addr = (void *) fp->ptregs.pc; | ||
| 297 | break; | ||
| 298 | case 2: | ||
| 299 | info.si_addr = (void *) fp->un.fmt2.iaddr; | ||
| 300 | break; | ||
| 301 | case 7: | ||
| 302 | info.si_addr = (void *) fp->un.fmt7.effaddr; | ||
| 303 | break; | ||
| 304 | case 9: | ||
| 305 | info.si_addr = (void *) fp->un.fmt9.iaddr; | ||
| 306 | break; | ||
| 307 | case 10: | ||
| 308 | info.si_addr = (void *) fp->un.fmta.daddr; | ||
| 309 | break; | ||
| 310 | case 11: | ||
| 311 | info.si_addr = (void *) fp->un.fmtb.daddr; | ||
| 312 | break; | ||
| 313 | } | ||
| 314 | force_sig_info (sig, &info, current); | ||
| 315 | } | ||
| 316 | |||
| 317 | asmlinkage void set_esp0(unsigned long ssp) | ||
| 318 | { | ||
| 319 | current->thread.esp0 = ssp; | ||
| 320 | } | ||
| 321 | |||
| 322 | /* | ||
| 323 | * The architecture-independent backtrace generator | ||
| 324 | */ | ||
| 325 | void dump_stack(void) | ||
| 326 | { | ||
| 327 | /* | ||
| 328 | * We need frame pointers for this little trick, which works as follows: | ||
| 329 | * | ||
| 330 | * +------------+ 0x00 | ||
| 331 | * | Next SP | -> 0x0c | ||
| 332 | * +------------+ 0x04 | ||
| 333 | * | Caller | | ||
| 334 | * +------------+ 0x08 | ||
| 335 | * | Local vars | -> our stack var | ||
| 336 | * +------------+ 0x0c | ||
| 337 | * | Next SP | -> 0x18, that is what we pass to show_stack() | ||
| 338 | * +------------+ 0x10 | ||
| 339 | * | Caller | | ||
| 340 | * +------------+ 0x14 | ||
| 341 | * | Local vars | | ||
| 342 | * +------------+ 0x18 | ||
| 343 | * | ... | | ||
| 344 | * +------------+ | ||
| 345 | */ | ||
| 346 | |||
| 347 | unsigned long *stack; | ||
| 348 | |||
| 349 | stack = (unsigned long *)&stack; | ||
| 350 | stack++; | ||
| 351 | __show_stack(current, stack); | ||
| 352 | } | ||
| 353 | EXPORT_SYMBOL(dump_stack); | ||
| 354 | |||
| 355 | void show_stack(struct task_struct *task, unsigned long *stack) | ||
| 356 | { | ||
| 357 | if (!stack && !task) | ||
| 358 | dump_stack(); | ||
| 359 | else | ||
| 360 | __show_stack(task, stack); | ||
| 361 | } | ||
diff --git a/arch/m68k/kernel/vectors.c b/arch/m68k/kernel/vectors.c new file mode 100644 index 000000000000..147b03fbc71e --- /dev/null +++ b/arch/m68k/kernel/vectors.c | |||
| @@ -0,0 +1,145 @@ | |||
| 1 | /* | ||
| 2 | * vectors.c | ||
| 3 | * | ||
| 4 | * Copyright (C) 1993, 1994 by Hamish Macdonald | ||
| 5 | * | ||
| 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 | ||
| 11 | * | ||
| 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 | ||
| 14 | * for more details. | ||
| 15 | */ | ||
| 16 | |||
| 17 | /* | ||
| 18 | * Sets up all exception vectors | ||
| 19 | */ | ||
| 20 | #include <linux/sched.h> | ||
| 21 | #include <linux/kernel.h> | ||
| 22 | #include <linux/linkage.h> | ||
| 23 | #include <linux/init.h> | ||
| 24 | #include <linux/kallsyms.h> | ||
| 25 | |||
| 26 | #include <asm/setup.h> | ||
| 27 | #include <asm/fpu.h> | ||
| 28 | #include <asm/system.h> | ||
| 29 | #include <asm/traps.h> | ||
| 30 | |||
| 31 | /* assembler routines */ | ||
| 32 | asmlinkage void system_call(void); | ||
| 33 | asmlinkage void buserr(void); | ||
| 34 | asmlinkage void trap(void); | ||
| 35 | asmlinkage void nmihandler(void); | ||
| 36 | #ifdef CONFIG_M68KFPU_EMU | ||
| 37 | asmlinkage void fpu_emu(void); | ||
| 38 | #endif | ||
| 39 | |||
| 40 | e_vector vectors[256]; | ||
| 41 | |||
| 42 | /* nmi handler for the Amiga */ | ||
| 43 | asm(".text\n" | ||
| 44 | __ALIGN_STR "\n" | ||
| 45 | "nmihandler: rte"); | ||
| 46 | |||
| 47 | /* | ||
| 48 | * this must be called very early as the kernel might | ||
| 49 | * use some instruction that are emulated on the 060 | ||
| 50 | * and so we're prepared for early probe attempts (e.g. nf_init). | ||
| 51 | */ | ||
| 52 | void __init base_trap_init(void) | ||
| 53 | { | ||
| 54 | if (MACH_IS_SUN3X) { | ||
| 55 | extern e_vector *sun3x_prom_vbr; | ||
| 56 | |||
| 57 | __asm__ volatile ("movec %%vbr, %0" : "=r" (sun3x_prom_vbr)); | ||
| 58 | } | ||
| 59 | |||
| 60 | /* setup the exception vector table */ | ||
| 61 | __asm__ volatile ("movec %0,%%vbr" : : "r" ((void*)vectors)); | ||
| 62 | |||
| 63 | if (CPU_IS_060) { | ||
| 64 | /* set up ISP entry points */ | ||
| 65 | asmlinkage void unimp_vec(void) asm ("_060_isp_unimp"); | ||
| 66 | |||
| 67 | vectors[VEC_UNIMPII] = unimp_vec; | ||
| 68 | } | ||
| 69 | |||
| 70 | vectors[VEC_BUSERR] = buserr; | ||
| 71 | vectors[VEC_ILLEGAL] = trap; | ||
| 72 | vectors[VEC_SYS] = system_call; | ||
| 73 | } | ||
| 74 | |||
| 75 | void __init trap_init (void) | ||
| 76 | { | ||
| 77 | int i; | ||
| 78 | |||
| 79 | for (i = VEC_SPUR; i <= VEC_INT7; i++) | ||
| 80 | vectors[i] = bad_inthandler; | ||
| 81 | |||
| 82 | for (i = 0; i < VEC_USER; i++) | ||
| 83 | if (!vectors[i]) | ||
| 84 | vectors[i] = trap; | ||
| 85 | |||
| 86 | for (i = VEC_USER; i < 256; i++) | ||
| 87 | vectors[i] = bad_inthandler; | ||
| 88 | |||
| 89 | #ifdef CONFIG_M68KFPU_EMU | ||
| 90 | if (FPU_IS_EMU) | ||
| 91 | vectors[VEC_LINE11] = fpu_emu; | ||
| 92 | #endif | ||
| 93 | |||
| 94 | if (CPU_IS_040 && !FPU_IS_EMU) { | ||
| 95 | /* set up FPSP entry points */ | ||
| 96 | asmlinkage void dz_vec(void) asm ("dz"); | ||
| 97 | asmlinkage void inex_vec(void) asm ("inex"); | ||
| 98 | asmlinkage void ovfl_vec(void) asm ("ovfl"); | ||
| 99 | asmlinkage void unfl_vec(void) asm ("unfl"); | ||
| 100 | asmlinkage void snan_vec(void) asm ("snan"); | ||
| 101 | asmlinkage void operr_vec(void) asm ("operr"); | ||
| 102 | asmlinkage void bsun_vec(void) asm ("bsun"); | ||
| 103 | asmlinkage void fline_vec(void) asm ("fline"); | ||
| 104 | asmlinkage void unsupp_vec(void) asm ("unsupp"); | ||
| 105 | |||
| 106 | vectors[VEC_FPDIVZ] = dz_vec; | ||
| 107 | vectors[VEC_FPIR] = inex_vec; | ||
| 108 | vectors[VEC_FPOVER] = ovfl_vec; | ||
| 109 | vectors[VEC_FPUNDER] = unfl_vec; | ||
| 110 | vectors[VEC_FPNAN] = snan_vec; | ||
| 111 | vectors[VEC_FPOE] = operr_vec; | ||
| 112 | vectors[VEC_FPBRUC] = bsun_vec; | ||
| 113 | vectors[VEC_LINE11] = fline_vec; | ||
| 114 | vectors[VEC_FPUNSUP] = unsupp_vec; | ||
| 115 | } | ||
| 116 | |||
| 117 | if (CPU_IS_060 && !FPU_IS_EMU) { | ||
| 118 | /* set up IFPSP entry points */ | ||
| 119 | asmlinkage void snan_vec6(void) asm ("_060_fpsp_snan"); | ||
| 120 | asmlinkage void operr_vec6(void) asm ("_060_fpsp_operr"); | ||
| 121 | asmlinkage void ovfl_vec6(void) asm ("_060_fpsp_ovfl"); | ||
| 122 | asmlinkage void unfl_vec6(void) asm ("_060_fpsp_unfl"); | ||
| 123 | asmlinkage void dz_vec6(void) asm ("_060_fpsp_dz"); | ||
| 124 | asmlinkage void inex_vec6(void) asm ("_060_fpsp_inex"); | ||
| 125 | asmlinkage void fline_vec6(void) asm ("_060_fpsp_fline"); | ||
| 126 | asmlinkage void unsupp_vec6(void) asm ("_060_fpsp_unsupp"); | ||
| 127 | asmlinkage void effadd_vec6(void) asm ("_060_fpsp_effadd"); | ||
| 128 | |||
| 129 | vectors[VEC_FPNAN] = snan_vec6; | ||
| 130 | vectors[VEC_FPOE] = operr_vec6; | ||
| 131 | vectors[VEC_FPOVER] = ovfl_vec6; | ||
| 132 | vectors[VEC_FPUNDER] = unfl_vec6; | ||
| 133 | vectors[VEC_FPDIVZ] = dz_vec6; | ||
| 134 | vectors[VEC_FPIR] = inex_vec6; | ||
| 135 | vectors[VEC_LINE11] = fline_vec6; | ||
| 136 | vectors[VEC_FPUNSUP] = unsupp_vec6; | ||
| 137 | vectors[VEC_UNIMPEA] = effadd_vec6; | ||
| 138 | } | ||
| 139 | |||
| 140 | /* if running on an amiga, make the NMI interrupt do nothing */ | ||
| 141 | if (MACH_IS_AMIGA) { | ||
| 142 | vectors[VEC_INT7] = nmihandler; | ||
| 143 | } | ||
| 144 | } | ||
| 145 | |||
diff --git a/arch/m68k/kernel/vmlinux.lds_no.S b/arch/m68k/kernel/vmlinux.lds_no.S index 7dc4087a9545..4e2389340837 100644 --- a/arch/m68k/kernel/vmlinux.lds_no.S +++ b/arch/m68k/kernel/vmlinux.lds_no.S | |||
| @@ -77,7 +77,6 @@ SECTIONS { | |||
| 77 | 77 | ||
| 78 | *(.rodata) *(.rodata.*) | 78 | *(.rodata) *(.rodata.*) |
| 79 | *(__vermagic) /* Kernel version magic */ | 79 | *(__vermagic) /* Kernel version magic */ |
| 80 | *(__markers_strings) | ||
| 81 | *(.rodata1) | 80 | *(.rodata1) |
| 82 | *(.rodata.str1.1) | 81 | *(.rodata.str1.1) |
| 83 | 82 | ||
