Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _ASM_X86_EXTABLE_H
0003 #define _ASM_X86_EXTABLE_H
0004 
0005 #include <asm/extable_fixup_types.h>
0006 
0007 /*
0008  * The exception table consists of two addresses relative to the
0009  * exception table entry itself and a type selector field.
0010  *
0011  * The first address is of an instruction that is allowed to fault, the
0012  * second is the target at which the program should continue.
0013  *
0014  * The type entry is used by fixup_exception() to select the handler to
0015  * deal with the fault caused by the instruction in the first field.
0016  *
0017  * All the routines below use bits of fixup code that are out of line
0018  * with the main instruction path.  This means when everything is well,
0019  * we don't even have to jump over them.  Further, they do not intrude
0020  * on our cache or tlb entries.
0021  */
0022 
0023 struct exception_table_entry {
0024     int insn, fixup, data;
0025 };
0026 struct pt_regs;
0027 
0028 #define ARCH_HAS_RELATIVE_EXTABLE
0029 
0030 #define swap_ex_entry_fixup(a, b, tmp, delta)           \
0031     do {                            \
0032         (a)->fixup = (b)->fixup + (delta);      \
0033         (b)->fixup = (tmp).fixup - (delta);     \
0034         (a)->data = (b)->data;              \
0035         (b)->data = (tmp).data;             \
0036     } while (0)
0037 
0038 extern int fixup_exception(struct pt_regs *regs, int trapnr,
0039                unsigned long error_code, unsigned long fault_addr);
0040 extern int fixup_bug(struct pt_regs *regs, int trapnr);
0041 extern int ex_get_fixup_type(unsigned long ip);
0042 extern void early_fixup_exception(struct pt_regs *regs, int trapnr);
0043 
0044 #ifdef CONFIG_X86_MCE
0045 extern void __noreturn ex_handler_msr_mce(struct pt_regs *regs, bool wrmsr);
0046 #else
0047 static inline void __noreturn ex_handler_msr_mce(struct pt_regs *regs, bool wrmsr)
0048 {
0049     for (;;)
0050         cpu_relax();
0051 }
0052 #endif
0053 
0054 #if defined(CONFIG_BPF_JIT) && defined(CONFIG_X86_64)
0055 bool ex_handler_bpf(const struct exception_table_entry *x, struct pt_regs *regs);
0056 #else
0057 static inline bool ex_handler_bpf(const struct exception_table_entry *x,
0058                   struct pt_regs *regs) { return false; }
0059 #endif
0060 
0061 #endif