blob: bc8352e7010a9e805c54068da84b3848dcc12048 [file] [log] [blame]
H. Peter Anvin1965aae2008-10-22 22:26:29 -07001#ifndef _ASM_X86_TRAPS_H
2#define _ASM_X86_TRAPS_H
Jaswinder Singh6ac8d512008-07-15 21:09:13 +05303
Andy Lutomirski5cec93c2011-06-05 13:50:24 -04004#include <linux/kprobes.h>
5
Srinivasa Dse8d3f452008-09-23 15:23:52 +05306#include <asm/debugreg.h>
Ingo Molnara2bcd472009-03-29 23:47:48 +02007#include <asm/siginfo.h> /* TRAP_TRACE, ... */
Srinivasa Dse8d3f452008-09-23 15:23:52 +05308
Andi Kleen9e1a4312013-08-05 15:02:36 -07009#define dotraplinkage __visible
Alexander van Heukelume407d6202008-09-30 18:41:36 +020010
Jaswinder Singh6ac8d512008-07-15 21:09:13 +053011asmlinkage void divide_error(void);
12asmlinkage void debug(void);
13asmlinkage void nmi(void);
14asmlinkage void int3(void);
Jeremy Fitzhardinge6cac5a92009-03-29 19:56:29 -070015asmlinkage void xen_debug(void);
16asmlinkage void xen_int3(void);
17asmlinkage void xen_stack_segment(void);
Jaswinder Singh6ac8d512008-07-15 21:09:13 +053018asmlinkage void overflow(void);
19asmlinkage void bounds(void);
20asmlinkage void invalid_op(void);
21asmlinkage void device_not_available(void);
Alexander van Heukelume407d6202008-09-30 18:41:36 +020022#ifdef CONFIG_X86_64
23asmlinkage void double_fault(void);
24#endif
Jaswinder Singh6ac8d512008-07-15 21:09:13 +053025asmlinkage void coprocessor_segment_overrun(void);
26asmlinkage void invalid_TSS(void);
27asmlinkage void segment_not_present(void);
28asmlinkage void stack_segment(void);
29asmlinkage void general_protection(void);
30asmlinkage void page_fault(void);
Gleb Natapov631bc482010-10-14 11:22:52 +020031asmlinkage void async_page_fault(void);
Jaswinder Singh6ac8d512008-07-15 21:09:13 +053032asmlinkage void spurious_interrupt_bug(void);
Alexander van Heukelume407d6202008-09-30 18:41:36 +020033asmlinkage void coprocessor_error(void);
34asmlinkage void alignment_check(void);
Jaswinder Singh6ac8d512008-07-15 21:09:13 +053035#ifdef CONFIG_X86_MCE
36asmlinkage void machine_check(void);
37#endif /* CONFIG_X86_MCE */
Alexander van Heukelume407d6202008-09-30 18:41:36 +020038asmlinkage void simd_coprocessor_error(void);
Jaswinder Singh6ac8d512008-07-15 21:09:13 +053039
Seiji Aguchi25c74b12013-10-30 16:37:00 -040040#ifdef CONFIG_TRACING
41asmlinkage void trace_page_fault(void);
42#define trace_divide_error divide_error
43#define trace_bounds bounds
44#define trace_invalid_op invalid_op
45#define trace_device_not_available device_not_available
46#define trace_coprocessor_segment_overrun coprocessor_segment_overrun
47#define trace_invalid_TSS invalid_TSS
48#define trace_segment_not_present segment_not_present
49#define trace_general_protection general_protection
50#define trace_spurious_interrupt_bug spurious_interrupt_bug
51#define trace_coprocessor_error coprocessor_error
52#define trace_alignment_check alignment_check
53#define trace_simd_coprocessor_error simd_coprocessor_error
54#define trace_async_page_fault async_page_fault
55#endif
56
Alexander van Heukelume407d6202008-09-30 18:41:36 +020057dotraplinkage void do_divide_error(struct pt_regs *, long);
58dotraplinkage void do_debug(struct pt_regs *, long);
59dotraplinkage void do_nmi(struct pt_regs *, long);
60dotraplinkage void do_int3(struct pt_regs *, long);
61dotraplinkage void do_overflow(struct pt_regs *, long);
62dotraplinkage void do_bounds(struct pt_regs *, long);
63dotraplinkage void do_invalid_op(struct pt_regs *, long);
Brian Gerstaa78bcf2009-02-10 09:51:45 -050064dotraplinkage void do_device_not_available(struct pt_regs *, long);
Alexander van Heukelume407d6202008-09-30 18:41:36 +020065dotraplinkage void do_coprocessor_segment_overrun(struct pt_regs *, long);
66dotraplinkage void do_invalid_TSS(struct pt_regs *, long);
67dotraplinkage void do_segment_not_present(struct pt_regs *, long);
68dotraplinkage void do_stack_segment(struct pt_regs *, long);
Jaswinder Singhd1769d52008-12-19 00:03:56 +053069#ifdef CONFIG_X86_64
70dotraplinkage void do_double_fault(struct pt_regs *, long);
Masami Hiramatsu93266382014-04-17 17:18:14 +090071asmlinkage struct pt_regs *sync_regs(struct pt_regs *);
Jaswinder Singhd1769d52008-12-19 00:03:56 +053072#endif
Alexander van Heukelume407d6202008-09-30 18:41:36 +020073dotraplinkage void do_general_protection(struct pt_regs *, long);
74dotraplinkage void do_page_fault(struct pt_regs *, unsigned long);
Seiji Aguchi25c74b12013-10-30 16:37:00 -040075#ifdef CONFIG_TRACING
76dotraplinkage void trace_do_page_fault(struct pt_regs *, unsigned long);
Dave Hansen65a7f032014-05-16 12:45:15 -070077#else
78static inline void trace_do_page_fault(struct pt_regs *regs, unsigned long error)
79{
80 do_page_fault(regs, error);
81}
Seiji Aguchi25c74b12013-10-30 16:37:00 -040082#endif
Alexander van Heukelume407d6202008-09-30 18:41:36 +020083dotraplinkage void do_spurious_interrupt_bug(struct pt_regs *, long);
84dotraplinkage void do_coprocessor_error(struct pt_regs *, long);
85dotraplinkage void do_alignment_check(struct pt_regs *, long);
86#ifdef CONFIG_X86_MCE
87dotraplinkage void do_machine_check(struct pt_regs *, long);
88#endif
89dotraplinkage void do_simd_coprocessor_error(struct pt_regs *, long);
90#ifdef CONFIG_X86_32
91dotraplinkage void do_iret_error(struct pt_regs *, long);
92#endif
Jaswinder Singh6ac8d512008-07-15 21:09:13 +053093
Srinivasa Dsda654b72008-09-23 15:23:52 +053094static inline int get_si_code(unsigned long condition)
95{
96 if (condition & DR_STEP)
97 return TRAP_TRACE;
98 else if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3))
99 return TRAP_HWBKPT;
100 else
101 return TRAP_BRKPT;
102}
103
Jaswinder Singh6ac8d512008-07-15 21:09:13 +0530104extern int panic_on_unrecovered_nmi;
Jaswinder Singh6ac8d512008-07-15 21:09:13 +0530105
Tejun Heod3157602009-02-09 22:17:39 +0900106void math_emulate(struct math_emu_info *);
Akinobu Mitafde03122009-07-19 00:09:56 +0900107#ifndef CONFIG_X86_32
Jaswinder Singhd1769d52008-12-19 00:03:56 +0530108asmlinkage void smp_thermal_interrupt(void);
109asmlinkage void mce_threshold_interrupt(void);
Alexander van Heukelume407d6202008-09-30 18:41:36 +0200110#endif
Jaswinder Singh6ac8d512008-07-15 21:09:13 +0530111
Kees Cookc9408262012-03-09 16:07:10 -0800112/* Interrupts/Exceptions */
113enum {
114 X86_TRAP_DE = 0, /* 0, Divide-by-zero */
115 X86_TRAP_DB, /* 1, Debug */
116 X86_TRAP_NMI, /* 2, Non-maskable Interrupt */
117 X86_TRAP_BP, /* 3, Breakpoint */
118 X86_TRAP_OF, /* 4, Overflow */
119 X86_TRAP_BR, /* 5, Bound Range Exceeded */
120 X86_TRAP_UD, /* 6, Invalid Opcode */
121 X86_TRAP_NM, /* 7, Device Not Available */
122 X86_TRAP_DF, /* 8, Double Fault */
123 X86_TRAP_OLD_MF, /* 9, Coprocessor Segment Overrun */
124 X86_TRAP_TS, /* 10, Invalid TSS */
125 X86_TRAP_NP, /* 11, Segment Not Present */
126 X86_TRAP_SS, /* 12, Stack Segment Fault */
127 X86_TRAP_GP, /* 13, General Protection Fault */
128 X86_TRAP_PF, /* 14, Page Fault */
129 X86_TRAP_SPURIOUS, /* 15, Spurious Interrupt */
130 X86_TRAP_MF, /* 16, x87 Floating-Point Exception */
131 X86_TRAP_AC, /* 17, Alignment Check */
132 X86_TRAP_MC, /* 18, Machine Check */
133 X86_TRAP_XF, /* 19, SIMD Floating-Point Exception */
134 X86_TRAP_IRET = 32, /* 32, IRET Exception */
135};
136
H. Peter Anvin1965aae2008-10-22 22:26:29 -0700137#endif /* _ASM_X86_TRAPS_H */