diff options
author | kaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk> | 2004-06-10 16:59:06 +0000 |
---|---|---|
committer | kaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk> | 2004-06-10 16:59:06 +0000 |
commit | 7f68576b77ef3c9fde1009100690ff996d4490e0 (patch) | |
tree | 6a87f66c7a03042baa556676add65252816fbd94 /xen/arch/x86/extable.c | |
parent | 822a0b35350d8006b808000eef3665ee4df7b297 (diff) | |
download | xen-7f68576b77ef3c9fde1009100690ff996d4490e0.tar.gz xen-7f68576b77ef3c9fde1009100690ff996d4490e0.tar.bz2 xen-7f68576b77ef3c9fde1009100690ff996d4490e0.zip |
bitkeeper revision 1.952 (40c8935a3XSRdQfnx5RoO7XgaggvOQ)
Towards x86_64 support. Merged a bunch of the existing x86_64 stuff
back into a generic 'x86' architecture. Aim is to share as much
as possible between 32- and 64-bit worlds.
Diffstat (limited to 'xen/arch/x86/extable.c')
-rw-r--r-- | xen/arch/x86/extable.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c new file mode 100644 index 0000000000..af37b86013 --- /dev/null +++ b/xen/arch/x86/extable.c @@ -0,0 +1,62 @@ +/* + * linux/arch/i386/mm/extable.c + */ + +#include <xen/config.h> +#include <xen/module.h> +#include <xen/spinlock.h> +#include <asm/uaccess.h> + +extern const struct exception_table_entry __start___ex_table[]; +extern const struct exception_table_entry __stop___ex_table[]; + +static inline unsigned long +search_one_table(const struct exception_table_entry *first, + const struct exception_table_entry *last, + unsigned long value) +{ + while (first <= last) { + const struct exception_table_entry *mid; + long diff; + + mid = (last - first) / 2 + first; + diff = mid->insn - value; + if (diff == 0) + return mid->fixup; + else if (diff < 0) + first = mid+1; + else + last = mid-1; + } + return 0; +} + +extern spinlock_t modlist_lock; + +unsigned long +search_exception_table(unsigned long addr) +{ + unsigned long ret = 0; + +#ifndef CONFIG_MODULES + /* There is only the kernel to search. */ + ret = search_one_table(__start___ex_table, __stop___ex_table-1, addr); + return ret; +#else + unsigned long flags; + /* The kernel is the last "module" -- no need to treat it special. */ + struct module *mp; + + spin_lock_irqsave(&modlist_lock, flags); + for (mp = module_list; mp != NULL; mp = mp->next) { + if (mp->ex_table_start == NULL || !(mp->flags&(MOD_RUNNING|MOD_INITIALIZING))) + continue; + ret = search_one_table(mp->ex_table_start, + mp->ex_table_end - 1, addr); + if (ret) + break; + } + spin_unlock_irqrestore(&modlist_lock, flags); + return ret; +#endif +} |