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, ... */
13 asmlinkage __visible notrace struct pt_regs *sync_regs(struct pt_regs *eregs);
14 asmlinkage __visible notrace
15 struct bad_iret_stack *fixup_bad_iret(struct bad_iret_stack *s);
16 void __init trap_init(void);
19 #ifdef CONFIG_X86_F00F_BUG
20 /* For handling the FOOF bug */
21 void handle_invalid_op(struct pt_regs *regs);
24 static inline int get_si_code(unsigned long condition)
26 if (condition & DR_STEP)
28 else if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3))
34 extern int panic_on_unrecovered_nmi;
36 void math_emulate(struct math_emu_info *);
38 #ifdef CONFIG_VMAP_STACK
39 void __noreturn handle_stack_overflow(const char *message,
41 unsigned long fault_address);
45 * Page fault error code bits:
47 * bit 0 == 0: no page found 1: protection fault
48 * bit 1 == 0: read access 1: write access
49 * bit 2 == 0: kernel-mode access 1: user-mode access
50 * bit 3 == 1: use of reserved bit detected
51 * bit 4 == 1: fault was an instruction fetch
52 * bit 5 == 1: protection keys block access
54 enum x86_pf_error_code {
56 X86_PF_WRITE = 1 << 1,
59 X86_PF_INSTR = 1 << 4,
62 #endif /* _ASM_X86_TRAPS_H */