1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_TRAPS_H
3 #define _ASM_X86_TRAPS_H
5 #include <linux/context_tracking_state.h>
6 #include <linux/kprobes.h>
8 #include <asm/debugreg.h>
9 #include <asm/idtentry.h>
10 #include <asm/siginfo.h> /* TRAP_TRACE, ... */
12 #define dotraplinkage __visible
14 asmlinkage void debug(void);
15 asmlinkage void nmi(void);
16 asmlinkage void int3(void);
18 asmlinkage void double_fault(void);
20 asmlinkage void page_fault(void);
21 asmlinkage void async_page_fault(void);
22 asmlinkage void alignment_check(void);
24 asmlinkage void machine_check(void);
25 #endif /* CONFIG_X86_MCE */
26 asmlinkage void simd_coprocessor_error(void);
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);
36 asmlinkage void xen_machine_check(void);
37 #endif /* CONFIG_X86_MCE */
38 asmlinkage void xen_simd_coprocessor_error(void);
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);
49 dotraplinkage void do_iret_error(struct pt_regs *regs, long error_code);
51 dotraplinkage void do_mce(struct pt_regs *regs, long error_code);
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);
60 #ifdef CONFIG_X86_F00F_BUG
61 /* For handling the FOOF bug */
62 void handle_invalid_op(struct pt_regs *regs);
65 static inline int get_si_code(unsigned long condition)
67 if (condition & DR_STEP)
69 else if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3))
75 extern int panic_on_unrecovered_nmi;
77 void math_emulate(struct math_emu_info *);
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);
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);
89 #ifdef CONFIG_VMAP_STACK
90 void __noreturn handle_stack_overflow(const char *message,
92 unsigned long fault_address);
96 * Page fault error code bits:
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
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,
113 #endif /* _ASM_X86_TRAPS_H */