Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / arch / i386 / kernel / traps-xen.c
1 /*
2  *  linux/arch/i386/traps.c
3  *
4  *  Copyright (C) 1991, 1992  Linus Torvalds
5  *
6  *  Pentium III FXSR, SSE support
7  *      Gareth Hughes <gareth@valinux.com>, May 2000
8  */
9
10 /*
11  * 'Traps.c' handles hardware traps and faults after we have saved some
12  * state in 'asm.s'.
13  */
14 #include <linux/sched.h>
15 #include <linux/kernel.h>
16 #include <linux/string.h>
17 #include <linux/errno.h>
18 #include <linux/timer.h>
19 #include <linux/mm.h>
20 #include <linux/init.h>
21 #include <linux/delay.h>
22 #include <linux/spinlock.h>
23 #include <linux/interrupt.h>
24 #include <linux/highmem.h>
25 #include <linux/kallsyms.h>
26 #include <linux/ptrace.h>
27 #include <linux/utsname.h>
28 #include <linux/kprobes.h>
29 #include <linux/kexec.h>
30 #include <linux/unwind.h>
31
32 #ifdef CONFIG_EISA
33 #include <linux/ioport.h>
34 #include <linux/eisa.h>
35 #endif
36
37 #ifdef CONFIG_MCA
38 #include <linux/mca.h>
39 #endif
40
41 #include <asm/processor.h>
42 #include <asm/system.h>
43 #include <asm/uaccess.h>
44 #include <asm/io.h>
45 #include <asm/atomic.h>
46 #include <asm/debugreg.h>
47 #include <asm/desc.h>
48 #include <asm/i387.h>
49 #include <asm/nmi.h>
50 #include <asm/unwind.h>
51 #include <asm/smp.h>
52 #include <asm/arch_hooks.h>
53 #include <asm/kdebug.h>
54 #include <asm/stacktrace.h>
55
56 #include <linux/module.h>
57 #include <linux/vserver/debug.h>
58
59 #include "mach_traps.h"
60
61 asmlinkage int system_call(void);
62
63 struct desc_struct default_ldt[] = { { 0, 0 }, { 0, 0 }, { 0, 0 },
64                 { 0, 0 }, { 0, 0 } };
65
66 /* Do we ignore FPU interrupts ? */
67 char ignore_fpu_irq = 0;
68
69 #ifndef CONFIG_X86_NO_IDT
70 /*
71  * The IDT has to be page-aligned to simplify the Pentium
72  * F0 0F bug workaround.. We have a special link segment
73  * for this.
74  */
75 struct desc_struct idt_table[256] __attribute__((__section__(".data.idt"))) = { {0, 0}, };
76 #endif
77
78 asmlinkage void divide_error(void);
79 asmlinkage void debug(void);
80 asmlinkage void nmi(void);
81 asmlinkage void int3(void);
82 asmlinkage void overflow(void);
83 asmlinkage void bounds(void);
84 asmlinkage void invalid_op(void);
85 asmlinkage void device_not_available(void);
86 asmlinkage void coprocessor_segment_overrun(void);
87 asmlinkage void invalid_TSS(void);
88 asmlinkage void segment_not_present(void);
89 asmlinkage void stack_segment(void);
90 asmlinkage void general_protection(void);
91 asmlinkage void page_fault(void);
92 asmlinkage void coprocessor_error(void);
93 asmlinkage void simd_coprocessor_error(void);
94 asmlinkage void alignment_check(void);
95 #ifndef CONFIG_XEN
96 asmlinkage void spurious_interrupt_bug(void);
97 #else
98 asmlinkage void fixup_4gb_segment(void);
99 #endif
100 asmlinkage void machine_check(void);
101
102 static int kstack_depth_to_print = 24;
103 #ifdef CONFIG_STACK_UNWIND
104 static int call_trace = 1;
105 #else
106 #define call_trace (-1)
107 #endif
108 ATOMIC_NOTIFIER_HEAD(i386die_chain);
109
110 extern char last_sysfs_file[];
111
112 int register_die_notifier(struct notifier_block *nb)
113 {
114         vmalloc_sync_all();
115         return atomic_notifier_chain_register(&i386die_chain, nb);
116 }
117 EXPORT_SYMBOL(register_die_notifier); /* used modular by kdb */
118
119 int unregister_die_notifier(struct notifier_block *nb)
120 {
121         return atomic_notifier_chain_unregister(&i386die_chain, nb);
122 }
123 EXPORT_SYMBOL(unregister_die_notifier); /* used modular by kdb */
124
125 static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
126 {
127         return  p > (void *)tinfo &&
128                 p < (void *)tinfo + THREAD_SIZE - 3;
129 }
130
131 static inline unsigned long print_context_stack(struct thread_info *tinfo,
132                                 unsigned long *stack, unsigned long ebp,
133                                 struct stacktrace_ops *ops, void *data)
134 {
135         unsigned long addr;
136
137 #ifdef  CONFIG_FRAME_POINTER
138         while (valid_stack_ptr(tinfo, (void *)ebp)) {
139                 addr = *(unsigned long *)(ebp + 4);
140                 ops->address(data, addr);
141                 /*
142                  * break out of recursive entries (such as
143                  * end_of_stack_stop_unwind_function):
144                  */
145                 if (ebp == *(unsigned long *)ebp)
146                         break;
147                 ebp = *(unsigned long *)ebp;
148         }
149 #else
150         while (valid_stack_ptr(tinfo, stack)) {
151                 addr = *stack++;
152                 if (__kernel_text_address(addr))
153                         ops->address(data, addr);
154         }
155 #endif
156         return ebp;
157 }
158
159 struct ops_and_data {
160         struct stacktrace_ops *ops;
161         void *data;
162 };
163
164 static asmlinkage int
165 dump_trace_unwind(struct unwind_frame_info *info, void *data)
166 {
167         struct ops_and_data *oad = (struct ops_and_data *)data;
168         int n = 0;
169
170         while (unwind(info) == 0 && UNW_PC(info)) {
171                 n++;
172                 oad->ops->address(oad->data, UNW_PC(info));
173                 if (arch_unw_user_mode(info))
174                         break;
175         }
176         return n;
177 }
178
179 void dump_trace(struct task_struct *task, struct pt_regs *regs,
180         unsigned long *stack,
181         struct stacktrace_ops *ops, void *data)
182 {
183         unsigned long ebp;
184
185         if (!task)
186                 task = current;
187
188         if (call_trace >= 0) {
189                 int unw_ret = 0;
190                 struct unwind_frame_info info;
191                 struct ops_and_data oad = { .ops = ops, .data = data };
192
193                 if (regs) {
194                         if (unwind_init_frame_info(&info, task, regs) == 0)
195                                 unw_ret = dump_trace_unwind(&info, &oad);
196                 } else if (task == current)
197                         unw_ret = unwind_init_running(&info, dump_trace_unwind, &oad);
198                 else {
199                         if (unwind_init_blocked(&info, task) == 0)
200                                 unw_ret = dump_trace_unwind(&info, &oad);
201                 }
202                 if (unw_ret > 0) {
203                         if (call_trace == 1 && !arch_unw_user_mode(&info)) {
204                                 ops->warning_symbol(data, "DWARF2 unwinder stuck at %s\n",
205                                              UNW_PC(&info));
206                                 if (UNW_SP(&info) >= PAGE_OFFSET) {
207                                         ops->warning(data, "Leftover inexact backtrace:\n");
208                                         stack = (void *)UNW_SP(&info);
209                                 } else
210                                         ops->warning(data, "Full inexact backtrace again:\n");
211                         } else if (call_trace >= 1)
212                                 return;
213                         else
214                                 ops->warning(data, "Full inexact backtrace again:\n");
215                 } else
216                         ops->warning(data, "Inexact backtrace:\n");
217
218         } else if (!stack) {
219                 unsigned long dummy;
220                 stack = &dummy;
221                 if (task && task != current)
222                         stack = (unsigned long *)task->thread.esp;
223         }
224
225         if (task == current) {
226                 /* Grab ebp right from our regs */
227                 asm ("movl %%ebp, %0" : "=r" (ebp) : );
228         } else {
229                 /* ebp is the last reg pushed by switch_to */
230                 ebp = *(unsigned long *) task->thread.esp;
231         }
232
233         while (1) {
234                 struct thread_info *context;
235                 context = (struct thread_info *)
236                         ((unsigned long)stack & (~(THREAD_SIZE - 1)));
237                 ebp = print_context_stack(context, stack, ebp, ops, data);
238                 /* Should be after the line below, but somewhere
239                    in early boot context comes out corrupted and we
240                    can't reference it -AK */
241                 if (ops->stack(data, "IRQ") < 0)
242                         break;
243                 stack = (unsigned long*)context->previous_esp;
244                 if (!stack)
245                         break;
246         }
247 }
248
249 EXPORT_SYMBOL(dump_trace);
250
251 static void
252 print_trace_warning_symbol(void *data, char *msg, unsigned long symbol)
253 {
254         printk(data);
255         print_symbol(msg, symbol);
256         printk("\n");
257 }
258
259 static void print_trace_warning(void *data, char *msg)
260 {
261         printk("%s%s\n", (char *)data, msg);
262 }
263
264 static int print_trace_stack(void *data, char *name)
265 {
266         return 0;
267 }
268
269 /*
270  * Print one address/symbol entries per line.
271  */
272 static void print_trace_address(void *data, unsigned long addr)
273 {
274         printk("%s [<%08lx>] ", (char *)data, addr);
275         print_symbol("%s\n", addr);
276 }
277
278 static struct stacktrace_ops print_trace_ops = {
279         .warning = print_trace_warning,
280         .warning_symbol = print_trace_warning_symbol,
281         .stack = print_trace_stack,
282         .address = print_trace_address,
283 };
284
285 static void
286 show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
287         unsigned long * stack, char *log_lvl)
288 {
289         dump_trace(task, regs, stack, &print_trace_ops, log_lvl);
290         printk("%s =======================\n", log_lvl);
291 }
292
293 void show_trace(struct task_struct *task, struct pt_regs *regs,
294                 unsigned long * stack)
295 {
296         show_trace_log_lvl(task, regs, stack, "");
297 }
298
299 static void show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
300                                unsigned long *esp, char *log_lvl)
301 {
302         unsigned long *stack;
303         int i;
304
305         if (esp == NULL) {
306                 if (task)
307                         esp = (unsigned long*)task->thread.esp;
308                 else
309                         esp = (unsigned long *)&esp;
310         }
311
312         stack = esp;
313         for(i = 0; i < kstack_depth_to_print; i++) {
314                 if (kstack_end(stack))
315                         break;
316                 if (i && ((i % 8) == 0))
317                         printk("\n%s       ", log_lvl);
318                 printk("%08lx ", *stack++);
319         }
320         printk("\n%sCall Trace:\n", log_lvl);
321         show_trace_log_lvl(task, regs, esp, log_lvl);
322 }
323
324 void show_stack(struct task_struct *task, unsigned long *esp)
325 {
326         printk("       ");
327         show_stack_log_lvl(task, NULL, esp, "");
328 }
329
330 /*
331  * The architecture-independent dump_stack generator
332  */
333 void dump_stack(void)
334 {
335         unsigned long stack;
336
337         show_trace(current, NULL, &stack);
338 }
339
340 EXPORT_SYMBOL(dump_stack);
341
342 void show_registers(struct pt_regs *regs)
343 {
344         int i;
345         int in_kernel = 1;
346         unsigned long esp;
347         unsigned short ss;
348
349         esp = (unsigned long) (&regs->esp);
350         savesegment(ss, ss);
351         if (user_mode_vm(regs)) {
352                 in_kernel = 0;
353                 esp = regs->esp;
354                 ss = regs->xss & 0xffff;
355         }
356         print_modules();
357         printk(KERN_EMERG "CPU:    %d\nEIP:    %04x:[<%08lx>]    %s VLI\n"
358                         "EFLAGS: %08lx   (%s %.*s) \n",
359                 smp_processor_id(), 0xffff & regs->xcs, regs->eip,
360                 print_tainted(), regs->eflags, system_utsname.release,
361                 (int)strcspn(system_utsname.version, " "),
362                 system_utsname.version);
363         print_symbol(KERN_EMERG "EIP is at %s\n", regs->eip);
364         printk(KERN_EMERG "eax: %08lx   ebx: %08lx   ecx: %08lx   edx: %08lx\n",
365                 regs->eax, regs->ebx, regs->ecx, regs->edx);
366         printk(KERN_EMERG "esi: %08lx   edi: %08lx   ebp: %08lx   esp: %08lx\n",
367                 regs->esi, regs->edi, regs->ebp, esp);
368         printk(KERN_EMERG "ds: %04x   es: %04x   ss: %04x\n",
369                 regs->xds & 0xffff, regs->xes & 0xffff, ss);
370         printk(KERN_EMERG "Process %.*s (pid: %d[#%u], ti=%p task=%p task.ti=%p)",
371                 TASK_COMM_LEN, current->comm, current->pid, current->xid,
372                 current_thread_info(), current, current->thread_info);
373         /*
374          * When in-kernel, we also print out the stack and code at the
375          * time of the fault..
376          */
377         if (in_kernel) {
378                 u8 __user *eip;
379
380                 printk("\n" KERN_EMERG "Stack: ");
381                 show_stack_log_lvl(NULL, regs, (unsigned long *)esp, KERN_EMERG);
382
383                 printk(KERN_EMERG "Code: ");
384
385                 eip = (u8 __user *)regs->eip - 43;
386                 for (i = 0; i < 64; i++, eip++) {
387                         unsigned char c;
388
389                         if (eip < (u8 __user *)PAGE_OFFSET || __get_user(c, eip)) {
390                                 printk(" Bad EIP value.");
391                                 break;
392                         }
393                         if (eip == (u8 __user *)regs->eip)
394                                 printk("<%02x> ", c);
395                         else
396                                 printk("%02x ", c);
397                 }
398         }
399         printk("\n");
400 }       
401
402 static void handle_BUG(struct pt_regs *regs)
403 {
404         unsigned long eip = regs->eip;
405         unsigned short ud2;
406
407         if (eip < PAGE_OFFSET)
408                 return;
409         if (__get_user(ud2, (unsigned short __user *)eip))
410                 return;
411         if (ud2 != 0x0b0f)
412                 return;
413
414         printk(KERN_EMERG "------------[ cut here ]------------\n");
415 #ifdef CONFIG_DEBUG_BUGVERBOSE
416         do {
417                 unsigned short line;
418                 char *file;
419                 char c;
420
421                 if (__get_user(line, (unsigned short __user *)(eip + 2)))
422                         break;
423                 if (__get_user(file, (char * __user *)(eip + 4)) ||
424                     (unsigned long)file < PAGE_OFFSET || __get_user(c, file))
425                         file = "<bad filename>";
426
427                 printk(KERN_EMERG "kernel BUG at %s:%d!\n", file, line);
428                 return;
429         } while (0);
430 #endif
431         printk(KERN_EMERG "Kernel BUG at [verbose debug info unavailable]\n");
432 }
433
434 /* This is gone through when something in the kernel
435  * has done something bad and is about to be terminated.
436 */
437 void die(const char * str, struct pt_regs * regs, long err)
438 {
439         static struct {
440                 spinlock_t lock;
441                 u32 lock_owner;
442                 int lock_owner_depth;
443         } die = {
444                 .lock =                 SPIN_LOCK_UNLOCKED,
445                 .lock_owner =           -1,
446                 .lock_owner_depth =     0
447         };
448         static int die_counter;
449         unsigned long flags;
450
451         oops_enter();
452
453         vxh_throw_oops();
454
455         if (die.lock_owner != raw_smp_processor_id()) {
456                 console_verbose();
457                 spin_lock_irqsave(&die.lock, flags);
458                 die.lock_owner = smp_processor_id();
459                 die.lock_owner_depth = 0;
460                 bust_spinlocks(1);
461         }
462         else
463                 local_save_flags(flags);
464
465         if (++die.lock_owner_depth < 3) {
466                 int nl = 0;
467                 unsigned long esp;
468                 unsigned short ss;
469
470                 handle_BUG(regs);
471                 printk(KERN_EMERG "%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter);
472 #ifdef CONFIG_PREEMPT
473                 printk(KERN_EMERG "PREEMPT ");
474                 nl = 1;
475 #endif
476 #ifdef CONFIG_SMP
477                 if (!nl)
478                         printk(KERN_EMERG);
479                 printk("SMP ");
480                 nl = 1;
481 #endif
482 #ifdef CONFIG_DEBUG_PAGEALLOC
483                 if (!nl)
484                         printk(KERN_EMERG);
485                 printk("DEBUG_PAGEALLOC");
486                 nl = 1;
487 #endif
488                 if (nl)
489                         printk("\n");
490 #ifdef CONFIG_SYSFS
491                 printk(KERN_ALERT "last sysfs file: %s\n", last_sysfs_file);
492 #endif
493                 if (notify_die(DIE_OOPS, str, regs, err,
494                         current->thread.trap_no, SIGSEGV) != NOTIFY_STOP) {
495                         show_registers(regs);
496                         vxh_dump_history();
497                         /* Executive summary in case the oops scrolled away */
498                         esp = (unsigned long) (&regs->esp);
499                         savesegment(ss, ss);
500                         if (user_mode(regs)) {
501                                 esp = regs->esp;
502                                 ss = regs->xss & 0xffff;
503                         }
504                         printk(KERN_EMERG "EIP: [<%08lx>] ", regs->eip);
505                         print_symbol("%s", regs->eip);
506                         printk(" SS:ESP %04x:%08lx\n", ss, esp);
507                 }
508                 else
509                         regs = NULL;
510         } else
511                 printk(KERN_EMERG "Recursive die() failure, output suppressed\n");
512
513         bust_spinlocks(0);
514         die.lock_owner = -1;
515         spin_unlock_irqrestore(&die.lock, flags);
516
517         if (!regs)
518                 return;
519
520         if (kexec_should_crash(current))
521                 crash_kexec(regs);
522
523         if (in_interrupt())
524                 panic("Fatal exception in interrupt");
525
526         if (panic_on_oops)
527                 panic("Fatal exception");
528
529         oops_exit();
530         do_exit(SIGSEGV);
531 }
532
533 static inline void die_if_kernel(const char * str, struct pt_regs * regs, long err)
534 {
535         if (!user_mode_vm(regs))
536                 die(str, regs, err);
537 }
538
539 static void __kprobes do_trap(int trapnr, int signr, char *str, int vm86,
540                               struct pt_regs * regs, long error_code,
541                               siginfo_t *info)
542 {
543         struct task_struct *tsk = current;
544         tsk->thread.error_code = error_code;
545         tsk->thread.trap_no = trapnr;
546
547         if (regs->eflags & VM_MASK) {
548                 if (vm86)
549                         goto vm86_trap;
550                 goto trap_signal;
551         }
552
553         if (!user_mode(regs))
554                 goto kernel_trap;
555
556         trap_signal: {
557                 if (info)
558                         force_sig_info(signr, info, tsk);
559                 else
560                         force_sig(signr, tsk);
561                 return;
562         }
563
564         kernel_trap: {
565                 if (!fixup_exception(regs))
566                         die(str, regs, error_code);
567                 return;
568         }
569
570         vm86_trap: {
571                 int ret = handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code, trapnr);
572                 if (ret) goto trap_signal;
573                 return;
574         }
575 }
576
577 #define DO_ERROR(trapnr, signr, str, name) \
578 fastcall void do_##name(struct pt_regs * regs, long error_code) \
579 { \
580         if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
581                                                 == NOTIFY_STOP) \
582                 return; \
583         do_trap(trapnr, signr, str, 0, regs, error_code, NULL); \
584 }
585
586 #define DO_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \
587 fastcall void do_##name(struct pt_regs * regs, long error_code) \
588 { \
589         siginfo_t info; \
590         info.si_signo = signr; \
591         info.si_errno = 0; \
592         info.si_code = sicode; \
593         info.si_addr = (void __user *)siaddr; \
594         if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
595                                                 == NOTIFY_STOP) \
596                 return; \
597         do_trap(trapnr, signr, str, 0, regs, error_code, &info); \
598 }
599
600 #define DO_VM86_ERROR(trapnr, signr, str, name) \
601 fastcall void do_##name(struct pt_regs * regs, long error_code) \
602 { \
603         if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
604                                                 == NOTIFY_STOP) \
605                 return; \
606         do_trap(trapnr, signr, str, 1, regs, error_code, NULL); \
607 }
608
609 #define DO_VM86_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \
610 fastcall void do_##name(struct pt_regs * regs, long error_code) \
611 { \
612         siginfo_t info; \
613         info.si_signo = signr; \
614         info.si_errno = 0; \
615         info.si_code = sicode; \
616         info.si_addr = (void __user *)siaddr; \
617         if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
618                                                 == NOTIFY_STOP) \
619                 return; \
620         do_trap(trapnr, signr, str, 1, regs, error_code, &info); \
621 }
622
623 DO_VM86_ERROR_INFO( 0, SIGFPE,  "divide error", divide_error, FPE_INTDIV, regs->eip)
624 #ifndef CONFIG_KPROBES
625 DO_VM86_ERROR( 3, SIGTRAP, "int3", int3)
626 #endif
627 DO_VM86_ERROR( 4, SIGSEGV, "overflow", overflow)
628 DO_VM86_ERROR( 5, SIGSEGV, "bounds", bounds)
629 DO_ERROR_INFO( 6, SIGILL,  "invalid opcode", invalid_op, ILL_ILLOPN, regs->eip)
630 DO_ERROR( 9, SIGFPE,  "coprocessor segment overrun", coprocessor_segment_overrun)
631 DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS)
632 DO_ERROR(11, SIGBUS,  "segment not present", segment_not_present)
633 DO_ERROR(12, SIGBUS,  "stack segment", stack_segment)
634 DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0)
635
636
637 /*
638  * lazy-check for CS validity on exec-shield binaries:
639  *
640  * the original non-exec stack patch was written by
641  * Solar Designer <solar at openwall.com>. Thanks!
642  */
643 static int
644 check_lazy_exec_limit(int cpu, struct pt_regs *regs, long error_code)
645 {
646         struct desc_struct *desc1, *desc2;
647         struct vm_area_struct *vma;
648         unsigned long limit;
649
650         if (current->mm == NULL)
651                 return 0;
652
653         limit = -1UL;
654         if (current->mm->context.exec_limit != -1UL) {
655                 limit = PAGE_SIZE;
656                 spin_lock(&current->mm->page_table_lock);
657                 for (vma = current->mm->mmap; vma; vma = vma->vm_next)
658                         if ((vma->vm_flags & VM_EXEC) && (vma->vm_end > limit))
659                                 limit = vma->vm_end;
660                 spin_unlock(&current->mm->page_table_lock);
661                 if (limit >= TASK_SIZE)
662                         limit = -1UL;
663                 current->mm->context.exec_limit = limit;
664         }
665         set_user_cs(&current->mm->context.user_cs, limit);
666
667         desc1 = &current->mm->context.user_cs;
668         desc2 = get_cpu_gdt_table(cpu) + GDT_ENTRY_DEFAULT_USER_CS;
669
670         if (desc1->a != desc2->a || desc1->b != desc2->b) {
671                 /*
672                  * The CS was not in sync - reload it and retry the
673                  * instruction. If the instruction still faults then
674                  * we won't hit this branch next time around.
675                  */
676                 if (print_fatal_signals >= 2) {
677                         printk("#GPF fixup (%ld[seg:%lx]) at %08lx, CPU#%d.\n", error_code, error_code/8, regs->eip, smp_processor_id());
678                         printk(" exec_limit: %08lx, user_cs: %08lx/%08lx, CPU_cs: %08lx/%08lx.\n", current->mm->context.exec_limit, desc1->a, desc1->b, desc2->a, desc2->b);
679                 }
680                 load_user_cs_desc(cpu, current->mm);
681                 return 1;
682         }
683
684         return 0;
685 }
686
687 /*
688  * The fixup code for errors in iret jumps to here (iret_exc).  It loses
689  * the original trap number and error code.  The bogus trap 32 and error
690  * code 0 are what the vanilla kernel delivers via:
691  * DO_ERROR_INFO(32, SIGSEGV, "iret exception", iret_error, ILL_BADSTK, 0)
692  *
693  * In case of a general protection fault in the iret instruction, we
694  * need to check for a lazy CS update for exec-shield.
695  */
696 fastcall void do_iret_error(struct pt_regs *regs, long error_code)
697 {
698         int ok = check_lazy_exec_limit(get_cpu(), regs, error_code);
699         put_cpu();
700         if (!ok && notify_die(DIE_TRAP, "iret exception", regs,
701                               error_code, 32, SIGSEGV) != NOTIFY_STOP) {
702                 siginfo_t info;
703                 info.si_signo = SIGSEGV;
704                 info.si_errno = 0;
705                 info.si_code = ILL_BADSTK;
706                 info.si_addr = 0;
707                 do_trap(32, SIGSEGV, "iret exception", 0, regs, error_code,
708                         &info);
709         }
710 }
711
712 fastcall void __kprobes do_general_protection(struct pt_regs * regs,
713                                               long error_code)
714 {
715         int cpu = get_cpu();
716         int ok;
717
718         current->thread.error_code = error_code;
719         current->thread.trap_no = 13;
720
721         if (regs->eflags & VM_MASK)
722                 goto gp_in_vm86;
723
724         if (!user_mode(regs))
725                 goto gp_in_kernel;
726
727         ok = check_lazy_exec_limit(cpu, regs, error_code);
728
729         put_cpu();
730
731         if (ok)
732                 return;
733
734         if (print_fatal_signals) {
735                 printk("#GPF(%ld[seg:%lx]) at %08lx, CPU#%d.\n", error_code, error_code/8, regs->eip, smp_processor_id());
736                 printk(" exec_limit: %08lx, user_cs: %08lx/%08lx.\n", current->mm->context.exec_limit, current->mm->context.user_cs.a, current->mm->context.user_cs.b);
737         }
738
739         current->thread.error_code = error_code;
740         current->thread.trap_no = 13;
741         force_sig(SIGSEGV, current);
742         return;
743
744 gp_in_vm86:
745         put_cpu();
746         local_irq_enable();
747         handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
748         return;
749
750 gp_in_kernel:
751         put_cpu();
752         if (!fixup_exception(regs)) {
753                 if (notify_die(DIE_GPF, "general protection fault", regs,
754                                 error_code, 13, SIGSEGV) == NOTIFY_STOP)
755                         return;
756                 die("general protection fault", regs, error_code);
757         }
758 }
759
760 static void mem_parity_error(unsigned char reason, struct pt_regs * regs)
761 {
762         printk(KERN_EMERG "Uhhuh. NMI received. Dazed and confused, but trying "
763                         "to continue\n");
764         printk(KERN_EMERG "You probably have a hardware problem with your RAM "
765                         "chips\n");
766
767         /* Clear and disable the memory parity error line. */
768         clear_mem_error(reason);
769 }
770
771 static void io_check_error(unsigned char reason, struct pt_regs * regs)
772 {
773         printk(KERN_EMERG "NMI: IOCK error (debug interrupt?)\n");
774         show_registers(regs);
775
776         /* Re-enable the IOCK line, wait for a few seconds */
777         clear_io_check_error(reason);
778 }
779
780 static void unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
781 {
782 #ifdef CONFIG_MCA
783         /* Might actually be able to figure out what the guilty party
784         * is. */
785         if( MCA_bus ) {
786                 mca_handle_nmi();
787                 return;
788         }
789 #endif
790         printk("Uhhuh. NMI received for unknown reason %02x on CPU %d.\n",
791                 reason, smp_processor_id());
792         printk("Dazed and confused, but trying to continue\n");
793         printk("Do you have a strange power saving mode enabled?\n");
794 }
795
796 static DEFINE_SPINLOCK(nmi_print_lock);
797
798 void die_nmi (struct pt_regs *regs, const char *msg)
799 {
800         if (notify_die(DIE_NMIWATCHDOG, msg, regs, 0, 2, SIGINT) ==
801             NOTIFY_STOP)
802                 return;
803
804         spin_lock(&nmi_print_lock);
805         /*
806         * We are in trouble anyway, lets at least try
807         * to get a message out.
808         */
809         bust_spinlocks(1);
810         printk(KERN_EMERG "%s", msg);
811         printk(" on CPU%d, eip %08lx, registers:\n",
812                 smp_processor_id(), regs->eip);
813         show_registers(regs);
814         printk(KERN_EMERG "console shuts up ...\n");
815         console_silent();
816         spin_unlock(&nmi_print_lock);
817         bust_spinlocks(0);
818
819         /* If we are in kernel we are probably nested up pretty bad
820          * and might aswell get out now while we still can.
821         */
822         if (!user_mode_vm(regs)) {
823                 current->thread.trap_no = 2;
824                 crash_kexec(regs);
825         }
826
827         do_exit(SIGSEGV);
828 }
829
830 static void default_do_nmi(struct pt_regs * regs)
831 {
832         unsigned char reason = 0;
833
834         /* Only the BSP gets external NMIs from the system.  */
835         if (!smp_processor_id())
836                 reason = get_nmi_reason();
837  
838         if (!(reason & 0xc0)) {
839                 if (notify_die(DIE_NMI_IPI, "nmi_ipi", regs, reason, 2, SIGINT)
840                                                         == NOTIFY_STOP)
841                         return;
842 #ifdef CONFIG_X86_LOCAL_APIC
843                 /*
844                  * Ok, so this is none of the documented NMI sources,
845                  * so it must be the NMI watchdog.
846                  */
847                 if (nmi_watchdog) {
848                         nmi_watchdog_tick(regs);
849                         return;
850                 }
851 #endif
852                 unknown_nmi_error(reason, regs);
853                 return;
854         }
855         if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT) == NOTIFY_STOP)
856                 return;
857         if (reason & 0x80)
858                 mem_parity_error(reason, regs);
859         if (reason & 0x40)
860                 io_check_error(reason, regs);
861         /*
862          * Reassert NMI in case it became active meanwhile
863          * as it's edge-triggered.
864          */
865         reassert_nmi();
866 }
867
868 static int dummy_nmi_callback(struct pt_regs * regs, int cpu)
869 {
870         return 0;
871 }
872  
873 static nmi_callback_t nmi_callback = dummy_nmi_callback;
874  
875 fastcall void do_nmi(struct pt_regs * regs, long error_code)
876 {
877         int cpu;
878
879         nmi_enter();
880
881         cpu = smp_processor_id();
882
883         ++nmi_count(cpu);
884
885         if (!rcu_dereference(nmi_callback)(regs, cpu))
886                 default_do_nmi(regs);
887
888         nmi_exit();
889 }
890
891 void set_nmi_callback(nmi_callback_t callback)
892 {
893         vmalloc_sync_all();
894         rcu_assign_pointer(nmi_callback, callback);
895 }
896 EXPORT_SYMBOL_GPL(set_nmi_callback);
897
898 void unset_nmi_callback(void)
899 {
900         nmi_callback = dummy_nmi_callback;
901 }
902 EXPORT_SYMBOL_GPL(unset_nmi_callback);
903
904 #ifdef CONFIG_KPROBES
905 fastcall void __kprobes do_int3(struct pt_regs *regs, long error_code)
906 {
907         if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP)
908                         == NOTIFY_STOP)
909                 return;
910         /* This is an interrupt gate, because kprobes wants interrupts
911         disabled.  Normal trap handlers don't. */
912         restore_interrupts(regs);
913         do_trap(3, SIGTRAP, "int3", 1, regs, error_code, NULL);
914 }
915 #endif
916
917 /*
918  * Our handling of the processor debug registers is non-trivial.
919  * We do not clear them on entry and exit from the kernel. Therefore
920  * it is possible to get a watchpoint trap here from inside the kernel.
921  * However, the code in ./ptrace.c has ensured that the user can
922  * only set watchpoints on userspace addresses. Therefore the in-kernel
923  * watchpoint trap can only occur in code which is reading/writing
924  * from user space. Such code must not hold kernel locks (since it
925  * can equally take a page fault), therefore it is safe to call
926  * force_sig_info even though that claims and releases locks.
927  * 
928  * Code in ./signal.c ensures that the debug control register
929  * is restored before we deliver any signal, and therefore that
930  * user code runs with the correct debug control register even though
931  * we clear it here.
932  *
933  * Being careful here means that we don't have to be as careful in a
934  * lot of more complicated places (task switching can be a bit lazy
935  * about restoring all the debug state, and ptrace doesn't have to
936  * find every occurrence of the TF bit that could be saved away even
937  * by user code)
938  */
939 fastcall void __kprobes do_debug(struct pt_regs * regs, long error_code)
940 {
941         unsigned int condition;
942         struct task_struct *tsk = current;
943
944         get_debugreg(condition, 6);
945
946         if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code,
947                                         SIGTRAP) == NOTIFY_STOP)
948                 return;
949         /* It's safe to allow irq's after DR6 has been saved */
950         if (regs->eflags & X86_EFLAGS_IF)
951                 local_irq_enable();
952
953         /* Mask out spurious debug traps due to lazy DR7 setting */
954         if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3)) {
955                 if (!tsk->thread.debugreg[7])
956                         goto clear_dr7;
957         }
958
959         if (regs->eflags & VM_MASK)
960                 goto debug_vm86;
961
962         /* Save debug status register where ptrace can see it */
963         tsk->thread.debugreg[6] = condition;
964
965         /*
966          * Single-stepping through TF: make sure we ignore any events in
967          * kernel space (but re-enable TF when returning to user mode).
968          */
969         if (condition & DR_STEP) {
970                 /*
971                  * We already checked v86 mode above, so we can
972                  * check for kernel mode by just checking the CPL
973                  * of CS.
974                  */
975                 if (!user_mode(regs))
976                         goto clear_TF_reenable;
977         }
978
979         /* Ok, finally something we can handle */
980         send_sigtrap(tsk, regs, error_code);
981
982         /* Disable additional traps. They'll be re-enabled when
983          * the signal is delivered.
984          */
985 clear_dr7:
986         set_debugreg(0, 7);
987         return;
988
989 debug_vm86:
990         handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code, 1);
991         return;
992
993 clear_TF_reenable:
994         set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
995         regs->eflags &= ~TF_MASK;
996         return;
997 }
998
999 /*
1000  * Note that we play around with the 'TS' bit in an attempt to get
1001  * the correct behaviour even in the presence of the asynchronous
1002  * IRQ13 behaviour
1003  */
1004 void math_error(void __user *eip)
1005 {
1006         struct task_struct * task;
1007         siginfo_t info;
1008         unsigned short cwd, swd;
1009
1010         /*
1011          * Save the info for the exception handler and clear the error.
1012          */
1013         task = current;
1014         save_init_fpu(task);
1015         task->thread.trap_no = 16;
1016         task->thread.error_code = 0;
1017         info.si_signo = SIGFPE;
1018         info.si_errno = 0;
1019         info.si_code = __SI_FAULT;
1020         info.si_addr = eip;
1021         /*
1022          * (~cwd & swd) will mask out exceptions that are not set to unmasked
1023          * status.  0x3f is the exception bits in these regs, 0x200 is the
1024          * C1 reg you need in case of a stack fault, 0x040 is the stack
1025          * fault bit.  We should only be taking one exception at a time,
1026          * so if this combination doesn't produce any single exception,
1027          * then we have a bad program that isn't syncronizing its FPU usage
1028          * and it will suffer the consequences since we won't be able to
1029          * fully reproduce the context of the exception
1030          */
1031         cwd = get_fpu_cwd(task);
1032         swd = get_fpu_swd(task);
1033         switch (swd & ~cwd & 0x3f) {
1034                 case 0x000: /* No unmasked exception */
1035                         return;
1036                 default:    /* Multiple exceptions */
1037                         break;
1038                 case 0x001: /* Invalid Op */
1039                         /*
1040                          * swd & 0x240 == 0x040: Stack Underflow
1041                          * swd & 0x240 == 0x240: Stack Overflow
1042                          * User must clear the SF bit (0x40) if set
1043                          */
1044                         info.si_code = FPE_FLTINV;
1045                         break;
1046                 case 0x002: /* Denormalize */
1047                 case 0x010: /* Underflow */
1048                         info.si_code = FPE_FLTUND;
1049                         break;
1050                 case 0x004: /* Zero Divide */
1051                         info.si_code = FPE_FLTDIV;
1052                         break;
1053                 case 0x008: /* Overflow */
1054                         info.si_code = FPE_FLTOVF;
1055                         break;
1056                 case 0x020: /* Precision */
1057                         info.si_code = FPE_FLTRES;
1058                         break;
1059         }
1060         force_sig_info(SIGFPE, &info, task);
1061 }
1062
1063 fastcall void do_coprocessor_error(struct pt_regs * regs, long error_code)
1064 {
1065         ignore_fpu_irq = 1;
1066         math_error((void __user *)regs->eip);
1067 }
1068
1069 static void simd_math_error(void __user *eip)
1070 {
1071         struct task_struct * task;
1072         siginfo_t info;
1073         unsigned short mxcsr;
1074
1075         /*
1076          * Save the info for the exception handler and clear the error.
1077          */
1078         task = current;
1079         save_init_fpu(task);
1080         task->thread.trap_no = 19;
1081         task->thread.error_code = 0;
1082         info.si_signo = SIGFPE;
1083         info.si_errno = 0;
1084         info.si_code = __SI_FAULT;
1085         info.si_addr = eip;
1086         /*
1087          * The SIMD FPU exceptions are handled a little differently, as there
1088          * is only a single status/control register.  Thus, to determine which
1089          * unmasked exception was caught we must mask the exception mask bits
1090          * at 0x1f80, and then use these to mask the exception bits at 0x3f.
1091          */
1092         mxcsr = get_fpu_mxcsr(task);
1093         switch (~((mxcsr & 0x1f80) >> 7) & (mxcsr & 0x3f)) {
1094                 case 0x000:
1095                 default:
1096                         break;
1097                 case 0x001: /* Invalid Op */
1098                         info.si_code = FPE_FLTINV;
1099                         break;
1100                 case 0x002: /* Denormalize */
1101                 case 0x010: /* Underflow */
1102                         info.si_code = FPE_FLTUND;
1103                         break;
1104                 case 0x004: /* Zero Divide */
1105                         info.si_code = FPE_FLTDIV;
1106                         break;
1107                 case 0x008: /* Overflow */
1108                         info.si_code = FPE_FLTOVF;
1109                         break;
1110                 case 0x020: /* Precision */
1111                         info.si_code = FPE_FLTRES;
1112                         break;
1113         }
1114         force_sig_info(SIGFPE, &info, task);
1115 }
1116
1117 fastcall void do_simd_coprocessor_error(struct pt_regs * regs,
1118                                           long error_code)
1119 {
1120         if (cpu_has_xmm) {
1121                 /* Handle SIMD FPU exceptions on PIII+ processors. */
1122                 ignore_fpu_irq = 1;
1123                 simd_math_error((void __user *)regs->eip);
1124         } else {
1125                 /*
1126                  * Handle strange cache flush from user space exception
1127                  * in all other cases.  This is undocumented behaviour.
1128                  */
1129                 if (regs->eflags & VM_MASK) {
1130                         handle_vm86_fault((struct kernel_vm86_regs *)regs,
1131                                           error_code);
1132                         return;
1133                 }
1134                 current->thread.trap_no = 19;
1135                 current->thread.error_code = error_code;
1136                 die_if_kernel("cache flush denied", regs, error_code);
1137                 force_sig(SIGSEGV, current);
1138         }
1139 }
1140
1141 #ifndef CONFIG_XEN
1142 fastcall void do_spurious_interrupt_bug(struct pt_regs * regs,
1143                                           long error_code)
1144 {
1145 #if 0
1146         /* No need to warn about this any longer. */
1147         printk("Ignoring P6 Local APIC Spurious Interrupt Bug...\n");
1148 #endif
1149 }
1150
1151 fastcall void setup_x86_bogus_stack(unsigned char * stk)
1152 {
1153         unsigned long *switch16_ptr, *switch32_ptr;
1154         struct pt_regs *regs;
1155         unsigned long stack_top, stack_bot;
1156         unsigned short iret_frame16_off;
1157         int cpu = smp_processor_id();
1158         /* reserve the space on 32bit stack for the magic switch16 pointer */
1159         memmove(stk, stk + 8, sizeof(struct pt_regs));
1160         switch16_ptr = (unsigned long *)(stk + sizeof(struct pt_regs));
1161         regs = (struct pt_regs *)stk;
1162         /* now the switch32 on 16bit stack */
1163         stack_bot = (unsigned long)&per_cpu(cpu_16bit_stack, cpu);
1164         stack_top = stack_bot + CPU_16BIT_STACK_SIZE;
1165         switch32_ptr = (unsigned long *)(stack_top - 8);
1166         iret_frame16_off = CPU_16BIT_STACK_SIZE - 8 - 20;
1167         /* copy iret frame on 16bit stack */
1168         memcpy((void *)(stack_bot + iret_frame16_off), &regs->eip, 20);
1169         /* fill in the switch pointers */
1170         switch16_ptr[0] = (regs->esp & 0xffff0000) | iret_frame16_off;
1171         switch16_ptr[1] = __ESPFIX_SS;
1172         switch32_ptr[0] = (unsigned long)stk + sizeof(struct pt_regs) +
1173                 8 - CPU_16BIT_STACK_SIZE;
1174         switch32_ptr[1] = __KERNEL_DS;
1175 }
1176
1177 fastcall unsigned char * fixup_x86_bogus_stack(unsigned short sp)
1178 {
1179         unsigned long *switch32_ptr;
1180         unsigned char *stack16, *stack32;
1181         unsigned long stack_top, stack_bot;
1182         int len;
1183         int cpu = smp_processor_id();
1184         stack_bot = (unsigned long)&per_cpu(cpu_16bit_stack, cpu);
1185         stack_top = stack_bot + CPU_16BIT_STACK_SIZE;
1186         switch32_ptr = (unsigned long *)(stack_top - 8);
1187         /* copy the data from 16bit stack to 32bit stack */
1188         len = CPU_16BIT_STACK_SIZE - 8 - sp;
1189         stack16 = (unsigned char *)(stack_bot + sp);
1190         stack32 = (unsigned char *)
1191                 (switch32_ptr[0] + CPU_16BIT_STACK_SIZE - 8 - len);
1192         memcpy(stack32, stack16, len);
1193         return stack32;
1194 }
1195 #endif
1196
1197 /*
1198  *  'math_state_restore()' saves the current math information in the
1199  * old math state array, and gets the new ones from the current task
1200  *
1201  * Careful.. There are problems with IBM-designed IRQ13 behaviour.
1202  * Don't touch unless you *really* know how it works.
1203  *
1204  * Must be called with kernel preemption disabled (in this case,
1205  * local interrupts are disabled at the call-site in entry.S).
1206  */
1207 asmlinkage void math_state_restore(struct pt_regs regs)
1208 {
1209         struct thread_info *thread = current_thread_info();
1210         struct task_struct *tsk = thread->task;
1211
1212         /* NB. 'clts' is done for us by Xen during virtual trap. */
1213         if (!tsk_used_math(tsk))
1214                 init_fpu(tsk);
1215         restore_fpu(tsk);
1216         thread->status |= TS_USEDFPU;   /* So we fnsave on switch_to() */
1217 }
1218
1219 #ifndef CONFIG_MATH_EMULATION
1220
1221 asmlinkage void math_emulate(long arg)
1222 {
1223         printk(KERN_EMERG "math-emulation not enabled and no coprocessor found.\n");
1224         printk(KERN_EMERG "killing %s.\n",current->comm);
1225         force_sig(SIGFPE,current);
1226         schedule();
1227 }
1228
1229 #endif /* CONFIG_MATH_EMULATION */
1230
1231 #ifdef CONFIG_X86_F00F_BUG
1232 void __init trap_init_f00f_bug(void)
1233 {
1234         __set_fixmap(FIX_F00F_IDT, __pa(&idt_table), PAGE_KERNEL_RO);
1235
1236         /*
1237          * Update the IDT descriptor and reload the IDT so that
1238          * it uses the read-only mapped virtual address.
1239          */
1240         idt_descr.address = fix_to_virt(FIX_F00F_IDT);
1241         load_idt(&idt_descr);
1242 }
1243 #endif
1244
1245
1246 /*
1247  * NB. All these are "trap gates" (i.e. events_mask isn't set) except
1248  * for those that specify <dpl>|4 in the second field.
1249  */
1250 static trap_info_t trap_table[] = {
1251         {  0, 0, __KERNEL_CS, (unsigned long)divide_error               },
1252         {  1, 0|4, __KERNEL_CS, (unsigned long)debug                    },
1253         {  3, 3|4, __KERNEL_CS, (unsigned long)int3                     },
1254         {  4, 3, __KERNEL_CS, (unsigned long)overflow                   },
1255         {  5, 0, __KERNEL_CS, (unsigned long)bounds                     },
1256         {  6, 0, __KERNEL_CS, (unsigned long)invalid_op                 },
1257         {  7, 0|4, __KERNEL_CS, (unsigned long)device_not_available     },
1258         {  9, 0, __KERNEL_CS, (unsigned long)coprocessor_segment_overrun },
1259         { 10, 0, __KERNEL_CS, (unsigned long)invalid_TSS                },
1260         { 11, 0, __KERNEL_CS, (unsigned long)segment_not_present        },
1261         { 12, 0, __KERNEL_CS, (unsigned long)stack_segment              },
1262         { 13, 0, __KERNEL_CS, (unsigned long)general_protection         },
1263         { 14, 0|4, __KERNEL_CS, (unsigned long)page_fault               },
1264         { 15, 0, __KERNEL_CS, (unsigned long)fixup_4gb_segment          },
1265         { 16, 0, __KERNEL_CS, (unsigned long)coprocessor_error          },
1266         { 17, 0, __KERNEL_CS, (unsigned long)alignment_check            },
1267 #ifdef CONFIG_X86_MCE
1268         { 18, 0, __KERNEL_CS, (unsigned long)machine_check              },
1269 #endif
1270         { 19, 0, __KERNEL_CS, (unsigned long)simd_coprocessor_error     },
1271         { SYSCALL_VECTOR,  3, __KERNEL_CS, (unsigned long)system_call   },
1272         {  0, 0,           0, 0                                         }
1273 };
1274
1275 void __init trap_init(void)
1276 {
1277         HYPERVISOR_set_trap_table(trap_table);
1278
1279         if (cpu_has_fxsr) {
1280                 /*
1281                  * Verify that the FXSAVE/FXRSTOR data will be 16-byte aligned.
1282                  * Generates a compile-time "error: zero width for bit-field" if
1283                  * the alignment is wrong.
1284                  */
1285                 struct fxsrAlignAssert {
1286                         int _:!(offsetof(struct task_struct,
1287                                         thread.i387.fxsave) & 15);
1288                 };
1289
1290                 printk(KERN_INFO "Enabling fast FPU save and restore... ");
1291                 set_in_cr4(X86_CR4_OSFXSR);
1292                 printk("done.\n");
1293         }
1294         if (cpu_has_xmm) {
1295                 printk(KERN_INFO "Enabling unmasked SIMD FPU exception "
1296                                 "support... ");
1297                 set_in_cr4(X86_CR4_OSXMMEXCPT);
1298                 printk("done.\n");
1299         }
1300
1301         /*
1302          * Should be a barrier for any external CPU state.
1303          */
1304         cpu_init();
1305 }
1306
1307 void smp_trap_init(trap_info_t *trap_ctxt)
1308 {
1309         trap_info_t *t = trap_table;
1310
1311         for (t = trap_table; t->address; t++) {
1312                 trap_ctxt[t->vector].flags = t->flags;
1313                 trap_ctxt[t->vector].cs = t->cs;
1314                 trap_ctxt[t->vector].address = t->address;
1315         }
1316 }
1317
1318 static int __init kstack_setup(char *s)
1319 {
1320         kstack_depth_to_print = simple_strtoul(s, NULL, 0);
1321         return 1;
1322 }
1323 __setup("kstack=", kstack_setup);
1324
1325 #ifdef CONFIG_STACK_UNWIND
1326 static int __init call_trace_setup(char *s)
1327 {
1328         if (strcmp(s, "old") == 0)
1329                 call_trace = -1;
1330         else if (strcmp(s, "both") == 0)
1331                 call_trace = 0;
1332         else if (strcmp(s, "newfallback") == 0)
1333                 call_trace = 1;
1334         else if (strcmp(s, "new") == 2)
1335                 call_trace = 2;
1336         return 1;
1337 }
1338 __setup("call_trace=", call_trace_setup);
1339 #endif