xref: /OK3568_Linux_fs/kernel/arch/x86/include/asm/extable.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef _ASM_X86_EXTABLE_H
3*4882a593Smuzhiyun #define _ASM_X86_EXTABLE_H
4*4882a593Smuzhiyun /*
5*4882a593Smuzhiyun  * The exception table consists of triples of addresses relative to the
6*4882a593Smuzhiyun  * exception table entry itself. The first address is of an instruction
7*4882a593Smuzhiyun  * that is allowed to fault, the second is the target at which the program
8*4882a593Smuzhiyun  * should continue. The third is a handler function to deal with the fault
9*4882a593Smuzhiyun  * caused by the instruction in the first field.
10*4882a593Smuzhiyun  *
11*4882a593Smuzhiyun  * All the routines below use bits of fixup code that are out of line
12*4882a593Smuzhiyun  * with the main instruction path.  This means when everything is well,
13*4882a593Smuzhiyun  * we don't even have to jump over them.  Further, they do not intrude
14*4882a593Smuzhiyun  * on our cache or tlb entries.
15*4882a593Smuzhiyun  */
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun struct exception_table_entry {
18*4882a593Smuzhiyun 	int insn, fixup, handler;
19*4882a593Smuzhiyun };
20*4882a593Smuzhiyun struct pt_regs;
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun #define ARCH_HAS_RELATIVE_EXTABLE
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun #define swap_ex_entry_fixup(a, b, tmp, delta)			\
25*4882a593Smuzhiyun 	do {							\
26*4882a593Smuzhiyun 		(a)->fixup = (b)->fixup + (delta);		\
27*4882a593Smuzhiyun 		(b)->fixup = (tmp).fixup - (delta);		\
28*4882a593Smuzhiyun 		(a)->handler = (b)->handler + (delta);		\
29*4882a593Smuzhiyun 		(b)->handler = (tmp).handler - (delta);		\
30*4882a593Smuzhiyun 	} while (0)
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun enum handler_type {
33*4882a593Smuzhiyun 	EX_HANDLER_NONE,
34*4882a593Smuzhiyun 	EX_HANDLER_FAULT,
35*4882a593Smuzhiyun 	EX_HANDLER_UACCESS,
36*4882a593Smuzhiyun 	EX_HANDLER_OTHER
37*4882a593Smuzhiyun };
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun extern int fixup_exception(struct pt_regs *regs, int trapnr,
40*4882a593Smuzhiyun 			   unsigned long error_code, unsigned long fault_addr);
41*4882a593Smuzhiyun extern int fixup_bug(struct pt_regs *regs, int trapnr);
42*4882a593Smuzhiyun extern enum handler_type ex_get_fault_handler_type(unsigned long ip);
43*4882a593Smuzhiyun extern void early_fixup_exception(struct pt_regs *regs, int trapnr);
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun #endif
46