/* SPDX-License-Identifier: GPL-2.0 */1#ifndef __PARISC_EXTABLE_H2#define __PARISC_EXTABLE_H34#include <asm/ptrace.h>5#include <linux/compiler.h>67/*8* The exception table consists of three addresses:9*10* - A relative address to the instruction that is allowed to fault.11* - A relative address at which the program should continue (fixup routine)12* - An asm statement which specifies which CPU register will13* receive -EFAULT when an exception happens if the lowest bit in14* the fixup address is set.15*16* Note: The register specified in the err_opcode instruction will be17* modified at runtime if a fault happens. Register %r0 will be ignored.18*19* Since relative addresses are used, 32bit values are sufficient even on20* 64bit kernel.21*/2223struct pt_regs;24int fixup_exception(struct pt_regs *regs);2526#define ARCH_HAS_RELATIVE_EXTABLE27struct exception_table_entry {28int insn; /* relative address of insn that is allowed to fault. */29int fixup; /* relative address of fixup routine */30int err_opcode; /* sample opcode with register which holds error code */31};3233#define ASM_EXCEPTIONTABLE_ENTRY( fault_addr, except_addr, opcode )\34".section __ex_table,\"aw\"\n" \35".align 4\n" \36".word (" #fault_addr " - .), (" #except_addr " - .)\n" \37opcode "\n" \38".previous\n"3940/*41* ASM_EXCEPTIONTABLE_ENTRY_EFAULT() creates a special exception table entry42* (with lowest bit set) for which the fault handler in fixup_exception() will43* load -EFAULT on fault into the register specified by the err_opcode instruction,44* and zeroes the target register in case of a read fault in get_user().45*/46#define ASM_EXCEPTIONTABLE_VAR(__err_var) \47int __err_var = 048#define ASM_EXCEPTIONTABLE_ENTRY_EFAULT( fault_addr, except_addr, register )\49ASM_EXCEPTIONTABLE_ENTRY( fault_addr, except_addr + 1, "or %%r0,%%r0," register)5051static inline void swap_ex_entry_fixup(struct exception_table_entry *a,52struct exception_table_entry *b,53struct exception_table_entry tmp,54int delta)55{56a->fixup = b->fixup + delta;57b->fixup = tmp.fixup - delta;58a->err_opcode = b->err_opcode;59b->err_opcode = tmp.err_opcode;60}61#define swap_ex_entry_fixup swap_ex_entry_fixup6263#endif646566