| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- 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 -N < ${{ github.action_path }}/patches/0001-libbpf-remove-feature-detection-BTF.patch
- - name: Apply resolve_btfids linker-flag fix (android12-5.10)
- shell: bash
- working-directory: ${{ github.workspace }}/kernel/common
- if: ${{ inputs.version == 'android12-5.10' }}
- run: |
- set -euo pipefail
- patch -p1 -N < ${{ github.action_path }}/patches/0002-resolve_btfids-inherit-host-linker-flags.patch
- - name: Apply xdp_buff BTF-emit fix (android12-5.10)
- shell: bash
- working-directory: ${{ github.workspace }}/kernel/common
- if: ${{ inputs.version == 'android12-5.10' }}
- run: |
- set -euo pipefail
- # bpf_types.h references struct xdp_buff via
- # BTF_ID_LIST_SINGLE(bpf_xdp_output_btf_ids) in net/core/filter.c, but
- # the oldest sublevels (5.10.43) never emit xdp_buff into vmlinux BTF,
- # so resolve_btfids aborts with "unresolved symbol xdp_buff". Force BTF
- # emission with BTF_TYPE_EMIT in net/core/xdp.c, which includes
- # <net/xdp.h> (the struct must be COMPLETE at the emit point, so it
- # cannot live in filter.c where xdp_buff is only forward-declared).
- # The patch also adds #include <linux/btf.h> so BTF_TYPE_EMIT is
- # declared in xdp.c (filter.c already pulls it in).
- # Idempotent/harmless on newer sublevels.
- patch -p1 -N < ${{ github.action_path }}/patches/0003-btf-emit-xdp-buff.patch
- - name: Apply resolve_btfids ELF_T_WORD endian fix (android12-5.10)
- shell: bash
- working-directory: ${{ github.workspace }}/kernel/common
- if: false
- run: |
- set -euo pipefail
- # Backport of upstream 61e8aeda9398 ("bpf: Fix libelf endian handling
- # in resolv_btfids"). The .BTF_ids section content defaults to
- # ELF_T_BYTE, so libelf does no per-word translation when
- # resolve_btfids patches the section back with elf_update(); without
- # ELF_T_WORD the BTF_ID entries (e.g. xdp_buff) are handled as raw
- # bytes and resolution fails with "FAILED unresolved symbol xdp_buff".
- # Sublevels >= 66 (2021-11+) already carry this fix in-tree, so only
- # patch when it is missing (sublevel-43 trees: 2021-10 and lower) to
- # stay idempotent under `set -e`.
- if ! grep -q 'd_type = ELF_T_WORD' tools/bpf/resolve_btfids/main.c; then
- patch -p1 -N < ${{ github.action_path }}/patches/0004-resolve_btfids-elf-word.patch
- else
- echo "resolve_btfids already has the ELF_T_WORD fix; skipping"
- fi
- - name: Expose host dd for hermetic BTF generation (android12-5.10)
- shell: bash
- working-directory: ${{ github.workspace }}/kernel/common
- if: ${{ inputs.version == 'android12-5.10' }}
- run: |
- set -euo pipefail
- # The hermetic toolchain PATH (build.config.common -> HERMETIC_TOOLCHAIN=1)
- # has no /usr/bin, so coreutils 'dd' is missing. gen_btf in
- # scripts/link-vmlinux.sh:253 does `printf ... | dd of=...`; without dd the
- # pipeline fails and the build aborts with "Failed to generate BTF".
- # ADDITIONAL_HOST_TOOLS is honored by build/_setup_env.sh (symlinked into
- # the hermetic host_tools dir, which IS on the PATH). Echo it into the
- # build config so both Normal and Bypass build.sh runs pick it up.
- grep -q '^ADDITIONAL_HOST_TOOLS=' build.config.gki.aarch64 || \
- echo 'ADDITIONAL_HOST_TOOLS="${ADDITIONAL_HOST_TOOLS} dd"' >> build.config.gki.aarch64
- - name: Build and use pahole >=1.26 for hermetic BTF generation (android12-5.10)
- shell: bash
- working-directory: ${{ github.workspace }}/kernel
- if: ${{ inputs.version == 'android12-5.10' }}
- run: |
- set -euo pipefail
- # android12-5.10 pins prebuilt pahole v1.19, which fails to recode the
- # DWARF types and DROPS symbols (e.g. xdp_buff) from the emitted BTF.
- # resolve_btfids then aborts with "FAILED unresolved symbol xdp_buff".
- # This is the exact failure Google/kernelci hit (see lore.kernel.org,
- # "kernelci failures due to pahole missing", Apr-Sep 2022): pahole emits
- # hundreds of MB of "namespace__recode_dwarf_types: couldn't find ..."
- # warnings and silently drops types. Even Ubuntu's apt pahole 1.25 still
- # cannot fully recode the 5.10.43 sublevel DWARF (5.10.66+ is fine).
- # Build the latest pahole from source (1.31, matching a working host)
- # and wrap the hermetic-path pahole to exec it.
- #
- # The wrapper also always injects --skip_encoding_btf_enum64 /
- # decl_tag / type_tag. Sublevels <=149 have no scripts/pahole-flags.sh
- # at all, so their link-vmlinux.sh calls pahole with no skip flags; the
- # old in-tree libbpf there only handles BTF kinds 1-15 and EINVALs on
- # enum64/decl_tag/type_tag. Newer sublevels pass --skip_encoding_btf_enum64
- # via pahole-flags.sh already; duplicate skip flags are harmless.
- sudo apt-get install -y -qq cmake gcc libdw-dev libelf-dev zlib1g-dev dwarves
- # Build pahole 1.31 from source (acmel/dwarves). Deterministic, self-hosted.
- # Release build type is required: the default Debug sets -Wall -Werror, and
- # the bundled libbpf/btf_encoder fail under newer GCC as -Werror.
- PAHOLE_SRC="$HOME/dwarves"
- rm -rf "$PAHOLE_SRC"
- git clone --depth 1 --branch v1.31 https://github.com/acmel/dwarves.git "$PAHOLE_SRC"
- mkdir -p "$PAHOLE_SRC/build"
- cd "$PAHOLE_SRC/build"
- cmake -D__LIB=lib -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release .. >/dev/null
- make -j"$(nproc)" pahole
- sudo make install pahole
- command -v pahole
- pahole --version
- HERMETIC_PAHOLE="${{ github.workspace }}/kernel/build/build-tools/path/linux-x86/pahole"
- REAL_PAHOLE="$(command -v pahole)"
- if [ -L "$HERMETIC_PAHOLE" ] || [ -f "$HERMETIC_PAHOLE" ]; then
- cat > "$HERMETIC_PAHOLE" <<EOF
- #!/bin/sh
- exec "$REAL_PAHOLE" --skip_encoding_btf_enum64 --skip_encoding_btf_decl_tag --skip_encoding_btf_type_tag "\$@"
- EOF
- chmod +x "$HERMETIC_PAHOLE"
- echo "Wrote wrapper $HERMETIC_PAHOLE -> $REAL_PAHOLE (skip enum64/decl_tag/type_tag)"
- "$HERMETIC_PAHOLE" --version
- else
- echo "WARNING: $HERMETIC_PAHOLE not found; leaving prebuilt pahole in place"
- fi
- - name: Enable BTF Config
- uses: ./.github/actions/set-kernel-config
- with:
- config_list: |
- CONFIG_DEBUG_INFO_BTF=y
|