0001
0002
0003 #ifndef _LINUX_BTF_IDS_H
0004 #define _LINUX_BTF_IDS_H
0005
0006 struct btf_id_set {
0007 u32 cnt;
0008 u32 ids[];
0009 };
0010
0011 struct btf_id_set8 {
0012 u32 cnt;
0013 u32 flags;
0014 struct {
0015 u32 id;
0016 u32 flags;
0017 } pairs[];
0018 };
0019
0020 #ifdef CONFIG_DEBUG_INFO_BTF
0021
0022 #include <linux/compiler.h> /* for __PASTE */
0023 #include <linux/compiler_attributes.h> /* for __maybe_unused */
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 #define BTF_IDS_SECTION ".BTF_ids"
0036
0037 #define ____BTF_ID(symbol, word) \
0038 asm( \
0039 ".pushsection " BTF_IDS_SECTION ",\"a\"; \n" \
0040 ".local " #symbol " ; \n" \
0041 ".type " #symbol ", STT_OBJECT; \n" \
0042 ".size " #symbol ", 4; \n" \
0043 #symbol ": \n" \
0044 ".zero 4 \n" \
0045 word \
0046 ".popsection; \n");
0047
0048 #define __BTF_ID(symbol, word) \
0049 ____BTF_ID(symbol, word)
0050
0051 #define __ID(prefix) \
0052 __PASTE(prefix, __COUNTER__)
0053
0054
0055
0056
0057
0058 #define BTF_ID(prefix, name) \
0059 __BTF_ID(__ID(__BTF_ID__##prefix##__##name##__), "")
0060
0061 #define ____BTF_ID_FLAGS(prefix, name, flags) \
0062 __BTF_ID(__ID(__BTF_ID__##prefix##__##name##__), ".long " #flags "\n")
0063 #define __BTF_ID_FLAGS(prefix, name, flags, ...) \
0064 ____BTF_ID_FLAGS(prefix, name, flags)
0065 #define BTF_ID_FLAGS(prefix, name, ...) \
0066 __BTF_ID_FLAGS(prefix, name, ##__VA_ARGS__, 0)
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083 #define __BTF_ID_LIST(name, scope) \
0084 asm( \
0085 ".pushsection " BTF_IDS_SECTION ",\"a\"; \n" \
0086 "." #scope " " #name "; \n" \
0087 #name ":; \n" \
0088 ".popsection; \n");
0089
0090 #define BTF_ID_LIST(name) \
0091 __BTF_ID_LIST(name, local) \
0092 extern u32 name[];
0093
0094 #define BTF_ID_LIST_GLOBAL(name, n) \
0095 __BTF_ID_LIST(name, globl)
0096
0097
0098
0099
0100 #define BTF_ID_LIST_SINGLE(name, prefix, typename) \
0101 BTF_ID_LIST(name) \
0102 BTF_ID(prefix, typename)
0103 #define BTF_ID_LIST_GLOBAL_SINGLE(name, prefix, typename) \
0104 BTF_ID_LIST_GLOBAL(name, 1) \
0105 BTF_ID(prefix, typename)
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118 #define BTF_ID_UNUSED \
0119 asm( \
0120 ".pushsection " BTF_IDS_SECTION ",\"a\"; \n" \
0121 ".zero 4 \n" \
0122 ".popsection; \n");
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142 #define __BTF_SET_START(name, scope) \
0143 asm( \
0144 ".pushsection " BTF_IDS_SECTION ",\"a\"; \n" \
0145 "." #scope " __BTF_ID__set__" #name "; \n" \
0146 "__BTF_ID__set__" #name ":; \n" \
0147 ".zero 4 \n" \
0148 ".popsection; \n");
0149
0150 #define BTF_SET_START(name) \
0151 __BTF_ID_LIST(name, local) \
0152 __BTF_SET_START(name, local)
0153
0154 #define BTF_SET_START_GLOBAL(name) \
0155 __BTF_ID_LIST(name, globl) \
0156 __BTF_SET_START(name, globl)
0157
0158 #define BTF_SET_END(name) \
0159 asm( \
0160 ".pushsection " BTF_IDS_SECTION ",\"a\"; \n" \
0161 ".size __BTF_ID__set__" #name ", .-" #name " \n" \
0162 ".popsection; \n"); \
0163 extern struct btf_id_set name;
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186 #define __BTF_SET8_START(name, scope) \
0187 asm( \
0188 ".pushsection " BTF_IDS_SECTION ",\"a\"; \n" \
0189 "." #scope " __BTF_ID__set8__" #name "; \n" \
0190 "__BTF_ID__set8__" #name ":; \n" \
0191 ".zero 8 \n" \
0192 ".popsection; \n");
0193
0194 #define BTF_SET8_START(name) \
0195 __BTF_ID_LIST(name, local) \
0196 __BTF_SET8_START(name, local)
0197
0198 #define BTF_SET8_END(name) \
0199 asm( \
0200 ".pushsection " BTF_IDS_SECTION ",\"a\"; \n" \
0201 ".size __BTF_ID__set8__" #name ", .-" #name " \n" \
0202 ".popsection; \n"); \
0203 extern struct btf_id_set8 name;
0204
0205 #else
0206
0207 #define BTF_ID_LIST(name) static u32 __maybe_unused name[5];
0208 #define BTF_ID(prefix, name)
0209 #define BTF_ID_FLAGS(prefix, name, ...)
0210 #define BTF_ID_UNUSED
0211 #define BTF_ID_LIST_GLOBAL(name, n) u32 __maybe_unused name[n];
0212 #define BTF_ID_LIST_SINGLE(name, prefix, typename) static u32 __maybe_unused name[1];
0213 #define BTF_ID_LIST_GLOBAL_SINGLE(name, prefix, typename) u32 __maybe_unused name[1];
0214 #define BTF_SET_START(name) static struct btf_id_set __maybe_unused name = { 0 };
0215 #define BTF_SET_START_GLOBAL(name) static struct btf_id_set __maybe_unused name = { 0 };
0216 #define BTF_SET_END(name)
0217 #define BTF_SET8_START(name) static struct btf_id_set8 __maybe_unused name = { 0 };
0218 #define BTF_SET8_END(name)
0219
0220 #endif
0221
0222 #ifdef CONFIG_NET
0223
0224
0225
0226
0227 #define BTF_SOCK_TYPE_xxx \
0228 BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET, inet_sock) \
0229 BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET_CONN, inet_connection_sock) \
0230 BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET_REQ, inet_request_sock) \
0231 BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET_TW, inet_timewait_sock) \
0232 BTF_SOCK_TYPE(BTF_SOCK_TYPE_REQ, request_sock) \
0233 BTF_SOCK_TYPE(BTF_SOCK_TYPE_SOCK, sock) \
0234 BTF_SOCK_TYPE(BTF_SOCK_TYPE_SOCK_COMMON, sock_common) \
0235 BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP, tcp_sock) \
0236 BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP_REQ, tcp_request_sock) \
0237 BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP_TW, tcp_timewait_sock) \
0238 BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP6, tcp6_sock) \
0239 BTF_SOCK_TYPE(BTF_SOCK_TYPE_UDP, udp_sock) \
0240 BTF_SOCK_TYPE(BTF_SOCK_TYPE_UDP6, udp6_sock) \
0241 BTF_SOCK_TYPE(BTF_SOCK_TYPE_UNIX, unix_sock) \
0242 BTF_SOCK_TYPE(BTF_SOCK_TYPE_MPTCP, mptcp_sock) \
0243 BTF_SOCK_TYPE(BTF_SOCK_TYPE_SOCKET, socket)
0244
0245 enum {
0246 #define BTF_SOCK_TYPE(name, str) name,
0247 BTF_SOCK_TYPE_xxx
0248 #undef BTF_SOCK_TYPE
0249 MAX_BTF_SOCK_TYPE,
0250 };
0251
0252 extern u32 btf_sock_ids[];
0253 #endif
0254
0255 #define BTF_TRACING_TYPE_xxx \
0256 BTF_TRACING_TYPE(BTF_TRACING_TYPE_TASK, task_struct) \
0257 BTF_TRACING_TYPE(BTF_TRACING_TYPE_FILE, file) \
0258 BTF_TRACING_TYPE(BTF_TRACING_TYPE_VMA, vm_area_struct)
0259
0260 enum {
0261 #define BTF_TRACING_TYPE(name, type) name,
0262 BTF_TRACING_TYPE_xxx
0263 #undef BTF_TRACING_TYPE
0264 MAX_BTF_TRACING_TYPE,
0265 };
0266
0267 extern u32 btf_tracing_ids[];
0268
0269 #endif