H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 1 | #ifndef _ASM_X86_TRAPS_H |
| 2 | #define _ASM_X86_TRAPS_H |
Jaswinder Singh | 6ac8d51 | 2008-07-15 21:09:13 +0530 | [diff] [blame] | 3 | |
Andy Lutomirski | 9592747 | 2014-11-19 17:41:09 -0800 | [diff] [blame] | 4 | #include <linux/context_tracking_state.h> |
Andy Lutomirski | 5cec93c | 2011-06-05 13:50:24 -0400 | [diff] [blame] | 5 | #include <linux/kprobes.h> |
| 6 | |
Srinivasa Ds | e8d3f45 | 2008-09-23 15:23:52 +0530 | [diff] [blame] | 7 | #include <asm/debugreg.h> |
Ingo Molnar | a2bcd47 | 2009-03-29 23:47:48 +0200 | [diff] [blame] | 8 | #include <asm/siginfo.h> /* TRAP_TRACE, ... */ |
Srinivasa Ds | e8d3f45 | 2008-09-23 15:23:52 +0530 | [diff] [blame] | 9 | |
Andi Kleen | 9e1a431 | 2013-08-05 15:02:36 -0700 | [diff] [blame] | 10 | #define dotraplinkage __visible |
Alexander van Heukelum | e407d620 | 2008-09-30 18:41:36 +0200 | [diff] [blame] | 11 | |
Jaswinder Singh | 6ac8d51 | 2008-07-15 21:09:13 +0530 | [diff] [blame] | 12 | asmlinkage void divide_error(void); |
| 13 | asmlinkage void debug(void); |
| 14 | asmlinkage void nmi(void); |
| 15 | asmlinkage void int3(void); |
Jeremy Fitzhardinge | 6cac5a9 | 2009-03-29 19:56:29 -0700 | [diff] [blame] | 16 | asmlinkage void xen_debug(void); |
| 17 | asmlinkage void xen_int3(void); |
| 18 | asmlinkage void xen_stack_segment(void); |
Jaswinder Singh | 6ac8d51 | 2008-07-15 21:09:13 +0530 | [diff] [blame] | 19 | asmlinkage void overflow(void); |
| 20 | asmlinkage void bounds(void); |
| 21 | asmlinkage void invalid_op(void); |
| 22 | asmlinkage void device_not_available(void); |
Alexander van Heukelum | e407d620 | 2008-09-30 18:41:36 +0200 | [diff] [blame] | 23 | #ifdef CONFIG_X86_64 |
| 24 | asmlinkage void double_fault(void); |
| 25 | #endif |
Jaswinder Singh | 6ac8d51 | 2008-07-15 21:09:13 +0530 | [diff] [blame] | 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); |
Gleb Natapov | 631bc48 | 2010-10-14 11:22:52 +0200 | [diff] [blame] | 32 | asmlinkage void async_page_fault(void); |
Jaswinder Singh | 6ac8d51 | 2008-07-15 21:09:13 +0530 | [diff] [blame] | 33 | asmlinkage void spurious_interrupt_bug(void); |
Alexander van Heukelum | e407d620 | 2008-09-30 18:41:36 +0200 | [diff] [blame] | 34 | asmlinkage void coprocessor_error(void); |
| 35 | asmlinkage void alignment_check(void); |
Jaswinder Singh | 6ac8d51 | 2008-07-15 21:09:13 +0530 | [diff] [blame] | 36 | #ifdef CONFIG_X86_MCE |
| 37 | asmlinkage void machine_check(void); |
| 38 | #endif /* CONFIG_X86_MCE */ |
Alexander van Heukelum | e407d620 | 2008-09-30 18:41:36 +0200 | [diff] [blame] | 39 | asmlinkage void simd_coprocessor_error(void); |
Jaswinder Singh | 6ac8d51 | 2008-07-15 21:09:13 +0530 | [diff] [blame] | 40 | |
Seiji Aguchi | 25c74b1 | 2013-10-30 16:37:00 -0400 | [diff] [blame] | 41 | #ifdef CONFIG_TRACING |
| 42 | asmlinkage void trace_page_fault(void); |
Andy Lutomirski | 6f442be | 2014-11-22 18:00:32 -0800 | [diff] [blame] | 43 | #define trace_stack_segment stack_segment |
Seiji Aguchi | 25c74b1 | 2013-10-30 16:37:00 -0400 | [diff] [blame] | 44 | #define trace_divide_error divide_error |
| 45 | #define trace_bounds bounds |
| 46 | #define trace_invalid_op invalid_op |
| 47 | #define trace_device_not_available device_not_available |
| 48 | #define trace_coprocessor_segment_overrun coprocessor_segment_overrun |
| 49 | #define trace_invalid_TSS invalid_TSS |
| 50 | #define trace_segment_not_present segment_not_present |
| 51 | #define trace_general_protection general_protection |
| 52 | #define trace_spurious_interrupt_bug spurious_interrupt_bug |
| 53 | #define trace_coprocessor_error coprocessor_error |
| 54 | #define trace_alignment_check alignment_check |
| 55 | #define trace_simd_coprocessor_error simd_coprocessor_error |
| 56 | #define trace_async_page_fault async_page_fault |
| 57 | #endif |
| 58 | |
Alexander van Heukelum | e407d620 | 2008-09-30 18:41:36 +0200 | [diff] [blame] | 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); |
Brian Gerst | aa78bcf | 2009-02-10 09:51:45 -0500 | [diff] [blame] | 66 | dotraplinkage void do_device_not_available(struct pt_regs *, long); |
Alexander van Heukelum | e407d620 | 2008-09-30 18:41:36 +0200 | [diff] [blame] | 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); |
Jaswinder Singh | d1769d5 | 2008-12-19 00:03:56 +0530 | [diff] [blame] | 71 | #ifdef CONFIG_X86_64 |
| 72 | dotraplinkage void do_double_fault(struct pt_regs *, long); |
Masami Hiramatsu | 9326638 | 2014-04-17 17:18:14 +0900 | [diff] [blame] | 73 | asmlinkage struct pt_regs *sync_regs(struct pt_regs *); |
Jaswinder Singh | d1769d5 | 2008-12-19 00:03:56 +0530 | [diff] [blame] | 74 | #endif |
Alexander van Heukelum | e407d620 | 2008-09-30 18:41:36 +0200 | [diff] [blame] | 75 | dotraplinkage void do_general_protection(struct pt_regs *, long); |
| 76 | dotraplinkage void do_page_fault(struct pt_regs *, unsigned long); |
Seiji Aguchi | 25c74b1 | 2013-10-30 16:37:00 -0400 | [diff] [blame] | 77 | #ifdef CONFIG_TRACING |
| 78 | dotraplinkage void trace_do_page_fault(struct pt_regs *, unsigned long); |
Dave Hansen | 65a7f03 | 2014-05-16 12:45:15 -0700 | [diff] [blame] | 79 | #else |
| 80 | static inline void trace_do_page_fault(struct pt_regs *regs, unsigned long error) |
| 81 | { |
| 82 | do_page_fault(regs, error); |
| 83 | } |
Seiji Aguchi | 25c74b1 | 2013-10-30 16:37:00 -0400 | [diff] [blame] | 84 | #endif |
Alexander van Heukelum | e407d620 | 2008-09-30 18:41:36 +0200 | [diff] [blame] | 85 | dotraplinkage void do_spurious_interrupt_bug(struct pt_regs *, long); |
| 86 | dotraplinkage void do_coprocessor_error(struct pt_regs *, long); |
| 87 | dotraplinkage void do_alignment_check(struct pt_regs *, long); |
| 88 | #ifdef CONFIG_X86_MCE |
| 89 | dotraplinkage void do_machine_check(struct pt_regs *, long); |
| 90 | #endif |
| 91 | dotraplinkage void do_simd_coprocessor_error(struct pt_regs *, long); |
| 92 | #ifdef CONFIG_X86_32 |
| 93 | dotraplinkage void do_iret_error(struct pt_regs *, long); |
| 94 | #endif |
Jaswinder Singh | 6ac8d51 | 2008-07-15 21:09:13 +0530 | [diff] [blame] | 95 | |
Srinivasa Ds | da654b7 | 2008-09-23 15:23:52 +0530 | [diff] [blame] | 96 | static inline int get_si_code(unsigned long condition) |
| 97 | { |
| 98 | if (condition & DR_STEP) |
| 99 | return TRAP_TRACE; |
| 100 | else if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3)) |
| 101 | return TRAP_HWBKPT; |
| 102 | else |
| 103 | return TRAP_BRKPT; |
| 104 | } |
| 105 | |
Jaswinder Singh | 6ac8d51 | 2008-07-15 21:09:13 +0530 | [diff] [blame] | 106 | extern int panic_on_unrecovered_nmi; |
Jaswinder Singh | 6ac8d51 | 2008-07-15 21:09:13 +0530 | [diff] [blame] | 107 | |
Tejun Heo | d315760 | 2009-02-09 22:17:39 +0900 | [diff] [blame] | 108 | void math_emulate(struct math_emu_info *); |
Akinobu Mita | fde0312 | 2009-07-19 00:09:56 +0900 | [diff] [blame] | 109 | #ifndef CONFIG_X86_32 |
Jaswinder Singh | d1769d5 | 2008-12-19 00:03:56 +0530 | [diff] [blame] | 110 | asmlinkage void smp_thermal_interrupt(void); |
Aravind Gopalakrishnan | 24fd78a | 2015-05-06 06:58:56 -0500 | [diff] [blame] | 111 | asmlinkage void smp_threshold_interrupt(void); |
| 112 | asmlinkage void smp_deferred_error_interrupt(void); |
Alexander van Heukelum | e407d620 | 2008-09-30 18:41:36 +0200 | [diff] [blame] | 113 | #endif |
Jaswinder Singh | 6ac8d51 | 2008-07-15 21:09:13 +0530 | [diff] [blame] | 114 | |
Andy Lutomirski | 9592747 | 2014-11-19 17:41:09 -0800 | [diff] [blame] | 115 | extern enum ctx_state ist_enter(struct pt_regs *regs); |
| 116 | extern void ist_exit(struct pt_regs *regs, enum ctx_state prev_state); |
Andy Lutomirski | bced35b | 2014-11-19 17:59:41 -0800 | [diff] [blame] | 117 | extern void ist_begin_non_atomic(struct pt_regs *regs); |
| 118 | extern void ist_end_non_atomic(void); |
Andy Lutomirski | 9592747 | 2014-11-19 17:41:09 -0800 | [diff] [blame] | 119 | |
Kees Cook | c940826 | 2012-03-09 16:07:10 -0800 | [diff] [blame] | 120 | /* Interrupts/Exceptions */ |
| 121 | enum { |
| 122 | X86_TRAP_DE = 0, /* 0, Divide-by-zero */ |
| 123 | X86_TRAP_DB, /* 1, Debug */ |
| 124 | X86_TRAP_NMI, /* 2, Non-maskable Interrupt */ |
| 125 | X86_TRAP_BP, /* 3, Breakpoint */ |
| 126 | X86_TRAP_OF, /* 4, Overflow */ |
| 127 | X86_TRAP_BR, /* 5, Bound Range Exceeded */ |
| 128 | X86_TRAP_UD, /* 6, Invalid Opcode */ |
| 129 | X86_TRAP_NM, /* 7, Device Not Available */ |
| 130 | X86_TRAP_DF, /* 8, Double Fault */ |
| 131 | X86_TRAP_OLD_MF, /* 9, Coprocessor Segment Overrun */ |
| 132 | X86_TRAP_TS, /* 10, Invalid TSS */ |
| 133 | X86_TRAP_NP, /* 11, Segment Not Present */ |
| 134 | X86_TRAP_SS, /* 12, Stack Segment Fault */ |
| 135 | X86_TRAP_GP, /* 13, General Protection Fault */ |
| 136 | X86_TRAP_PF, /* 14, Page Fault */ |
| 137 | X86_TRAP_SPURIOUS, /* 15, Spurious Interrupt */ |
| 138 | X86_TRAP_MF, /* 16, x87 Floating-Point Exception */ |
| 139 | X86_TRAP_AC, /* 17, Alignment Check */ |
| 140 | X86_TRAP_MC, /* 18, Machine Check */ |
| 141 | X86_TRAP_XF, /* 19, SIMD Floating-Point Exception */ |
| 142 | X86_TRAP_IRET = 32, /* 32, IRET Exception */ |
| 143 | }; |
| 144 | |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 145 | #endif /* _ASM_X86_TRAPS_H */ |