xref: /openbmc/linux/arch/riscv/mm/extable.c (revision 67559900)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (C) 2009 Sunplus Core Technology Co., Ltd.
4  *  Lennox Wu <lennox.wu@sunplusct.com>
5  *  Chen Liqin <liqin.chen@sunplusct.com>
6  * Copyright (C) 2013 Regents of the University of California
7  */
8 
9 
10 #include <linux/extable.h>
11 #include <linux/module.h>
12 #include <linux/uaccess.h>
13 
14 #if defined(CONFIG_BPF_JIT) && defined(CONFIG_ARCH_RV64I)
15 int rv_bpf_fixup_exception(const struct exception_table_entry *ex, struct pt_regs *regs);
16 #endif
17 
18 int fixup_exception(struct pt_regs *regs)
19 {
20 	const struct exception_table_entry *fixup;
21 
22 	fixup = search_exception_tables(regs->epc);
23 	if (!fixup)
24 		return 0;
25 
26 #if defined(CONFIG_BPF_JIT) && defined(CONFIG_ARCH_RV64I)
27 	if (regs->epc >= BPF_JIT_REGION_START && regs->epc < BPF_JIT_REGION_END)
28 		return rv_bpf_fixup_exception(fixup, regs);
29 #endif
30 
31 	regs->epc = fixup->fixup;
32 	return 1;
33 }
34