GNU Linux-libre 5.15.72-gnu
[releases.git] / arch / arm64 / mm / extable.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Based on arch/arm/mm/extable.c
4  */
5
6 #include <linux/extable.h>
7 #include <linux/uaccess.h>
8
9 int fixup_exception(struct pt_regs *regs)
10 {
11         const struct exception_table_entry *fixup;
12         unsigned long addr;
13
14         addr = instruction_pointer(regs);
15
16         /* Search the BPF tables first, these are formatted differently */
17         fixup = search_bpf_extables(addr);
18         if (fixup)
19                 return arm64_bpf_fixup_exception(fixup, regs);
20
21         fixup = search_exception_tables(addr);
22         if (!fixup)
23                 return 0;
24
25         regs->pc = (unsigned long)&fixup->fixup + fixup->fixup;
26         return 1;
27 }