Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions .github/scripts/kernel-release-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-only
#
# Build the Aurora kernel release artifacts from this tree.
#
# Usage: kernel-release-build.sh <objdir> <distdir> <localversion> <pkgbase>
#
# The configuration is the fleet configuration: arch/arm64/configs/aurora_defconfig
# (savedefconfig output of the fleet .config) with arch/arm64/configs/asahi.config
# merged on top, so options added to asahi.config reach the release before
# aurora_defconfig is regenerated. Requires ARCH=arm64 LLVM=1 toolchain in PATH
# (clang/lld, rustc + rust-src, bindgen, pahole).
#
# Modules are signed with the key the build generates (certs/signing_key.pem).
# The private key is deleted at the end and never packaged.

set -euo pipefail

O=$(realpath -m "$1")
D=$(realpath -m "$2")
LV=$3
PKGBASE=$4
S=$(git rev-parse --show-toplevel)
JOBS=${JOBS:-$(nproc)}

export ARCH=arm64 LLVM=1
export KBUILD_BUILD_USER=${KBUILD_BUILD_USER:-aurora} KBUILD_BUILD_HOST=${KBUILD_BUILD_HOST:-github}
export KBUILD_BUILD_TIMESTAMP=${KBUILD_BUILD_TIMESTAMP:-$(git -C "$S" log -1 --format=%cD HEAD)}

mk() { make -C "$S" O="$O" LOCALVERSION="$LV" -j"$JOBS" "$@"; }

mkdir -p "$O" "$D"
rm -f "$O/.config"

echo "::group::toolchain"
clang --version | head -1
ld.lld --version | head -1
rustc --version
bindgen --version
pahole --version
echo "::endgroup::"

echo "::group::config"
mk aurora_defconfig asahi.config
mk savedefconfig
if cmp -s "$O/defconfig" "$S/arch/arm64/configs/aurora_defconfig"; then
echo "config: identical to aurora_defconfig"
else
echo "::warning::generated config differs from aurora_defconfig (asahi.config or Kconfig changed); regenerate it with savedefconfig"
diff -u "$S/arch/arm64/configs/aurora_defconfig" "$O/defconfig" || true
fi
python3 - "$S/arch/arm64/configs/asahi.config" "$O/.config" <<'PY'
import re, sys
def load(p):
d = {}
for l in open(p):
l = l.strip()
m = re.match(r'^(CONFIG_\w+)=(.*)$', l)
if m:
d[m.group(1)] = m.group(2)
continue
m = re.match(r'^# (CONFIG_\w+) is not set$', l)
if m:
d[m.group(1)] = 'n'
return d
want, have = load(sys.argv[1]), load(sys.argv[2])
bad = [(k, v, have.get(k, 'n')) for k, v in want.items() if have.get(k, 'n') != v]
print(f"asahi.config requests {len(want)}; mismatches {len(bad)}")
for k, v, h in bad:
print(f"MISMATCH {k}: want {v} got {h}")
sys.exit(1 if bad else 0)
PY
grep -qx 'CONFIG_MODULE_SIG_KEY="certs/signing_key.pem"' "$O/.config"
echo "::endgroup::"

echo "::group::build"
mk Image.gz modules dtbs
echo "::endgroup::"

ARCH_RUNTIME=
echo "::group::pacman-pkg"
if command -v makepkg >/dev/null; then
rm -f "$O"/*.pkg.tar.*
# Debian/Ubuntu's makepkg.conf defaults to .pkg.tar.gz.
if PKGEXT=.pkg.tar.zst mk PACMAN_PKGBASE="$PKGBASE" PACMAN_EXTRAPACKAGES=headers \
MAKEPKGOPTS="--nodeps --noconfirm" pacman-pkg; then
runtimes=("$O"/"$PKGBASE"-[0-9]*.pkg.tar.zst)
headers=("$O"/"$PKGBASE"-headers-[0-9]*.pkg.tar.zst)
if [[ ${#runtimes[@]} -ne 1 || ! -f ${runtimes[0]} ||
${#headers[@]} -ne 1 || ! -f ${headers[0]} ]]; then
echo "::error::expected one Arch runtime and one headers package"; exit 1
fi
ARCH_RUNTIME=${runtimes[0]}
ARCH_HEADERS=${headers[0]}
cp "$ARCH_RUNTIME" "$ARCH_HEADERS" "$D/"
else
echo "::warning::make pacman-pkg failed; release ships without the Arch package"
fi
else
echo "::warning::makepkg not installed; skipping the Arch package"
fi
echo "::endgroup::"

KREL=$(cat "$O/include/config/kernel.release")
if [[ -n $ARCH_RUNTIME ]]; then
member="usr/lib/modules/$KREL/build"
tar --zstd -xOf "$ARCH_HEADERS" "$member/.config" > "$D/config-$KREL"
tar --zstd -xOf "$ARCH_HEADERS" "$member/System.map" > "$D/System.map-$KREL"
bash "$S/.github/scripts/kernel-release-stage-arch.sh" \
"$ARCH_RUNTIME" "$KREL" "$D/System.map-$KREL" "$D"
else
M=$O/modroot
rm -rf "$M"
mk INSTALL_MOD_PATH="$M" INSTALL_MOD_STRIP=1 modules_install
rm -f "$M/lib/modules/$KREL/build" "$M/lib/modules/$KREL/source"

TAR=(tar --sort=name --mtime="$KBUILD_BUILD_TIMESTAMP" --owner=0 --group=0 --numeric-owner)
cp "$O/arch/arm64/boot/Image.gz" "$D/Image-$KREL.gz"
cp "$O/.config" "$D/config-$KREL"
cp "$O/System.map" "$D/System.map-$KREL"
"${TAR[@]}" --zstd -C "$M" -cf "$D/modules-$KREL.tar.zst" "lib/modules/$KREL"
"${TAR[@]}" --zstd -C "$O/arch/arm64/boot/dts" -cf "$D/dtbs-$KREL.tar.zst" \
$(cd "$O/arch/arm64/boot/dts" && find . -name '*.dtb' | sort)
fi
cp "$O/certs/signing_key.x509" "$D/module-signing-cert-$KREL.der"
git -C "$S" rev-parse HEAD > "$D/source.commit"
echo "$KREL" > "$D/kernel.release"
echo "dtbs: $(cd "$O/arch/arm64/boot/dts" && find . -name '*.dtb' | wc -l)"

# The private signing key stays on the builder for this run only.
rm -f "$O/certs/signing_key.pem"
for f in "$D"/*.tar.* ; do
# List first: grep -q in a pipeline would end it early and, under
# pipefail, turn a match into a pass.
list=$(tar -tf "$f") || { echo "::error::cannot list $f"; exit 1; }
if grep -q 'signing_key\.pem$' <<<"$list"; then
echo "::error::$f contains the private signing key"
exit 1
fi
done

(cd "$D" && sha256sum $(ls | grep -v -x SHA256SUMS) > SHA256SUMS)
cat "$D/SHA256SUMS"
echo "BUILD-OK $KREL"
45 changes: 45 additions & 0 deletions .github/scripts/kernel-release-stage-arch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-only
# Stage standalone release artifacts from the Arch runtime package.

set -euo pipefail

package=$(realpath "$1")
release=$2
system_map=$(realpath "$3")
output=$(realpath "$4")
stage=$(mktemp -d "$output/.arch-runtime.XXXXXX")
trap 'rm -rf -- "$stage"' EXIT

member="usr/lib/modules/$release"
tar --no-same-owner --zstd -xf "$package" -C "$stage" "$member"
mkdir -p "$stage/lib/modules"
mv "$stage/$member" "$stage/lib/modules/"
runtime="$stage/lib/modules/$release"
mv "$runtime/dtb" "$stage/dtb"
python3 - "$runtime/vmlinuz" <<'PY' | gzip -n > "$output/Image-$release.gz"
import gzip
from pathlib import Path
import struct
import subprocess
import sys

image = Path(sys.argv[1]).read_bytes()
if image.startswith(b"\x1f\x8b"):
image = gzip.decompress(image)
elif image[:2] == b"MZ" and image[4:8] == b"zimg":
offset, length = struct.unpack_from("<II", image, 8)
if (image[24:32].rstrip(b"\0") != b"zstd"
or not (32 <= offset < len(image) and 0 < length <= len(image) - offset)):
sys.exit("Invalid ARM64 EFI zboot payload")
image = subprocess.check_output(["zstd", "-dq"], input=image[offset:offset + length])
if image[56:60] != b"ARM\x64":
sys.exit("The Arch runtime package did not contain an ARM64 Linux Image")
sys.stdout.buffer.write(image)
PY
rm -f "$runtime/vmlinuz" "$runtime/pkgbase"
depmod -b "$stage" -F "$system_map" "$release"
TAR=(tar --sort=name --mtime="$KBUILD_BUILD_TIMESTAMP" --owner=0 --group=0 --numeric-owner)
"${TAR[@]}" --zstd -C "$stage" -cf "$output/modules-$release.tar.zst" "lib/modules/$release"
"${TAR[@]}" --zstd -C "$stage/dtb" -cf "$output/dtbs-$release.tar.zst" \
$(cd "$stage/dtb" && find . -name '*.dtb' | sort)
33 changes: 33 additions & 0 deletions .github/scripts/kernel-smoke-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Modules the QEMU smoke run does not load, or that are known not to load
# under QEMU, and KUnit suites known to fail there. One per line:
# skip <module> <reason> never loaded
# fail <module> <reason> loading may fail or hang without failing the run
# warn <module> <reason> a kernel warning while loading it does not fail the run
# kunit <suite> <reason> the suite may fail without failing the run
# Names may be shell globs. Every entry needs a reason. Remove an entry once it
# passes.
skip rcutorture runs torture kthreads until unloaded
skip locktorture runs torture kthreads until unloaded
skip scftorture runs torture kthreads until unloaded
skip rcuscale runs a benchmark until unloaded
skip refscale runs a benchmark until unloaded
skip torture only a library for the torture tests above
skip test_lockup provokes soft/hard lockups on purpose
skip test_vmalloc vmalloc stress test, runs for minutes under emulation
skip speakup_* speech synthesizer drivers; the serial ones wait for a synthesizer on a serial port
fail tcrypt returns -EAGAIN by design after running its tests
fail xusbatm needs vendor/product module parameters
fail ptp_kvm needs the KVM PTP hypervisor service
fail alim7101_wdt probes for an ALi M7101 chipset (-EBUSY without it)
fail dtpm Rockchip SoC power hierarchy, refuses on other machines
fail snd-soc-uda1342 its I2C driver name "uda1342" is already taken by the media uda1342 driver
fail nhc_ghc_* 6LoWPAN GHC compression claims the NHC IDs of the plain nhc_* modules loaded before it
warn serial_ir PC serial-port IR receiver requests a fixed legacy IRQ the virt machine does not have
warn snd-mtpav PC parallel-port MIDI driver requests a fixed legacy IRQ the virt machine does not have
fail ubifs init cannot get the zstd compressor (-ENOENT) in this initramfs; not yet triaged
kunit arm-smmu-v3-kunit-test arm_smmu_v3_invs_test trips UBSAN array-index-out-of-bounds in arm-smmu-v3.c; not yet triaged
kunit amdv1_iommu_test test_map_simple secondary page-table accounting mismatch; not yet triaged
kunit amdgpu_dm_hdcp dm_test_event_cpirq_schedules_property_validate fails; not yet triaged
kunit amdgpu_dm_irq dm_test_dcn10_register_irq_handlers_one_crtc fails; not yet triaged
kunit amdgpu_dm_crtc dm_test_crtc_enable_vblank_ips_restore{,_replay} fault (unexpected DAIF); not yet triaged
kunit binder_alloc binder_alloc_exhaustive_test reports failures; not yet triaged
Loading
Loading