2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * arch/sh64/mm/extable.c
8 * Copyright (C) 2003 Richard Curnow
9 * Copyright (C) 2003, 2004 Paul Mundt
11 * Cloned from the 2.5 SH version..
13 #include <linux/config.h>
14 #include <linux/rwsem.h>
15 #include <linux/module.h>
16 #include <asm/uaccess.h>
18 extern unsigned long copy_user_memcpy, copy_user_memcpy_end;
19 extern void __copy_user_fixup(void);
21 static const struct exception_table_entry __copy_user_fixup_ex = {
22 .fixup = (unsigned long)&__copy_user_fixup,
25 /* Some functions that may trap due to a bad user-mode address have too many loads
26 and stores in them to make it at all practical to label each one and put them all in
27 the main exception table.
29 In particular, the fast memcpy routine is like this. It's fix-up is just to fall back
30 to a slow byte-at-a-time copy, which is handled the conventional way. So it's functionally
31 OK to just handle any trap occurring in the fast memcpy with that fixup. */
32 static const struct exception_table_entry *check_exception_ranges(unsigned long addr)
34 if ((addr >= (unsigned long)©_user_memcpy) &&
35 (addr <= (unsigned long)©_user_memcpy_end))
36 return &__copy_user_fixup_ex;
41 /* Simple binary search */
42 const struct exception_table_entry *
43 search_extable(const struct exception_table_entry *first,
44 const struct exception_table_entry *last,
47 const struct exception_table_entry *mid;
49 mid = check_exception_ranges(value);
53 while (first <= last) {
56 mid = (last - first) / 2 + first;
57 diff = mid->insn - value;
69 int fixup_exception(struct pt_regs *regs)
71 const struct exception_table_entry *fixup;
73 fixup = search_exception_tables(regs->pc);
75 regs->pc = fixup->fixup;