kbuild: fix decl_tag_kfuncs gating to require pahole v1.27
Subsystems (5)
PATCH 1/1 kbuild: fix decl_tag_kfuncs gating to require pahole v1.27
decl_tag_kfuncs was implemented in pahole v1.27 (dwarves commit 72e88f29c6f7 [1]). However, ebb79e96f1ea ("kbuild: bpf: Tell pahole to DECL_TAG kfuncs") appended it to the list of --btf_features flags already gated on pahole >= 1.26, making it silently inactive on any pahole v1.26 build.
Without decl_tag_kfuncs, pahole does not emit DECL_TAG BTF entries for __bpf_kfunc-annotated functions. resolve_btfids then skips process_kfunc_with_implicit_args(), so KF_IMPLICIT_ARGS kfuncs keep their full prototype (including the implicit aux parameter) in vmlinux BTF. BPF programs loading such kfuncs as weak ksyms fail with:
libbpf: extern (func ksym) 'scx_bpf_create_dsq': func_proto [N]
incompatible with vmlinux [M]
Fix by splitting decl_tag_kfuncs into its own >= 127 line in Makefile.btf. Add a PAHOLE_HAS_DECL_TAG_KFUNCS Kconfig symbol so build rules can gate on this feature explicitly. Update Documentation/process/changes.rst to reflect the corrected minimum pahole version for KF_IMPLICIT_ARGS support.
[1] https://github.com/acmel/dwarves/commit/72e88f29c6f7e14201756e65bd66157427a61aaf
--- Documentation/process/changes.rst | 4 ++-- lib/Kconfig.debug | 10 ++++++++++ scripts/Makefile.btf | 6 +++++- 3 files changed, 17 insertions(+), 3 deletions(-)
Documentation/process/changes.rst +2 -2
@@ -38,7 +38,7 @@ bash 4.2 bash --version binutils 2.30 ld -v flex 2.5.35 flex --version bison 2.0 bison --version -pahole 1.26 pahole --version +pahole 1.27 pahole --version util-linux 2.10o mount --version kmod 13 depmod -V e2fsprogs 1.41.4 e2fsck -V
@@ -145,7 +145,7 @@ Since Linux 5.2, if CONFIG_DEBUG_INFO_BTF is selected, the build system generates BTF (BPF Type Format) from DWARF in vmlinux, a bit later from kernel modules as well. This requires pahole v1.22 or later. -Since Linux 7.0, kfuncs annotated with KF_IMPLICIT_ARGS require pahole v1.26 +Since Linux 7.0, kfuncs annotated with KF_IMPLICIT_ARGS require pahole v1.27 or later. Without it, such kfuncs will have incorrect BTF prototypes in vmlinux, causing BPF programs to fail to load with a "func_proto incompatible with vmlinux" error. Many sched_ext kfuncs are affected.
lib/Kconfig.debug +10 -0
@@ -425,6 +425,16 @@ config PAHOLE_HAS_LANG_EXCLUDE otherwise it would emit malformed kernel and module binaries when using DEBUG_INFO_BTF_MODULES. +config PAHOLE_HAS_DECL_TAG_KFUNCS + def_bool PAHOLE_VERSION >= 127 + help + Support for the decl_tag_kfuncs BTF feature, which is required for + kfuncs annotated with KF_IMPLICIT_ARGS to receive correct BTF + prototypes. Without it, such kfuncs retain their full prototype + (including the implicit aux parameter) in vmlinux BTF, causing BPF + programs to fail to load with a "func_proto incompatible" error. + Implemented in pahole v1.27 (commit 72e88f29c). + config DEBUG_INFO_BTF_MODULES bool "Generate BTF type information for kernel modules" default y
scripts/Makefile.btf +5 -1
@@ -14,7 +14,11 @@ pahole-flags-$(call test-ge, $(pahole-ver), 125) += --skip_encoding_btf_inconsis else # Switch to using --btf_features for v1.26 and later. -pahole-flags-$(call test-ge, $(pahole-ver), 126) = -j$(JOBS) --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func,decl_tag_kfuncs +pahole-flags-$(call test-ge, $(pahole-ver), 126) = -j$(JOBS) --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func + +# decl_tag_kfuncs was implemented in pahole v1.27 (commit 72e88f29c). +# It was incorrectly gated on >= 126 by ebb79e96f1ea. +pahole-flags-$(call test-ge, $(pahole-ver), 127) += --btf_features=decl_tag_kfuncs pahole-flags-$(call test-ge, $(pahole-ver), 130) += --btf_features=attributes
Signature · 1 line
2.43.0
Ihor Solodrai
reviewerQuoted 21 lines · zhidao su
decl_tag_kfuncswas implemented in pahole v1.27 (dwarves commit72e88f29c6f7[1]). However,ebb79e96f1ea("kbuild: bpf: Tell pahole toDECL_TAGkfuncs") appended it to the list of --btf_features flags already gated on pahole >= 1.26, making it silently inactive on any pahole v1.26 build.Without
decl_tag_kfuncs, pahole does not emitDECL_TAGBTF entries for __bpf_kfunc-annotated functions.resolve_btfidsthen skipsprocess_kfunc_with_implicit_args(), soKF_IMPLICIT_ARGSkfuncs keep their full prototype (including the implicit aux parameter) in vmlinux BTF. BPF programs loading such kfuncs as weak ksyms fail with:libbpf: extern (func ksym) '
scx_bpf_create_dsq':func_proto[N]
incompatible with vmlinux [M]Fix by splitting
decl_tag_kfuncsinto its own >= 127 line in Makefile.btf. Add aPAHOLE_HAS_DECL_TAG_KFUNCSKconfigsymbol so build rules can gate on this feature explicitly. UpdateDocumentation/process/changes.rstto reflect the corrected minimum pahole version forKF_IMPLICIT_ARGSsupport.
Quoted 5 lines
[1] https://github.com/acmel/dwarves/commit/72e88f29c6f7e14201756e65bd66157427a61aaf
Fixes ebb79e96f1ea ("kbuild: bpf: Tell pahole to DECL_TAG kfuncs")Reported-by Ihor Solodrai <[email protected]>
No. Please read the feedback behind this link carefully and check the patch bumping to v1.22 before submitting a new version.
Hint: you can feed it to your "AI agent" too, it should be able to figure it out.
We don't need a new kconfig flag to enforce higher minimum pahole version.
pw-bot: cr
Quoted 67 lines
Signed-off-by zhidao su <[email protected]>--- Documentation/process/changes.rst | 4 ++-- lib/Kconfig.debug | 10 ++++++++++ scripts/Makefile.btf | 6 +++++- 3 files changed, 17 insertions(+), 3 deletions(-)Documentation/process/changes.rst +2
-2@@ -38,7 +38,7 @@ bash 4.2 bash --version binutils 2.30 ld -v flex 2.5.35 flex --version bison 2.0 bison --version -pahole 1.26 pahole --version +pahole 1.27 pahole --version util-linux 2.10o mount --version kmod 13 depmod -V e2fsprogs 1.41.4 e2fsck -V@@ -145,7 +145,7 @@ Since Linux 5.2, if CONFIG_DEBUG_INFO_BTF is selected, the build system generates BTF (BPF Type Format) from DWARF in vmlinux, a bit later from kernel modules as well. This requires pahole v1.22 or later. -Since Linux 7.0, kfuncs annotated with KF_IMPLICIT_ARGS require pahole v1.26 +Since Linux 7.0, kfuncs annotated with KF_IMPLICIT_ARGS require pahole v1.27 or later. Without it, such kfuncs will have incorrect BTF prototypes in vmlinux, causing BPF programs to fail to load with a "func_proto incompatible with vmlinux" error. Many sched_ext kfuncs are affected.lib/Kconfig.debug +10
-0@@ -425,6 +425,16 @@ config PAHOLE_HAS_LANG_EXCLUDE otherwise it would emit malformed kernel and module binaries when using DEBUG_INFO_BTF_MODULES. +config PAHOLE_HAS_DECL_TAG_KFUNCS + def_bool PAHOLE_VERSION >= 127 + help + Support for the decl_tag_kfuncs BTF feature, which is required for + kfuncs annotated with KF_IMPLICIT_ARGS to receive correct BTF + prototypes. Without it, such kfuncs retain their full prototype + (including the implicit aux parameter) in vmlinux BTF, causing BPF + programs to fail to load with a "func_proto incompatible" error. + Implemented in pahole v1.27 (commit 72e88f29c). + config DEBUG_INFO_BTF_MODULES bool "Generate BTF type information for kernel modules" default yscripts/Makefile.btf +5
-1@@ -14,7 +14,11 @@ pahole-flags-$(call test-ge, $(pahole-ver), 125) += --skip_encoding_btf_inconsis else # Switch to using --btf_features for v1.26 and later. -pahole-flags-$(call test-ge, $(pahole-ver), 126) = -j$(JOBS) --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func,decl_tag_kfuncs +pahole-flags-$(call test-ge, $(pahole-ver), 126) = -j$(JOBS) --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func + +# decl_tag_kfuncs was implemented in pahole v1.27 (commit 72e88f29c). +# It was incorrectly gated on >= 126 by ebb79e96f1ea. +pahole-flags-$(call test-ge, $(pahole-ver), 127) += --btf_features=decl_tag_kfuncs pahole-flags-$(call test-ge, $(pahole-ver), 130) += --btf_features=attributes