blob: c5380bea2a36aaa533fd8aa28c58ff2ee68a7dec [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 Lutomirski95927472014-11-19 17:41:09 -08004#include <linux/context_tracking_state.h>
Andy Lutomirski5cec93c2011-06-05 13:50:24 -04005#include <linux/kprobes.h>
6
Srinivasa Dse8d3f452008-09-23 15:23:52 +05307#include <asm/debugreg.h>
Ingo Molnara2bcd472009-03-29 23:47:48 +02008#include <asm/siginfo.h> /* TRAP_TRACE, ... */
Srinivasa Dse8d3f452008-09-23 15:23:52 +05309
Andi Kleen9e1a4312013-08-05 15:02:36 -070010#define dotraplinkage __visible
Alexander van Heukelume407d6202008-09-30 18:41:36 +020011
Jaswinder Singh6ac8d512008-07-15 21:09:13 +053012asmlinkage void divide_error(void);
13asmlinkage void debug(void);
14asmlinkage void nmi(void);
15asmlinkage void int3(void);
Jeremy Fitzhardinge6cac5a92009-03-29 19:56:29 -070016asmlinkage void xen_debug(void);
17asmlinkage void xen_int3(void);
18asmlinkage void xen_stack_segment(void);
Jaswinder Singh6ac8d512008-07-15 21:09:13 +053019asmlinkage void overflow(void);
20asmlinkage void bounds(void);
21asmlinkage void invalid_op(void);
22asmlinkage void device_not_available(void);
Alexander van Heukelume407d6202008-09-30 18:41:36 +020023#ifdef CONFIG_X86_64
24asmlinkage void double_fault(void);
25#endif
Jaswinder Singh6ac8d512008-07-15 21:09:13 +053026asmlinkage void coprocessor_segment_overrun(void);
27asmlinkage void invalid_TSS(void);
28asmlinkage void segment_not_present(void);
29asmlinkage void stack_segment(void);
30asmlinkage void general_protection(void);
31asmlinkage void page_fault(void);
Gleb Natapov631bc482010-10-14 11:22:52 +020032asmlinkage void async_page_fault(void);
Jaswinder Singh6ac8d512008-07-15 21:09:13 +053033asmlinkage void spurious_interrupt_bug(void);
Alexander van Heukelume407d6202008-09-30 18:41:36 +020034asmlinkage void coprocessor_error(void);
35asmlinkage void alignment_check(void);
Jaswinder Singh6ac8d512008-07-15 21:09:13 +053036#ifdef CONFIG_X86_MCE
37asmlinkage void machine_check(void);
38#endif /* CONFIG_X86_MCE */
Alexander van Heukelume407d6202008-09-30 18:41:36 +020039asmlinkage void simd_coprocessor_error(void);
Jaswinder Singh6ac8d512008-07-15 21:09:13 +053040
Seiji Aguchi25c74b12013-10-30 16:37:00 -040041#ifdef CONFIG_TRACING
42asmlinkage void trace_page_fault(void);
Andy Lutomirski6f442be2014-11-22 18:00:32 -080043#define trace_stack_segment stack_segment
Seiji Aguchi25c74b12013-10-30 16:37:00 -040044#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 Heukelume407d6202008-09-30 18:41:36 +020059dotraplinkage void do_divide_error(struct pt_regs *, long);
60dotraplinkage void do_debug(struct pt_regs *, long);
61dotraplinkage void do_nmi(struct pt_regs *, long);
62dotraplinkage void do_int3(struct pt_regs *, long);
63dotraplinkage void do_overflow(struct pt_regs *, long);
64dotraplinkage void do_bounds(struct pt_regs *, long);
65dotraplinkage void do_invalid_op(struct pt_regs *, long);
Brian Gerstaa78bcf2009-02-10 09:51:45 -050066dotraplinkage void do_device_not_available(struct pt_regs *, long);
Alexander van Heukelume407d6202008-09-30 18:41:36 +020067dotraplinkage void do_coprocessor_segment_overrun(struct pt_regs *, long);
68dotraplinkage void do_invalid_TSS(struct pt_regs *, long);
69dotraplinkage void do_segment_not_present(struct pt_regs *, long);
70dotraplinkage void do_stack_segment(struct pt_regs *, long);
Jaswinder Singhd1769d52008-12-19 00:03:56 +053071#ifdef CONFIG_X86_64
72dotraplinkage void do_double_fault(struct pt_regs *, long);
Masami Hiramatsu93266382014-04-17 17:18:14 +090073asmlinkage struct pt_regs *sync_regs(struct pt_regs *);
Jaswinder Singhd1769d52008-12-19 00:03:56 +053074#endif
Alexander van Heukelume407d6202008-09-30 18:41:36 +020075dotraplinkage void do_general_protection(struct pt_regs *, long);
76dotraplinkage void do_page_fault(struct pt_regs *, unsigned long);
Seiji Aguchi25c74b12013-10-30 16:37:00 -040077#ifdef CONFIG_TRACING
78dotraplinkage void trace_do_page_fault(struct pt_regs *, unsigned long);
Dave Hansen65a7f032014-05-16 12:45:15 -070079#else
80static inline void trace_do_page_fault(struct pt_regs *regs, unsigned long error)
81{
82 do_page_fault(regs, error);
83}
Seiji Aguchi25c74b12013-10-30 16:37:00 -040084#endif
Alexander van Heukelume407d6202008-09-30 18:41:36 +020085dotraplinkage void do_spurious_interrupt_bug(struct pt_regs *, long);
86dotraplinkage void do_coprocessor_error(struct pt_regs *, long);
87dotraplinkage void do_alignment_check(struct pt_regs *, long);
88#ifdef CONFIG_X86_MCE
89dotraplinkage void do_machine_check(struct pt_regs *, long);
90#endif
91dotraplinkage void do_simd_coprocessor_error(struct pt_regs *, long);
92#ifdef CONFIG_X86_32
93dotraplinkage void do_iret_error(struct pt_regs *, long);
94#endif
Jaswinder Singh6ac8d512008-07-15 21:09:13 +053095
Srinivasa Dsda654b72008-09-23 15:23:52 +053096static 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 Singh6ac8d512008-07-15 21:09:13 +0530106extern int panic_on_unrecovered_nmi;
Jaswinder Singh6ac8d512008-07-15 21:09:13 +0530107
Tejun Heod3157602009-02-09 22:17:39 +0900108void math_emulate(struct math_emu_info *);
Akinobu Mitafde03122009-07-19 00:09:56 +0900109#ifndef CONFIG_X86_32
Jaswinder Singhd1769d52008-12-19 00:03:56 +0530110asmlinkage void smp_thermal_interrupt(void);
Aravind Gopalakrishnan24fd78a2015-05-06 06:58:56 -0500111asmlinkage void smp_threshold_interrupt(void);
112asmlinkage void smp_deferred_error_interrupt(void);
Alexander van Heukelume407d6202008-09-30 18:41:36 +0200113#endif
Jaswinder Singh6ac8d512008-07-15 21:09:13 +0530114
Andy Lutomirski95927472014-11-19 17:41:09 -0800115extern enum ctx_state ist_enter(struct pt_regs *regs);
116extern void ist_exit(struct pt_regs *regs, enum ctx_state prev_state);
Andy Lutomirskibced35b2014-11-19 17:59:41 -0800117extern void ist_begin_non_atomic(struct pt_regs *regs);
118extern void ist_end_non_atomic(void);
Andy Lutomirski95927472014-11-19 17:41:09 -0800119
Kees Cookc9408262012-03-09 16:07:10 -0800120/* Interrupts/Exceptions */
121enum {
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 Anvin1965aae2008-10-22 22:26:29 -0700145#endif /* _ASM_X86_TRAPS_H */