Merge branch 'core/printk' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux...
[deliverable/linux.git] / arch / x86 / kernel / traps_64.c
CommitLineData
1da177e4 1/*
1da177e4
LT
2 * Copyright (C) 1991, 1992 Linus Torvalds
3 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
4 *
5 * Pentium III FXSR, SSE support
6 * Gareth Hughes <gareth@valinux.com>, May 2000
1da177e4
LT
7 */
8
9/*
10 * 'Traps.c' handles hardware traps and faults after we have saved some
11 * state in 'entry.S'.
12 */
badc7652
AH
13#include <linux/moduleparam.h>
14#include <linux/interrupt.h>
15#include <linux/kallsyms.h>
16#include <linux/spinlock.h>
17#include <linux/kprobes.h>
18#include <linux/uaccess.h>
19#include <linux/utsname.h>
20#include <linux/kdebug.h>
1da177e4 21#include <linux/kernel.h>
badc7652
AH
22#include <linux/module.h>
23#include <linux/ptrace.h>
1da177e4 24#include <linux/string.h>
badc7652
AH
25#include <linux/unwind.h>
26#include <linux/delay.h>
1da177e4 27#include <linux/errno.h>
badc7652
AH
28#include <linux/kexec.h>
29#include <linux/sched.h>
1da177e4 30#include <linux/timer.h>
1da177e4 31#include <linux/init.h>
c31a0bf3 32#include <linux/bug.h>
badc7652
AH
33#include <linux/nmi.h>
34#include <linux/mm.h>
e32ede19 35
c0d12172
DJ
36#if defined(CONFIG_EDAC)
37#include <linux/edac.h>
38#endif
39
badc7652
AH
40#include <asm/stacktrace.h>
41#include <asm/processor.h>
1da177e4 42#include <asm/debugreg.h>
badc7652
AH
43#include <asm/atomic.h>
44#include <asm/system.h>
45#include <asm/unwind.h>
1da177e4
LT
46#include <asm/desc.h>
47#include <asm/i387.h>
badc7652 48#include <asm/nmi.h>
1da177e4 49#include <asm/smp.h>
badc7652 50#include <asm/io.h>
1da177e4 51#include <asm/pgalloc.h>
1da177e4 52#include <asm/proto.h>
badc7652
AH
53#include <asm/pda.h>
54
55#include <mach_traps.h>
1da177e4 56
1da177e4
LT
57asmlinkage void divide_error(void);
58asmlinkage void debug(void);
59asmlinkage void nmi(void);
60asmlinkage void int3(void);
61asmlinkage void overflow(void);
62asmlinkage void bounds(void);
63asmlinkage void invalid_op(void);
64asmlinkage void device_not_available(void);
65asmlinkage void double_fault(void);
66asmlinkage void coprocessor_segment_overrun(void);
67asmlinkage void invalid_TSS(void);
68asmlinkage void segment_not_present(void);
69asmlinkage void stack_segment(void);
70asmlinkage void general_protection(void);
71asmlinkage void page_fault(void);
72asmlinkage void coprocessor_error(void);
73asmlinkage void simd_coprocessor_error(void);
1da177e4 74asmlinkage void alignment_check(void);
1da177e4 75asmlinkage void spurious_interrupt_bug(void);
badc7652 76asmlinkage void machine_check(void);
1da177e4 77
c6425b9f 78int panic_on_unrecovered_nmi;
badc7652 79int kstack_depth_to_print = 12;
a25bd949 80static unsigned int code_bytes = 64;
badc7652
AH
81static int ignore_nmis;
82static int die_counter;
a25bd949 83
1da177e4
LT
84static inline void conditional_sti(struct pt_regs *regs)
85{
65ea5b03 86 if (regs->flags & X86_EFLAGS_IF)
1da177e4
LT
87 local_irq_enable();
88}
89
a65d17c9
JB
90static inline void preempt_conditional_sti(struct pt_regs *regs)
91{
e8bff74a 92 inc_preempt_count();
65ea5b03 93 if (regs->flags & X86_EFLAGS_IF)
a65d17c9
JB
94 local_irq_enable();
95}
96
97static inline void preempt_conditional_cli(struct pt_regs *regs)
98{
65ea5b03 99 if (regs->flags & X86_EFLAGS_IF)
a65d17c9 100 local_irq_disable();
40e59a61
AK
101 /* Make sure to not schedule here because we could be running
102 on an exception stack. */
e8bff74a 103 dec_preempt_count();
a65d17c9
JB
104}
105
bc850d6b 106void printk_address(unsigned long address, int reliable)
3ac94932 107{
7daf705f 108 printk(" [<%016lx>] %s%pS\n", address, reliable ? "": "? ", (void *) address);
a5ff677c 109}
1da177e4 110
0a658002 111static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
c0b766f1 112 unsigned *usedp, char **idp)
0a658002 113{
b556b35e 114 static char ids[][8] = {
0a658002
AK
115 [DEBUG_STACK - 1] = "#DB",
116 [NMI_STACK - 1] = "NMI",
117 [DOUBLEFAULT_STACK - 1] = "#DF",
118 [STACKFAULT_STACK - 1] = "#SS",
119 [MCE_STACK - 1] = "#MC",
b556b35e
JB
120#if DEBUG_STKSZ > EXCEPTION_STKSZ
121 [N_EXCEPTION_STACKS ... N_EXCEPTION_STACKS + DEBUG_STKSZ / EXCEPTION_STKSZ - 2] = "#DB[?]"
122#endif
0a658002
AK
123 };
124 unsigned k;
1da177e4 125
c9ca1ba5
IM
126 /*
127 * Iterate over all exception stacks, and figure out whether
128 * 'stack' is in one of them:
129 */
0a658002 130 for (k = 0; k < N_EXCEPTION_STACKS; k++) {
f5741644 131 unsigned long end = per_cpu(orig_ist, cpu).ist[k];
c9ca1ba5
IM
132 /*
133 * Is 'stack' above this exception frame's end?
134 * If yes then skip to the next frame.
135 */
0a658002
AK
136 if (stack >= end)
137 continue;
c9ca1ba5
IM
138 /*
139 * Is 'stack' above this exception frame's start address?
140 * If yes then we found the right frame.
141 */
0a658002 142 if (stack >= end - EXCEPTION_STKSZ) {
c9ca1ba5
IM
143 /*
144 * Make sure we only iterate through an exception
145 * stack once. If it comes up for the second time
146 * then there's something wrong going on - just
147 * break out and return NULL:
148 */
0a658002
AK
149 if (*usedp & (1U << k))
150 break;
151 *usedp |= 1U << k;
152 *idp = ids[k];
153 return (unsigned long *)end;
154 }
c9ca1ba5
IM
155 /*
156 * If this is a debug stack, and if it has a larger size than
157 * the usual exception stacks, then 'stack' might still
158 * be within the lower portion of the debug stack:
159 */
b556b35e
JB
160#if DEBUG_STKSZ > EXCEPTION_STKSZ
161 if (k == DEBUG_STACK - 1 && stack >= end - DEBUG_STKSZ) {
162 unsigned j = N_EXCEPTION_STACKS - 1;
163
c9ca1ba5
IM
164 /*
165 * Black magic. A large debug stack is composed of
166 * multiple exception stack entries, which we
167 * iterate through now. Dont look:
168 */
b556b35e
JB
169 do {
170 ++j;
171 end -= EXCEPTION_STKSZ;
172 ids[j][4] = '1' + (j - N_EXCEPTION_STACKS);
173 } while (stack < end - EXCEPTION_STKSZ);
174 if (*usedp & (1U << j))
175 break;
176 *usedp |= 1U << j;
177 *idp = ids[j];
178 return (unsigned long *)end;
179 }
180#endif
1da177e4
LT
181 }
182 return NULL;
0a658002 183}
1da177e4
LT
184
185/*
676b1855 186 * x86-64 can have up to three kernel stacks:
1da177e4
LT
187 * process stack
188 * interrupt stack
0a658002 189 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
1da177e4
LT
190 */
191
e4a94568
AV
192static inline int valid_stack_ptr(struct thread_info *tinfo,
193 void *p, unsigned int size, void *end)
c547c77e 194{
ade1af77 195 void *t = tinfo;
e4a94568
AV
196 if (end) {
197 if (p < end && p >= (end-THREAD_SIZE))
198 return 1;
199 else
200 return 0;
201 }
202 return p > t && p < t + THREAD_SIZE - size;
203}
204
80b51f31
AV
205/* The form of the top of the frame on the stack */
206struct stack_frame {
207 struct stack_frame *next_frame;
208 unsigned long return_address;
209};
210
a8c1be9d
AH
211static inline unsigned long
212print_context_stack(struct thread_info *tinfo,
213 unsigned long *stack, unsigned long bp,
214 const struct stacktrace_ops *ops, void *data,
215 unsigned long *end)
e4a94568 216{
80b51f31
AV
217 struct stack_frame *frame = (struct stack_frame *)bp;
218
219 while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
220 unsigned long addr;
221
222 addr = *stack;
e4a94568 223 if (__kernel_text_address(addr)) {
80b51f31
AV
224 if ((unsigned long) stack == bp + 8) {
225 ops->address(data, addr, 1);
226 frame = frame->next_frame;
227 bp = (unsigned long) frame;
228 } else {
229 ops->address(data, addr, bp == 0);
230 }
e4a94568 231 }
80b51f31 232 stack++;
e4a94568
AV
233 }
234 return bp;
c547c77e
AK
235}
236
a8c1be9d 237void dump_trace(struct task_struct *task, struct pt_regs *regs,
bc850d6b 238 unsigned long *stack, unsigned long bp,
9689ba8a 239 const struct stacktrace_ops *ops, void *data)
1da177e4 240{
da68933e 241 const unsigned cpu = get_cpu();
b615ebda 242 unsigned long *irqstack_end = (unsigned long*)cpu_pda(cpu)->irqstackptr;
0a658002 243 unsigned used = 0;
c547c77e 244 struct thread_info *tinfo;
1da177e4 245
a8c1be9d
AH
246 if (!task)
247 task = current;
b538ed27 248
c0b766f1
AK
249 if (!stack) {
250 unsigned long dummy;
251 stack = &dummy;
a8c1be9d
AH
252 if (task && task != current)
253 stack = (unsigned long *)task->thread.sp;
b538ed27
JB
254 }
255
80b51f31
AV
256#ifdef CONFIG_FRAME_POINTER
257 if (!bp) {
a8c1be9d 258 if (task == current) {
80b51f31 259 /* Grab bp right from our regs */
a8c1be9d 260 asm("movq %%rbp, %0" : "=r" (bp) :);
80b51f31
AV
261 } else {
262 /* bp is the last reg pushed by switch_to */
a8c1be9d 263 bp = *(unsigned long *) task->thread.sp;
80b51f31
AV
264 }
265 }
266#endif
267
c9ca1ba5
IM
268 /*
269 * Print function call entries in all stacks, starting at the
270 * current stack address. If the stacks consist of nested
271 * exceptions
272 */
7b4fd4bb 273 tinfo = task_thread_info(task);
c0b766f1
AK
274 for (;;) {
275 char *id;
0a658002
AK
276 unsigned long *estack_end;
277 estack_end = in_exception_stack(cpu, (unsigned long)stack,
278 &used, &id);
279
280 if (estack_end) {
c0b766f1
AK
281 if (ops->stack(data, id) < 0)
282 break;
e4a94568 283
80b51f31
AV
284 bp = print_context_stack(tinfo, stack, bp, ops,
285 data, estack_end);
c0b766f1 286 ops->stack(data, "<EOE>");
c9ca1ba5
IM
287 /*
288 * We link to the next stack via the
289 * second-to-last pointer (index -2 to end) in the
290 * exception stack:
291 */
0a658002
AK
292 stack = (unsigned long *) estack_end[-2];
293 continue;
1da177e4 294 }
0a658002
AK
295 if (irqstack_end) {
296 unsigned long *irqstack;
297 irqstack = irqstack_end -
298 (IRQSTACKSIZE - 64) / sizeof(*irqstack);
299
300 if (stack >= irqstack && stack < irqstack_end) {
c0b766f1
AK
301 if (ops->stack(data, "IRQ") < 0)
302 break;
80b51f31
AV
303 bp = print_context_stack(tinfo, stack, bp,
304 ops, data, irqstack_end);
c9ca1ba5
IM
305 /*
306 * We link to the next stack (which would be
307 * the process stack normally) the last
308 * pointer (index -1 to end) in the IRQ stack:
309 */
0a658002
AK
310 stack = (unsigned long *) (irqstack_end[-1]);
311 irqstack_end = NULL;
c0b766f1 312 ops->stack(data, "EOI");
0a658002 313 continue;
1da177e4 314 }
1da177e4 315 }
0a658002 316 break;
1da177e4 317 }
0a658002 318
c9ca1ba5 319 /*
c0b766f1 320 * This handles the process stack:
c9ca1ba5 321 */
80b51f31 322 bp = print_context_stack(tinfo, stack, bp, ops, data, NULL);
da68933e 323 put_cpu();
c0b766f1
AK
324}
325EXPORT_SYMBOL(dump_trace);
326
327static void
328print_trace_warning_symbol(void *data, char *msg, unsigned long symbol)
329{
330 print_symbol(msg, symbol);
331 printk("\n");
332}
333
334static void print_trace_warning(void *data, char *msg)
335{
336 printk("%s\n", msg);
337}
338
339static int print_trace_stack(void *data, char *name)
340{
341 printk(" <%s> ", name);
342 return 0;
343}
3ac94932 344
bc850d6b 345static void print_trace_address(void *data, unsigned long addr, int reliable)
c0b766f1 346{
1c978b93 347 touch_nmi_watchdog();
bc850d6b 348 printk_address(addr, reliable);
c0b766f1
AK
349}
350
9689ba8a 351static const struct stacktrace_ops print_trace_ops = {
c0b766f1
AK
352 .warning = print_trace_warning,
353 .warning_symbol = print_trace_warning_symbol,
354 .stack = print_trace_stack,
355 .address = print_trace_address,
356};
357
a8c1be9d
AH
358void show_trace(struct task_struct *task, struct pt_regs *regs,
359 unsigned long *stack, unsigned long bp)
c0b766f1
AK
360{
361 printk("\nCall Trace:\n");
a8c1be9d 362 dump_trace(task, regs, stack, bp, &print_trace_ops, NULL);
1da177e4
LT
363 printk("\n");
364}
365
c0b766f1 366static void
a8c1be9d
AH
367_show_stack(struct task_struct *task, struct pt_regs *regs,
368 unsigned long *sp, unsigned long bp)
1da177e4
LT
369{
370 unsigned long *stack;
371 int i;
151f8cc1 372 const int cpu = smp_processor_id();
df79efde
RT
373 unsigned long *irqstack_end = (unsigned long *) (cpu_pda(cpu)->irqstackptr);
374 unsigned long *irqstack = (unsigned long *) (cpu_pda(cpu)->irqstackptr - IRQSTACKSIZE);
1da177e4
LT
375
376 // debugging aid: "show_stack(NULL, NULL);" prints the
377 // back trace for this cpu.
378
65ea5b03 379 if (sp == NULL) {
a8c1be9d
AH
380 if (task)
381 sp = (unsigned long *)task->thread.sp;
1da177e4 382 else
65ea5b03 383 sp = (unsigned long *)&sp;
1da177e4
LT
384 }
385
65ea5b03 386 stack = sp;
a8c1be9d 387 for (i = 0; i < kstack_depth_to_print; i++) {
1da177e4
LT
388 if (stack >= irqstack && stack <= irqstack_end) {
389 if (stack == irqstack_end) {
390 stack = (unsigned long *) (irqstack_end[-1]);
391 printk(" <EOI> ");
392 }
393 } else {
394 if (((long) stack & (THREAD_SIZE-1)) == 0)
395 break;
396 }
397 if (i && ((i % 4) == 0))
3ac94932
IM
398 printk("\n");
399 printk(" %016lx", *stack++);
35faa714 400 touch_nmi_watchdog();
1da177e4 401 }
a8c1be9d 402 show_trace(task, regs, sp, bp);
b538ed27
JB
403}
404
a8c1be9d 405void show_stack(struct task_struct *task, unsigned long *sp)
b538ed27 406{
a8c1be9d 407 _show_stack(task, NULL, sp, 0);
1da177e4
LT
408}
409
410/*
411 * The architecture-independent dump_stack generator
412 */
413void dump_stack(void)
414{
bc850d6b 415 unsigned long bp = 0;
7b4fd4bb 416 unsigned long stack;
57c351de 417
80b51f31
AV
418#ifdef CONFIG_FRAME_POINTER
419 if (!bp)
420 asm("movq %%rbp, %0" : "=r" (bp):);
421#endif
422
57c351de
AV
423 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
424 current->pid, current->comm, print_tainted(),
425 init_utsname()->release,
426 (int)strcspn(init_utsname()->version, " "),
427 init_utsname()->version);
a8c1be9d 428 show_trace(NULL, NULL, &stack, bp);
1da177e4
LT
429}
430
431EXPORT_SYMBOL(dump_stack);
432
433void show_registers(struct pt_regs *regs)
434{
435 int i;
65ea5b03 436 unsigned long sp;
151f8cc1 437 const int cpu = smp_processor_id();
df79efde 438 struct task_struct *cur = cpu_pda(cpu)->pcurrent;
1da177e4 439
65ea5b03 440 sp = regs->sp;
1da177e4
LT
441 printk("CPU %d ", cpu);
442 __show_regs(regs);
443 printk("Process %s (pid: %d, threadinfo %p, task %p)\n",
e4f17c43 444 cur->comm, cur->pid, task_thread_info(cur), cur);
1da177e4
LT
445
446 /*
447 * When in-kernel, we also print out the stack and code at the
448 * time of the fault..
449 */
a25bd949 450 if (!user_mode(regs)) {
7b4fd4bb
AH
451 unsigned int code_prologue = code_bytes * 43 / 64;
452 unsigned int code_len = code_bytes;
a25bd949 453 unsigned char c;
7b4fd4bb
AH
454 u8 *ip;
455
1da177e4 456 printk("Stack: ");
bc850d6b 457 _show_stack(NULL, regs, (unsigned long *)sp, regs->bp);
a25bd949 458 printk("\n");
1da177e4 459
a25bd949 460 printk(KERN_EMERG "Code: ");
7b4fd4bb
AH
461
462 ip = (u8 *)regs->ip - code_prologue;
a25bd949
AV
463 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
464 /* try starting at RIP */
a8c1be9d 465 ip = (u8 *)regs->ip;
a25bd949
AV
466 code_len = code_len - code_prologue + 1;
467 }
468 for (i = 0; i < code_len; i++, ip++) {
469 if (ip < (u8 *)PAGE_OFFSET ||
470 probe_kernel_address(ip, c)) {
1da177e4
LT
471 printk(" Bad RIP value.");
472 break;
473 }
a25bd949
AV
474 if (ip == (u8 *)regs->ip)
475 printk("<%02x> ", c);
476 else
477 printk("%02x ", c);
1da177e4
LT
478 }
479 }
480 printk("\n");
a8c1be9d 481}
1da177e4 482
65ea5b03 483int is_valid_bugaddr(unsigned long ip)
c31a0bf3
JF
484{
485 unsigned short ud2;
486
65ea5b03 487 if (__copy_from_user(&ud2, (const void __user *) ip, sizeof(ud2)))
c31a0bf3
JF
488 return 0;
489
490 return ud2 == 0x0b0f;
491}
1da177e4 492
39743c9e 493static raw_spinlock_t die_lock = __RAW_SPIN_LOCK_UNLOCKED;
1da177e4 494static int die_owner = -1;
cdc60a4c 495static unsigned int die_nest_count;
1da177e4 496
eddb6fb9 497unsigned __kprobes long oops_begin(void)
1da177e4 498{
b39b7036 499 int cpu;
1209140c
JB
500 unsigned long flags;
501
abf0f109
AM
502 oops_enter();
503
1209140c 504 /* racy, but better than risking deadlock. */
39743c9e 505 raw_local_irq_save(flags);
b39b7036 506 cpu = smp_processor_id();
39743c9e 507 if (!__raw_spin_trylock(&die_lock)) {
1da177e4
LT
508 if (cpu == die_owner)
509 /* nested oops. should stop eventually */;
510 else
39743c9e 511 __raw_spin_lock(&die_lock);
1da177e4 512 }
cdc60a4c 513 die_nest_count++;
1209140c 514 die_owner = cpu;
1da177e4 515 console_verbose();
1209140c
JB
516 bust_spinlocks(1);
517 return flags;
1da177e4
LT
518}
519
22f5991c 520void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
1da177e4
LT
521{
522 die_owner = -1;
1209140c 523 bust_spinlocks(0);
cdc60a4c 524 die_nest_count--;
39743c9e 525 if (!die_nest_count)
cdc60a4c 526 /* Nest count reaches zero, release the lock. */
39743c9e
AK
527 __raw_spin_unlock(&die_lock);
528 raw_local_irq_restore(flags);
22f5991c
JB
529 if (!regs) {
530 oops_exit();
531 return;
532 }
1da177e4 533 if (panic_on_oops)
012c437d 534 panic("Fatal exception");
abf0f109 535 oops_exit();
22f5991c 536 do_exit(signr);
1209140c 537}
1da177e4 538
e423f49f 539int __kprobes __die(const char *str, struct pt_regs *regs, long err)
1da177e4 540{
e423f49f 541 printk(KERN_EMERG "%s: %04lx [%u] ", str, err & 0xffff, ++die_counter);
1da177e4
LT
542#ifdef CONFIG_PREEMPT
543 printk("PREEMPT ");
544#endif
545#ifdef CONFIG_SMP
546 printk("SMP ");
547#endif
548#ifdef CONFIG_DEBUG_PAGEALLOC
549 printk("DEBUG_PAGEALLOC");
550#endif
551 printk("\n");
a8c1be9d
AH
552 if (notify_die(DIE_OOPS, str, regs, err,
553 current->thread.trap_no, SIGSEGV) == NOTIFY_STOP)
22f5991c 554 return 1;
a8c1be9d 555
1da177e4 556 show_registers(regs);
bcdcd8e7 557 add_taint(TAINT_DIE);
1da177e4
LT
558 /* Executive summary in case the oops scrolled away */
559 printk(KERN_ALERT "RIP ");
aafbd7eb 560 printk_address(regs->ip, 1);
65ea5b03 561 printk(" RSP <%016lx>\n", regs->sp);
8bcc5280
VG
562 if (kexec_should_crash(current))
563 crash_kexec(regs);
22f5991c 564 return 0;
1da177e4
LT
565}
566
7b4fd4bb 567void die(const char *str, struct pt_regs *regs, long err)
1da177e4 568{
1209140c
JB
569 unsigned long flags = oops_begin();
570
c31a0bf3 571 if (!user_mode(regs))
65ea5b03 572 report_bug(regs->ip, regs);
c31a0bf3 573
22f5991c
JB
574 if (__die(str, regs, err))
575 regs = NULL;
576 oops_end(flags, regs, SIGSEGV);
1da177e4 577}
1da177e4 578
5deb45e3
SR
579notrace __kprobes void
580die_nmi(char *str, struct pt_regs *regs, int do_panic)
1da177e4 581{
737a460f 582 unsigned long flags;
1209140c 583
a8c1be9d 584 if (notify_die(DIE_NMIWATCHDOG, str, regs, 0, 2, SIGINT) == NOTIFY_STOP)
737a460f 585 return;
1209140c 586
737a460f 587 flags = oops_begin();
1da177e4
LT
588 /*
589 * We are in trouble anyway, lets at least try
590 * to get a message out.
591 */
e56b3a12
CG
592 printk(KERN_EMERG "%s", str);
593 printk(" on CPU%d, ip %08lx, registers:\n",
594 smp_processor_id(), regs->ip);
1da177e4 595 show_registers(regs);
8bcc5280
VG
596 if (kexec_should_crash(current))
597 crash_kexec(regs);
fac58550
AK
598 if (do_panic || panic_on_oops)
599 panic("Non maskable interrupt");
22f5991c 600 oops_end(flags, NULL, SIGBUS);
8b1ffe95
CM
601 nmi_exit();
602 local_irq_enable();
22f5991c 603 do_exit(SIGBUS);
1da177e4
LT
604}
605
a8c1be9d
AH
606static void __kprobes
607do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
608 long error_code, siginfo_t *info)
1da177e4 609{
6e3f3617
JB
610 struct task_struct *tsk = current;
611
a7bbb0ce
AH
612 if (!user_mode(regs))
613 goto kernel_trap;
1da177e4 614
a7bbb0ce
AH
615 /*
616 * We want error_code and trap_no set for userspace faults and
617 * kernelspace faults which result in die(), but not
618 * kernelspace faults which are fixed up. die() gives the
619 * process no chance to handle the signal and notice the
620 * kernel fault information, so that won't result in polluting
621 * the information about previously queued, but not yet
622 * delivered, faults. See also do_general_protection below.
623 */
624 tsk->thread.error_code = error_code;
625 tsk->thread.trap_no = trapnr;
626
627 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
628 printk_ratelimit()) {
629 printk(KERN_INFO
630 "%s[%d] trap %s ip:%lx sp:%lx error:%lx",
631 tsk->comm, tsk->pid, str,
632 regs->ip, regs->sp, error_code);
633 print_vma_addr(" in ", regs->ip);
634 printk("\n");
1da177e4
LT
635 }
636
a7bbb0ce
AH
637 if (info)
638 force_sig_info(signr, info, tsk);
639 else
640 force_sig(signr, tsk);
641 return;
1da177e4 642
a7bbb0ce 643kernel_trap:
b3a5acc1
HH
644 if (!fixup_exception(regs)) {
645 tsk->thread.error_code = error_code;
646 tsk->thread.trap_no = trapnr;
647 die(str, regs, error_code);
1da177e4 648 }
b3a5acc1 649 return;
1da177e4
LT
650}
651
652#define DO_ERROR(trapnr, signr, str, name) \
a8c1be9d
AH
653asmlinkage void do_##name(struct pt_regs * regs, long error_code) \
654{ \
655 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
656 == NOTIFY_STOP) \
657 return; \
40e59a61 658 conditional_sti(regs); \
a8c1be9d 659 do_trap(trapnr, signr, str, regs, error_code, NULL); \
1da177e4
LT
660}
661
a8c1be9d
AH
662#define DO_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \
663asmlinkage void do_##name(struct pt_regs * regs, long error_code) \
664{ \
665 siginfo_t info; \
666 info.si_signo = signr; \
667 info.si_errno = 0; \
668 info.si_code = sicode; \
669 info.si_addr = (void __user *)siaddr; \
670 trace_hardirqs_fixup(); \
671 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
672 == NOTIFY_STOP) \
673 return; \
40e59a61 674 conditional_sti(regs); \
a8c1be9d 675 do_trap(trapnr, signr, str, regs, error_code, &info); \
1da177e4
LT
676}
677
a8c1be9d
AH
678DO_ERROR_INFO(0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->ip)
679DO_ERROR(4, SIGSEGV, "overflow", overflow)
680DO_ERROR(5, SIGSEGV, "bounds", bounds)
681DO_ERROR_INFO(6, SIGILL, "invalid opcode", invalid_op, ILL_ILLOPN, regs->ip)
682DO_ERROR(9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun)
1da177e4 683DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS)
a8c1be9d 684DO_ERROR(11, SIGBUS, "segment not present", segment_not_present)
1da177e4 685DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0)
40e59a61
AK
686
687/* Runs on IST stack */
688asmlinkage void do_stack_segment(struct pt_regs *regs, long error_code)
689{
690 if (notify_die(DIE_TRAP, "stack segment", regs, error_code,
691 12, SIGBUS) == NOTIFY_STOP)
692 return;
693 preempt_conditional_sti(regs);
694 do_trap(12, SIGBUS, "stack segment", regs, error_code, NULL);
695 preempt_conditional_cli(regs);
696}
eca37c18
JB
697
698asmlinkage void do_double_fault(struct pt_regs * regs, long error_code)
699{
700 static const char str[] = "double fault";
701 struct task_struct *tsk = current;
702
703 /* Return not checked because double check cannot be ignored */
704 notify_die(DIE_TRAP, str, regs, error_code, 8, SIGSEGV);
705
706 tsk->thread.error_code = error_code;
707 tsk->thread.trap_no = 8;
708
709 /* This is always a kernel trap and never fixable (and thus must
710 never return). */
711 for (;;)
712 die(str, regs, error_code);
713}
1da177e4 714
13485ab5
AH
715asmlinkage void __kprobes
716do_general_protection(struct pt_regs *regs, long error_code)
1da177e4 717{
13485ab5 718 struct task_struct *tsk;
6e3f3617 719
1da177e4
LT
720 conditional_sti(regs);
721
13485ab5
AH
722 tsk = current;
723 if (!user_mode(regs))
724 goto gp_in_kernel;
1da177e4 725
13485ab5
AH
726 tsk->thread.error_code = error_code;
727 tsk->thread.trap_no = 13;
728
729 if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) &&
730 printk_ratelimit()) {
731 printk(KERN_INFO
732 "%s[%d] general protection ip:%lx sp:%lx error:%lx",
733 tsk->comm, tsk->pid,
734 regs->ip, regs->sp, error_code);
735 print_vma_addr(" in ", regs->ip);
736 printk("\n");
737 }
738
739 force_sig(SIGSEGV, tsk);
740 return;
1da177e4 741
13485ab5 742gp_in_kernel:
b3a5acc1
HH
743 if (fixup_exception(regs))
744 return;
d1895183 745
b3a5acc1
HH
746 tsk->thread.error_code = error_code;
747 tsk->thread.trap_no = 13;
748 if (notify_die(DIE_GPF, "general protection fault", regs,
749 error_code, 13, SIGSEGV) == NOTIFY_STOP)
750 return;
751 die("general protection fault", regs, error_code);
1da177e4
LT
752}
753
5deb45e3 754static notrace __kprobes void
a8c1be9d 755mem_parity_error(unsigned char reason, struct pt_regs *regs)
1da177e4 756{
c41c5cd3
DZ
757 printk(KERN_EMERG "Uhhuh. NMI received for unknown reason %02x.\n",
758 reason);
9c5f8be4 759 printk(KERN_EMERG "You have some hardware problem, likely on the PCI bus.\n");
c41c5cd3 760
c0d12172 761#if defined(CONFIG_EDAC)
a8c1be9d 762 if (edac_handler_set()) {
c0d12172
DJ
763 edac_atomic_assert_error();
764 return;
765 }
766#endif
767
8da5adda 768 if (panic_on_unrecovered_nmi)
c41c5cd3
DZ
769 panic("NMI: Not continuing");
770
771 printk(KERN_EMERG "Dazed and confused, but trying to continue\n");
1da177e4
LT
772
773 /* Clear and disable the memory parity error line. */
774 reason = (reason & 0xf) | 4;
775 outb(reason, 0x61);
776}
777
5deb45e3 778static notrace __kprobes void
a8c1be9d 779io_check_error(unsigned char reason, struct pt_regs *regs)
1da177e4
LT
780{
781 printk("NMI: IOCK error (debug interrupt?)\n");
782 show_registers(regs);
783
784 /* Re-enable the IOCK line, wait for a few seconds */
785 reason = (reason & 0xf) | 8;
786 outb(reason, 0x61);
787 mdelay(2000);
788 reason &= ~8;
789 outb(reason, 0x61);
790}
791
5deb45e3 792static notrace __kprobes void
eddb6fb9 793unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
c41c5cd3 794{
d3597524
JW
795 if (notify_die(DIE_NMIUNKNOWN, "nmi", regs, reason, 2, SIGINT) == NOTIFY_STOP)
796 return;
c41c5cd3
DZ
797 printk(KERN_EMERG "Uhhuh. NMI received for unknown reason %02x.\n",
798 reason);
799 printk(KERN_EMERG "Do you have a strange power saving mode enabled?\n");
8da5adda
DZ
800
801 if (panic_on_unrecovered_nmi)
c41c5cd3 802 panic("NMI: Not continuing");
8da5adda 803
c41c5cd3 804 printk(KERN_EMERG "Dazed and confused, but trying to continue\n");
1da177e4
LT
805}
806
6fefb0d1
AK
807/* Runs on IST stack. This code must keep interrupts off all the time.
808 Nested NMIs are prevented by the CPU. */
abd34807 809asmlinkage notrace __kprobes void default_do_nmi(struct pt_regs *regs)
1da177e4
LT
810{
811 unsigned char reason = 0;
76e4f660
AR
812 int cpu;
813
814 cpu = smp_processor_id();
1da177e4 815
a8c1be9d 816 /* Only the BSP gets external NMIs from the system. */
76e4f660 817 if (!cpu)
1da177e4
LT
818 reason = get_nmi_reason();
819
820 if (!(reason & 0xc0)) {
6e3f3617 821 if (notify_die(DIE_NMI_IPI, "nmi_ipi", regs, reason, 2, SIGINT)
1da177e4
LT
822 == NOTIFY_STOP)
823 return;
1da177e4
LT
824 /*
825 * Ok, so this is none of the documented NMI sources,
826 * so it must be the NMI watchdog.
827 */
a8c1be9d 828 if (nmi_watchdog_tick(regs, reason))
1da177e4 829 return;
a8c1be9d 830 if (!do_nmi_callback(regs, cpu))
3adbbcce
DZ
831 unknown_nmi_error(reason, regs);
832
1da177e4
LT
833 return;
834 }
6e3f3617 835 if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT) == NOTIFY_STOP)
a8c1be9d 836 return;
1da177e4
LT
837
838 /* AK: following checks seem to be broken on modern chipsets. FIXME */
1da177e4
LT
839 if (reason & 0x80)
840 mem_parity_error(reason, regs);
841 if (reason & 0x40)
842 io_check_error(reason, regs);
843}
844
c6425b9f
CG
845asmlinkage notrace __kprobes void
846do_nmi(struct pt_regs *regs, long error_code)
847{
848 nmi_enter();
a8c1be9d 849
c6425b9f 850 add_pda(__nmi_count, 1);
a8c1be9d 851
c6425b9f
CG
852 if (!ignore_nmis)
853 default_do_nmi(regs);
a8c1be9d 854
c6425b9f
CG
855 nmi_exit();
856}
857
858void stop_nmi(void)
859{
860 acpi_nmi_disable();
861 ignore_nmis++;
862}
863
864void restart_nmi(void)
865{
866 ignore_nmis--;
867 acpi_nmi_enable();
868}
869
b556b35e 870/* runs on IST stack. */
a8c1be9d 871asmlinkage void __kprobes do_int3(struct pt_regs *regs, long error_code)
1da177e4 872{
143a5d32
PZ
873 trace_hardirqs_fixup();
874
a8c1be9d
AH
875 if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP)
876 == NOTIFY_STOP)
1da177e4 877 return;
a8c1be9d 878
40e59a61 879 preempt_conditional_sti(regs);
1da177e4 880 do_trap(3, SIGTRAP, "int3", regs, error_code, NULL);
40e59a61 881 preempt_conditional_cli(regs);
1da177e4
LT
882}
883
6fefb0d1
AK
884/* Help handler running on IST stack to switch back to user stack
885 for scheduling or signal handling. The actual stack switch is done in
886 entry.S */
eddb6fb9 887asmlinkage __kprobes struct pt_regs *sync_regs(struct pt_regs *eregs)
6fefb0d1
AK
888{
889 struct pt_regs *regs = eregs;
890 /* Did already sync */
65ea5b03 891 if (eregs == (struct pt_regs *)eregs->sp)
6fefb0d1
AK
892 ;
893 /* Exception from user space */
76381fee 894 else if (user_mode(eregs))
bb049232 895 regs = task_pt_regs(current);
6fefb0d1
AK
896 /* Exception from kernel and interrupts are enabled. Move to
897 kernel process stack. */
65ea5b03
PA
898 else if (eregs->flags & X86_EFLAGS_IF)
899 regs = (struct pt_regs *)(eregs->sp -= sizeof(struct pt_regs));
6fefb0d1
AK
900 if (eregs != regs)
901 *regs = *eregs;
902 return regs;
903}
904
1da177e4 905/* runs on IST stack. */
0f2fbdcb
PP
906asmlinkage void __kprobes do_debug(struct pt_regs * regs,
907 unsigned long error_code)
1da177e4 908{
1da177e4 909 struct task_struct *tsk = current;
7b4fd4bb 910 unsigned long condition;
1da177e4
LT
911 siginfo_t info;
912
000f4a9e
PZ
913 trace_hardirqs_fixup();
914
e9129e56 915 get_debugreg(condition, 6);
1da177e4 916
10faa81e
RM
917 /*
918 * The processor cleared BTF, so don't mark that we need it set.
919 */
920 clear_tsk_thread_flag(tsk, TIF_DEBUGCTLMSR);
921 tsk->thread.debugctlmsr = 0;
922
1da177e4 923 if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code,
daeeafec 924 SIGTRAP) == NOTIFY_STOP)
6fefb0d1 925 return;
daeeafec 926
a65d17c9 927 preempt_conditional_sti(regs);
1da177e4
LT
928
929 /* Mask out spurious debug traps due to lazy DR7 setting */
930 if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3)) {
a8c1be9d 931 if (!tsk->thread.debugreg7)
1da177e4 932 goto clear_dr7;
1da177e4
LT
933 }
934
935 tsk->thread.debugreg6 = condition;
936
e1f28773
RM
937 /*
938 * Single-stepping through TF: make sure we ignore any events in
939 * kernel space (but re-enable TF when returning to user mode).
940 */
daeeafec 941 if (condition & DR_STEP) {
a8c1be9d
AH
942 if (!user_mode(regs))
943 goto clear_TF_reenable;
1da177e4
LT
944 }
945
946 /* Ok, finally something we can handle */
947 tsk->thread.trap_no = 1;
948 tsk->thread.error_code = error_code;
949 info.si_signo = SIGTRAP;
950 info.si_errno = 0;
951 info.si_code = TRAP_BRKPT;
65ea5b03 952 info.si_addr = user_mode(regs) ? (void __user *)regs->ip : NULL;
01b8faae 953 force_sig_info(SIGTRAP, &info, tsk);
1da177e4 954
1da177e4 955clear_dr7:
a8c1be9d 956 set_debugreg(0, 7);
a65d17c9 957 preempt_conditional_cli(regs);
6fefb0d1 958 return;
1da177e4
LT
959
960clear_TF_reenable:
961 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
053de044 962 regs->flags &= ~X86_EFLAGS_TF;
a65d17c9 963 preempt_conditional_cli(regs);
a8c1be9d 964 return;
1da177e4
LT
965}
966
6e3f3617 967static int kernel_math_error(struct pt_regs *regs, const char *str, int trapnr)
1da177e4 968{
b3a5acc1 969 if (fixup_exception(regs))
1da177e4 970 return 1;
b3a5acc1 971
6e3f3617 972 notify_die(DIE_GPF, str, regs, 0, trapnr, SIGFPE);
3a848f63 973 /* Illegal floating point operation in the kernel */
6e3f3617 974 current->thread.trap_no = trapnr;
1da177e4 975 die(str, regs, 0);
1da177e4
LT
976 return 0;
977}
978
979/*
980 * Note that we play around with the 'TS' bit in an attempt to get
981 * the correct behaviour even in the presence of the asynchronous
982 * IRQ13 behaviour
983 */
984asmlinkage void do_coprocessor_error(struct pt_regs *regs)
985{
65ea5b03 986 void __user *ip = (void __user *)(regs->ip);
a8c1be9d 987 struct task_struct *task;
1da177e4
LT
988 siginfo_t info;
989 unsigned short cwd, swd;
990
991 conditional_sti(regs);
76381fee 992 if (!user_mode(regs) &&
6e3f3617 993 kernel_math_error(regs, "kernel x87 math error", 16))
1da177e4
LT
994 return;
995
996 /*
997 * Save the info for the exception handler and clear the error.
998 */
999 task = current;
1000 save_init_fpu(task);
1001 task->thread.trap_no = 16;
1002 task->thread.error_code = 0;
1003 info.si_signo = SIGFPE;
1004 info.si_errno = 0;
1005 info.si_code = __SI_FAULT;
65ea5b03 1006 info.si_addr = ip;
1da177e4
LT
1007 /*
1008 * (~cwd & swd) will mask out exceptions that are not set to unmasked
1009 * status. 0x3f is the exception bits in these regs, 0x200 is the
1010 * C1 reg you need in case of a stack fault, 0x040 is the stack
1011 * fault bit. We should only be taking one exception at a time,
1012 * so if this combination doesn't produce any single exception,
1013 * then we have a bad program that isn't synchronizing its FPU usage
1014 * and it will suffer the consequences since we won't be able to
1015 * fully reproduce the context of the exception
1016 */
1017 cwd = get_fpu_cwd(task);
1018 swd = get_fpu_swd(task);
ff347b22 1019 switch (swd & ~cwd & 0x3f) {
a8c1be9d
AH
1020 case 0x000: /* No unmasked exception */
1021 default: /* Multiple exceptions */
1022 break;
1023 case 0x001: /* Invalid Op */
1024 /*
1025 * swd & 0x240 == 0x040: Stack Underflow
1026 * swd & 0x240 == 0x240: Stack Overflow
1027 * User must clear the SF bit (0x40) if set
1028 */
1029 info.si_code = FPE_FLTINV;
1030 break;
1031 case 0x002: /* Denormalize */
1032 case 0x010: /* Underflow */
1033 info.si_code = FPE_FLTUND;
1034 break;
1035 case 0x004: /* Zero Divide */
1036 info.si_code = FPE_FLTDIV;
1037 break;
1038 case 0x008: /* Overflow */
1039 info.si_code = FPE_FLTOVF;
1040 break;
1041 case 0x020: /* Precision */
1042 info.si_code = FPE_FLTRES;
1043 break;
1da177e4
LT
1044 }
1045 force_sig_info(SIGFPE, &info, task);
1046}
1047
1048asmlinkage void bad_intr(void)
1049{
1050 printk("bad interrupt");
1051}
1052
1053asmlinkage void do_simd_coprocessor_error(struct pt_regs *regs)
1054{
65ea5b03 1055 void __user *ip = (void __user *)(regs->ip);
a8c1be9d 1056 struct task_struct *task;
1da177e4
LT
1057 siginfo_t info;
1058 unsigned short mxcsr;
1059
1060 conditional_sti(regs);
76381fee 1061 if (!user_mode(regs) &&
6e3f3617 1062 kernel_math_error(regs, "kernel simd math error", 19))
1da177e4
LT
1063 return;
1064
1065 /*
1066 * Save the info for the exception handler and clear the error.
1067 */
1068 task = current;
1069 save_init_fpu(task);
1070 task->thread.trap_no = 19;
1071 task->thread.error_code = 0;
1072 info.si_signo = SIGFPE;
1073 info.si_errno = 0;
1074 info.si_code = __SI_FAULT;
65ea5b03 1075 info.si_addr = ip;
1da177e4
LT
1076 /*
1077 * The SIMD FPU exceptions are handled a little differently, as there
1078 * is only a single status/control register. Thus, to determine which
1079 * unmasked exception was caught we must mask the exception mask bits
1080 * at 0x1f80, and then use these to mask the exception bits at 0x3f.
1081 */
1082 mxcsr = get_fpu_mxcsr(task);
1083 switch (~((mxcsr & 0x1f80) >> 7) & (mxcsr & 0x3f)) {
a8c1be9d
AH
1084 case 0x000:
1085 default:
1086 break;
1087 case 0x001: /* Invalid Op */
1088 info.si_code = FPE_FLTINV;
1089 break;
1090 case 0x002: /* Denormalize */
1091 case 0x010: /* Underflow */
1092 info.si_code = FPE_FLTUND;
1093 break;
1094 case 0x004: /* Zero Divide */
1095 info.si_code = FPE_FLTDIV;
1096 break;
1097 case 0x008: /* Overflow */
1098 info.si_code = FPE_FLTOVF;
1099 break;
1100 case 0x020: /* Precision */
1101 info.si_code = FPE_FLTRES;
1102 break;
1da177e4
LT
1103 }
1104 force_sig_info(SIGFPE, &info, task);
1105}
1106
1107asmlinkage void do_spurious_interrupt_bug(struct pt_regs * regs)
1108{
1109}
1110
1111asmlinkage void __attribute__((weak)) smp_thermal_interrupt(void)
89b831ef
JS
1112{
1113}
1114
1115asmlinkage void __attribute__((weak)) mce_threshold_interrupt(void)
1da177e4
LT
1116{
1117}
1118
1119/*
a8c1be9d 1120 * 'math_state_restore()' saves the current math information in the
1da177e4
LT
1121 * old math state array, and gets the new ones from the current task
1122 *
1123 * Careful.. There are problems with IBM-designed IRQ13 behaviour.
1124 * Don't touch unless you *really* know how it works.
1125 */
1126asmlinkage void math_state_restore(void)
1127{
1128 struct task_struct *me = current;
1da177e4 1129
aa283f49
SS
1130 if (!used_math()) {
1131 local_irq_enable();
1132 /*
1133 * does a slab alloc which can sleep
1134 */
1135 if (init_fpu(me)) {
1136 /*
1137 * ran out of memory!
1138 */
1139 do_group_exit(SIGKILL);
1140 return;
1141 }
1142 local_irq_disable();
1143 }
1144
a8c1be9d 1145 clts(); /* Allow maths ops (or we recurse) */
61c4628b 1146 restore_fpu_checking(&me->thread.xstate->fxsave);
e4f17c43 1147 task_thread_info(me)->status |= TS_USEDFPU;
e07e23e1 1148 me->fpu_counter++;
1da177e4 1149}
21db5584 1150EXPORT_SYMBOL_GPL(math_state_restore);
1da177e4 1151
1da177e4
LT
1152void __init trap_init(void)
1153{
a8c1be9d
AH
1154 set_intr_gate(0, &divide_error);
1155 set_intr_gate_ist(1, &debug, DEBUG_STACK);
1156 set_intr_gate_ist(2, &nmi, NMI_STACK);
1157 set_system_gate_ist(3, &int3, DEBUG_STACK); /* int3 can be called from all */
1158 set_system_gate(4, &overflow); /* int4 can be called from all */
1159 set_intr_gate(5, &bounds);
1160 set_intr_gate(6, &invalid_op);
1161 set_intr_gate(7, &device_not_available);
1162 set_intr_gate_ist(8, &double_fault, DOUBLEFAULT_STACK);
1163 set_intr_gate(9, &coprocessor_segment_overrun);
1164 set_intr_gate(10, &invalid_TSS);
1165 set_intr_gate(11, &segment_not_present);
1166 set_intr_gate_ist(12, &stack_segment, STACKFAULT_STACK);
1167 set_intr_gate(13, &general_protection);
1168 set_intr_gate(14, &page_fault);
1169 set_intr_gate(15, &spurious_interrupt_bug);
1170 set_intr_gate(16, &coprocessor_error);
1171 set_intr_gate(17, &alignment_check);
1da177e4 1172#ifdef CONFIG_X86_MCE
a8c1be9d 1173 set_intr_gate_ist(18, &machine_check, MCE_STACK);
1da177e4 1174#endif
a8c1be9d 1175 set_intr_gate(19, &simd_coprocessor_error);
1da177e4
LT
1176
1177#ifdef CONFIG_IA32_EMULATION
1178 set_system_gate(IA32_SYSCALL_VECTOR, ia32_syscall);
1179#endif
61c4628b
SS
1180 /*
1181 * initialize the per thread extended state:
1182 */
7b4fd4bb 1183 init_thread_xstate();
1da177e4 1184 /*
a8c1be9d 1185 * Should be a barrier for any external CPU state:
1da177e4
LT
1186 */
1187 cpu_init();
1188}
1189
2c8c0e6b 1190static int __init oops_setup(char *s)
a8c1be9d 1191{
2c8c0e6b
AK
1192 if (!s)
1193 return -EINVAL;
1194 if (!strcmp(s, "panic"))
1195 panic_on_oops = 1;
1196 return 0;
a8c1be9d 1197}
2c8c0e6b 1198early_param("oops", oops_setup);
1da177e4
LT
1199
1200static int __init kstack_setup(char *s)
1201{
2c8c0e6b
AK
1202 if (!s)
1203 return -EINVAL;
a8c1be9d 1204 kstack_depth_to_print = simple_strtoul(s, NULL, 0);
2c8c0e6b 1205 return 0;
1da177e4 1206}
2c8c0e6b 1207early_param("kstack", kstack_setup);
a25bd949 1208
a25bd949
AV
1209static int __init code_bytes_setup(char *s)
1210{
1211 code_bytes = simple_strtoul(s, NULL, 0);
1212 if (code_bytes > 8192)
1213 code_bytes = 8192;
1214
1215 return 1;
1216}
1217__setup("code_bytes=", code_bytes_setup);
This page took 0.439521 seconds and 5 git commands to generate.