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