Browse Source

btf: add btf action with libbpf feature-detect fix for android12-5.10

TheWildJames 1 month ago
parent
commit
a3dd4bb9fd

+ 29 - 0
.github/actions/btf/action.yml

@@ -0,0 +1,29 @@
+name: 'Enable BTF'
+description: 'Enable CONFIG_DEBUG_INFO_BTF and apply libbpf feature-detection fix for android12-5.10'
+inputs:
+  version:
+    description: 'Kernel config version (e.g., android12-5.10)'
+    required: true
+  kernel_version:
+    description: 'Kernel version (e.g., 5.10)'
+    required: true
+  sublevel:
+    description: 'Kernel sublevel'
+    required: true
+
+runs:
+  using: 'composite'
+  steps:
+    - name: Apply libbpf feature-detection fix (android12-5.10)
+      shell: bash
+      working-directory: ${{ github.workspace }}/kernel/common
+      if: ${{ inputs.version == 'android12-5.10' }}
+      run: |
+        set -euo pipefail
+        patch -p1 < ${{ github.action_path }}/patches/0001-libbpf-remove-feature-detection-BTF.patch
+
+    - name: Enable BTF Config
+      uses: ./.github/actions/set-kernel-config
+      with:
+        config_list: |
+          CONFIG_DEBUG_INFO_BTF=y

+ 86 - 0
.github/actions/btf/patches/0001-libbpf-remove-feature-detection-BTF.patch

@@ -0,0 +1,86 @@
+--- a/tools/lib/bpf/Makefile
++++ b/tools/lib/bpf/Makefile
+@@ -59,28 +59,7 @@
+   VERBOSE = 0
+ endif
+ 
+-FEATURE_USER = .libbpf
+-FEATURE_TESTS = libelf zlib bpf
+-FEATURE_DISPLAY = libelf zlib bpf
+-
+ INCLUDES = -I. -I$(srctree)/tools/include -I$(srctree)/tools/include/uapi
+-FEATURE_CHECK_CFLAGS-bpf = $(INCLUDES)
+-
+-check_feat := 1
+-NON_CHECK_FEAT_TARGETS := clean TAGS tags cscope help
+-ifdef MAKECMDGOALS
+-ifeq ($(filter-out $(NON_CHECK_FEAT_TARGETS),$(MAKECMDGOALS)),)
+-  check_feat := 0
+-endif
+-endif
+-
+-ifeq ($(check_feat),1)
+-ifeq ($(FEATURES_DUMP),)
+-include $(srctree)/tools/build/Makefile.feature
+-else
+-include $(FEATURES_DUMP)
+-endif
+-endif
+ 
+ export prefix libdir src obj
+ 
+@@ -157,7 +136,7 @@
+ 
+ all_cmd: $(CMD_TARGETS) check
+ 
+-$(BPF_IN_SHARED): force elfdep zdep bpfdep $(BPF_HELPER_DEFS)
++$(BPF_IN_SHARED): force $(BPF_HELPER_DEFS)
+ 	@(test -f ../../include/uapi/linux/bpf.h -a -f ../../../include/uapi/linux/bpf.h && ( \
+ 	(diff -B ../../include/uapi/linux/bpf.h ../../../include/uapi/linux/bpf.h >/dev/null) || \
+ 	echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/bpf.h' differs from latest version at 'include/uapi/linux/bpf.h'" >&2 )) || true
+@@ -175,7 +154,7 @@
+ 	echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/if_xdp.h' differs from latest version at 'include/uapi/linux/if_xdp.h'" >&2 )) || true
+ 	$(Q)$(MAKE) $(build)=libbpf OUTPUT=$(SHARED_OBJDIR) CFLAGS="$(CFLAGS) $(SHLIB_FLAGS)"
+ 
+-$(BPF_IN_STATIC): force elfdep zdep bpfdep $(BPF_HELPER_DEFS)
++$(BPF_IN_STATIC): force $(BPF_HELPER_DEFS)
+ 	$(Q)$(MAKE) $(build)=libbpf OUTPUT=$(STATIC_OBJDIR)
+ 
+ $(BPF_HELPER_DEFS): $(srctree)/tools/include/uapi/linux/bpf.h
+@@ -264,34 +243,16 @@
+ 
+ install: install_lib install_pkgconfig install_headers
+ 
+-### Cleaning rules
+-
+-config-clean:
+-	$(call QUIET_CLEAN, feature-detect)
+-	$(Q)$(MAKE) -C $(srctree)/tools/build/feature/ clean >/dev/null
+-
+-clean: config-clean
++clean:
+ 	$(call QUIET_CLEAN, libbpf) $(RM) -rf $(CMD_TARGETS)		     \
+ 		*~ .*.d .*.cmd LIBBPF-CFLAGS $(BPF_HELPER_DEFS)		     \
+ 		$(SHARED_OBJDIR) $(STATIC_OBJDIR)			     \
+ 		$(addprefix $(OUTPUT),					     \
+ 			    *.o *.a *.so *.so.$(LIBBPF_MAJOR_VERSION) *.pc)
+-	$(call QUIET_CLEAN, core-gen) $(RM) $(OUTPUT)FEATURE-DUMP.libbpf
+-
+-
+ 
+-PHONY += force elfdep zdep bpfdep cscope tags
++PHONY += force cscope tags
+ force:
+ 
+-elfdep:
+-	@if [ "$(feature-libelf)" != "1" ]; then echo "No libelf found"; exit 1 ; fi
+-
+-zdep:
+-	@if [ "$(feature-zlib)" != "1" ]; then echo "No zlib found"; exit 1 ; fi
+-
+-bpfdep:
+-	@if [ "$(feature-bpf)" != "1" ]; then echo "BPF API too old"; exit 1 ; fi
+-
+ cscope:
+ 	ls *.c *.h > cscope.files
+ 	cscope -b -q -I $(srctree)/include -f cscope.out

+ 4 - 3
.github/workflows/build.yml

@@ -202,10 +202,11 @@ jobs:
       uses: ./.github/actions/misc
 
     - name: Enable BTF
-      uses: ./.github/actions/set-kernel-config
+      uses: ./.github/actions/btf
       with:
-        config_list: |
-          CONFIG_DEBUG_INFO_BTF=y
+        version: ${{ inputs.version }}
+        kernel_version: ${{ inputs.kernel_version }}
+        sublevel: ${{ steps.extract.outputs.sublevel }}
 
     - name: Apply Device-Specific Patches
       uses: ./.github/actions/apply-device-patches