2 * Copyright (C) 2003 Maciej W. Rozycki
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 #include <linux/init.h>
10 #include <linux/kernel.h>
11 #include <linux/ptrace.h>
12 #include <linux/stddef.h>
17 #include <asm/mipsregs.h>
18 #include <asm/system.h>
20 static inline void check_mult_sh(void)
26 printk("Checking for the multiply/shift bug... ");
28 local_irq_save(flags
);
30 * The following code leads to a wrong result of dsll32 when
31 * executed on R4000 rev. 2.2 or 3.0.
33 * See "MIPS R4000PC/SC Errata, Processor Revision 2.2 and
34 * 3.0" by MIPS Technologies, Inc., errata #16 and #28 for
35 * details. I got no permission to duplicate them here,
44 "dsll32 %0, %3, %4\n\t"
48 : "r" (5), "r" (8), "r" (5), "I" (0)
49 : "hi", "lo", "accum");
50 local_irq_restore(flags
);
57 printk("yes, workaround... ");
58 local_irq_save(flags
);
60 * We want the multiply and the shift to be isolated from the
61 * rest of the code to disable gcc optimizations. Hence the
62 * asm statements that execute nothing, but make gcc not know
63 * what the values of m1, m2 and s are and what v and p are
66 * We have to use single integers for m1 and m2 and a double
67 * one for p to be sure the mulsidi3 gcc's RTL multiplication
68 * instruction has the workaround applied. Older versions of
69 * gcc have correct mulsi3, but other multiplication variants
70 * lack the workaround.
74 : "=r" (m1
), "=r" (m2
), "=r" (s
)
75 : "0" (5), "1" (8), "2" (5));
82 local_irq_restore(flags
);
90 panic("Reliable operation impossible!\n"
91 #ifndef CONFIG_CPU_R4000
92 "Configure for R4000 to enable the workaround."
94 "Please report to <linux-mips@linux-mips.org>."
99 static volatile int daddi_ov __initdata
= 0;
101 asmlinkage
void __init
do_daddi_ov(struct pt_regs
*regs
)
107 static inline void check_daddi(void)
109 extern asmlinkage
void handle_daddi_ov(void);
114 printk("Checking for the daddi bug... ");
116 local_irq_save(flags
);
117 handler
= set_except_vector(12, handle_daddi_ov
);
119 * The following code fails to trigger an overflow exception
120 * when executed on R4000 rev. 2.2 or 3.0.
122 * See "MIPS R4000PC/SC Errata, Processor Revision 2.2 and
123 * 3.0" by MIPS Technologies, Inc., erratum #23 for details.
124 * I got no permission to duplicate it here, sigh... --macro
131 #ifdef HAVE_AS_SET_DADDI
134 "daddi %0, %1, %2\n\t"
137 : "r" (0x7fffffffffffedcd), "I" (0x1234));
138 set_except_vector(12, handler
);
139 local_irq_restore(flags
);
146 printk("yes, workaround... ");
148 local_irq_save(flags
);
149 handler
= set_except_vector(12, handle_daddi_ov
);
153 : "r" (0x7fffffffffffedcd), "I" (0x1234));
154 set_except_vector(12, handler
);
155 local_irq_restore(flags
);
163 panic("Reliable operation impossible!\n"
164 #if !defined(CONFIG_CPU_R4000) && !defined(CONFIG_CPU_R4400)
165 "Configure for R4000 or R4400 to enable the workaround."
167 "Please report to <linux-mips@linux-mips.org>."
172 static inline void check_daddiu(void)
176 printk("Checking for the daddiu bug... ");
179 * The following code leads to a wrong result of daddiu when
180 * executed on R4400 rev. 1.0.
182 * See "MIPS R4400PC/SC Errata, Processor Revision 1.0" by
183 * MIPS Technologies, Inc., erratum #7 for details.
185 * According to "MIPS R4000PC/SC Errata, Processor Revision
186 * 2.2 and 3.0" by MIPS Technologies, Inc., erratum #41 this
187 * problem affects R4000 rev. 2.2 and 3.0, too. Testing
188 * failed to trigger it so far.
190 * I got no permission to duplicate the errata here, sigh...
198 #ifdef HAVE_AS_SET_DADDI
201 "daddiu %0, %2, %3\n\t"
202 "addiu %1, $0, %3\n\t"
205 : "=&r" (v
), "=&r" (w
)
206 : "r" (0x7fffffffffffedcd), "I" (0x1234));
213 printk("yes, workaround... ");
216 "daddiu %0, %2, %3\n\t"
217 "addiu %1, $0, %3\n\t"
219 : "=&r" (v
), "=&r" (w
)
220 : "r" (0x7fffffffffffedcd), "I" (0x1234));
228 panic("Reliable operation impossible!\n"
229 #if !defined(CONFIG_CPU_R4000) && !defined(CONFIG_CPU_R4400)
230 "Configure for R4000 or R4400 to enable the workaround."
232 "Please report to <linux-mips@linux-mips.org>."
237 void __init
check_bugs64(void)