x86/entry: Convert Coprocessor error exception to IDTENTRY
[linux-2.6-microblaze.git] / arch / x86 / include / asm / traps.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_TRAPS_H
3 #define _ASM_X86_TRAPS_H
4
5 #include <linux/context_tracking_state.h>
6 #include <linux/kprobes.h>
7
8 #include <asm/debugreg.h>
9 #include <asm/idtentry.h>
10 #include <asm/siginfo.h>                        /* TRAP_TRACE, ... */
11
12 #define dotraplinkage __visible
13
14 asmlinkage void debug(void);
15 asmlinkage void nmi(void);
16 asmlinkage void int3(void);
17 #ifdef CONFIG_X86_64
18 asmlinkage void double_fault(void);
19 #endif
20 asmlinkage void page_fault(void);
21 asmlinkage void async_page_fault(void);
22 asmlinkage void alignment_check(void);
23 #ifdef CONFIG_X86_MCE
24 asmlinkage void machine_check(void);
25 #endif /* CONFIG_X86_MCE */
26 asmlinkage void simd_coprocessor_error(void);
27
28 #if defined(CONFIG_X86_64) && defined(CONFIG_XEN_PV)
29 asmlinkage void xen_xennmi(void);
30 asmlinkage void xen_xendebug(void);
31 asmlinkage void xen_int3(void);
32 asmlinkage void xen_double_fault(void);
33 asmlinkage void xen_page_fault(void);
34 asmlinkage void xen_alignment_check(void);
35 #ifdef CONFIG_X86_MCE
36 asmlinkage void xen_machine_check(void);
37 #endif /* CONFIG_X86_MCE */
38 asmlinkage void xen_simd_coprocessor_error(void);
39 #endif
40
41 dotraplinkage void do_debug(struct pt_regs *regs, long error_code);
42 dotraplinkage void do_nmi(struct pt_regs *regs, long error_code);
43 dotraplinkage void do_int3(struct pt_regs *regs, long error_code);
44 dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code, unsigned long cr2);
45 dotraplinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
46 dotraplinkage void do_alignment_check(struct pt_regs *regs, long error_code);
47 dotraplinkage void do_simd_coprocessor_error(struct pt_regs *regs, long error_code);
48 #ifdef CONFIG_X86_32
49 dotraplinkage void do_iret_error(struct pt_regs *regs, long error_code);
50 #endif
51 dotraplinkage void do_mce(struct pt_regs *regs, long error_code);
52
53 #ifdef CONFIG_X86_64
54 asmlinkage __visible notrace struct pt_regs *sync_regs(struct pt_regs *eregs);
55 asmlinkage __visible notrace
56 struct bad_iret_stack *fixup_bad_iret(struct bad_iret_stack *s);
57 void __init trap_init(void);
58 #endif
59
60 #ifdef CONFIG_X86_F00F_BUG
61 /* For handling the FOOF bug */
62 void handle_invalid_op(struct pt_regs *regs);
63 #endif
64
65 static inline int get_si_code(unsigned long condition)
66 {
67         if (condition & DR_STEP)
68                 return TRAP_TRACE;
69         else if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3))
70                 return TRAP_HWBKPT;
71         else
72                 return TRAP_BRKPT;
73 }
74
75 extern int panic_on_unrecovered_nmi;
76
77 void math_emulate(struct math_emu_info *);
78 #ifndef CONFIG_X86_32
79 asmlinkage void smp_thermal_interrupt(struct pt_regs *regs);
80 asmlinkage void smp_threshold_interrupt(struct pt_regs *regs);
81 asmlinkage void smp_deferred_error_interrupt(struct pt_regs *regs);
82 #endif
83
84 void smp_apic_timer_interrupt(struct pt_regs *regs);
85 void smp_spurious_interrupt(struct pt_regs *regs);
86 void smp_error_interrupt(struct pt_regs *regs);
87 asmlinkage void smp_irq_move_cleanup_interrupt(void);
88
89 #ifdef CONFIG_VMAP_STACK
90 void __noreturn handle_stack_overflow(const char *message,
91                                       struct pt_regs *regs,
92                                       unsigned long fault_address);
93 #endif
94
95 /*
96  * Page fault error code bits:
97  *
98  *   bit 0 ==    0: no page found       1: protection fault
99  *   bit 1 ==    0: read access         1: write access
100  *   bit 2 ==    0: kernel-mode access  1: user-mode access
101  *   bit 3 ==                           1: use of reserved bit detected
102  *   bit 4 ==                           1: fault was an instruction fetch
103  *   bit 5 ==                           1: protection keys block access
104  */
105 enum x86_pf_error_code {
106         X86_PF_PROT     =               1 << 0,
107         X86_PF_WRITE    =               1 << 1,
108         X86_PF_USER     =               1 << 2,
109         X86_PF_RSVD     =               1 << 3,
110         X86_PF_INSTR    =               1 << 4,
111         X86_PF_PK       =               1 << 5,
112 };
113 #endif /* _ASM_X86_TRAPS_H */