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 #ifdef CONFIG_X86_64 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); 17 #endif 18 19 #ifdef CONFIG_X86_F00F_BUG 20 /* For handling the FOOF bug */ 21 void handle_invalid_op(struct pt_regs *regs); 22 #endif 23 24 static inline int get_si_code(unsigned long condition) 25 { 26 if (condition & DR_STEP) 27 return TRAP_TRACE; 28 else if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3)) 29 return TRAP_HWBKPT; 30 else 31 return TRAP_BRKPT; 32 } 33 34 extern int panic_on_unrecovered_nmi; 35 36 void math_emulate(struct math_emu_info *); 37 #ifndef CONFIG_X86_32 38 asmlinkage void smp_thermal_interrupt(struct pt_regs *regs); 39 asmlinkage void smp_threshold_interrupt(struct pt_regs *regs); 40 asmlinkage void smp_deferred_error_interrupt(struct pt_regs *regs); 41 #endif 42 43 #ifdef CONFIG_VMAP_STACK 44 void __noreturn handle_stack_overflow(const char *message, 45 struct pt_regs *regs, 46 unsigned long fault_address); 47 #endif 48 49 /* 50 * Page fault error code bits: 51 * 52 * bit 0 == 0: no page found 1: protection fault 53 * bit 1 == 0: read access 1: write access 54 * bit 2 == 0: kernel-mode access 1: user-mode access 55 * bit 3 == 1: use of reserved bit detected 56 * bit 4 == 1: fault was an instruction fetch 57 * bit 5 == 1: protection keys block access 58 */ 59 enum x86_pf_error_code { 60 X86_PF_PROT = 1 << 0, 61 X86_PF_WRITE = 1 << 1, 62 X86_PF_USER = 1 << 2, 63 X86_PF_RSVD = 1 << 3, 64 X86_PF_INSTR = 1 << 4, 65 X86_PF_PK = 1 << 5, 66 }; 67 #endif /* _ASM_X86_TRAPS_H */ 68