| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
#include <linux/config.h> |
|---|
| 14 |
#include <linux/module.h> |
|---|
| 15 |
#include <linux/init.h> |
|---|
| 16 |
#include <asm/uaccess.h> |
|---|
| 17 |
|
|---|
| 18 |
extern struct exception_table_entry __start___ex_table[]; |
|---|
| 19 |
extern struct exception_table_entry __stop___ex_table[]; |
|---|
| 20 |
|
|---|
| 21 |
#ifndef ARCH_HAS_SORT_EXTABLE |
|---|
| 22 |
|
|---|
| 23 |
* The exception table needs to be sorted so that the binary |
|---|
| 24 |
* search that we use to find entries in it works properly. |
|---|
| 25 |
* This is used both for the kernel exception table and for |
|---|
| 26 |
* the exception tables of modules that get loaded. |
|---|
| 27 |
*/ |
|---|
| 28 |
void sort_extable(struct exception_table_entry *start, |
|---|
| 29 |
struct exception_table_entry *finish) |
|---|
| 30 |
{ |
|---|
| 31 |
struct exception_table_entry el, *p, *q; |
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
for (p = start + 1; p < finish; ++p) { |
|---|
| 35 |
|
|---|
| 36 |
if (p[0].insn < p[-1].insn) { |
|---|
| 37 |
|
|---|
| 38 |
el = *p; |
|---|
| 39 |
q = p; |
|---|
| 40 |
do { |
|---|
| 41 |
|
|---|
| 42 |
q[0] = q[-1]; |
|---|
| 43 |
--q; |
|---|
| 44 |
} while (q > start && el.insn < q[-1].insn); |
|---|
| 45 |
*q = el; |
|---|
| 46 |
} |
|---|
| 47 |
} |
|---|
| 48 |
} |
|---|
| 49 |
#endif |
|---|
| 50 |
|
|---|
| 51 |
#ifndef ARCH_HAS_SEARCH_EXTABLE |
|---|
| 52 |
|
|---|
| 53 |
* Search one exception table for an entry corresponding to the |
|---|
| 54 |
* given instruction address, and return the address of the entry, |
|---|
| 55 |
* or NULL if none is found. |
|---|
| 56 |
* We use a binary search, and thus we assume that the table is |
|---|
| 57 |
* already sorted. |
|---|
| 58 |
*/ |
|---|
| 59 |
const struct exception_table_entry * |
|---|
| 60 |
search_extable(const struct exception_table_entry *first, |
|---|
| 61 |
const struct exception_table_entry *last, |
|---|
| 62 |
unsigned long value) |
|---|
| 63 |
{ |
|---|
| 64 |
while (first <= last) { |
|---|
| 65 |
const struct exception_table_entry *mid; |
|---|
| 66 |
|
|---|
| 67 |
mid = (last - first) / 2 + first; |
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
if (mid->insn < value) |
|---|
| 73 |
first = mid + 1; |
|---|
| 74 |
else if (mid->insn > value) |
|---|
| 75 |
last = mid - 1; |
|---|
| 76 |
else |
|---|
| 77 |
return mid; |
|---|
| 78 |
} |
|---|
| 79 |
return NULL; |
|---|
| 80 |
} |
|---|
| 81 |
#endif |
|---|
| 82 |
|
|---|