1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * code tagging framework 4 */ 5 #ifndef _LINUX_CODETAG_H 6 #define _LINUX_CODETAG_H 7 8 #include <linux/types.h> 9 10 struct codetag_iterator; 11 struct codetag_type; 12 struct codetag_module; 13 struct seq_buf; 14 struct module; 15 16 /* 17 * An instance of this structure is created in a special ELF section at every 18 * code location being tagged. At runtime, the special section is treated as 19 * an array of these. 20 */ 21 struct codetag { 22 unsigned int flags; /* used in later patches */ 23 unsigned int lineno; 24 const char *modname; 25 const char *function; 26 const char *filename; 27 } __aligned(8); 28 29 union codetag_ref { 30 struct codetag *ct; 31 }; 32 33 struct codetag_type_desc { 34 const char *section; 35 size_t tag_size; 36 }; 37 38 struct codetag_iterator { 39 struct codetag_type *cttype; 40 struct codetag_module *cmod; 41 unsigned long mod_id; 42 struct codetag *ct; 43 }; 44 45 #ifdef MODULE 46 #define CT_MODULE_NAME KBUILD_MODNAME 47 #else 48 #define CT_MODULE_NAME NULL 49 #endif 50 51 #define CODE_TAG_INIT { \ 52 .modname = CT_MODULE_NAME, \ 53 .function = __func__, \ 54 .filename = __FILE__, \ 55 .lineno = __LINE__, \ 56 .flags = 0, \ 57 } 58 59 void codetag_lock_module_list(struct codetag_type *cttype, bool lock); 60 struct codetag_iterator codetag_get_ct_iter(struct codetag_type *cttype); 61 struct codetag *codetag_next_ct(struct codetag_iterator *iter); 62 63 void codetag_to_text(struct seq_buf *out, struct codetag *ct); 64 65 struct codetag_type * 66 codetag_register_type(const struct codetag_type_desc *desc); 67 68 #endif /* _LINUX_CODETAG_H */ 69