2 * Copyright (C) 1991, 1992 Linus Torvalds
3 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
5 * Pentium III FXSR, SSE support
6 * Gareth Hughes <gareth@valinux.com>, May 2000
10 * Handle hardware traps and faults.
12 #include <linux/interrupt.h>
13 #include <linux/kallsyms.h>
14 #include <linux/spinlock.h>
15 #include <linux/kprobes.h>
16 #include <linux/uaccess.h>
17 #include <linux/utsname.h>
18 #include <linux/kdebug.h>
19 #include <linux/kernel.h>
20 #include <linux/module.h>
21 #include <linux/ptrace.h>
22 #include <linux/string.h>
23 #include <linux/unwind.h>
24 #include <linux/delay.h>
25 #include <linux/errno.h>
26 #include <linux/kexec.h>
27 #include <linux/sched.h>
28 #include <linux/timer.h>
29 #include <linux/init.h>
30 #include <linux/bug.h>
31 #include <linux/nmi.h>
33 #include <linux/smp.h>
37 #include <linux/ioport.h>
38 #include <linux/eisa.h>
42 #include <linux/mca.h>
45 #if defined(CONFIG_EDAC)
46 #include <linux/edac.h>
49 #include <asm/stacktrace.h>
50 #include <asm/processor.h>
51 #include <asm/debugreg.h>
52 #include <asm/atomic.h>
53 #include <asm/system.h>
54 #include <asm/unwind.h>
55 #include <asm/traps.h>
59 #include <mach_traps.h>
62 #include <asm/pgalloc.h>
63 #include <asm/proto.h>
66 #include <asm/processor-flags.h>
67 #include <asm/arch_hooks.h>
72 #include "cpu/mcheck/mce.h"
74 DECLARE_BITMAP(used_vectors, NR_VECTORS);
75 EXPORT_SYMBOL_GPL(used_vectors);
77 asmlinkage int system_call(void);
79 /* Do we ignore FPU interrupts ? */
83 * The IDT has to be page-aligned to simplify the Pentium
84 * F0 0F bug workaround.. We have a special link segment
87 gate_desc idt_table[256]
88 __attribute__((__section__(".data.idt"))) = { { { { 0, 0 } } }, };
91 static int ignore_nmis;
93 static inline void conditional_sti(struct pt_regs *regs)
95 if (regs->flags & X86_EFLAGS_IF)
99 static inline void preempt_conditional_sti(struct pt_regs *regs)
102 if (regs->flags & X86_EFLAGS_IF)
106 static inline void preempt_conditional_cli(struct pt_regs *regs)
108 if (regs->flags & X86_EFLAGS_IF)
115 die_if_kernel(const char *str, struct pt_regs *regs, long err)
117 if (!user_mode_vm(regs))
122 * Perform the lazy TSS's I/O bitmap copy. If the TSS has an
123 * invalid offset set (the LAZY one) and the faulting thread has
124 * a valid I/O bitmap pointer, we copy the I/O bitmap in the TSS,
125 * we set the offset field correctly and return 1.
127 static int lazy_iobitmap_copy(void)
129 struct thread_struct *thread;
130 struct tss_struct *tss;
134 tss = &per_cpu(init_tss, cpu);
135 thread = ¤t->thread;
137 if (tss->x86_tss.io_bitmap_base == INVALID_IO_BITMAP_OFFSET_LAZY &&
138 thread->io_bitmap_ptr) {
139 memcpy(tss->io_bitmap, thread->io_bitmap_ptr,
140 thread->io_bitmap_max);
142 * If the previously set map was extending to higher ports
143 * than the current one, pad extra space with 0xff (no access).
145 if (thread->io_bitmap_max < tss->io_bitmap_max) {
146 memset((char *) tss->io_bitmap +
147 thread->io_bitmap_max, 0xff,
148 tss->io_bitmap_max - thread->io_bitmap_max);
150 tss->io_bitmap_max = thread->io_bitmap_max;
151 tss->x86_tss.io_bitmap_base = IO_BITMAP_OFFSET;
152 tss->io_bitmap_owner = thread;
163 static void __kprobes
164 do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
165 long error_code, siginfo_t *info)
167 struct task_struct *tsk = current;
170 if (regs->flags & X86_VM_MASK) {
172 * traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
173 * On nmi (interrupt 2), do_trap should not be called.
181 if (!user_mode(regs))
188 * We want error_code and trap_no set for userspace faults and
189 * kernelspace faults which result in die(), but not
190 * kernelspace faults which are fixed up. die() gives the
191 * process no chance to handle the signal and notice the
192 * kernel fault information, so that won't result in polluting
193 * the information about previously queued, but not yet
194 * delivered, faults. See also do_general_protection below.
196 tsk->thread.error_code = error_code;
197 tsk->thread.trap_no = trapnr;
200 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
201 printk_ratelimit()) {
203 "%s[%d] trap %s ip:%lx sp:%lx error:%lx",
204 tsk->comm, tsk->pid, str,
205 regs->ip, regs->sp, error_code);
206 print_vma_addr(" in ", regs->ip);
212 force_sig_info(signr, info, tsk);
214 force_sig(signr, tsk);
218 if (!fixup_exception(regs)) {
219 tsk->thread.error_code = error_code;
220 tsk->thread.trap_no = trapnr;
221 die(str, regs, error_code);
227 if (handle_vm86_trap((struct kernel_vm86_regs *) regs,
234 #define DO_ERROR(trapnr, signr, str, name) \
235 dotraplinkage void do_##name(struct pt_regs *regs, long error_code) \
237 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
240 conditional_sti(regs); \
241 do_trap(trapnr, signr, str, regs, error_code, NULL); \
244 #define DO_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \
245 dotraplinkage void do_##name(struct pt_regs *regs, long error_code) \
248 info.si_signo = signr; \
250 info.si_code = sicode; \
251 info.si_addr = (void __user *)siaddr; \
252 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
255 conditional_sti(regs); \
256 do_trap(trapnr, signr, str, regs, error_code, &info); \
259 DO_ERROR_INFO(0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->ip)
260 DO_ERROR(4, SIGSEGV, "overflow", overflow)
261 DO_ERROR(5, SIGSEGV, "bounds", bounds)
262 DO_ERROR_INFO(6, SIGILL, "invalid opcode", invalid_op, ILL_ILLOPN, regs->ip)
263 DO_ERROR(9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun)
264 DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS)
265 DO_ERROR(11, SIGBUS, "segment not present", segment_not_present)
267 DO_ERROR(12, SIGBUS, "stack segment", stack_segment)
269 DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0)
272 /* Runs on IST stack */
273 dotraplinkage void do_stack_segment(struct pt_regs *regs, long error_code)
275 if (notify_die(DIE_TRAP, "stack segment", regs, error_code,
276 12, SIGBUS) == NOTIFY_STOP)
278 preempt_conditional_sti(regs);
279 do_trap(12, SIGBUS, "stack segment", regs, error_code, NULL);
280 preempt_conditional_cli(regs);
283 dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code)
285 static const char str[] = "double fault";
286 struct task_struct *tsk = current;
288 /* Return not checked because double check cannot be ignored */
289 notify_die(DIE_TRAP, str, regs, error_code, 8, SIGSEGV);
291 tsk->thread.error_code = error_code;
292 tsk->thread.trap_no = 8;
294 /* This is always a kernel trap and never fixable (and thus must
297 die(str, regs, error_code);
301 dotraplinkage void __kprobes
302 do_general_protection(struct pt_regs *regs, long error_code)
304 struct task_struct *tsk;
306 conditional_sti(regs);
309 if (lazy_iobitmap_copy()) {
310 /* restart the faulting instruction */
314 if (regs->flags & X86_VM_MASK)
319 if (!user_mode(regs))
322 tsk->thread.error_code = error_code;
323 tsk->thread.trap_no = 13;
325 if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) &&
326 printk_ratelimit()) {
328 "%s[%d] general protection ip:%lx sp:%lx error:%lx",
329 tsk->comm, task_pid_nr(tsk),
330 regs->ip, regs->sp, error_code);
331 print_vma_addr(" in ", regs->ip);
335 force_sig(SIGSEGV, tsk);
341 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
346 if (fixup_exception(regs))
349 tsk->thread.error_code = error_code;
350 tsk->thread.trap_no = 13;
351 if (notify_die(DIE_GPF, "general protection fault", regs,
352 error_code, 13, SIGSEGV) == NOTIFY_STOP)
354 die("general protection fault", regs, error_code);
357 static notrace __kprobes void
358 mem_parity_error(unsigned char reason, struct pt_regs *regs)
361 "Uhhuh. NMI received for unknown reason %02x on CPU %d.\n",
362 reason, smp_processor_id());
365 "You have some hardware problem, likely on the PCI bus.\n");
367 #if defined(CONFIG_EDAC)
368 if (edac_handler_set()) {
369 edac_atomic_assert_error();
374 if (panic_on_unrecovered_nmi)
375 panic("NMI: Not continuing");
377 printk(KERN_EMERG "Dazed and confused, but trying to continue\n");
379 /* Clear and disable the memory parity error line. */
380 reason = (reason & 0xf) | 4;
384 static notrace __kprobes void
385 io_check_error(unsigned char reason, struct pt_regs *regs)
389 printk(KERN_EMERG "NMI: IOCK error (debug interrupt?)\n");
390 show_registers(regs);
392 /* Re-enable the IOCK line, wait for a few seconds */
393 reason = (reason & 0xf) | 8;
404 static notrace __kprobes void
405 unknown_nmi_error(unsigned char reason, struct pt_regs *regs)
407 if (notify_die(DIE_NMIUNKNOWN, "nmi", regs, reason, 2, SIGINT) ==
412 * Might actually be able to figure out what the guilty party
421 "Uhhuh. NMI received for unknown reason %02x on CPU %d.\n",
422 reason, smp_processor_id());
424 printk(KERN_EMERG "Do you have a strange power saving mode enabled?\n");
425 if (panic_on_unrecovered_nmi)
426 panic("NMI: Not continuing");
428 printk(KERN_EMERG "Dazed and confused, but trying to continue\n");
432 static DEFINE_SPINLOCK(nmi_print_lock);
434 void notrace __kprobes die_nmi(char *str, struct pt_regs *regs, int do_panic)
436 if (notify_die(DIE_NMIWATCHDOG, str, regs, 0, 2, SIGINT) == NOTIFY_STOP)
439 spin_lock(&nmi_print_lock);
441 * We are in trouble anyway, lets at least try
442 * to get a message out:
445 printk(KERN_EMERG "%s", str);
446 printk(" on CPU%d, ip %08lx, registers:\n",
447 smp_processor_id(), regs->ip);
448 show_registers(regs);
450 panic("Non maskable interrupt");
452 spin_unlock(&nmi_print_lock);
456 * If we are in kernel we are probably nested up pretty bad
457 * and might aswell get out now while we still can:
459 if (!user_mode_vm(regs)) {
460 current->thread.trap_no = 2;
468 static notrace __kprobes void default_do_nmi(struct pt_regs *regs)
470 unsigned char reason = 0;
473 cpu = smp_processor_id();
475 /* Only the BSP gets external NMIs from the system. */
477 reason = get_nmi_reason();
479 if (!(reason & 0xc0)) {
480 if (notify_die(DIE_NMI_IPI, "nmi_ipi", regs, reason, 2, SIGINT)
483 #ifdef CONFIG_X86_LOCAL_APIC
485 * Ok, so this is none of the documented NMI sources,
486 * so it must be the NMI watchdog.
488 if (nmi_watchdog_tick(regs, reason))
490 if (!do_nmi_callback(regs, cpu))
491 unknown_nmi_error(reason, regs);
493 unknown_nmi_error(reason, regs);
498 if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT) == NOTIFY_STOP)
501 /* AK: following checks seem to be broken on modern chipsets. FIXME */
503 mem_parity_error(reason, regs);
505 io_check_error(reason, regs);
508 * Reassert NMI in case it became active meanwhile
509 * as it's edge-triggered:
515 dotraplinkage notrace __kprobes void
516 do_nmi(struct pt_regs *regs, long error_code)
521 { int cpu; cpu = smp_processor_id(); ++nmi_count(cpu); }
523 add_pda(__nmi_count, 1);
527 default_do_nmi(regs);
538 void restart_nmi(void)
544 /* May run on IST stack. */
545 dotraplinkage void __kprobes do_int3(struct pt_regs *regs, long error_code)
547 #ifdef CONFIG_KPROBES
548 if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP)
552 if (notify_die(DIE_TRAP, "int3", regs, error_code, 3, SIGTRAP)
557 preempt_conditional_sti(regs);
558 do_trap(3, SIGTRAP, "int3", regs, error_code, NULL);
559 preempt_conditional_cli(regs);
563 /* Help handler running on IST stack to switch back to user stack
564 for scheduling or signal handling. The actual stack switch is done in
566 asmlinkage __kprobes struct pt_regs *sync_regs(struct pt_regs *eregs)
568 struct pt_regs *regs = eregs;
569 /* Did already sync */
570 if (eregs == (struct pt_regs *)eregs->sp)
572 /* Exception from user space */
573 else if (user_mode(eregs))
574 regs = task_pt_regs(current);
575 /* Exception from kernel and interrupts are enabled. Move to
576 kernel process stack. */
577 else if (eregs->flags & X86_EFLAGS_IF)
578 regs = (struct pt_regs *)(eregs->sp -= sizeof(struct pt_regs));
586 * Our handling of the processor debug registers is non-trivial.
587 * We do not clear them on entry and exit from the kernel. Therefore
588 * it is possible to get a watchpoint trap here from inside the kernel.
589 * However, the code in ./ptrace.c has ensured that the user can
590 * only set watchpoints on userspace addresses. Therefore the in-kernel
591 * watchpoint trap can only occur in code which is reading/writing
592 * from user space. Such code must not hold kernel locks (since it
593 * can equally take a page fault), therefore it is safe to call
594 * force_sig_info even though that claims and releases locks.
596 * Code in ./signal.c ensures that the debug control register
597 * is restored before we deliver any signal, and therefore that
598 * user code runs with the correct debug control register even though
601 * Being careful here means that we don't have to be as careful in a
602 * lot of more complicated places (task switching can be a bit lazy
603 * about restoring all the debug state, and ptrace doesn't have to
604 * find every occurrence of the TF bit that could be saved away even
607 * May run on IST stack.
609 dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
611 struct task_struct *tsk = current;
612 unsigned long condition;
615 get_debugreg(condition, 6);
618 * The processor cleared BTF, so don't mark that we need it set.
620 clear_tsk_thread_flag(tsk, TIF_DEBUGCTLMSR);
621 tsk->thread.debugctlmsr = 0;
623 if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code,
624 SIGTRAP) == NOTIFY_STOP)
627 /* It's safe to allow irq's after DR6 has been saved */
628 preempt_conditional_sti(regs);
630 /* Mask out spurious debug traps due to lazy DR7 setting */
631 if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3)) {
632 if (!tsk->thread.debugreg7)
637 if (regs->flags & X86_VM_MASK)
641 /* Save debug status register where ptrace can see it */
642 tsk->thread.debugreg6 = condition;
645 * Single-stepping through TF: make sure we ignore any events in
646 * kernel space (but re-enable TF when returning to user mode).
648 if (condition & DR_STEP) {
649 if (!user_mode(regs))
650 goto clear_TF_reenable;
653 si_code = get_si_code(condition);
654 /* Ok, finally something we can handle */
655 send_sigtrap(tsk, regs, error_code, si_code);
658 * Disable additional traps. They'll be re-enabled when
659 * the signal is delivered.
663 preempt_conditional_cli(regs);
668 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code, 1);
669 preempt_conditional_cli(regs);
674 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
675 regs->flags &= ~X86_EFLAGS_TF;
676 preempt_conditional_cli(regs);
681 static int kernel_math_error(struct pt_regs *regs, const char *str, int trapnr)
683 if (fixup_exception(regs))
686 notify_die(DIE_GPF, str, regs, 0, trapnr, SIGFPE);
687 /* Illegal floating point operation in the kernel */
688 current->thread.trap_no = trapnr;
695 * Note that we play around with the 'TS' bit in an attempt to get
696 * the correct behaviour even in the presence of the asynchronous
699 void math_error(void __user *ip)
701 struct task_struct *task;
703 unsigned short cwd, swd;
706 * Save the info for the exception handler and clear the error.
710 task->thread.trap_no = 16;
711 task->thread.error_code = 0;
712 info.si_signo = SIGFPE;
714 info.si_code = __SI_FAULT;
717 * (~cwd & swd) will mask out exceptions that are not set to unmasked
718 * status. 0x3f is the exception bits in these regs, 0x200 is the
719 * C1 reg you need in case of a stack fault, 0x040 is the stack
720 * fault bit. We should only be taking one exception at a time,
721 * so if this combination doesn't produce any single exception,
722 * then we have a bad program that isn't synchronizing its FPU usage
723 * and it will suffer the consequences since we won't be able to
724 * fully reproduce the context of the exception
726 cwd = get_fpu_cwd(task);
727 swd = get_fpu_swd(task);
728 switch (swd & ~cwd & 0x3f) {
729 case 0x000: /* No unmasked exception */
733 default: /* Multiple exceptions */
735 case 0x001: /* Invalid Op */
737 * swd & 0x240 == 0x040: Stack Underflow
738 * swd & 0x240 == 0x240: Stack Overflow
739 * User must clear the SF bit (0x40) if set
741 info.si_code = FPE_FLTINV;
743 case 0x002: /* Denormalize */
744 case 0x010: /* Underflow */
745 info.si_code = FPE_FLTUND;
747 case 0x004: /* Zero Divide */
748 info.si_code = FPE_FLTDIV;
750 case 0x008: /* Overflow */
751 info.si_code = FPE_FLTOVF;
753 case 0x020: /* Precision */
754 info.si_code = FPE_FLTRES;
757 force_sig_info(SIGFPE, &info, task);
760 dotraplinkage void do_coprocessor_error(struct pt_regs *regs, long error_code)
762 conditional_sti(regs);
767 if (!user_mode(regs) &&
768 kernel_math_error(regs, "kernel x87 math error", 16))
772 math_error((void __user *)regs->ip);
775 static void simd_math_error(void __user *ip)
777 struct task_struct *task;
779 unsigned short mxcsr;
782 * Save the info for the exception handler and clear the error.
786 task->thread.trap_no = 19;
787 task->thread.error_code = 0;
788 info.si_signo = SIGFPE;
790 info.si_code = __SI_FAULT;
793 * The SIMD FPU exceptions are handled a little differently, as there
794 * is only a single status/control register. Thus, to determine which
795 * unmasked exception was caught we must mask the exception mask bits
796 * at 0x1f80, and then use these to mask the exception bits at 0x3f.
798 mxcsr = get_fpu_mxcsr(task);
799 switch (~((mxcsr & 0x1f80) >> 7) & (mxcsr & 0x3f)) {
803 case 0x001: /* Invalid Op */
804 info.si_code = FPE_FLTINV;
806 case 0x002: /* Denormalize */
807 case 0x010: /* Underflow */
808 info.si_code = FPE_FLTUND;
810 case 0x004: /* Zero Divide */
811 info.si_code = FPE_FLTDIV;
813 case 0x008: /* Overflow */
814 info.si_code = FPE_FLTOVF;
816 case 0x020: /* Precision */
817 info.si_code = FPE_FLTRES;
820 force_sig_info(SIGFPE, &info, task);
824 do_simd_coprocessor_error(struct pt_regs *regs, long error_code)
826 conditional_sti(regs);
830 /* Handle SIMD FPU exceptions on PIII+ processors. */
832 simd_math_error((void __user *)regs->ip);
836 * Handle strange cache flush from user space exception
837 * in all other cases. This is undocumented behaviour.
839 if (regs->flags & X86_VM_MASK) {
840 handle_vm86_fault((struct kernel_vm86_regs *)regs, error_code);
843 current->thread.trap_no = 19;
844 current->thread.error_code = error_code;
845 die_if_kernel("cache flush denied", regs, error_code);
846 force_sig(SIGSEGV, current);
848 if (!user_mode(regs) &&
849 kernel_math_error(regs, "kernel simd math error", 19))
851 simd_math_error((void __user *)regs->ip);
856 do_spurious_interrupt_bug(struct pt_regs *regs, long error_code)
858 conditional_sti(regs);
860 /* No need to warn about this any longer. */
861 printk(KERN_INFO "Ignoring P6 Local APIC Spurious Interrupt Bug...\n");
866 unsigned long patch_espfix_desc(unsigned long uesp, unsigned long kesp)
868 struct desc_struct *gdt = get_cpu_gdt_table(smp_processor_id());
869 unsigned long base = (kesp - uesp) & -THREAD_SIZE;
870 unsigned long new_kesp = kesp - base;
871 unsigned long lim_pages = (new_kesp | (THREAD_SIZE - 1)) >> PAGE_SHIFT;
872 __u64 desc = *(__u64 *)&gdt[GDT_ENTRY_ESPFIX_SS];
874 /* Set up base for espfix segment */
875 desc &= 0x00f0ff0000000000ULL;
876 desc |= ((((__u64)base) << 16) & 0x000000ffffff0000ULL) |
877 ((((__u64)base) << 32) & 0xff00000000000000ULL) |
878 ((((__u64)lim_pages) << 32) & 0x000f000000000000ULL) |
879 (lim_pages & 0xffff);
880 *(__u64 *)&gdt[GDT_ENTRY_ESPFIX_SS] = desc;
885 asmlinkage void __attribute__((weak)) smp_thermal_interrupt(void)
889 asmlinkage void __attribute__((weak)) mce_threshold_interrupt(void)
895 * 'math_state_restore()' saves the current math information in the
896 * old math state array, and gets the new ones from the current task
898 * Careful.. There are problems with IBM-designed IRQ13 behaviour.
899 * Don't touch unless you *really* know how it works.
901 * Must be called with kernel preemption disabled (in this case,
902 * local interrupts are disabled at the call-site in entry.S).
904 asmlinkage void math_state_restore(void)
906 struct thread_info *thread = current_thread_info();
907 struct task_struct *tsk = thread->task;
909 if (!tsk_used_math(tsk)) {
912 * does a slab alloc which can sleep
918 do_group_exit(SIGKILL);
924 clts(); /* Allow maths ops (or we recurse) */
929 * Paranoid restore. send a SIGSEGV if we fail to restore the state.
931 if (unlikely(restore_fpu_checking(tsk))) {
933 force_sig(SIGSEGV, tsk);
937 thread->status |= TS_USEDFPU; /* So we fnsave on switch_to() */
940 EXPORT_SYMBOL_GPL(math_state_restore);
942 #ifndef CONFIG_MATH_EMULATION
943 asmlinkage void math_emulate(long arg)
946 "math-emulation not enabled and no coprocessor found.\n");
947 printk(KERN_EMERG "killing %s.\n", current->comm);
948 force_sig(SIGFPE, current);
951 #endif /* CONFIG_MATH_EMULATION */
953 dotraplinkage void __kprobes
954 do_device_not_available(struct pt_regs *regs, long error)
957 if (read_cr0() & X86_CR0_EM) {
958 conditional_sti(regs);
961 math_state_restore(); /* interrupts still off */
962 conditional_sti(regs);
965 math_state_restore();
970 #ifdef CONFIG_X86_MCE
971 dotraplinkage void __kprobes do_machine_check(struct pt_regs *regs, long error)
973 conditional_sti(regs);
974 machine_check_vector(regs, error);
978 dotraplinkage void do_iret_error(struct pt_regs *regs, long error_code)
983 info.si_signo = SIGILL;
985 info.si_code = ILL_BADSTK;
987 if (notify_die(DIE_TRAP, "iret exception",
988 regs, error_code, 32, SIGILL) == NOTIFY_STOP)
990 do_trap(32, SIGILL, "iret exception", regs, error_code, &info);
994 void __init trap_init(void)
1001 void __iomem *p = early_ioremap(0x0FFFD9, 4);
1003 if (readl(p) == 'E' + ('I'<<8) + ('S'<<16) + ('A'<<24))
1005 early_iounmap(p, 4);
1008 set_intr_gate(0, ÷_error);
1009 set_intr_gate_ist(1, &debug, DEBUG_STACK);
1010 set_intr_gate_ist(2, &nmi, NMI_STACK);
1011 /* int3 can be called from all */
1012 set_system_intr_gate_ist(3, &int3, DEBUG_STACK);
1013 /* int4 can be called from all */
1014 set_system_intr_gate(4, &overflow);
1015 set_intr_gate(5, &bounds);
1016 set_intr_gate(6, &invalid_op);
1017 set_intr_gate(7, &device_not_available);
1018 #ifdef CONFIG_X86_32
1019 set_task_gate(8, GDT_ENTRY_DOUBLEFAULT_TSS);
1021 set_intr_gate_ist(8, &double_fault, DOUBLEFAULT_STACK);
1023 set_intr_gate(9, &coprocessor_segment_overrun);
1024 set_intr_gate(10, &invalid_TSS);
1025 set_intr_gate(11, &segment_not_present);
1026 set_intr_gate_ist(12, &stack_segment, STACKFAULT_STACK);
1027 set_intr_gate(13, &general_protection);
1028 set_intr_gate(14, &page_fault);
1029 set_intr_gate(15, &spurious_interrupt_bug);
1030 set_intr_gate(16, &coprocessor_error);
1031 set_intr_gate(17, &alignment_check);
1032 #ifdef CONFIG_X86_MCE
1033 set_intr_gate_ist(18, &machine_check, MCE_STACK);
1035 set_intr_gate(19, &simd_coprocessor_error);
1037 #ifdef CONFIG_IA32_EMULATION
1038 set_system_intr_gate(IA32_SYSCALL_VECTOR, ia32_syscall);
1041 #ifdef CONFIG_X86_32
1043 printk(KERN_INFO "Enabling fast FPU save and restore... ");
1044 set_in_cr4(X86_CR4_OSFXSR);
1049 "Enabling unmasked SIMD FPU exception support... ");
1050 set_in_cr4(X86_CR4_OSXMMEXCPT);
1054 set_system_trap_gate(SYSCALL_VECTOR, &system_call);
1056 /* Reserve all the builtin and the syscall vector: */
1057 for (i = 0; i < FIRST_EXTERNAL_VECTOR; i++)
1058 set_bit(i, used_vectors);
1060 set_bit(SYSCALL_VECTOR, used_vectors);
1063 * Should be a barrier for any external CPU state:
1067 #ifdef CONFIG_X86_32