xref: /openbmc/linux/arch/x86/include/asm/traps.h (revision bc000245)
1 #ifndef _ASM_X86_TRAPS_H
2 #define _ASM_X86_TRAPS_H
3 
4 #include <linux/kprobes.h>
5 
6 #include <asm/debugreg.h>
7 #include <asm/siginfo.h>			/* TRAP_TRACE, ... */
8 
9 #define dotraplinkage __visible
10 
11 asmlinkage void divide_error(void);
12 asmlinkage void debug(void);
13 asmlinkage void nmi(void);
14 asmlinkage void int3(void);
15 asmlinkage void xen_debug(void);
16 asmlinkage void xen_int3(void);
17 asmlinkage void xen_stack_segment(void);
18 asmlinkage void overflow(void);
19 asmlinkage void bounds(void);
20 asmlinkage void invalid_op(void);
21 asmlinkage void device_not_available(void);
22 #ifdef CONFIG_X86_64
23 asmlinkage void double_fault(void);
24 #endif
25 asmlinkage void coprocessor_segment_overrun(void);
26 asmlinkage void invalid_TSS(void);
27 asmlinkage void segment_not_present(void);
28 asmlinkage void stack_segment(void);
29 asmlinkage void general_protection(void);
30 asmlinkage void page_fault(void);
31 asmlinkage void async_page_fault(void);
32 asmlinkage void spurious_interrupt_bug(void);
33 asmlinkage void coprocessor_error(void);
34 asmlinkage void alignment_check(void);
35 #ifdef CONFIG_X86_MCE
36 asmlinkage void machine_check(void);
37 #endif /* CONFIG_X86_MCE */
38 asmlinkage void simd_coprocessor_error(void);
39 
40 #ifdef CONFIG_TRACING
41 asmlinkage 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 
57 dotraplinkage void do_divide_error(struct pt_regs *, long);
58 dotraplinkage void do_debug(struct pt_regs *, long);
59 dotraplinkage void do_nmi(struct pt_regs *, long);
60 dotraplinkage void do_int3(struct pt_regs *, long);
61 dotraplinkage void do_overflow(struct pt_regs *, long);
62 dotraplinkage void do_bounds(struct pt_regs *, long);
63 dotraplinkage void do_invalid_op(struct pt_regs *, long);
64 dotraplinkage void do_device_not_available(struct pt_regs *, long);
65 dotraplinkage void do_coprocessor_segment_overrun(struct pt_regs *, long);
66 dotraplinkage void do_invalid_TSS(struct pt_regs *, long);
67 dotraplinkage void do_segment_not_present(struct pt_regs *, long);
68 dotraplinkage void do_stack_segment(struct pt_regs *, long);
69 #ifdef CONFIG_X86_64
70 dotraplinkage void do_double_fault(struct pt_regs *, long);
71 asmlinkage __kprobes struct pt_regs *sync_regs(struct pt_regs *);
72 #endif
73 dotraplinkage void do_general_protection(struct pt_regs *, long);
74 dotraplinkage void do_page_fault(struct pt_regs *, unsigned long);
75 #ifdef CONFIG_TRACING
76 dotraplinkage void trace_do_page_fault(struct pt_regs *, unsigned long);
77 #endif
78 dotraplinkage void do_spurious_interrupt_bug(struct pt_regs *, long);
79 dotraplinkage void do_coprocessor_error(struct pt_regs *, long);
80 dotraplinkage void do_alignment_check(struct pt_regs *, long);
81 #ifdef CONFIG_X86_MCE
82 dotraplinkage void do_machine_check(struct pt_regs *, long);
83 #endif
84 dotraplinkage void do_simd_coprocessor_error(struct pt_regs *, long);
85 #ifdef CONFIG_X86_32
86 dotraplinkage void do_iret_error(struct pt_regs *, long);
87 #endif
88 
89 static inline int get_si_code(unsigned long condition)
90 {
91 	if (condition & DR_STEP)
92 		return TRAP_TRACE;
93 	else if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3))
94 		return TRAP_HWBKPT;
95 	else
96 		return TRAP_BRKPT;
97 }
98 
99 extern int panic_on_unrecovered_nmi;
100 
101 void math_error(struct pt_regs *, int, int);
102 void math_emulate(struct math_emu_info *);
103 #ifndef CONFIG_X86_32
104 asmlinkage void smp_thermal_interrupt(void);
105 asmlinkage void mce_threshold_interrupt(void);
106 #endif
107 
108 /* Interrupts/Exceptions */
109 enum {
110 	X86_TRAP_DE = 0,	/*  0, Divide-by-zero */
111 	X86_TRAP_DB,		/*  1, Debug */
112 	X86_TRAP_NMI,		/*  2, Non-maskable Interrupt */
113 	X86_TRAP_BP,		/*  3, Breakpoint */
114 	X86_TRAP_OF,		/*  4, Overflow */
115 	X86_TRAP_BR,		/*  5, Bound Range Exceeded */
116 	X86_TRAP_UD,		/*  6, Invalid Opcode */
117 	X86_TRAP_NM,		/*  7, Device Not Available */
118 	X86_TRAP_DF,		/*  8, Double Fault */
119 	X86_TRAP_OLD_MF,	/*  9, Coprocessor Segment Overrun */
120 	X86_TRAP_TS,		/* 10, Invalid TSS */
121 	X86_TRAP_NP,		/* 11, Segment Not Present */
122 	X86_TRAP_SS,		/* 12, Stack Segment Fault */
123 	X86_TRAP_GP,		/* 13, General Protection Fault */
124 	X86_TRAP_PF,		/* 14, Page Fault */
125 	X86_TRAP_SPURIOUS,	/* 15, Spurious Interrupt */
126 	X86_TRAP_MF,		/* 16, x87 Floating-Point Exception */
127 	X86_TRAP_AC,		/* 17, Alignment Check */
128 	X86_TRAP_MC,		/* 18, Machine Check */
129 	X86_TRAP_XF,		/* 19, SIMD Floating-Point Exception */
130 	X86_TRAP_IRET = 32,	/* 32, IRET Exception */
131 };
132 
133 #endif /* _ASM_X86_TRAPS_H */
134