Skip to content

eBPF-based security platform

ci: build and run the unit tests on arm64 and riscv64

Daniel Borkmann7b82eb1c32a8
diff --git a/.github/scripts/build-debian.sh b/.github/scripts/build-debian.sh
new file mode 100755
index 00000000..67840d02
--- /dev/null
+++ b/.github/scripts/build-debian.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+#
+# .github/scripts/build-debian.sh -- build on a Debian testing container of
+# any architecture, with the distribution's compiler and libraries, which
+# are new enough to need no toolchain of their own: the binary and the
+# shirudo-build helper, then the unit tests and the linkage check. The BPF
+# objects are bytecode whatever the host, so the BTF can come from a
+# kernel of another architecture.
+#
+# .github/scripts/build-debian.sh <vmlinux-btf>
+#
+# Run as root in the checkout root, inside a throwaway container: it
+# installs packages and changes the git configuration.
+
+set -eu
+
+if [ "$#" -ne 1 ]; then
+ printf 'usage: %s <vmlinux-btf>\n' "$0" >&2
+ exit 2
+fi
+btf=$1
+
+grep -aq 'signature_size' "$btf" || {
+ echo "$btf lacks bpf_attr.signature_size; needs a signed-BPF capable bpf-next kernel" >&2
+ exit 1
+}
+
+export DEBIAN_FRONTEND=noninteractive
+apt-get update
+apt-get install -y --no-install-recommends \
+ build-essential \
+ ca-certificates \
+ clang \
+ git \
+ llvm \
+ openssl \
+ pkgconf \
+ python3 \
+ libcurl4-openssl-dev \
+ libelf-dev \
+ libluajit-5.1-dev \
+ libssl-dev \
+ libtss2-dev \
+ zlib1g-dev
+
+git config --global --add safe.directory "$PWD"
+uname -m
+cc --version | head -n 1
+
+export BPF_VMLINUX_BTF="$btf"
+make -j"$(nproc)"
+make shirudo-build
+make -C testing unit
+sh .github/scripts/check-operator-linkage.sh shirudo \
+ tools/shirudo-build/shirudo-build
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index a746585e..b97c173d 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -51,3 +51,81 @@ jobs:
make -C testing CC=clang unit
sh .github/scripts/check-operator-linkage.sh shirudo \
tools/shirudo-build/shirudo-build
+
+ btf:
+ name: bpf-next BTF
+ runs-on: ubuntu-latest
+ timeout-minutes: 30
+
+ steps:
+ # The BTF of the bpf-next kernel the other builds run on, for the
+ # builds that cannot boot it themselves.
+ - name: Copy the kernel BTF out of the LVH VM
+ uses: cilium/little-vm-helper@f86d344aca812dda5aef167867a9a0a90ca6cca5 # v0.0.31
+ with:
+ test-name: shirudo-btf
+ image: kind
+ image-version: bpf-next-20260603.072225
+ kernel-version: bpf-next-main
+ host-mount: ${{ github.workspace }}
+ images-folder-parent: ${{ github.workspace }}/../lvh
+ install-dependencies: true
+ cpu: 2
+ mem: 4G
+ cmd: |
+ grep -aq 'signature_size' /sys/kernel/btf/vmlinux || {
+ echo 'kernel BTF lacks bpf_attr.signature_size; needs a signed-BPF capable bpf-next kernel' >&2
+ exit 1
+ }
+ mkdir -p /host/build
+ cp /sys/kernel/btf/vmlinux /host/build/vmlinux.btf
+
+ - name: Upload the kernel BTF
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
+ with:
+ name: bpf-next-btf
+ path: build/vmlinux.btf
+ if-no-files-found: error
+ retention-days: 1
+
+ arch:
+ name: ${{ matrix.arch }}
+ needs: btf
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 90
+
+ # Every other job builds and tests on x86-64. arm64 builds natively on
+ # an arm64 runner; riscv64, which has none, under QEMU user emulation.
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - arch: arm64
+ runner: ubuntu-24.04-arm
+ - arch: riscv64
+ runner: ubuntu-latest
+
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+
+ - name: Download the kernel BTF
+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
+ with:
+ name: bpf-next-btf
+ path: build
+
+ - name: Set up QEMU user emulation
+ if: matrix.arch == 'riscv64'
+ uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
+ with:
+ image: tonistiigi/binfmt:qemu-v10.2.3@sha256:400a4873b838d1b89194d982c45e5fb3cda4593fbfd7e08a02e76b03b21166f0
+ platforms: riscv64
+
+ - name: Build and run the unit tests on Debian testing
+ env:
+ ARCH: ${{ matrix.arch }}
+ run: >-
+ docker run --rm --platform "linux/$ARCH"
+ -v "$PWD:/src" -w /src debian:testing
+ sh .github/scripts/build-debian.sh build/vmlinux.btf
diff --git a/Documentation/contribute/code/developer-guide.rst b/Documentation/contribute/code/developer-guide.rst
index df87d185..02c211f4 100644
--- a/Documentation/contribute/code/developer-guide.rst
+++ b/Documentation/contribute/code/developer-guide.rst
@@ -451,6 +451,13 @@ the commit at ``HEAD`` alone without them.
shirudo-build`` and ``make -C testing test-helpers``. It
refuses to start with uncommitted changes and checks out each
commit in the working tree.
+ * - ``build-debian.sh <btf>``
+ - Installs Debian testing's compiler and libraries, builds the
+ binary and the helper with the BTF given, and runs the unit tests
+ and ``check-operator-linkage.sh``. The ``Build`` workflow runs it
+ in a ``debian:testing`` container on arm64 and riscv64. It
+ installs packages as root, so run it only in a throwaway
+ container.
* - ``check-static-target.sh <binary>``
- That a target binary is a static PIE.
* - ``check-operator-linkage.sh <binary>...``
diff --git a/Documentation/contribute/testing/test-coverage.rst b/Documentation/contribute/testing/test-coverage.rst
index c36b00d1..90497cd5 100644
--- a/Documentation/contribute/testing/test-coverage.rst
+++ b/Documentation/contribute/testing/test-coverage.rst
@@ -801,9 +801,11 @@ Platforms
- Real TPMs. Every TPM test uses ``swtpm`` in the VM or the libtpms
simulator helper. ``t1008`` checks only the kernel configuration for
NitroTPM.
-- Architectures. CI runs every tier on x86-64 only. The test VM boots
- arm64 too, and ``t1007`` checks its arm64 settings without booting.
- riscv64 has no test VM.
+- Architectures. CI builds and runs the unit tests on arm64 and on
+ riscv64, under QEMU user emulation, with the BPF objects built from
+ the BTF of the x86-64 bpf-next kernel. Every other tier runs on
+ x86-64 only. The test VM boots arm64 too, and ``t1007`` checks its
+ arm64 settings without booting. riscv64 has no test VM.
- Kernels. CI boots bpf-next only. ``KERNEL=`` boots a release kernel
by hand.