]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
bpf: btf: Support flags for BTF_SET8 sets
authorDaniel Xu <dxu@dxuuu.xyz>
Mon, 29 Jan 2024 01:24:06 +0000 (18:24 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 31 Jan 2024 20:05:24 +0000 (12:05 -0800)
This commit adds support for flags on BTF_SET8s. struct btf_id_set8
already supported 32 bits worth of flags, but was only used for
alignment purposes before.

We now use these bits to encode flags. The first use case is tagging
kfunc sets with a flag so that pahole can recognize which
BTF_ID_FLAGS(func, ..) are actual kfuncs.

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
Link: https://lore.kernel.org/r/7bb152ec76d6c2c930daec88e995bf18484a5ebb.1706491398.git.dxu@dxuuu.xyz
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/linux/btf_ids.h

index a9cb10b0e2e9bf45c33f4ad39e7a95d8d9b6b1b5..dca09b7f21dc28aada3841dcf4711b77591cf3c2 100644 (file)
@@ -21,6 +21,7 @@ struct btf_id_set8 {
 
 #include <linux/compiler.h> /* for __PASTE */
 #include <linux/compiler_attributes.h> /* for __maybe_unused */
+#include <linux/stringify.h>
 
 /*
  * Following macros help to define lists of BTF IDs placed
@@ -183,17 +184,18 @@ extern struct btf_id_set name;
  * .word (1 << 3) | (1 << 1) | (1 << 2)
  *
  */
-#define __BTF_SET8_START(name, scope)                  \
+#define __BTF_SET8_START(name, scope, flags)           \
+__BTF_ID_LIST(name, local)                             \
 asm(                                                   \
 ".pushsection " BTF_IDS_SECTION ",\"a\";       \n"     \
 "." #scope " __BTF_ID__set8__" #name ";        \n"     \
 "__BTF_ID__set8__" #name ":;                   \n"     \
-".zero 8                                       \n"     \
+".zero 4                                       \n"     \
+".long " __stringify(flags)                   "\n"     \
 ".popsection;                                  \n");
 
 #define BTF_SET8_START(name)                           \
-__BTF_ID_LIST(name, local)                             \
-__BTF_SET8_START(name, local)
+__BTF_SET8_START(name, local, 0)
 
 #define BTF_SET8_END(name)                             \
 asm(                                                   \