x86/traps: Simplify pagefault tracing logic
[linux-stable.git] / arch / x86 / include / asm / traps.h
blobb4f322d6c95ff9e9f735a3174bac9268c53b48fa
1 #ifndef _ASM_X86_TRAPS_H
2 #define _ASM_X86_TRAPS_H
4 #include <linux/context_tracking_state.h>
5 #include <linux/kprobes.h>
7 #include <asm/debugreg.h>
8 #include <asm/siginfo.h> /* TRAP_TRACE, ... */
10 #define dotraplinkage __visible
12 asmlinkage void divide_error(void);
13 asmlinkage void debug(void);
14 asmlinkage void nmi(void);
15 asmlinkage void int3(void);
16 asmlinkage void xen_debug(void);
17 asmlinkage void xen_int3(void);
18 asmlinkage void xen_stack_segment(void);
19 asmlinkage void overflow(void);
20 asmlinkage void bounds(void);
21 asmlinkage void invalid_op(void);
22 asmlinkage void device_not_available(void);
23 #ifdef CONFIG_X86_64
24 asmlinkage void double_fault(void);
25 #endif
26 asmlinkage void coprocessor_segment_overrun(void);
27 asmlinkage void invalid_TSS(void);
28 asmlinkage void segment_not_present(void);
29 asmlinkage void stack_segment(void);
30 asmlinkage void general_protection(void);
31 asmlinkage void page_fault(void);
32 asmlinkage void async_page_fault(void);
33 asmlinkage void spurious_interrupt_bug(void);
34 asmlinkage void coprocessor_error(void);
35 asmlinkage void alignment_check(void);
36 #ifdef CONFIG_X86_MCE
37 asmlinkage void machine_check(void);
38 #endif /* CONFIG_X86_MCE */
39 asmlinkage void simd_coprocessor_error(void);
41 #ifdef CONFIG_TRACING
42 #define trace_stack_segment stack_segment
43 #define trace_divide_error divide_error
44 #define trace_bounds bounds
45 #define trace_invalid_op invalid_op
46 #define trace_device_not_available device_not_available
47 #define trace_coprocessor_segment_overrun coprocessor_segment_overrun
48 #define trace_invalid_TSS invalid_TSS
49 #define trace_segment_not_present segment_not_present
50 #define trace_general_protection general_protection
51 #define trace_spurious_interrupt_bug spurious_interrupt_bug
52 #define trace_coprocessor_error coprocessor_error
53 #define trace_alignment_check alignment_check
54 #define trace_simd_coprocessor_error simd_coprocessor_error
55 #define trace_async_page_fault async_page_fault
56 #define trace_page_fault page_fault
57 #endif
59 dotraplinkage void do_divide_error(struct pt_regs *, long);
60 dotraplinkage void do_debug(struct pt_regs *, long);
61 dotraplinkage void do_nmi(struct pt_regs *, long);
62 dotraplinkage void do_int3(struct pt_regs *, long);
63 dotraplinkage void do_overflow(struct pt_regs *, long);
64 dotraplinkage void do_bounds(struct pt_regs *, long);
65 dotraplinkage void do_invalid_op(struct pt_regs *, long);
66 dotraplinkage void do_device_not_available(struct pt_regs *, long);
67 dotraplinkage void do_coprocessor_segment_overrun(struct pt_regs *, long);
68 dotraplinkage void do_invalid_TSS(struct pt_regs *, long);
69 dotraplinkage void do_segment_not_present(struct pt_regs *, long);
70 dotraplinkage void do_stack_segment(struct pt_regs *, long);
71 #ifdef CONFIG_X86_64
72 dotraplinkage void do_double_fault(struct pt_regs *, long);
73 asmlinkage struct pt_regs *sync_regs(struct pt_regs *);
74 #endif
75 dotraplinkage void do_general_protection(struct pt_regs *, long);
76 dotraplinkage void do_page_fault(struct pt_regs *, unsigned long);
77 dotraplinkage void do_spurious_interrupt_bug(struct pt_regs *, long);
78 dotraplinkage void do_coprocessor_error(struct pt_regs *, long);
79 dotraplinkage void do_alignment_check(struct pt_regs *, long);
80 #ifdef CONFIG_X86_MCE
81 dotraplinkage void do_machine_check(struct pt_regs *, long);
82 #endif
83 dotraplinkage void do_simd_coprocessor_error(struct pt_regs *, long);
84 #ifdef CONFIG_X86_32
85 dotraplinkage void do_iret_error(struct pt_regs *, long);
86 #endif
88 static inline int get_si_code(unsigned long condition)
90 if (condition & DR_STEP)
91 return TRAP_TRACE;
92 else if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3))
93 return TRAP_HWBKPT;
94 else
95 return TRAP_BRKPT;
98 extern int panic_on_unrecovered_nmi;
100 void math_emulate(struct math_emu_info *);
101 #ifndef CONFIG_X86_32
102 asmlinkage void smp_thermal_interrupt(void);
103 asmlinkage void smp_threshold_interrupt(void);
104 asmlinkage void smp_deferred_error_interrupt(void);
105 #endif
107 extern void ist_enter(struct pt_regs *regs);
108 extern void ist_exit(struct pt_regs *regs);
109 extern void ist_begin_non_atomic(struct pt_regs *regs);
110 extern void ist_end_non_atomic(void);
112 #ifdef CONFIG_VMAP_STACK
113 void __noreturn handle_stack_overflow(const char *message,
114 struct pt_regs *regs,
115 unsigned long fault_address);
116 #endif
118 /* Interrupts/Exceptions */
119 enum {
120 X86_TRAP_DE = 0, /* 0, Divide-by-zero */
121 X86_TRAP_DB, /* 1, Debug */
122 X86_TRAP_NMI, /* 2, Non-maskable Interrupt */
123 X86_TRAP_BP, /* 3, Breakpoint */
124 X86_TRAP_OF, /* 4, Overflow */
125 X86_TRAP_BR, /* 5, Bound Range Exceeded */
126 X86_TRAP_UD, /* 6, Invalid Opcode */
127 X86_TRAP_NM, /* 7, Device Not Available */
128 X86_TRAP_DF, /* 8, Double Fault */
129 X86_TRAP_OLD_MF, /* 9, Coprocessor Segment Overrun */
130 X86_TRAP_TS, /* 10, Invalid TSS */
131 X86_TRAP_NP, /* 11, Segment Not Present */
132 X86_TRAP_SS, /* 12, Stack Segment Fault */
133 X86_TRAP_GP, /* 13, General Protection Fault */
134 X86_TRAP_PF, /* 14, Page Fault */
135 X86_TRAP_SPURIOUS, /* 15, Spurious Interrupt */
136 X86_TRAP_MF, /* 16, x87 Floating-Point Exception */
137 X86_TRAP_AC, /* 17, Alignment Check */
138 X86_TRAP_MC, /* 18, Machine Check */
139 X86_TRAP_XF, /* 19, SIMD Floating-Point Exception */
140 X86_TRAP_IRET = 32, /* 32, IRET Exception */
143 #endif /* _ASM_X86_TRAPS_H */