xref: /linux/arch/x86/include/asm/traps.h (revision a5f6c2ace9974adf92ce65dacca8126d90adabfe)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21965aae3SH. Peter Anvin #ifndef _ASM_X86_TRAPS_H
31965aae3SH. Peter Anvin #define _ASM_X86_TRAPS_H
4bb898558SAl Viro 
595927475SAndy Lutomirski #include <linux/context_tracking_state.h>
65cec93c2SAndy Lutomirski #include <linux/kprobes.h>
75cec93c2SAndy Lutomirski 
8bb898558SAl Viro #include <asm/debugreg.h>
953aaf262SThomas Gleixner #include <asm/idtentry.h>
10a2bcd473SIngo Molnar #include <asm/siginfo.h>			/* TRAP_TRACE, ... */
1105a2fdf3SJoerg Roedel #include <asm/trap_pf.h>
12bb898558SAl Viro 
133ba4f0a6SThomas Gleixner #ifdef CONFIG_X86_64
143ba4f0a6SThomas Gleixner asmlinkage __visible notrace struct pt_regs *sync_regs(struct pt_regs *eregs);
153ba4f0a6SThomas Gleixner asmlinkage __visible notrace
160aca53c6SLai Jiangshan struct pt_regs *fixup_bad_iret(struct pt_regs *bad_regs);
173ba4f0a6SThomas Gleixner void __init trap_init(void);
18a13644f3SJoerg Roedel asmlinkage __visible noinstr struct pt_regs *vc_switch_off_ist(struct pt_regs *eregs);
193ba4f0a6SThomas Gleixner #endif
203ba4f0a6SThomas Gleixner 
21991625f3SPeter Zijlstra extern bool ibt_selftest(void);
22991625f3SPeter Zijlstra 
2349893c5cSThomas Gleixner #ifdef CONFIG_X86_F00F_BUG
2449893c5cSThomas Gleixner /* For handling the FOOF bug */
2549893c5cSThomas Gleixner void handle_invalid_op(struct pt_regs *regs);
2649893c5cSThomas Gleixner #endif
2749893c5cSThomas Gleixner 
28bb898558SAl Viro static inline int get_si_code(unsigned long condition)
29bb898558SAl Viro {
30bb898558SAl Viro 	if (condition & DR_STEP)
31bb898558SAl Viro 		return TRAP_TRACE;
32bb898558SAl Viro 	else if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3))
33bb898558SAl Viro 		return TRAP_HWBKPT;
34bb898558SAl Viro 	else
35bb898558SAl Viro 		return TRAP_BRKPT;
36bb898558SAl Viro }
37bb898558SAl Viro 
38bb898558SAl Viro extern int panic_on_unrecovered_nmi;
39bb898558SAl Viro 
40d315760fSTejun Heo void math_emulate(struct math_emu_info *);
41bb898558SAl Viro 
4230063810STony Luck bool fault_in_kernel_space(unsigned long address);
4330063810STony Luck 
446271cfdfSAndy Lutomirski #ifdef CONFIG_VMAP_STACK
4544b979faSPeter Zijlstra void __noreturn handle_stack_overflow(struct pt_regs *regs,
4644b979faSPeter Zijlstra 				      unsigned long fault_address,
4744b979faSPeter Zijlstra 				      struct stack_info *info);
486271cfdfSAndy Lutomirski #endif
496271cfdfSAndy Lutomirski 
50*a5f6c2acSRick Edgecombe static inline void cond_local_irq_enable(struct pt_regs *regs)
51*a5f6c2acSRick Edgecombe {
52*a5f6c2acSRick Edgecombe 	if (regs->flags & X86_EFLAGS_IF)
53*a5f6c2acSRick Edgecombe 		local_irq_enable();
54*a5f6c2acSRick Edgecombe }
55*a5f6c2acSRick Edgecombe 
56*a5f6c2acSRick Edgecombe static inline void cond_local_irq_disable(struct pt_regs *regs)
57*a5f6c2acSRick Edgecombe {
58*a5f6c2acSRick Edgecombe 	if (regs->flags & X86_EFLAGS_IF)
59*a5f6c2acSRick Edgecombe 		local_irq_disable();
60*a5f6c2acSRick Edgecombe }
61*a5f6c2acSRick Edgecombe 
621965aae3SH. Peter Anvin #endif /* _ASM_X86_TRAPS_H */
63