eBPF-based security platform
Build, stage and BTF
- Build the test kernel by hand
- Stage a build for the VM
- vmlinux.h, BTF and vendor/libbpf
Build the test kernel by hand
testing/kernel/build-kernel.sh --config-only # patches and .config only
testing/kernel/build-kernel.sh --llvm 20 # as CI builds, host arch
testing/kernel/build-kernel.sh --llvm 20 --arch arm64
- Install what
.github/scripts/build-test-kernel.shlists, or ask the user to; never run that script on a host. The script checks for its tools and for a complete LLVM:clang,ld.lld,llvm-objcopy,llvm-ar,llvm-nmandllvm-configof one version, with its headers, whichCONFIG_BPF_FMODRET_SCANneeds. Without--llvmthe newest complete version onPATHbuilds;LLVM_CONFIGnames anotherllvm-config. - Every run applies every patch,
--config-onlyincluded. No option skips or selects one, and a patch that touches one architecture's files is applied on the others too. Only x86-64 and arm64 build. - The configuration is
allnoconfig, the common and architecture fragments,olddefconfig. Then every symbol a fragment sets is checked against the result, andCONFIG_LSM="bpf"andCONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS=ywhatever the fragments say. A symbol whose dependencies are missing ends unset and fails the check; alint:line names one the tree does not have. Each group of options carries a comment saying why the test kernel needs it. - Under
build/test-kernel/, or the directory-onames:src/, the bpf-next checkout with the patches as commits. Never edit it: every run checks out the pin there again, and an edit that does not conflict is built in silently.obj-<arch>/, the object tree with.config,merge.logand the module signing key, which stays there.kernel-<arch>.config, the verified configuration.pkgs/<arch>/<release>-<stamp>/, the packages,config-<release>,System.map-<release>,vmlinux-<release>.btf, the module signing certificate,BUILD-INFOandSHA256SUMS.kernel-ci-source.tar.zst, the patched source withtesting/kernel/.
- An arm64 build on an x86-64 host has no headers package.
Stage a build for the VM
testing/vm/kernel-artifact.sh stage build/test-kernel/pkgs/<arch>/<release>-<stamp>
stage takes the directory of one build (or a directory holding
exactly one), checks its BTF for the signed-loader ABI and every hook
bpf/*.c attaches to, and puts the image, BTF, configuration and
modules under artifacts/bpf-next-kernel-debs/. That replaces the
checkout's staged kernel, which every VM goal and every BPF build then
uses: say so first. It writes no kernel-run-id. Remove
artifacts/bpf-next-kernel-debs/ to get the pinned kernel back on the
next VM goal. A headers package is optional.
vmlinux.h, BTF and vendor/libbpf
vendor/linux/vmlinux.his generated, never committed:tools/gen-vmlinux-h/gen-vmlinux-hdumps the BTFBPF_VMLINUX_BTFnames, by defaultartifacts/bpf-next-kernel-debs/vmlinux.btfwhen a kernel is staged and/sys/kernel/btf/vmlinuxotherwise;BPF_VMLINUX_H=<file>copies a header instead.vendor/linux/.vmlinux-btf-sourcerecords the source, and a build regenerates the header when the selection or the BTF changes.make -n -f Makefile.shirudo vendor/linux/vmlinux.hshows what it would read.- A worktree has no
artifacts/; give itBPF_VMLINUX_BTF(pre-submitskill). upatches/kernel-cve/vmlinux.his a tracked header of that package; nothing regenerates it.make bpf-depsrefreshesvendor/libbpf/, libbpf and the BPF UAPI headers, notvmlinux.h. Run it only when asked. PassKERNEL_SRC=<tree at the pin>; without it the script clones bpf-next's tip, which can be ahead of the pin. It overwrites the local changesvendor/libbpf/README.mdlists: apply them again.vendor/libbpf/COMMITrecords its commit, which need not be the pin.