2 * linux/arch/x86-64/traps.c
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
7 * Pentium III FXSR, SSE support
8 * Gareth Hughes <gareth@valinux.com>, May 2000
10 * $Id: traps.c,v 1.36 2002/03/24 11:09:10 ak Exp $
14 * 'Traps.c' handles hardware traps and faults after we have saved some
17 #include <linux/config.h>
18 #include <linux/sched.h>
19 #include <linux/kernel.h>
20 #include <linux/string.h>
21 #include <linux/errno.h>
22 #include <linux/ptrace.h>
23 #include <linux/timer.h>
25 #include <linux/init.h>
26 #include <linux/delay.h>
27 #include <linux/spinlock.h>
28 #include <linux/interrupt.h>
29 #include <linux/module.h>
30 #include <linux/moduleparam.h>
31 #include <linux/nmi.h>
32 #include <linux/kprobes.h>
34 #include <asm/system.h>
35 #include <asm/uaccess.h>
37 #include <asm/atomic.h>
38 #include <asm/debugreg.h>
41 #include <asm/kdebug.h>
42 #include <asm/processor.h>
45 #include <asm/pgalloc.h>
47 #include <asm/proto.h>
50 extern struct gate_struct idt_table[256];
52 asmlinkage void divide_error(void);
53 asmlinkage void debug(void);
54 asmlinkage void nmi(void);
55 asmlinkage void int3(void);
56 asmlinkage void overflow(void);
57 asmlinkage void bounds(void);
58 asmlinkage void invalid_op(void);
59 asmlinkage void device_not_available(void);
60 asmlinkage void double_fault(void);
61 asmlinkage void coprocessor_segment_overrun(void);
62 asmlinkage void invalid_TSS(void);
63 asmlinkage void segment_not_present(void);
64 asmlinkage void stack_segment(void);
65 asmlinkage void general_protection(void);
66 asmlinkage void page_fault(void);
67 asmlinkage void coprocessor_error(void);
68 asmlinkage void simd_coprocessor_error(void);
69 asmlinkage void reserved(void);
70 asmlinkage void alignment_check(void);
71 asmlinkage void machine_check(void);
72 asmlinkage void spurious_interrupt_bug(void);
74 struct notifier_block *die_chain;
75 static DEFINE_SPINLOCK(die_notifier_lock);
77 int register_die_notifier(struct notifier_block *nb)
83 spin_lock_irqsave(&die_notifier_lock, flags);
84 err = notifier_chain_register(&die_chain, nb);
85 spin_unlock_irqrestore(&die_notifier_lock, flags);
89 static inline void conditional_sti(struct pt_regs *regs)
91 if (regs->eflags & X86_EFLAGS_IF)
95 static inline void preempt_conditional_sti(struct pt_regs *regs)
98 if (regs->eflags & X86_EFLAGS_IF)
102 static inline void preempt_conditional_cli(struct pt_regs *regs)
104 if (regs->eflags & X86_EFLAGS_IF)
106 preempt_enable_no_resched();
109 static int kstack_depth_to_print = 10;
111 #ifdef CONFIG_KALLSYMS
112 #include <linux/kallsyms.h>
113 int printk_address(unsigned long address)
115 unsigned long offset = 0, symsize;
121 symname = kallsyms_lookup(address, &symsize, &offset, &modname, namebuf);
123 return printk("[<%016lx>]", address);
125 modname = delim = "";
126 return printk("<%016lx>{%s%s%s%s%+ld}",
127 address, delim, modname, delim, symname, offset);
130 int printk_address(unsigned long address)
132 return printk("[<%016lx>]", address);
136 static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
137 unsigned *usedp, const char **idp)
139 static char ids[][8] = {
140 [DEBUG_STACK - 1] = "#DB",
141 [NMI_STACK - 1] = "NMI",
142 [DOUBLEFAULT_STACK - 1] = "#DF",
143 [STACKFAULT_STACK - 1] = "#SS",
144 [MCE_STACK - 1] = "#MC",
145 #if DEBUG_STKSZ > EXCEPTION_STKSZ
146 [N_EXCEPTION_STACKS ... N_EXCEPTION_STACKS + DEBUG_STKSZ / EXCEPTION_STKSZ - 2] = "#DB[?]"
151 for (k = 0; k < N_EXCEPTION_STACKS; k++) {
155 #if DEBUG_STKSZ > EXCEPTION_STKSZ
157 end = cpu_pda(cpu)->debugstack + DEBUG_STKSZ;
161 end = per_cpu(init_tss, cpu).ist[k];
166 if (stack >= end - EXCEPTION_STKSZ) {
167 if (*usedp & (1U << k))
171 return (unsigned long *)end;
173 #if DEBUG_STKSZ > EXCEPTION_STKSZ
174 if (k == DEBUG_STACK - 1 && stack >= end - DEBUG_STKSZ) {
175 unsigned j = N_EXCEPTION_STACKS - 1;
179 end -= EXCEPTION_STKSZ;
180 ids[j][4] = '1' + (j - N_EXCEPTION_STACKS);
181 } while (stack < end - EXCEPTION_STKSZ);
182 if (*usedp & (1U << j))
186 return (unsigned long *)end;
194 * x86-64 can have upto three kernel stacks:
197 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
200 void show_trace(unsigned long *stack)
202 const unsigned cpu = safe_smp_processor_id();
203 unsigned long *irqstack_end = (unsigned long *)cpu_pda(cpu)->irqstackptr;
207 printk("\nCall Trace:");
209 #define HANDLE_STACK(cond) \
211 unsigned long addr = *stack++; \
212 if (kernel_text_address(addr)) { \
220 * If the address is either in the text segment of the \
221 * kernel, or in the region which contains vmalloc'ed \
222 * memory, it *may* be the address of a calling \
223 * routine; if so, print it so that someone tracing \
224 * down the cause of the crash will be able to figure \
225 * out the call path that was taken. \
227 i += printk_address(addr); \
233 unsigned long *estack_end;
234 estack_end = in_exception_stack(cpu, (unsigned long)stack,
238 i += printk(" <%s>", id);
239 HANDLE_STACK (stack < estack_end);
240 i += printk(" <EOE>");
241 stack = (unsigned long *) estack_end[-2];
245 unsigned long *irqstack;
246 irqstack = irqstack_end -
247 (IRQSTACKSIZE - 64) / sizeof(*irqstack);
249 if (stack >= irqstack && stack < irqstack_end) {
250 i += printk(" <IRQ>");
251 HANDLE_STACK (stack < irqstack_end);
252 stack = (unsigned long *) (irqstack_end[-1]);
254 i += printk(" <EOI>");
261 HANDLE_STACK (((long) stack & (THREAD_SIZE-1)) != 0);
266 void show_stack(struct task_struct *tsk, unsigned long * rsp)
268 unsigned long *stack;
270 const int cpu = safe_smp_processor_id();
271 unsigned long *irqstack_end = (unsigned long *) (cpu_pda(cpu)->irqstackptr);
272 unsigned long *irqstack = (unsigned long *) (cpu_pda(cpu)->irqstackptr - IRQSTACKSIZE);
274 // debugging aid: "show_stack(NULL, NULL);" prints the
275 // back trace for this cpu.
279 rsp = (unsigned long *)tsk->thread.rsp;
281 rsp = (unsigned long *)&rsp;
285 for(i=0; i < kstack_depth_to_print; i++) {
286 if (stack >= irqstack && stack <= irqstack_end) {
287 if (stack == irqstack_end) {
288 stack = (unsigned long *) (irqstack_end[-1]);
292 if (((long) stack & (THREAD_SIZE-1)) == 0)
295 if (i && ((i % 4) == 0))
297 printk("%016lx ", *stack++);
298 touch_nmi_watchdog();
300 show_trace((unsigned long *)rsp);
304 * The architecture-independent dump_stack generator
306 void dump_stack(void)
312 EXPORT_SYMBOL(dump_stack);
314 void show_registers(struct pt_regs *regs)
317 int in_kernel = !user_mode(regs);
319 const int cpu = safe_smp_processor_id();
320 struct task_struct *cur = cpu_pda(cpu)->pcurrent;
324 printk("CPU %d ", cpu);
326 printk("Process %s (pid: %d, threadinfo %p, task %p)\n",
327 cur->comm, cur->pid, task_thread_info(cur), cur);
330 * When in-kernel, we also print out the stack and code at the
331 * time of the fault..
336 show_stack(NULL, (unsigned long*)rsp);
339 if (regs->rip < PAGE_OFFSET)
342 for (i=0; i<20; i++) {
344 if (__get_user(c, &((unsigned char*)regs->rip)[i])) {
346 printk(" Bad RIP value.");
355 void handle_BUG(struct pt_regs *regs)
359 const char *prefix = "";
363 if (__copy_from_user(&f, (const void __user *) regs->rip,
364 sizeof(struct bug_frame)))
366 if (f.filename >= 0 ||
367 f.ud2[0] != 0x0f || f.ud2[1] != 0x0b)
369 len = __strnlen_user((char *)(long)f.filename, PATH_MAX) - 1;
370 if (len < 0 || len >= PATH_MAX)
371 f.filename = (int)(long)"unmapped filename";
373 f.filename += len - 50;
376 printk("----------- [cut here ] --------- [please bite here ] ---------\n");
377 printk(KERN_ALERT "Kernel BUG at %s%.50s:%d\n", prefix, (char *)(long)f.filename, f.line);
381 void out_of_line_bug(void)
387 static DEFINE_SPINLOCK(die_lock);
388 static int die_owner = -1;
390 unsigned __kprobes long oops_begin(void)
392 int cpu = safe_smp_processor_id();
395 /* racy, but better than risking deadlock. */
396 local_irq_save(flags);
397 if (!spin_trylock(&die_lock)) {
398 if (cpu == die_owner)
399 /* nested oops. should stop eventually */;
401 spin_lock(&die_lock);
409 void __kprobes oops_end(unsigned long flags)
413 spin_unlock_irqrestore(&die_lock, flags);
418 void __kprobes __die(const char * str, struct pt_regs * regs, long err)
420 static int die_counter;
421 printk(KERN_EMERG "%s: %04lx [%u] ", str, err & 0xffff,++die_counter);
422 #ifdef CONFIG_PREEMPT
428 #ifdef CONFIG_DEBUG_PAGEALLOC
429 printk("DEBUG_PAGEALLOC");
432 notify_die(DIE_OOPS, str, regs, err, current->thread.trap_no, SIGSEGV);
433 show_registers(regs);
434 /* Executive summary in case the oops scrolled away */
435 printk(KERN_ALERT "RIP ");
436 printk_address(regs->rip);
437 printk(" RSP <%016lx>\n", regs->rsp);
440 void die(const char * str, struct pt_regs * regs, long err)
442 unsigned long flags = oops_begin();
445 __die(str, regs, err);
450 void __kprobes die_nmi(char *str, struct pt_regs *regs)
452 unsigned long flags = oops_begin();
455 * We are in trouble anyway, lets at least try
456 * to get a message out.
458 printk(str, safe_smp_processor_id());
459 show_registers(regs);
460 if (panic_on_timeout || panic_on_oops)
461 panic("nmi watchdog");
462 printk("console shuts up ...\n");
467 static void __kprobes do_trap(int trapnr, int signr, char *str,
468 struct pt_regs * regs, long error_code,
471 struct task_struct *tsk = current;
473 conditional_sti(regs);
475 tsk->thread.error_code = error_code;
476 tsk->thread.trap_no = trapnr;
478 if (user_mode(regs)) {
479 if (exception_trace && unhandled_signal(tsk, signr))
481 "%s[%d] trap %s rip:%lx rsp:%lx error:%lx\n",
482 tsk->comm, tsk->pid, str,
483 regs->rip, regs->rsp, error_code);
486 force_sig_info(signr, info, tsk);
488 force_sig(signr, tsk);
495 const struct exception_table_entry *fixup;
496 fixup = search_exception_tables(regs->rip);
498 regs->rip = fixup->fixup;
500 die(str, regs, error_code);
505 #define DO_ERROR(trapnr, signr, str, name) \
506 asmlinkage void do_##name(struct pt_regs * regs, long error_code) \
508 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
511 do_trap(trapnr, signr, str, regs, error_code, NULL); \
514 #define DO_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \
515 asmlinkage void do_##name(struct pt_regs * regs, long error_code) \
518 info.si_signo = signr; \
520 info.si_code = sicode; \
521 info.si_addr = (void __user *)siaddr; \
522 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
525 do_trap(trapnr, signr, str, regs, error_code, &info); \
528 DO_ERROR_INFO( 0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->rip)
529 DO_ERROR( 4, SIGSEGV, "overflow", overflow)
530 DO_ERROR( 5, SIGSEGV, "bounds", bounds)
531 DO_ERROR_INFO( 6, SIGILL, "invalid opcode", invalid_op, ILL_ILLOPN, regs->rip)
532 DO_ERROR( 7, SIGSEGV, "device not available", device_not_available)
533 DO_ERROR( 9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun)
534 DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS)
535 DO_ERROR(11, SIGBUS, "segment not present", segment_not_present)
536 DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0)
537 DO_ERROR(18, SIGSEGV, "reserved", reserved)
538 DO_ERROR(12, SIGBUS, "stack segment", stack_segment)
540 asmlinkage void do_double_fault(struct pt_regs * regs, long error_code)
542 static const char str[] = "double fault";
543 struct task_struct *tsk = current;
545 /* Return not checked because double check cannot be ignored */
546 notify_die(DIE_TRAP, str, regs, error_code, 8, SIGSEGV);
548 tsk->thread.error_code = error_code;
549 tsk->thread.trap_no = 8;
551 /* This is always a kernel trap and never fixable (and thus must
554 die(str, regs, error_code);
557 asmlinkage void __kprobes do_general_protection(struct pt_regs * regs,
560 struct task_struct *tsk = current;
562 conditional_sti(regs);
564 tsk->thread.error_code = error_code;
565 tsk->thread.trap_no = 13;
567 if (user_mode(regs)) {
568 if (exception_trace && unhandled_signal(tsk, SIGSEGV))
570 "%s[%d] general protection rip:%lx rsp:%lx error:%lx\n",
572 regs->rip, regs->rsp, error_code);
574 force_sig(SIGSEGV, tsk);
580 const struct exception_table_entry *fixup;
581 fixup = search_exception_tables(regs->rip);
583 regs->rip = fixup->fixup;
586 if (notify_die(DIE_GPF, "general protection fault", regs,
587 error_code, 13, SIGSEGV) == NOTIFY_STOP)
589 die("general protection fault", regs, error_code);
593 static __kprobes void
594 mem_parity_error(unsigned char reason, struct pt_regs * regs)
596 printk("Uhhuh. NMI received. Dazed and confused, but trying to continue\n");
597 printk("You probably have a hardware problem with your RAM chips\n");
599 /* Clear and disable the memory parity error line. */
600 reason = (reason & 0xf) | 4;
604 static __kprobes void
605 io_check_error(unsigned char reason, struct pt_regs * regs)
607 printk("NMI: IOCK error (debug interrupt?)\n");
608 show_registers(regs);
610 /* Re-enable the IOCK line, wait for a few seconds */
611 reason = (reason & 0xf) | 8;
618 static __kprobes void
619 unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
620 { printk("Uhhuh. NMI received for unknown reason %02x.\n", reason);
621 printk("Dazed and confused, but trying to continue\n");
622 printk("Do you have a strange power saving mode enabled?\n");
625 /* Runs on IST stack. This code must keep interrupts off all the time.
626 Nested NMIs are prevented by the CPU. */
627 asmlinkage __kprobes void default_do_nmi(struct pt_regs *regs)
629 unsigned char reason = 0;
632 cpu = smp_processor_id();
634 /* Only the BSP gets external NMIs from the system. */
636 reason = get_nmi_reason();
638 if (!(reason & 0xc0)) {
639 if (notify_die(DIE_NMI_IPI, "nmi_ipi", regs, reason, 2, SIGINT)
642 #ifdef CONFIG_X86_LOCAL_APIC
644 * Ok, so this is none of the documented NMI sources,
645 * so it must be the NMI watchdog.
647 if (nmi_watchdog > 0) {
648 nmi_watchdog_tick(regs,reason);
652 unknown_nmi_error(reason, regs);
655 if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT) == NOTIFY_STOP)
658 /* AK: following checks seem to be broken on modern chipsets. FIXME */
661 mem_parity_error(reason, regs);
663 io_check_error(reason, regs);
666 /* runs on IST stack. */
667 asmlinkage void __kprobes do_int3(struct pt_regs * regs, long error_code)
669 if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP) == NOTIFY_STOP) {
672 do_trap(3, SIGTRAP, "int3", regs, error_code, NULL);
676 /* Help handler running on IST stack to switch back to user stack
677 for scheduling or signal handling. The actual stack switch is done in
679 asmlinkage __kprobes struct pt_regs *sync_regs(struct pt_regs *eregs)
681 struct pt_regs *regs = eregs;
682 /* Did already sync */
683 if (eregs == (struct pt_regs *)eregs->rsp)
685 /* Exception from user space */
686 else if (user_mode(eregs))
687 regs = task_pt_regs(current);
688 /* Exception from kernel and interrupts are enabled. Move to
689 kernel process stack. */
690 else if (eregs->eflags & X86_EFLAGS_IF)
691 regs = (struct pt_regs *)(eregs->rsp -= sizeof(struct pt_regs));
697 /* runs on IST stack. */
698 asmlinkage void __kprobes do_debug(struct pt_regs * regs,
699 unsigned long error_code)
701 unsigned long condition;
702 struct task_struct *tsk = current;
705 get_debugreg(condition, 6);
707 if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code,
708 SIGTRAP) == NOTIFY_STOP)
711 preempt_conditional_sti(regs);
713 /* Mask out spurious debug traps due to lazy DR7 setting */
714 if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3)) {
715 if (!tsk->thread.debugreg7) {
720 tsk->thread.debugreg6 = condition;
722 /* Mask out spurious TF errors due to lazy TF clearing */
723 if (condition & DR_STEP) {
725 * The TF error should be masked out only if the current
726 * process is not traced and if the TRAP flag has been set
727 * previously by a tracing process (condition detected by
728 * the PT_DTRACE flag); remember that the i386 TRAP flag
729 * can be modified by the process itself in user mode,
730 * allowing programs to debug themselves without the ptrace()
733 if (!user_mode(regs))
734 goto clear_TF_reenable;
736 * Was the TF flag set by a debugger? If so, clear it now,
737 * so that register information is correct.
739 if (tsk->ptrace & PT_DTRACE) {
740 regs->eflags &= ~TF_MASK;
741 tsk->ptrace &= ~PT_DTRACE;
745 /* Ok, finally something we can handle */
746 tsk->thread.trap_no = 1;
747 tsk->thread.error_code = error_code;
748 info.si_signo = SIGTRAP;
750 info.si_code = TRAP_BRKPT;
751 info.si_addr = user_mode(regs) ? (void __user *)regs->rip : NULL;
752 force_sig_info(SIGTRAP, &info, tsk);
755 set_debugreg(0UL, 7);
756 preempt_conditional_cli(regs);
760 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
761 regs->eflags &= ~TF_MASK;
762 preempt_conditional_cli(regs);
765 static int kernel_math_error(struct pt_regs *regs, const char *str, int trapnr)
767 const struct exception_table_entry *fixup;
768 fixup = search_exception_tables(regs->rip);
770 regs->rip = fixup->fixup;
773 notify_die(DIE_GPF, str, regs, 0, trapnr, SIGFPE);
774 /* Illegal floating point operation in the kernel */
775 current->thread.trap_no = trapnr;
781 * Note that we play around with the 'TS' bit in an attempt to get
782 * the correct behaviour even in the presence of the asynchronous
785 asmlinkage void do_coprocessor_error(struct pt_regs *regs)
787 void __user *rip = (void __user *)(regs->rip);
788 struct task_struct * task;
790 unsigned short cwd, swd;
792 conditional_sti(regs);
793 if (!user_mode(regs) &&
794 kernel_math_error(regs, "kernel x87 math error", 16))
798 * Save the info for the exception handler and clear the error.
802 task->thread.trap_no = 16;
803 task->thread.error_code = 0;
804 info.si_signo = SIGFPE;
806 info.si_code = __SI_FAULT;
809 * (~cwd & swd) will mask out exceptions that are not set to unmasked
810 * status. 0x3f is the exception bits in these regs, 0x200 is the
811 * C1 reg you need in case of a stack fault, 0x040 is the stack
812 * fault bit. We should only be taking one exception at a time,
813 * so if this combination doesn't produce any single exception,
814 * then we have a bad program that isn't synchronizing its FPU usage
815 * and it will suffer the consequences since we won't be able to
816 * fully reproduce the context of the exception
818 cwd = get_fpu_cwd(task);
819 swd = get_fpu_swd(task);
820 switch (swd & ~cwd & 0x3f) {
824 case 0x001: /* Invalid Op */
826 * swd & 0x240 == 0x040: Stack Underflow
827 * swd & 0x240 == 0x240: Stack Overflow
828 * User must clear the SF bit (0x40) if set
830 info.si_code = FPE_FLTINV;
832 case 0x002: /* Denormalize */
833 case 0x010: /* Underflow */
834 info.si_code = FPE_FLTUND;
836 case 0x004: /* Zero Divide */
837 info.si_code = FPE_FLTDIV;
839 case 0x008: /* Overflow */
840 info.si_code = FPE_FLTOVF;
842 case 0x020: /* Precision */
843 info.si_code = FPE_FLTRES;
846 force_sig_info(SIGFPE, &info, task);
849 asmlinkage void bad_intr(void)
851 printk("bad interrupt");
854 asmlinkage void do_simd_coprocessor_error(struct pt_regs *regs)
856 void __user *rip = (void __user *)(regs->rip);
857 struct task_struct * task;
859 unsigned short mxcsr;
861 conditional_sti(regs);
862 if (!user_mode(regs) &&
863 kernel_math_error(regs, "kernel simd math error", 19))
867 * Save the info for the exception handler and clear the error.
871 task->thread.trap_no = 19;
872 task->thread.error_code = 0;
873 info.si_signo = SIGFPE;
875 info.si_code = __SI_FAULT;
878 * The SIMD FPU exceptions are handled a little differently, as there
879 * is only a single status/control register. Thus, to determine which
880 * unmasked exception was caught we must mask the exception mask bits
881 * at 0x1f80, and then use these to mask the exception bits at 0x3f.
883 mxcsr = get_fpu_mxcsr(task);
884 switch (~((mxcsr & 0x1f80) >> 7) & (mxcsr & 0x3f)) {
888 case 0x001: /* Invalid Op */
889 info.si_code = FPE_FLTINV;
891 case 0x002: /* Denormalize */
892 case 0x010: /* Underflow */
893 info.si_code = FPE_FLTUND;
895 case 0x004: /* Zero Divide */
896 info.si_code = FPE_FLTDIV;
898 case 0x008: /* Overflow */
899 info.si_code = FPE_FLTOVF;
901 case 0x020: /* Precision */
902 info.si_code = FPE_FLTRES;
905 force_sig_info(SIGFPE, &info, task);
908 asmlinkage void do_spurious_interrupt_bug(struct pt_regs * regs)
912 asmlinkage void __attribute__((weak)) smp_thermal_interrupt(void)
916 asmlinkage void __attribute__((weak)) mce_threshold_interrupt(void)
921 * 'math_state_restore()' saves the current math information in the
922 * old math state array, and gets the new ones from the current task
924 * Careful.. There are problems with IBM-designed IRQ13 behaviour.
925 * Don't touch unless you *really* know how it works.
927 asmlinkage void math_state_restore(void)
929 struct task_struct *me = current;
930 clts(); /* Allow maths ops (or we recurse) */
934 restore_fpu_checking(&me->thread.i387.fxsave);
935 task_thread_info(me)->status |= TS_USEDFPU;
938 void __init trap_init(void)
940 set_intr_gate(0,÷_error);
941 set_intr_gate_ist(1,&debug,DEBUG_STACK);
942 set_intr_gate_ist(2,&nmi,NMI_STACK);
943 set_system_gate_ist(3,&int3,DEBUG_STACK); /* int3 can be called from all */
944 set_system_gate(4,&overflow); /* int4 can be called from all */
945 set_intr_gate(5,&bounds);
946 set_intr_gate(6,&invalid_op);
947 set_intr_gate(7,&device_not_available);
948 set_intr_gate_ist(8,&double_fault, DOUBLEFAULT_STACK);
949 set_intr_gate(9,&coprocessor_segment_overrun);
950 set_intr_gate(10,&invalid_TSS);
951 set_intr_gate(11,&segment_not_present);
952 set_intr_gate_ist(12,&stack_segment,STACKFAULT_STACK);
953 set_intr_gate(13,&general_protection);
954 set_intr_gate(14,&page_fault);
955 set_intr_gate(15,&spurious_interrupt_bug);
956 set_intr_gate(16,&coprocessor_error);
957 set_intr_gate(17,&alignment_check);
958 #ifdef CONFIG_X86_MCE
959 set_intr_gate_ist(18,&machine_check, MCE_STACK);
961 set_intr_gate(19,&simd_coprocessor_error);
963 #ifdef CONFIG_IA32_EMULATION
964 set_system_gate(IA32_SYSCALL_VECTOR, ia32_syscall);
968 * Should be a barrier for any external CPU state.
974 /* Actual parsing is done early in setup.c. */
975 static int __init oops_dummy(char *s)
980 __setup("oops=", oops_dummy);
982 static int __init kstack_setup(char *s)
984 kstack_depth_to_print = simple_strtoul(s,NULL,0);
987 __setup("kstack=", kstack_setup);