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