eBPF-based security platform
ci: run host functional tests on arm64
Andrea Lattuada313c41a05f02
diff --git a/.github/scripts/tests.sh b/.github/scripts/tests.shindex dac3828b..d1034de3 100755--- a/.github/scripts/tests.sh+++ b/.github/scripts/tests.sh@@ -9,6 +9,8 @@# unit, ci-checks, functional and end2end tests, each family of target tests# in a VM of its own, or one part of them: unit runs the unit and# ci-checks tests, functional and end2end the tier of that name.+# With VM=0, setup installs only host test dependencies using the kernel+# CI artifact's BTF, and run leaves out target VMs.## .github/scripts/tests.sh setup|run [unit|functional|end2end]#@@ -46,7 +48,7 @@ restore_workspace_ownership() {finish() {status=$?restore_workspace_ownership || status=$?- [ "$status" -eq 0 ] || diagnose+ [ "$status" -eq 0 ] || [ "${VM:-1}" = 0 ] || diagnoseexit "$status"}@@ -200,15 +202,23 @@ stage_kernel_ci_artifact() {package_dir=${image_package%/*}release=${image_package##*/linux-image-}release=${release%%_*}+ btf="$package_dir/vmlinux-$release.btf"+ [ -s "$btf" ] || {+ echo "kernel CI artifact lacks BTF for $release" >&2+ return 1+ }+ mkdir -p "$kernel" || return 1+ cp "$btf" "$kernel/vmlinux.btf" || return 1+ [ "${VM:-1}" != 0 ] || return 0+set -- "$package_dir"/linux-headers-"$release"_*_amd64.deb[ "$#" -eq 1 ] && [ -s "$1" ] || {echo "expected headers package for kernel $release in $package_dir" >&2return 1}- btf="$package_dir/vmlinux-$release.btf"config="$package_dir/config-$release"- [ -s "$btf" ] && [ -s "$config" ] || {- echo "kernel CI artifact lacks BTF or config for $release" >&2+ [ -s "$config" ] || {+ echo "kernel CI artifact lacks config for $release" >&2return 1}install_root="$PWD/build/kernel-ci-extract"@@ -238,13 +248,9 @@ build_test_kernel() {}setup() {- sudo rm -rf /opt/ghc /usr/local/lib/android /usr/share/dotnet-- # /dev/kvm belongs to root on the runner.- echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' |- sudo tee /etc/udev/rules.d/99-kvm.rules >/dev/null- sudo udevadm control --reload-rules- sudo udevadm trigger --name-match=kvm+ if [ "${VM:-1}" != 0 ]; then+ sudo rm -rf /opt/ghc /usr/local/lib/android /usr/share/dotnet+ fiif [ -n "${KERNEL_CI_ARTIFACT_DIR:-}" ]; thenstage_kernel_ci_artifact "$KERNEL_CI_ARTIFACT_DIR" || exit 1@@ -259,32 +265,43 @@ setup() {build_test_kernelfi+ set -- rpm coccinelle+ if [ "${VM:-1}" != 0 ]; then+ set -- "$@" autoconf autoconf-archive automake cloud-image-utils \+ dracut-core file isc-dhcp-client libguestfs-tools libltdl-dev \+ libtool libzstd-dev qemu-system-x86 qemu-utils swtpm \+ swtpm-tools tpm2-tools+ fimkdir -p buildsudo BPF_VMLINUX_BTF="$PWD/$kernel/vmlinux.btf" \- .github/scripts/vm-toolchain.sh \- autoconf autoconf-archive automake cloud-image-utils \- dracut-core file isc-dhcp-client libguestfs-tools libltdl-dev \- libtool libzstd-dev cryptsetup-bin e2fsprogs qemu-system-x86 qemu-utils swtpm \- swtpm-tools tpm2-tools coccinelle-- # Ubuntu's dracut 060 looks for systemd-pcrphase, which systemd 255- # calls systemd-pcrextend, and so leaves out the PCR phase- # measurement shirudo's initrd needs.- if [ ! -e /usr/lib/systemd/systemd-pcrphase ]; then- sudo ln -s systemd-pcrextend /usr/lib/systemd/systemd-pcrphase- fi+ .github/scripts/vm-toolchain.sh "$@"- # libguestfs networks the appliance through passt. Ubuntu's AppArmor- # profile for passt refuses the socket libguestfs asks for under- # XDG_RUNTIME_DIR, and without that profile Ubuntu's restriction of- # unprivileged user namespaces keeps passt from sandboxing itself.- # The runner is discarded after the job, so lift both.- apparmor=/sys/kernel/security/apparmor- if sudo grep -q '^passt ' "$apparmor/profiles" 2>/dev/null; then- printf passt | sudo tee "$apparmor/.remove" >/dev/null- fi- if [ -e /proc/sys/kernel/apparmor_restrict_unprivileged_userns ]; then- sudo sysctl -q -w kernel.apparmor_restrict_unprivileged_userns=0+ if [ "${VM:-1}" != 0 ]; then+ # /dev/kvm belongs to root on the runner.+ echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' |+ sudo tee /etc/udev/rules.d/99-kvm.rules >/dev/null+ sudo udevadm control --reload-rules+ sudo udevadm trigger --name-match=kvm++ # Ubuntu's dracut 060 looks for systemd-pcrphase, which systemd 255+ # calls systemd-pcrextend, and so leaves out the PCR phase+ # measurement shirudo's initrd needs.+ if [ ! -e /usr/lib/systemd/systemd-pcrphase ]; then+ sudo ln -s systemd-pcrextend /usr/lib/systemd/systemd-pcrphase+ fi++ # libguestfs networks the appliance through passt. Ubuntu's AppArmor+ # profile for passt refuses the socket libguestfs asks for under+ # XDG_RUNTIME_DIR, and without that profile Ubuntu's restriction of+ # unprivileged user namespaces keeps passt from sandboxing itself.+ # The runner is discarded after the job, so lift both.+ apparmor=/sys/kernel/security/apparmor+ if sudo grep -q '^passt ' "$apparmor/profiles" 2>/dev/null; then+ printf passt | sudo tee "$apparmor/.remove" >/dev/null+ fi+ if [ -e /proc/sys/kernel/apparmor_restrict_unprivileged_userns ]; then+ sudo sysctl -q -w kernel.apparmor_restrict_unprivileged_userns=0+ fifi}@@ -318,6 +335,8 @@ fi# shellcheck source=/dev/null. build/vm-toolchain.env+export BPF_VMLINUX_BTF="$PWD/$kernel/vmlinux.btf"+# A guest that boots runs the suite in minutes; one that hangs, in# emergency mode for instance, would otherwise hold the job for an hour.export TEST_VM_TIMEOUT=900@@ -334,4 +353,4 @@ sudo prlimit --pid "$$" --memlock=unlimited:unlimited# secure_path, and the OpenSSL 3.5 build needs both: for the openssl the# config probes run and for every shirudo binary the tests run here.# shellcheck disable=SC2086-sudo -E env PATH="$PATH" LD_LIBRARY_PATH="$LD_LIBRARY_PATH" make $goals+sudo -E env PATH="$PATH" LD_LIBRARY_PATH="$LD_LIBRARY_PATH" make VM="${VM:-1}" $goalsdiff --git a/.github/workflows/tests.yml b/.github/workflows/tests.ymlindex 6e79bd43..01b42745 100644--- a/.github/workflows/tests.yml+++ b/.github/workflows/tests.yml@@ -23,9 +23,21 @@ concurrency:jobs:tests:- name: CI tests- runs-on: ubuntu-latest+ name: ${{ matrix.name }}+ runs-on: ${{ matrix.runner }}timeout-minutes: 150+ strategy:+ fail-fast: false+ matrix:+ include:+ - name: CI tests+ runner: ubuntu-latest+ vm: '1'+ - name: CI host tests (arm64)+ runner: ubuntu-24.04-arm+ vm: '0'+ env:+ VM: ${{ matrix.vm }}steps:- name: Check out repository@@ -58,6 +70,7 @@ jobs:path: build/kernel-ci-artifact- name: Restore the static target dependencies+ if: matrix.vm == '1'id: target-depsuses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0with:@@ -72,13 +85,14 @@ jobs:key: host-openssl-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.github/scripts/vm-toolchain.sh') }}- name: Restore the VM images+ if: matrix.vm == '1'id: imagesuses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0with:path: build/test-vm/cachekey: test-vm-images-${{ hashFiles('testing/vm/runtime-packages', 'testing/vm/prepare-runtime.sh', 'testing/vm/build-bundle.sh', 'testing/vm/arch.sh') }}- - name: Prepare the runner as the VM host+ - name: Prepare the test environmentid: setupenv:KERNEL_CI_ARTIFACT_DIR: ${{ format('{0}/build/kernel-ci-artifact', github.workspace) }}@@ -115,7 +129,7 @@ jobs:- name: Run end-to-end testsid: end2end- if: ${{ !cancelled() && steps.setup.outcome == 'success' }}+ if: ${{ !cancelled() && steps.setup.outcome == 'success' && matrix.vm == '1' }}run: .github/scripts/tests.sh run end2end- name: Upload end-to-end guest logs@@ -131,7 +145,7 @@ jobs:# Save each expensive build once it is complete, even when a later# step fails, so the next run does not rebuild it.- name: Save the static target dependencies- if: always() && steps.target-deps.outputs.cache-hit != 'true' && hashFiles('build/target-deps/lib/libcrypto.a') != '' && hashFiles('build/target-deps/curl/lib/libcurl.a') != ''+ if: always() && matrix.vm == '1' && steps.target-deps.outputs.cache-hit != 'true' && hashFiles('build/target-deps/lib/libcrypto.a') != '' && hashFiles('build/target-deps/curl/lib/libcurl.a') != ''uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0with:path: build/target-deps@@ -148,7 +162,7 @@ jobs:# minutes, too short for an image; the key file beside one is# written once the image is complete.- name: Save the VM images- if: always() && steps.images.outputs.cache-hit != 'true' && hashFiles('build/test-vm/cache/runtime/.*.key') != ''+ if: always() && matrix.vm == '1' && steps.images.outputs.cache-hit != 'true' && hashFiles('build/test-vm/cache/runtime/.*.key') != ''uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0with:path: build/test-vm/cachediff --git a/Documentation/contribute/code/developer-guide.rst b/Documentation/contribute/code/developer-guide.rstindex 061af800..c3809107 100644--- a/Documentation/contribute/code/developer-guide.rst+++ b/Documentation/contribute/code/developer-guide.rst@@ -485,6 +485,9 @@ the commit at ``HEAD`` alone without them.one part of it: ``unit`` runs the unit and ``ci-checks`` tests,``functional`` and ``end2end`` the tier of that name. The ``CIsuite`` workflow runs the three parts as checks of their own.+ With ``VM=0``, setup uses the kernel CI artifact's BTF and installs+ only host test dependencies. The arm64 job uses this to run unit,+ ``ci-checks`` and host functional tests without target VMs.Meant for CI runners, which are discarded afterwards.``check-style.sh`` fetches the kernel's ``checkpatch.pl`` at a pinneddiff --git a/Documentation/contribute/testing/test-coverage.rst b/Documentation/contribute/testing/test-coverage.rstindex 6c942f1c..db88cf3b 100644--- a/Documentation/contribute/testing/test-coverage.rst+++ b/Documentation/contribute/testing/test-coverage.rst@@ -872,9 +872,11 @@ PlatformsNitroTPM.- Architectures. CI builds and runs the unit tests on arm64 and onriscv64, 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.+ the BTF of the x86-64 bpf-next kernel. The CI suite also runs unit,+ ``ci-checks`` and host functional tests on arm64 with ``VM=0``.+ Target VM tests, end-to-end tests and fuzzing run 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 kernelby hand.