1 /* SPDX-License-Identifier: GPL-2.0 */
3 * code tagging framework
5 #ifndef _LINUX_CODETAG_H
6 #define _LINUX_CODETAG_H
8 #include <linux/types.h>
10 struct codetag_iterator;
12 struct codetag_module;
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
22 unsigned int flags; /* used in later patches */
33 struct codetag_type_desc {
36 void (*module_load)(struct codetag_type *cttype,
37 struct codetag_module *cmod);
38 bool (*module_unload)(struct codetag_type *cttype,
39 struct codetag_module *cmod);
42 struct codetag_iterator {
43 struct codetag_type *cttype;
44 struct codetag_module *cmod;
50 #define CT_MODULE_NAME KBUILD_MODNAME
52 #define CT_MODULE_NAME NULL
55 #define CODE_TAG_INIT { \
56 .modname = CT_MODULE_NAME, \
57 .function = __func__, \
58 .filename = __FILE__, \
63 void codetag_lock_module_list(struct codetag_type *cttype, bool lock);
64 bool codetag_trylock_module_list(struct codetag_type *cttype);
65 struct codetag_iterator codetag_get_ct_iter(struct codetag_type *cttype);
66 struct codetag *codetag_next_ct(struct codetag_iterator *iter);
68 void codetag_to_text(struct seq_buf *out, struct codetag *ct);
71 codetag_register_type(const struct codetag_type_desc *desc);
73 #if defined(CONFIG_CODE_TAGGING) && defined(CONFIG_MODULES)
74 void codetag_load_module(struct module *mod);
75 bool codetag_unload_module(struct module *mod);
77 static inline void codetag_load_module(struct module *mod) {}
78 static inline bool codetag_unload_module(struct module *mod) { return true; }
81 #endif /* _LINUX_CODETAG_H */