| 1 |
|
| 2 | #ifndef __PARISC_EXTABLE_H
|
| 3 | #define __PARISC_EXTABLE_H
|
| 4 |
|
| 5 | #include <asm/ptrace.h>
|
| 6 | #include <linux/compiler.h>
|
| 7 |
|
| 8 | |
| 9 | * The exception table consists of three addresses:
|
| 10 | *
|
| 11 | * - A relative address to the instruction that is allowed to fault.
|
| 12 | * - A relative address at which the program should continue (fixup routine)
|
| 13 | * - An asm statement which specifies which CPU register will
|
| 14 | * receive -EFAULT when an exception happens if the lowest bit in
|
| 15 | * the fixup address is set.
|
| 16 | *
|
| 17 | * Note: The register specified in the err_opcode instruction will be
|
| 18 | * modified at runtime if a fault happens. Register %r0 will be ignored.
|
| 19 | *
|
| 20 | * Since relative addresses are used, 32bit values are sufficient even on
|
| 21 | * 64bit kernel.
|
| 22 |
|
| 23 |
|
| 24 | struct pt_regs;
|
| 25 | int fixup_exception(struct pt_regs *regs);
|
| 26 |
|
| 27 | #define ARCH_HAS_RELATIVE_EXTABLE
|
| 28 | struct exception_table_entry {
|
| 29 | int insn;
|
| 30 | int fixup;
|
| 31 | int err_opcode;
|
| 32 | };
|
| 33 |
|
| 34 | #define ASM_EXCEPTIONTABLE_ENTRY( fault_addr, except_addr, opcode )\
|
| 35 | ".section __ex_table,\"aw\"\n" \
|
| 36 | ".align 4\n" \
|
| 37 | ".word (" #fault_addr " - .), (" #except_addr " - .)\n" \
|
| 38 | opcode "\n" \
|
| 39 | ".previous\n"
|
| 40 |
|
| 41 | |
| 42 | * ASM_EXCEPTIONTABLE_ENTRY_EFAULT() creates a special exception table entry
|
| 43 | * (with lowest bit set) for which the fault handler in fixup_exception() will
|
| 44 | * load -EFAULT on fault into the register specified by the err_opcode instruction,
|
| 45 | * and zeroes the target register in case of a read fault in get_user().
|
| 46 |
|
| 47 | #define ASM_EXCEPTIONTABLE_VAR(__err_var) \
|
| 48 | int __err_var = 0
|
| 49 | #define ASM_EXCEPTIONTABLE_ENTRY_EFAULT( fault_addr, except_addr, register )\
|
| 50 | ASM_EXCEPTIONTABLE_ENTRY( fault_addr, except_addr + 1, "or %%r0,%%r0," register)
|
| 51 |
|
| 52 | static inline void swap_ex_entry_fixup(struct exception_table_entry *a,
|
| 53 | struct exception_table_entry *b,
|
| 54 | struct exception_table_entry tmp,
|
| 55 | int delta)
|
| 56 | {
|
| 57 | a->fixup = b->fixup + delta;
|
| 58 | b->fixup = tmp.fixup - delta;
|
| 59 | a->err_opcode = b->err_opcode;
|
| 60 | b->err_opcode = tmp.err_opcode;
|
| 61 | }
|
| 62 | #define swap_ex_entry_fixup swap_ex_entry_fixup
|
| 63 |
|
| 64 | #endif
|