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 <linux/bits.h> 7 #include <asm/asm-const.h> 8 9 #define EX_TYPE_NONE 0 10 #define EX_TYPE_FIXUP 1 11 #define EX_TYPE_BPF 2 12 #define EX_TYPE_UA_STORE 3 13 #define EX_TYPE_UA_LOAD_MEM 4 14 #define EX_TYPE_UA_LOAD_REG 5 15 #define EX_TYPE_UA_LOAD_REGPAIR 6 16 #define EX_TYPE_ZEROPAD 7 17 18 #define EX_DATA_REG_ERR_SHIFT 0 19 #define EX_DATA_REG_ERR GENMASK(3, 0) 20 21 #define EX_DATA_REG_ADDR_SHIFT 4 22 #define EX_DATA_REG_ADDR GENMASK(7, 4) 23 24 #define EX_DATA_LEN_SHIFT 8 25 #define EX_DATA_LEN GENMASK(11, 8) 26 27 #define __EX_TABLE(_section, _fault, _target, _type, _regerr, _regaddr, _len) \ 28 stringify_in_c(.section _section,"a";) \ 29 stringify_in_c(.balign 4;) \ 30 stringify_in_c(.long (_fault) - .;) \ 31 stringify_in_c(.long (_target) - .;) \ 32 stringify_in_c(.short (_type);) \ 33 stringify_in_c(.macro extable_reg regerr, regaddr;) \ 34 stringify_in_c(.set .Lfound, 0;) \ 35 stringify_in_c(.set .Lcurr, 0;) \ 36 stringify_in_c(.irp rs,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15;) \ 37 stringify_in_c( .ifc "\regerr", "%%r\rs";) \ 38 stringify_in_c( .set .Lfound, 1;) \ 39 stringify_in_c( .set .Lregerr, .Lcurr;) \ 40 stringify_in_c( .endif;) \ 41 stringify_in_c( .set .Lcurr, .Lcurr+1;) \ 42 stringify_in_c(.endr;) \ 43 stringify_in_c(.ifne (.Lfound != 1);) \ 44 stringify_in_c( .error "extable_reg: bad register argument1";) \ 45 stringify_in_c(.endif;) \ 46 stringify_in_c(.set .Lfound, 0;) \ 47 stringify_in_c(.set .Lcurr, 0;) \ 48 stringify_in_c(.irp rs,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15;) \ 49 stringify_in_c( .ifc "\regaddr", "%%r\rs";) \ 50 stringify_in_c( .set .Lfound, 1;) \ 51 stringify_in_c( .set .Lregaddr, .Lcurr;) \ 52 stringify_in_c( .endif;) \ 53 stringify_in_c( .set .Lcurr, .Lcurr+1;) \ 54 stringify_in_c(.endr;) \ 55 stringify_in_c(.ifne (.Lfound != 1);) \ 56 stringify_in_c( .error "extable_reg: bad register argument2";) \ 57 stringify_in_c(.endif;) \ 58 stringify_in_c(.short .Lregerr << EX_DATA_REG_ERR_SHIFT | \ 59 .Lregaddr << EX_DATA_REG_ADDR_SHIFT | \ 60 _len << EX_DATA_LEN_SHIFT;) \ 61 stringify_in_c(.endm;) \ 62 stringify_in_c(extable_reg _regerr,_regaddr;) \ 63 stringify_in_c(.purgem extable_reg;) \ 64 stringify_in_c(.previous) 65 66 #define EX_TABLE(_fault, _target) \ 67 __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_FIXUP, __stringify(%%r0), __stringify(%%r0), 0) 68 69 #define EX_TABLE_AMODE31(_fault, _target) \ 70 __EX_TABLE(.amode31.ex_table, _fault, _target, EX_TYPE_FIXUP, __stringify(%%r0), __stringify(%%r0), 0) 71 72 #define EX_TABLE_UA_STORE(_fault, _target, _regerr) \ 73 __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_UA_STORE, _regerr, _regerr, 0) 74 75 #define EX_TABLE_UA_LOAD_MEM(_fault, _target, _regerr, _regmem, _len) \ 76 __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_UA_LOAD_MEM, _regerr, _regmem, _len) 77 78 #define EX_TABLE_UA_LOAD_REG(_fault, _target, _regerr, _regzero) \ 79 __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_UA_LOAD_REG, _regerr, _regzero, 0) 80 81 #define EX_TABLE_UA_LOAD_REGPAIR(_fault, _target, _regerr, _regzero) \ 82 __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_UA_LOAD_REGPAIR, _regerr, _regzero, 0) 83 84 #define EX_TABLE_ZEROPAD(_fault, _target, _regdata, _regaddr) \ 85 __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_ZEROPAD, _regdata, _regaddr, 0) 86 87 #endif /* __ASM_EXTABLE_H */ 88
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.