Skip to content

iommu/apple-dart: run the apple-dart KUnit suite in CI, fix its stack overflow - #3888

Merged
DjDeveloperr merged 1 commit into
mainfrom
fix/apple-dart-kunit-stack-ci
Dec 2, 2026
Merged

DjDeveloperr merged 1 commit into
mainfrom
fix/apple-dart-kunit-stack-ci

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What: apple_dart_test_t8132_fw_mirror_selection() kept a struct apple_dart on the stack. The struct has outgrown the 32 KiB task stack (its memset is 0x9480 bytes), so the case overflows the stack and panics the KUnit kernel, and the 24 cases after it never run. This happens on main (13c7f69) too. The fix allocates the DART with kunit_kzalloc(), as the neighbouring cases do. Linux CI had no apple-dart suite, so nothing noticed. This adds drivers/iommu/apple-dart.kunitconfig (16K pages, which the J713 cases need) and an apple-dart entry in scripts/ci/apple-kunit.py that runs when drivers/iommu/apple-dart* or include/linux/soc/apple/dcp-v27-sleep.h changes.

Tested: scripts/ci/apple-kunit.py run apple-dart (the CI command, LLVM=1, arm64 QEMU) on the buildbox ran 39/39 passing. Main without the test fix crashes at case 16 ("kernel stack overflow", lr apple_dart_test_t8132_fw_mirror_selection+0x44), and 15 cases pass. plan --files maps drivers/iommu/apple-dart.c to apple-dart jpeg. checkpatch --strict found 0 errors (only the MAINTAINERS new-file note). This PR touches apple-kunit.py, so its own run is the full KUnit set.
Risk: two-way · test and CI only, no kernel code change. DART PRs gain one KUnit job: about 3 s of tests on a build that shares the jpeg suite's job and build dir.

… overflow

apple_dart_test_t8132_fw_mirror_selection() put a struct apple_dart on
the stack. The struct is now larger than the 32 KiB task stack (its
memset alone is 0x9480 bytes), so the test overflowed the stack and
panicked the KUnit kernel. The 24 cases after it never ran, on main as
well. Allocate the DART with kunit_kzalloc() like the other cases do.

Nothing caught this because the linux CI KUnit table had no apple-dart
suite. Add drivers/iommu/apple-dart.kunitconfig (16K pages, which the
J713 cases need) and an 'apple-dart' entry that runs when apple-dart*
or the v27 sleep header changes.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve at 66cbc2d.

What I checked:

  • The case now allocates the DART with kunit_kzalloc() and asserts it isn't NULL, the same as every neighbouring case. kunit_kzalloc() returns NULL on failure (never an error pointer) and frees the memory on every exit path, including a failed assert. The memory starts zeroed, like the old { .locked = true } initializer, and the five expectations are unchanged, so the case tests the same thing.
  • The suite entry has the same shape as the others (name, kunitconfig, no Rust, paths, filter). The apple-dart* filter runs the apple-dart suite plus the one-case apple-dart-firmware-leaf suite in apple-dart.c, which is where 39 comes from (38 + 1). plan --files sends apple-dart.c, apple-dart-test.c, apple-dart-v27-late.inc and dcp-v27-sleep.h to the new suite as intended. The kunitconfig meets the Kconfig dependencies (APPLE_DART=y, KUNIT=y), and it uses 16K pages for the T8132 cases that skip below 16 KiB.
  • apple-build is unaffected: defconfig + asahi.config don't enable KUnit, so the test file isn't compiled there. No host test reads these files.
  • KUnit runs on arm64 QEMU, so I didn't run it here. This relies on the 39/39 run at this head in the description, and on hosted CI.
  • pr-text would have failed because the Risk line said neither one-way nor two-way. I added "two-way ·" to it and changed nothing else in the description. The checker passes locally on the edited text.

Notes, not blockers:

  • Since this PR's base, main gained apple_dart_test_v27_cycle_errors (from #3807). It comes after the old crash, so it has never run. The first main run after this lands will be its first run. If it fails, the bug is in that code or test, not in this PR.
  • The nine host-power cases stay compiled out. They sit under CONFIG_APPLE_DART_J713_DCP, which this kunitconfig doesn't set (asahi.config does). A follow-up could add CONFIG_APPLE_DART_J713_DCP=y.
  • When a DART PR runs apple-dart and jpeg in one job, the page size switches from 16K to 4K, so most of the kernel rebuilds for jpeg. The extra cost is closer to a second kernel build than to 3 s.

@DjDeveloperr
DjDeveloperr merged commit 2225082 into main Dec 2, 2026
10 of 19 checks passed
@DjDeveloperr
DjDeveloperr deleted the fix/apple-dart-kunit-stack-ci branch December 2, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants