X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=kitten%2Farch%2Fx86_64%2Flib%2Fextable.c;fp=kitten%2Farch%2Fx86_64%2Flib%2Fextable.c;h=8956ea651c021b3f11805fcee7ba50dbb475f399;hb=66a1a4c7a9edcd7d8bc207aca093d694a6e6b5b2;hp=0000000000000000000000000000000000000000;hpb=f7cf9c19ecb0a589dd45ae0d2c91814bd3c2acc2;p=palacios.git diff --git a/kitten/arch/x86_64/lib/extable.c b/kitten/arch/x86_64/lib/extable.c new file mode 100644 index 0000000..8956ea6 --- /dev/null +++ b/kitten/arch/x86_64/lib/extable.c @@ -0,0 +1,32 @@ +/* + * lwk/arch/x86_64/lib/extable.c + */ + +#include +#include + +/* Simple binary search */ +const struct exception_table_entry * +search_extable(const struct exception_table_entry *first, + const struct exception_table_entry *last, + unsigned long value) +{ + /* Work around a B stepping K8 bug */ + if ((value >> 32) == 0) + value |= 0xffffffffUL << 32; + + 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; + else if (diff < 0) + first = mid+1; + else + last = mid-1; + } + return NULL; +}