1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __ASM_EXTABLE_H 3 #define __ASM_EXTABLE_H 4 5 #include <linux/stringify.h> 6 #include <asm/asm-const.h> 7 8 #define EX_TYPE_NONE 0 9 #define EX_TYPE_FIXUP 1 10 #define EX_TYPE_BPF 2 11 #define EX_TYPE_UACCESS 3 12 13 #define __EX_TABLE(_section, _fault, _target, _type) \ 14 stringify_in_c(.section _section,"a";) \ 15 stringify_in_c(.align 4;) \ 16 stringify_in_c(.long (_fault) - .;) \ 17 stringify_in_c(.long (_target) - .;) \ 18 stringify_in_c(.short (_type);) \ 19 stringify_in_c(.short 0;) \ 20 stringify_in_c(.previous) 21 22 #define __EX_TABLE_UA(_section, _fault, _target, _type, _reg) \ 23 stringify_in_c(.section _section,"a";) \ 24 stringify_in_c(.align 4;) \ 25 stringify_in_c(.long (_fault) - .;) \ 26 stringify_in_c(.long (_target) - .;) \ 27 stringify_in_c(.short (_type);) \ 28 stringify_in_c(.macro extable_reg reg;) \ 29 stringify_in_c(.set found, 0;) \ 30 stringify_in_c(.set regnr, 0;) \ 31 stringify_in_c(.irp rs,r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15;) \ 32 stringify_in_c(.ifc "\reg", "%%\rs";) \ 33 stringify_in_c(.set found, 1;) \ 34 stringify_in_c(.short regnr;) \ 35 stringify_in_c(.endif;) \ 36 stringify_in_c(.set regnr, regnr+1;) \ 37 stringify_in_c(.endr;) \ 38 stringify_in_c(.ifne (found != 1);) \ 39 stringify_in_c(.error "extable_reg: bad register argument";) \ 40 stringify_in_c(.endif;) \ 41 stringify_in_c(.endm;) \ 42 stringify_in_c(extable_reg _reg;) \ 43 stringify_in_c(.purgem extable_reg;) \ 44 stringify_in_c(.previous) 45 46 #define EX_TABLE(_fault, _target) \ 47 __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_FIXUP) 48 #define EX_TABLE_AMODE31(_fault, _target) \ 49 __EX_TABLE(.amode31.ex_table, _fault, _target, EX_TYPE_FIXUP) 50 #define EX_TABLE_UA(_fault, _target, _reg) \ 51 __EX_TABLE_UA(__ex_table, _fault, _target, EX_TYPE_UACCESS, _reg) 52 53 #endif /* __ASM_EXTABLE_H */ 54