#include <xen/spinlock.h>
#include <asm/uaccess.h>
#include <xen/virtual_region.h>
+#include <xen/xsplice.h>
#define EX_FIELD(ptr, field) ((unsigned long)&(ptr)->field + (ptr)->field)
return EX_FIELD(x, cont);
}
-static int __init cmp_ex(const void *a, const void *b)
+static int init_or_xsplice cmp_ex(const void *a, const void *b)
{
const struct exception_table_entry *l = a, *r = b;
unsigned long lip = ex_addr(l);
}
#ifndef swap_ex
-static void __init swap_ex(void *a, void *b, int size)
+static void init_or_xsplice swap_ex(void *a, void *b, int size)
{
struct exception_table_entry *l = a, *r = b, tmp;
long delta = b - a;
}
#endif
-void __init sort_exception_tables(void)
+void init_or_xsplice sort_exception_table(struct exception_table_entry *start,
+ const struct exception_table_entry *stop)
{
- sort(__start___ex_table, __stop___ex_table - __start___ex_table,
- sizeof(struct exception_table_entry), cmp_ex, swap_ex);
- sort(__start___pre_ex_table,
- __stop___pre_ex_table - __start___pre_ex_table,
+ sort(start, stop - start,
sizeof(struct exception_table_entry), cmp_ex, swap_ex);
}
-static inline unsigned long
-search_one_table(const struct exception_table_entry *first,
- const struct exception_table_entry *last,
- unsigned long value)
+void __init sort_exception_tables(void)
+{
+ sort_exception_table(__start___ex_table, __stop___ex_table);
+ sort_exception_table(__start___pre_ex_table, __stop___pre_ex_table);
+}
+
+unsigned long
+search_one_extable(const struct exception_table_entry *first,
+ const struct exception_table_entry *last,
+ unsigned long value)
{
const struct exception_table_entry *mid;
long diff;
const struct virtual_region *region = find_text_region(addr);
if ( region && region->ex )
- return search_one_table(region->ex, region->ex_end - 1, addr);
+ return search_one_extable(region->ex, region->ex_end - 1, addr);
return 0;
}
search_pre_exception_table(struct cpu_user_regs *regs)
{
unsigned long addr = (unsigned long)regs->eip;
- unsigned long fixup = search_one_table(
+ unsigned long fixup = search_one_extable(
__start___pre_ex_table, __stop___pre_ex_table-1, addr);
if ( fixup )
{
sizeof(*region->frame[i].bugs);
}
+#ifndef CONFIG_ARM
+ sec = xsplice_elf_sec_by_name(elf, ".ex_table");
+ if ( sec )
+ {
+ struct exception_table_entry *s, *e;
+
+ if ( !sec->sec->sh_size ||
+ (sec->sec->sh_size % sizeof(*region->ex)) )
+ {
+ dprintk(XENLOG_ERR, XSPLICE "%s: Wrong size of .ex_table (exp:%lu vs %lu)!\n",
+ elf->name, sizeof(*region->ex),
+ sec->sec->sh_size);
+ return -EINVAL;
+ }
+
+ s = sec->load_addr;
+ e = sec->load_addr + sec->sec->sh_size;
+
+ sort_exception_table(s ,e);
+
+ region->ex = s;
+ region->ex_end = e;
+ }
+#endif
+
return 0;
}
#include <xen/elfstructs.h>
#ifdef CONFIG_XSPLICE
+/*
+ * We use alternative and exception table code - which by default are __init
+ * only, however we need them during runtime. These macros allows us to build
+ * the image with these functions built-in. (See the #else below).
+ */
+#define init_or_xsplice_const
+#define init_or_xsplice_constrel
+#define init_or_xsplice_data
+#define init_or_xsplice
+
/* Convenience define for printk. */
#define XSPLICE "xsplice: "
/* ELF payload special section names. */
void arch_xsplice_unmask(void);
#else
+/*
+ * If not compiling with xSplice certain functionality should stay as
+ * __init.
+ */
+#define init_or_xsplice_const __initconst
+#define init_or_xsplice_constrel __initconstrel
+#define init_or_xsplice_data __initdata
+#define init_or_xsplice __init
+
#include <xen/errno.h> /* For -ENOSYS */
static inline int xsplice_op(struct xen_sysctl_xsplice_op *op)
{