Skip to content

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

Open
RyanTheTide wants to merge 4 commits into
integration/aurorafrom
fix/apple-kasan-frame-size
Open

RyanTheTide wants to merge 4 commits into
integration/aurorafrom
fix/apple-kasan-frame-size

Conversation

@RyanTheTide

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 unused panel_test_adt array is removed (panel_test_mode stays).

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.

Still to run

Nothing on hardware: the DART and iomfb changes pass the same values through a pointer or an id instead of a copy. A display row on the next fleet kernel covers it like any other change.

Reviewer detail

Assisted-by: LLM (Claude:Opus 5.5)

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.

Assisted-by: LLM (Gemini 4 Neon)

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

Assisted-by: LLM (Gemini 4 Neon)

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