riscv: extable: add `type` and `data` fields
[linux-2.6-microblaze.git] / arch / riscv / mm / extable.c
index 18bf338..91e52c4 100644 (file)
 #include <linux/extable.h>
 #include <linux/module.h>
 #include <linux/uaccess.h>
+#include <asm/asm-extable.h>
 
-#ifdef CONFIG_BPF_JIT
-int rv_bpf_fixup_exception(const struct exception_table_entry *ex, struct pt_regs *regs);
-#endif
+static inline unsigned long
+get_ex_fixup(const struct exception_table_entry *ex)
+{
+       return ((unsigned long)&ex->fixup + ex->fixup);
+}
+
+static bool ex_handler_fixup(const struct exception_table_entry *ex,
+                            struct pt_regs *regs)
+{
+       regs->epc = get_ex_fixup(ex);
+       return true;
+}
 
-int fixup_exception(struct pt_regs *regs)
+bool fixup_exception(struct pt_regs *regs)
 {
-       const struct exception_table_entry *fixup;
+       const struct exception_table_entry *ex;
 
-       fixup = search_exception_tables(regs->epc);
-       if (!fixup)
-               return 0;
+       ex = search_exception_tables(regs->epc);
+       if (!ex)
+               return false;
 
-#ifdef CONFIG_BPF_JIT
-       if (regs->epc >= BPF_JIT_REGION_START && regs->epc < BPF_JIT_REGION_END)
-               return rv_bpf_fixup_exception(fixup, regs);
-#endif
+       switch (ex->type) {
+       case EX_TYPE_FIXUP:
+               return ex_handler_fixup(ex, regs);
+       case EX_TYPE_BPF:
+               return ex_handler_bpf(ex, regs);
+       }
 
-       regs->epc = fixup->fixup;
-       return 1;
+       BUG();
 }