Skip to content

iommu: apple-dart, drm/apple: build under KASAN with CONFIG_WERROR (frame size, unused fixture) - #2924

Merged
DjDeveloperr merged 7 commits into
mainfrom
fix/apple-kasan-frame-size
Nov 26, 2026
Merged

DjDeveloperr merged 7 commits into
mainfrom
fix/apple-kasan-frame-size

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A KASAN kernel with CONFIG_WERROR=y does not build: four functions in our Apple code go over the default 2048-byte frame limit, and one parser-test fixture has been unused since c7e3f37. That blocks the full-debug (KASAN/UBSAN/lockdep) KUnit row unless WERROR is turned off.

Change

  • iommu: apple-dart: apple_dart_dcp_import() took the 552-byte struct dcp_adt_tables by value, and its callers copied it again to adjust start/end. It now takes a const pointer plus the table range: dispext_prepare 2144 → 944 bytes, frontend_prepare 2144 → 976.
  • drm/apple iomfb: dcp_swapped() built a zeroed 0x730-byte dc_swap_complete_resp on the stack just to pass a swap id. The id handling is split out into dcp_swap_complete_id(): 2080 → 96 bytes. The receive path is unchanged.
  • drm/apple av test: the lifetime test's apple_epic_service is now allocated with kunit_kzalloc(): 2240 → 416 bytes.
  • drm/apple parser test: the shared panel_test_adt array is marked __maybe_unused and remains available to the host identity test.

No functional change.

Testing

arm64, KASAN + UBSAN + PROVE_LOCKING + DEBUG_OBJECTS, CONFIG_WERROR=y, CONFIG_FRAME_WARN=2048:

checkpatch --strict: one CHECK on the DCP_FW_NAME() macro in an unchanged signature, and one commit-reference line over 75 chars.

Tested: J616s (M4 Pro) and J700 (Neo) passed the display and DART checks in the hardware candidate carrying b1e599fbe90a, with zero DART faults and no new kernel errors. The updated head 81b40d7c6f40 has the same stable patch ID (013c429d0c88). The only intervening merge on main was #2918, which changes PWM KUnit coverage.

Risk: two-way · Macs using Apple DCP and DART.

Reviewer detail

apple_dart_dcp_import() takes struct dcp_adt_tables by value, and its
callers copy the 552-byte table description into a local 'bounds' only
to change start and end. With the import inlined, the external and
internal frontend prepare paths each carry several copies: 2144 bytes
of stack under KASAN, which fails a CONFIG_WERROR build at the default
2048-byte frame limit.

Pass the firmware description by const pointer with the table range as
two arguments, and store the adjusted copy only in the imported DCP.
apple_dart_dispext_prepare() drops to 944 bytes and
apple_dart_frontend_prepare() to 976 (arm64, KASAN inline). No change
in behaviour.

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

dcp_swapped() completes a swap whose completion arrived early on
external desktop 26.x firmware by building a zeroed
dc_swap_complete_resp on the stack and passing it to
dcpep_cb_swap_complete(), which only reads its swap_id. The record is
0x730 bytes on those firmware versions, enough to put dcp_swapped() at
2080 bytes under KASAN and fail a CONFIG_WERROR build.

Split the swap-id handling out of dcpep_cb_swap_complete() into
dcp_swap_complete_id() and call that directly. dcp_swapped() drops to
96 bytes. The receive path is unchanged.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
av_lifetime_report_after_stop() keeps a struct apple_epic_service,
pending-command table included, on the stack. Under KASAN that is a
2240-byte frame and a CONFIG_WERROR build fails. Allocate it with
kunit_kzalloc() like the rest of the fixture (416 bytes).

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Commit c7e3f37 ("drm/apple: read the panel colour target from raw ADT")
removed the only user of panel_test_adt, so a CONFIG_WERROR build of
the parser tests fails on -Wunused-const-variable. Remove the array and
keep panel_test_mode, which the tests still use.

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

Copy link
Copy Markdown
Contributor Author

Review at 7663a8b.

Read all four commits at 7663a8b. No new heap or static storage on any kernel path: the DART change only passes the 552-byte table description by const pointer, so there is no allocation or concurrency question. The only new allocation is kunit_kzalloc() in a test. Behaviour is the same with or without KASAN.

  1. drivers/iommu/apple-dart-dcp.h:553-555: dcp->firmware = *firmware plus start/end gives the same stored copy as the old bounds, and start/end replace every bounds.start/bounds.end in the import. This all runs at probe time, not on the map/unmap path. Fine.
  2. drivers/gpu/drm/apple/iomfb_template.c:846-861,3484: dcpep_cb_swap_complete() only ever read resp->swap_id, so dcp_swap_complete_id() is equivalent. The early-complete path still swaps ext26_rx_ns around the call. Fine.
  3. drivers/gpu/drm/apple/av-lifetime-test.c: the service now lives until test cleanup instead of function return. That is strictly safer, because t->asrv->srv no longer points at a dead stack slot after the function returns.
  4. Nit, 7663a8b: this commit fixes a -Wunused-const-variable left behind by c7e3f37, so it can carry Fixes: c7e3f37e7cb9 ("drm/apple: read the panel colour target from raw ADT") in place of the over-long inline reference. The three frame-size commits only fail under KASAN+WERROR and don't need Fixes tags.
  5. No __maybe_unused or new #ifdef hides anything. The fixture is deleted, not silenced.

@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.

Formal adversarial §1–§6 pre-PR checklist review at 7663a8b04ed2bd380fe887c8357d9ad208b8fc19 (COMMENT — 0 code/policy blockers; waiting on CI).

Checklist Summary

  • §1 (No model gating): Pass — no chip, SoC, board, or firmware-version gates introduced.
  • §2 (Production-ready, no hacks): Pass — pure stack-frame reductions and removal of dead test fixture (panel_test_adt, unused since c7e3f37e7cb9).
  • §3 (Safety / correctness): Pass — verified all 4 commits introduce zero functional change:
    • drivers/iommu/apple-dart-dcp.h: apple_dart_dcp_import() takes const struct dcp_adt_tables *firmware plus explicit start/end, stores *firmware into dcp->firmware and overrides dcp->firmware.start/end before apple_dart_dcp_excluded_regions(dcp). Every former bounds.start/bounds.end reference inside apple_dart_dcp_import() is updated consistently, and all 5 call sites (apple_dart_dcp_prepare SID23, apple_dart_dispext_prepare SID16/SID0, apple_dart_frontend_prepare SID0/SID16) pass identical ranges.
    • drivers/gpu/drm/apple/iomfb_template.c: dcp_swap_complete_id() extracts the swap-ID completion path cleanly out of dcpep_cb_swap_complete(), eliminating the 0x730-byte dc_swap_complete_resp stack allocation in dcp_swapped(). Each versioned iomfb_v*.c includes iomfb_template.c once as its own translation unit, so static void dcp_swap_complete_id() has no linkage collision.
    • drivers/gpu/drm/apple/av-lifetime-test.c: moves struct apple_epic_service to kunit_kzalloc() with KUNIT_ASSERT_NOT_NULL().
    • drivers/gpu/drm/apple/dcp-panel-test.h: removes unused panel_test_adt[] while retaining panel_test_mode.
  • §4 (Clean-room & attribution): Pass — all 4 commits carry human author/committer (Ryan Murray <ryan@aurorasilicon.org>) and human Signed-off-by: only (zero AI trailers in commits); PR body includes Assisted-by:.
  • §5 (Evidence): Waiting on CI — KASAN+UBSAN+PROVE_LOCKING+DEBUG_OBJECTS arm64 build (CONFIG_WERROR=y, CONFIG_FRAME_WARN=2048) and QEMU KUnit run are well documented for this no-functional-change refactor, but GitHub CI is still queued (host-tests QUEUED, 0/1 completed). Cannot approve until required CI finishes green.
  • §6 (Naming): Pass.

Verdict

0 code or policy blockers. Ready to approve once CI completes green.

@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.

Follow-up after host-tests CI run 45103041644 completed with FAILURE on 7663a8b04ed2:

  1. dcpext26-present-tests failed to compile (exit 1): tools/asahi/dcpext26-present-tests.py extracts code from drivers/gpu/drm/apple/dcp.c and now fails with error: call to undeclared function 'dcp_swap_complete_id' (-Wimplicit-function-declaration). The stack-frame helper split in dcp.c needs the host test extractor/stubs updated to match.
  2. apple-dcp host suite failed (exit 1): FAIL apple-dcp (167.3s): exit 1 in the same run — please inspect and resolve the failing subtest alongside dcpext26-present-tests.

Holding approval until host-tests passes green.

@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) ci-failing A check failed at the PR head (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge readiness at 81b40d7c: not ready yet

Check Detail
CI at head running running: host-tests, KUnit ane-pm, KUnit dcp-topology, KUnit asahi, KUnit spi-hid-apple, KUnit avd
Review ok approved by DjDeveloperr, satchlj
Requested changes ok none
Hardware row at head ok in the PR body at 81b40d7c
Conflicts ok none
PR text ok Risk: two-way · Macs using Apple DCP and DART.

Areas: area:display, area:gpu

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@github-actions github-actions Bot added merge-conflict Conflicts with the base branch (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Nov 24, 2026

@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.

Verdict: FINISH, then merge at 7663a8b04ed2

Blockers:

  1. CI is red: tools/asahi/dcpext26-present-tests.py extracts code from drivers/gpu/drm/apple/dcp.c and now fails to compile (an undeclared function after the frame-size split). Fix: update the extraction list or keep the helper the test expects.
  2. The branch conflicts with main; update it.

Rows before merging: the frame-size split changes built DCP and DART code, so at the new head it needs one boot on each of two generations with the display up and no DART faults.

Checked: no Apple material, no runtime change beyond the KASAN/CONFIG_WERROR build fixes (frame size, unused function).

@DjDeveloperr
DjDeveloperr dismissed their stale review November 24, 2026 23:56

Superseded by the review at 7663a8b

@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Nov 25, 2026
Keep the current H17 shown flag when forwarding the stack-frame fix.
Use the new completion helper in the ext26 fixture and keep its
synthetic shown state clear. Retain the panel identity test's synthetic
ADT input with an unused annotation for the kernel translation unit.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The synthetic ADT buffer and the two-mode catalogue push their
respective test frames past 2048 bytes with generic KASAN and WERROR.
Use KUnit-managed storage for those fixtures and preserve their
initialization and checks.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide
RyanTheTide requested review from a team as code owners November 25, 2026 00:53
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) and removed ci-failing A check failed at the PR head (bot) merge-conflict Conflicts with the base branch (bot) labels Nov 25, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Forwarded to current main at b1e599fbe90a. The display callback keeps main's H17 shown flag and the smaller stack frame. The ext26 fixture now uses the scalar completion helper, and the J616s panel identity fixture retains its synthetic ADT input.

The standalone ext26 host check and all 95 Apple DCP host checks passed. Seven ARM64 driver and test objects built with generic KASAN, WERROR and the unchanged 2,048-byte stack frame limit. Two parser-only test fixtures needed KUnit-managed storage to pass that limit. Hosted CI and the two-generation display and DART boot results remain due.

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Gemini 4 Neon on @satchlj's behalf

Verdict at b1e599fbe90a

APPROVE — Clean KASAN + CONFIG_WERROR stack-frame reductions across apple-dart-dcp.h, iomfb_template.c, and DCP KUnit tests (av-lifetime-test.c, parser-test.c), properly preserving main's H17 shown flag, updating both host test harnesses (dcpext26-present-tests.py, j616s.py), and passing all 4/4 CI checks.

Blockers

  • None on code, KUnit tests, or CI. (See Untested scope regarding hardware boot verification across two generations.)

Checked

  • Full diff audit (7 changed files, +65/-47):
    • drivers/iommu/apple-dart-dcp.h: changes apple_dart_dcp_import() to accept const struct dcp_adt_tables *firmware, u64 start, u64 end, copies *firmware into heap-allocated dcp->firmware, and overrides .start/.end, eliminating the ~552 B by-value parameter and extra bounds stack copy in apple_dart_dispext_prepare() and apple_dart_frontend_prepare().
    • drivers/gpu/drm/apple/iomfb_template.c: extracts dcp_swap_complete_id(dcp, swap_id, shown) so dcp_swapped() passes (swap_id, false) directly without stack-allocating struct DCP_FW_NAME(dc_swap_complete_resp), while dcpep_cb_swap_complete() preserves resp->unkbool under #if DCP_FW_H17(DCP_FW_VER).
    • tools/asahi/dcpext26-present-tests.py: updated cleanly to stub dcp_swap_complete_id() (asserting !shown), resolving the prior host-test compile failure.
    • drivers/gpu/drm/apple/av-lifetime-test.c & parser-test.c: moves large stack allocations (struct apple_epic_service, u8 adt[512], struct dcp_display_mode catalog[2]) to kunit_kzalloc/kunit_kmalloc/kunit_kcalloc with KUNIT_ASSERT_NOT_NULL.
    • drivers/gpu/drm/apple/dcp-panel-test.h & tools/testing/selftests/drivers/gpu/apple-dcp/j616s.py: marks panel_test_adt[] __maybe_unused and defines #define __maybe_unused in the standalone host test script.
  • CI at b1e599fbe90a: kunit PASS, host-tests PASS, readiness / readiness PASS, pr-text / pr-text PASS (4/4 green).
  • Untested scope: Static diff and CI review only; no kernel build or live Mac hardware boot (including two-generation DCP/DART boot checks) was executed locally in this userspace-only review.
Evidence
  • PR head: b1e599fbe90a (base=main, MERGEABLE, 7 files +65/-47)
  • CI: kunit: SUCCESS, host-tests: SUCCESS, readiness / readiness: SUCCESS, pr-text / pr-text: SUCCESS

@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.

Code approved at b1e599fbe90a. The ext26 fixture now calls the scalar swap-completion helper, and the hosted DCP tests pass. The branch merges cleanly. Before merge, this still needs display and DART boot results on the target Mac and a second generation.

@DjDeveloperr
DjDeveloperr dismissed their stale review November 26, 2026 00:57

Superseded by the review at b1e599f

@github-actions github-actions Bot removed changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 26, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

b1e599f J616s (T6040, M4 Pro) + J700 (Neo, T8140) PASS (2 generations): guarded one-shot combined batch (427b2c2dc67c over main 8f99a85, 0 merge-tree diffs on 7 changed files, default cmdline): J616s (boot c03a4ac6-7a26-444a-b5d3-cddf0c5d9bdc) eDP-1 connected pre/post, 0 DART faults, 0 GPU faults, 2/2 rtc1 s2idle, 0 failed units, Enforcing, 0 new AVC, 0 new kernel errors; J700 (boot 3f98d23f-1816-4823-8fa0-0857950bb565) eDP-1 + DP-1 connected, 0 DART faults, 0 GPU faults, Wi-Fi 3/3 ping, 0 failed units, Enforcing, 0 new AVC, 0 new kernel errors; stock 7.3.0-aurora-fleet89 restored on both.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-hw-row No hardware row at the PR head (bot) labels Nov 26, 2026
@DjDeveloperr
DjDeveloperr requested a review from a team as a code owner November 26, 2026 01:43
@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) and removed ready-to-merge Meets the merge policy: merge it (bot) needs-hw-row No hardware row at the PR head (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 26, 2026
@DjDeveloperr
DjDeveloperr merged commit 15695c3 into main Nov 26, 2026
22 checks passed
@RyanTheTide
RyanTheTide deleted the fix/apple-kasan-frame-size branch November 27, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:display Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) door:two-way Revertible or not, from Merge risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants