From e7daf694732bf91042481030c7447c74be4b4d64 Mon Sep 17 00:00:00 2001 From: Alyx-ML <256263590+Alyx-ML@users.noreply.github.com> Date: Sun, 22 Nov 2026 01:10:52 +0000 Subject: [PATCH] ci: build the Apple drivers and run their KUnit suites CI compiled only apple-sep.o and the DWC3 object. It ran only sep.kunitconfig and mt7932.kunitconfig. Most Apple drivers and their kunitconfig files had no CI at all. A change that broke them was only found on hardware. The new workflow has two jobs: - apple-build: arm64 defconfig plus asahi.config with LLVM=1 and Rust 1.96.0 (the host-tests pin), with the tree's own bindgen. It checks that every Apple driver is still in .config, so a driver that drops out cannot pass by building nothing. Then it compiles the Apple driver directories and the core files the user4k and KSM work touches. - kunit: one arm64 QEMU run per suite (ANE boot and PM; DCP fabric and topology; asahi; spi-hid; AVD; AVE; ISP; JPEG; ProRes; scaler; macsmc; CLPC; trusted keys). fail-fast is off. Suites that already have their own workflow are not repeated: sep, mt7932, the Apple display suite (apple-drm-kunit.yml) and pmgr-pwrstate. Two kunitconfigs are left out because another one runs the same suites: ane transport.kunitconfig (boot.kunitconfig also sets UBSAN_SHIFT, and KASAN_INLINE is the default) and avd-pm.kunitconfig (PM_SLEEP is on by default on arm64). push on integration/aurora uses the same paths filter as pull_request, as dt-checks.yml does, so an unrelated merge does not start the jobs. Two suites had no kunitconfig, so add them: - drivers/mfd/macsmc.kunitconfig runs the macsmc MFD and macsmc-power KUnit tests. - security/keys/trusted-keys/tests/.kunitconfig runs trusted_source, the tests for trust sources registered at runtime. PR #2697 adds the AVE host harnesses to host-tests. This does not overlap with it. Verified: the YAML parses, every matrix kunitconfig exists in this tree, and the push and pull_request paths lists are the same. Signed-off-by: Alyx-ML <256263590+Alyx-ML@users.noreply.github.com> --- .github/workflows/apple-build-kunit.yml | 189 ++++++++++++++++++ drivers/mfd/macsmc.kunitconfig | 11 + security/keys/trusted-keys/tests/.kunitconfig | 4 + 3 files changed, 204 insertions(+) create mode 100644 .github/workflows/apple-build-kunit.yml create mode 100644 drivers/mfd/macsmc.kunitconfig create mode 100644 security/keys/trusted-keys/tests/.kunitconfig diff --git a/.github/workflows/apple-build-kunit.yml b/.github/workflows/apple-build-kunit.yml new file mode 100644 index 0000000000000..431cc715d8dda --- /dev/null +++ b/.github/workflows/apple-build-kunit.yml @@ -0,0 +1,189 @@ +name: Apple build and KUnit + +# Compiles every Apple driver directory with the configuration a Mac runs +# (arm64 defconfig plus asahi.config, LLVM=1 and Rust), and runs each Apple +# KUnit suite on arm64 QEMU. The suites use synthetic devices and stubbed +# firmware, so no Apple hardware is needed. Suites that have their own +# workflow are not repeated here: sep.kunitconfig (sep-source.yml), +# mt7932.kunitconfig (mt7932-kunit.yml), display.kunitconfig +# (apple-drm-kunit.yml) and .kunitconfig.pmgr-pwrstate +# (pmgr-pwrstate-kunit.yml). + +on: + pull_request: + branches: [integration/aurora, aurora-wip] + paths: + - 'arch/arm64/configs/**' + - 'drivers/accel/ane/**' + - 'drivers/gpu/drm/apple/**' + - 'drivers/gpu/drm/asahi/**' + - 'drivers/hid/spi-hid/**' + - 'drivers/iommu/**' + - 'drivers/media/platform/apple/**' + - 'drivers/mfd/**' + - 'drivers/nvme/host/**' + - 'drivers/pci/controller/**' + - 'drivers/power/**' + - 'drivers/soc/apple/**' + - 'drivers/thunderbolt/**' + - 'fs/splice.c' + - 'include/**' + - 'kernel/sys.c' + - 'mm/**' + - 'rust/**' + - 'security/keys/**' + - 'tools/testing/selftests/drivers/ane/**' + - '**/Kconfig*' + - '**/Makefile' + - '.github/workflows/apple-build-kunit.yml' + # Same paths as pull_request, so an unrelated merge does not start the jobs. + push: + branches: [integration/aurora] + paths: + - 'arch/arm64/configs/**' + - 'drivers/accel/ane/**' + - 'drivers/gpu/drm/apple/**' + - 'drivers/gpu/drm/asahi/**' + - 'drivers/hid/spi-hid/**' + - 'drivers/iommu/**' + - 'drivers/media/platform/apple/**' + - 'drivers/mfd/**' + - 'drivers/nvme/host/**' + - 'drivers/pci/controller/**' + - 'drivers/power/**' + - 'drivers/soc/apple/**' + - 'drivers/thunderbolt/**' + - 'fs/splice.c' + - 'include/**' + - 'kernel/sys.c' + - 'mm/**' + - 'rust/**' + - 'security/keys/**' + - 'tools/testing/selftests/drivers/ane/**' + - '**/Kconfig*' + - '**/Makefile' + - '.github/workflows/apple-build-kunit.yml' + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: apple-build-kunit-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + RUST_VERSION: '1.96.0' + LIBCLANG_PATH: /usr/lib/llvm-18/lib + +jobs: + apple-build: + runs-on: ubuntu-24.04 + timeout-minutes: 120 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + - name: Install kernel build dependencies + run: | + # Avoid the hosted runner's Azure mirror after repeated DNS failures. + # Keep signed Ubuntu archive/security suites and fail on update errors. + if [ -f /etc/apt/apt-mirrors.txt ]; then + printf '%s\n' 'https://archive.ubuntu.com/ubuntu/' 'https://security.ubuntu.com/ubuntu/' | \ + sudo tee /etc/apt/apt-mirrors.txt >/dev/null + fi + sudo apt-get update -o APT::Update::Error-Mode=any + sudo apt-get install -y clang lld llvm libclang-dev libelf-dev libssl-dev \ + flex bison bc pkg-config make perl + rustup toolchain install "$RUST_VERSION" --profile minimal --component rust-src --no-self-update + echo "RUSTUP_TOOLCHAIN=$RUST_VERSION" >> "$GITHUB_ENV" + - name: Prepare the layout-corrected bindgen + run: python3 tools/aurora-bindgen/build.py + - name: Configure as a Mac runs it + run: | + make LLVM=1 ARCH=arm64 rustavailable + make LLVM=1 ARCH=arm64 defconfig + scripts/kconfig/merge_config.sh -m .config arch/arm64/configs/asahi.config + make LLVM=1 ARCH=arm64 olddefconfig + # A driver that drops out of the configuration would build nothing and pass. + for opt in RUST=y DRM_ASAHI=m DRM_APPLE=m DRM_ACCEL_ANE=m VIDEO_APPLE_AVD=m \ + NVME_APPLE=m APPLE_DART=y PCIE_APPLE=y USB4=m USB4_APPLE_SOC=m \ + SPI_HID_APPLE_OF=m MFD_MACSMC=y MACSMC_POWER=m POWER_RESET_MACSMC=m \ + APPLE_SEP=m KSM=y MM_SUBPAGE=y; do + grep -qx "CONFIG_$opt" .config || { echo "::error::CONFIG_$opt is not set"; exit 1; } + done + - name: Compile the Apple drivers + run: | + make -j"$(nproc)" LLVM=1 ARCH=arm64 modules_prepare + make -j"$(nproc)" LLVM=1 ARCH=arm64 \ + drivers/accel/ane/ \ + drivers/gpu/drm/apple/ \ + drivers/gpu/drm/asahi/ \ + drivers/hid/spi-hid/ \ + drivers/iommu/ \ + drivers/media/platform/apple/ \ + drivers/mfd/ \ + drivers/nvme/host/ \ + drivers/pci/controller/ \ + drivers/power/ \ + drivers/soc/apple/ \ + drivers/thunderbolt/ \ + fs/splice.o kernel/sys.o mm/ksm.o mm/madvise.o mm/vma_exec.o + + kunit: + name: KUnit ${{ matrix.suite }} + runs-on: ubuntu-24.04 + timeout-minutes: 60 + strategy: + fail-fast: false + max-parallel: 4 + matrix: + include: + # boot.kunitconfig runs the same ANE suites as transport.kunitconfig. + # It also sets UBSAN_SHIFT, and KASAN_INLINE is the default, so it + # covers both. + - { suite: ane-boot, kunitconfig: drivers/accel/ane/boot.kunitconfig } + - { suite: ane-pm, kunitconfig: tools/testing/selftests/drivers/ane/pm.kunitconfig } + - { suite: dcp-fabric, kunitconfig: drivers/gpu/drm/apple/tests/.kunitconfig } + - { suite: dcp-topology, kunitconfig: drivers/gpu/drm/apple/tests/topology.kunitconfig } + - { suite: asahi, kunitconfig: drivers/gpu/drm/asahi/.kunitconfig, rust: true } + - { suite: spi-hid-apple, kunitconfig: drivers/hid/spi-hid/.kunitconfig } + # avd-pm.kunitconfig runs the same AVD suites. PM_SLEEP, which it + # adds, is already on by default on arm64. + - { suite: avd, kunitconfig: drivers/media/platform/apple/avd/tests/.kunitconfig } + - { suite: ave, kunitconfig: drivers/media/platform/apple/ave/.kunitconfig } + - { suite: isp, kunitconfig: drivers/media/platform/apple/isp/.kunitconfig } + - { suite: jpeg, kunitconfig: drivers/media/platform/apple/jpeg/.kunitconfig } + - { suite: prores, kunitconfig: drivers/media/platform/apple/prores/.kunitconfig } + - { suite: scaler, kunitconfig: drivers/media/platform/apple/scaler/.kunitconfig } + - { suite: macsmc, kunitconfig: drivers/mfd/macsmc.kunitconfig } + - { suite: clpc, kunitconfig: drivers/soc/apple/clpc.kunitconfig } + - { suite: trusted-keys, kunitconfig: security/keys/trusted-keys/tests/.kunitconfig } + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + - name: Install kernel build and QEMU dependencies + run: | + # As sep-source.yml: avoid the hosted runner's Azure mirror. + if [ -f /etc/apt/apt-mirrors.txt ]; then + printf '%s\n' 'https://archive.ubuntu.com/ubuntu/' 'https://security.ubuntu.com/ubuntu/' | \ + sudo tee /etc/apt/apt-mirrors.txt >/dev/null + fi + sudo apt-get update -o APT::Update::Error-Mode=any + sudo apt-get install -y clang lld llvm libclang-dev libelf-dev libssl-dev \ + flex bison bc pkg-config make perl qemu-system-arm + - name: Pin the Rust toolchain and prepare bindgen + if: ${{ matrix.rust }} + run: | + rustup toolchain install "$RUST_VERSION" --profile minimal --component rust-src --no-self-update + echo "RUSTUP_TOOLCHAIN=$RUST_VERSION" >> "$GITHUB_ENV" + python3 tools/aurora-bindgen/build.py + - name: Run ${{ matrix.kunitconfig }} on arm64 QEMU + env: + KUNITCONFIG: ${{ matrix.kunitconfig }} + run: | + ./tools/testing/kunit/kunit.py run --arch=arm64 \ + --make_options LLVM=1 \ + --kunitconfig="$KUNITCONFIG" \ + --jobs="$(nproc)" --timeout=900 diff --git a/drivers/mfd/macsmc.kunitconfig b/drivers/mfd/macsmc.kunitconfig new file mode 100644 index 0000000000000..936dd1cab0313 --- /dev/null +++ b/drivers/mfd/macsmc.kunitconfig @@ -0,0 +1,11 @@ +CONFIG_KUNIT=y +CONFIG_ARCH_APPLE=y +CONFIG_OF=y +CONFIG_MAILBOX=y +CONFIG_APPLE_MAILBOX=y +CONFIG_APPLE_RTKIT=y +CONFIG_MFD_MACSMC=y +CONFIG_MFD_MACSMC_KUNIT_TEST=y +CONFIG_POWER_SUPPLY=y +CONFIG_MACSMC_POWER=y +CONFIG_MACSMC_POWER_KUNIT_TEST=y diff --git a/security/keys/trusted-keys/tests/.kunitconfig b/security/keys/trusted-keys/tests/.kunitconfig new file mode 100644 index 0000000000000..3b5f98f28758f --- /dev/null +++ b/security/keys/trusted-keys/tests/.kunitconfig @@ -0,0 +1,4 @@ +CONFIG_KUNIT=y +CONFIG_KEYS=y +CONFIG_TRUSTED_KEYS=y +CONFIG_TRUSTED_SOURCE_KUNIT_TEST=y