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