Skip to content

accel/ane: run the T8132 (M4) Neural Engine on macOS 27.2 firmware - #2630

Merged
RyanTheTide merged 2 commits into
integration/aurorafrom
ane/t8132-27.2
Nov 22, 2026
Merged

RyanTheTide merged 2 commits into
integration/aurorafrom
ane/t8132-27.2

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Problem. On macOS 27.2 (26B123) firmware the M4 (T8132) Neural Engine never starts. iBoot preloads a T8132 image with a new TEXT/DATA split (TEXT 0xbc000, DATA 0x2b0000, DATA at DVA 0x100_000b_c000), but ane_t8132_platform only knows the 26.6.2 sizes (0xc0000 / 0x2ac000), so preflight refuses the hand-off with -EINVAL ("H16 requires bootloader-reserved no-map TEXT/DATA preload ranges") and every M4 on 27.2 has no ANE.

Change.

  • The H16 path now picks the firmware build the loader handed over through next_build, the same way the H17 staged path already does. Preflight and probe use the build whose preload sizes and IOVAs match. SoCs without next_build (the M4 Pro and M4 Max H16 table) are unchanged.
  • A preload rule can carry the TEXT and DATA sizes it was made for (0 keeps the 26.5-27.0 sizes), and the digest checks the snapshots against those sizes.
  • New T8132 27.2 build (sizes, DATA IOVA) with a J713 profile. DATA has the 26A428 patchbay records and rewritten range 0x10 bytes earlier; GKTS and ECAP change on every boot, as on 25G83. The boot values are the T8132 25G83 ones.
  • A second commit fixes program_add128_slots_test, which read an uninitialized binding (fails with pattern-initialized stacks; also fails on the base without this series).

Testing.

  • J713 (M4 Air 16 GB), macOS 27.2 system firmware, Stage 2 from aura main, kernel 7.3.0-bj713b2+ on its stock cmdline, with this series' ANE modules swapped in at runtime: "H16 preload identity H16 T8132 27.2 26B123 J713 accepted", firmware READY and all startup acks, accel node up.
    • H16G add-128: 1000 runs, output bit-exact (16384/16384 fp16 elements equal in0+in1), p50 116 us.
    • MobileNetV1 224 H16G (the same package the M4 Pro rows use): top-1 16/16, EXECUTE p50 0.90 ms.
    • 0 WARN, oops, DART faults or quarantines, 0 AVCs.
    • The same with this series built into the J713 lab kernel (stock cmdline, no module swap): the engine is up at boot (identity accepted at 5.7 s), add-128 output sha256 a001d87e...a839, MobileNet 16/16.
  • J616s (M4 Pro, T6040), unchanged production kernel with this series' modules: "H16 preload identity H16 26.6.2 25G83 accepted", MobileNet top-1 16/16 at EXECUTE p50 0.268 ms (as before), add-128 1000 runs PASS; the add-128 output is byte-identical to the J713's (sha256 a001d87e...a839). 0 WARN, oops, DART faults, quarantines, AVCs.
  • Two boots: only GKTS and ECAP change between them, and the normalized digest is the same on both.
  • KUnit (arm64 qemu, all ANE suites): 294 pass, 1 skip, 0 fail. New cases: ane_t8132_builds_test (each T8132 build admits only its own layout) and preload_sized_rule_test.
  • checkpatch clean; ANE modules build with W=1 and 0 warnings.

Still to run.

  • Suspend with the engine loaded on 27.2 (the cold-sleep path is the same as 25G83).
  • Other T8132 boards (M4 Mac mini, iMac) on 27.2 need their own profile digests: the preload carries board data, the same as on T6041.
  • Performance: MobileNet runs at about 0.9 ms here, against 0.23-0.27 ms on the M4 Pro, which has CLPC ANE floors. T8132 has none yet. That's a follow-up, not part of this change.
Bring-up log excerpt (J713, 27.2)
ane_t6021 500000000.ane: H16 preload identity H16 T8132 27.2 26B123 J713 accepted
ane_t6021 500000000.ane: H16 READY 8042006 0
ane_t6021 500000000.ane: H16 startup ack 4 0
ane_t6021 500000000.ane: H16 startup ack 0 0
ane_t6021 500000000.ane: H16 startup ack 3 0
ane_t6021 500000000.ane: H16 startup ack 22 0
[drm] Initialized ane 3.1.0 for 500000000.ane on minor 0
ane_t6021 500000000.ane: H16 stage 5 program window 10001f00000..10041efffff

MobileNet: per-image top-1 matched the reference on all 16 images, max |logit diff| vs the CPU fp16 chain 0.031-0.078; firmware time 0.663 ms mean over 1000 runs (submit->ack 0.200, report->done 0.461).

How the 27.2 rule was made

The two preload ranges were read from the running Linux (no-map reserved memory, outside System RAM, unclaimed because the driver had refused them) on two boots. The rule's record offsets, rewritten range and digest come from those reads, using the same normalization as ane_h16_preload_digest(). Nothing from the image goes into the tree except those numbers, as with the existing H16 rules.

Assisted-by: LLM (Claude:Opus 5.5)

On macOS 27.2 (26B123) iBoot preloads a T8132 ANE image with a different
TEXT/DATA split than 26.6.2: TEXT 0xbc000 and DATA 0x2b0000, DATA at DVA
0x100_000b_c000 (as on T6050 and T8142 at 27.2). The T8132 platform pins
the 25G83 sizes, so preflight refuses the hand-off with -EINVAL and the
engine stays off on every M4 Mac that runs 27.2 firmware.

- Let the H16 path pick the loader's build through next_build, as the
  H17 staged path already does: preflight and probe use the build whose
  preload sizes and IOVAs match the hand-off.
- Let a preload rule carry the TEXT and DATA sizes it was made for (0
  keeps the 26.5-27.0 sizes), and check the snapshots against them.
- Add the T8132 27.2 build and its J713 profile. Its DATA has the 26A428
  patchbay records and rewritten range 0x10 bytes earlier; GKTS and ECAP
  change on every boot, as on 25G83. The boot values are the T8132 25G83
  ones.

KUnit covers both T8132 builds (each admits only its own layout) and a
rule that refuses snapshots of another size.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
program_add128_slots_test checks that a program without a scratch segment
gets no scratch binding, but it passes NULL for the binding and then reads
its own uninitialized one. With the stack pattern-filled the check fails
(scratch.index 0xfefefefe). Pass the zeroed binding to
ane_h16_process_bindings() so the check tests what it says.

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.

Reviewed 8f2af6f. Approving the code:

  • The build is selected by what the loader preloaded (next_build, matched on the preload sizes and IOVAs), not by firmware version.
  • SoCs without next_build are unchanged.
  • A sized preload rule with 0 keeps the old sizes.
  • The 27.2 profile is accepted only by its digest.

KUnit covers each T8132 build admitting only its own layout, and the program_add128_slots_test fix is a real uninitialized read.

Two things before merge:

  1. Overlap with my linux#2642 (J773g, the M4 mini). It adds the same mechanism under the same names: ane_t8132_platform_26b123, next_build, ane_fw_platform_build(), the sized H16 rules, build_name. Both can't land as they are. Fine with this one going first; #2642 then rebases down to just the J773g 27.2 profile.
  2. Rows. The J713 27.2 row (add-128 1000/1000 exact, MobileNet 16/16) and the J616s no-regression row are good. The build selection now also decides the 26.6.2 case on T8132, which is what the installer gives a J713 today. So it needs one T8132 Mac on the 26.6.2 stub (J604, J713 or J773g) with these modules: H16 preload identity H16 T8132 26.6.2 25G83 ... accepted, and add-128 exact over 1000 runs.

Nit: the body calls the J616s "T6041". It's the M4 Pro, T6040.

Assisted-by: Claude Opus 5.5

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Thanks. Fixed the T6040 slip in the body.

#2642: agreed, this can go first and #2642 rebases onto it for just the J773g profile.

26.6.2 on T8132: on a 25G83 hand-off the base ane_t8132_platform is tried first and matches (its sizes and IOVAs), so it's selected exactly as before; ane_t8132_builds_test checks that each T8132 build accepts only its own layout. Our J713 only has a 27.2 stub now, so the 26.6.2 row (identity H16 T8132 26.6.2 25G83 J713 accepted + add-128 1000/1000 exact) needs a J604/J713/J773g that's still on the 26.6.2 stub. I'm asking an owner for it and will post it here.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

No blockers. Build selection in ane_fw_platform_build() comes from the handed-over preload sizes and IOVAs, the base 25G83 build is tried first, and unknown layouts and digests still refuse, so T6040/T6041 and the H13/H14 path are unchanged. 27.2 heap tail = 0x1000036c000, the same as 25G83, so reusing ane_h16_build_t8132_25g83's config_span is consistent. One robustness note: in ane_h16_preload_identity() (ane_h16_backend.c:1864) a profile whose rule size does not match returns -EINVAL, and that ends the ret == -ENOEXEC loop before later profiles are tried. That's harmless with today's single-size tables, but resetting ret to -ENOEXEC on that path, or asserting one size per table in preload_profiles_check(), would keep a future mixed table from failing silently. Before merge this still needs the T8132 26.6.2 stub row on this head (identity H16 T8132 26.6.2 25G83 ... accepted, add-128 1000/1000 exact), because the 25G83 hand-off now goes through the new selection.

@RyanTheTide
RyanTheTide merged commit d9531cb into integration/aurora Nov 22, 2026
1 check passed
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