Skip to content

drm/asahi: identify the T6040 GPU firmware by its loaded TEXT (shared with G16) - #428

Merged
RyanTheTide merged 6 commits into
aurora-silicon:integration/aurorafrom
jgoyvaerts:m4pro/g17-t6040-text-identity
Oct 25, 2026
Merged

RyanTheTide merged 6 commits into
aurora-silicon:integration/aurorafrom
jgoyvaerts:m4pro/g17-t6040-text-identity

Conversation

@jgoyvaerts

Copy link
Copy Markdown
Contributor

The firmware-identity point from the #408 review: the T6040 chose its firmware build only from apple,firmware-version, and the init-data hash covers the driver's own constants, so neither proves which build is loaded. This reuses the G16 backend's check instead of adding a second one.

DT (commits 1-2)

  • fw-text reserved region on the J616s GPU node: the text segment of the loaded GPU firmware (ADT gfx-asc segment-ranges[0], 0x60000 bytes), after the five regions it already has. Like them, the node stays disabled until a boot loader fills it.
  • Binding (its own commit): fw-text allowed as the sixth memory-region-names entry, and in the T6040 branch's list.

Driver (commit 3)

  • Shared fwid module: G16's loaded-TEXT identity (g16/identity.rs + the SHA-256 glue) moves to drivers/gpu/drm/asahi/fwid.{rs,c}, built for every asahi build. It hashes the image with the entropy bytes of its GKTS and ECAP records zeroed, plus the segment sizes. A build entry names its two record offsets, which are checked and zeroed exactly as G16 did with its fixed offsets. Only an unknown image has its records found by their tags, so it's reported with a digest that stays the same across boots (a new variant, like the 8-core J713 image in drm/asahi: g16: accept the 8-core J713 loaded 25G83 image #389, is then one more FirmwareBuild entry). G16 behaves as before: the T8132 entry keeps its offsets (0x5c8df / 0x5c9c2) and digest.
  • G17: a Build now carries its FirmwareBuild. After apple,firmware-version selects the build, identify_image() measures the fw-text region against it, with the fw-data region's size as the DATA size. A missing region, a different image or a different size refuses the GPU (ENODEV, with "GPU firmware image not admitted" and the measured digest in the log).
  • T6040: the 25G83 image as measured on a J616s with macOS 26.6.2: TEXT 0x60000, DATA 0x138000, entropy at 0x59839 / 0x5991c, SHA-256 03df7548…63876dcd.

This answers fbalazsy's .701.1 question on #408. A Recovery-installed 26.6.2 (mBoot-18000.161.10.701.1) is admitted when its loaded TEXT is this image, and refused when it isn't. A tree whose fw-text address doesn't match the unit is refused the same way, rather than running the GPU with the wrong layouts. A tree without fw-text no longer gets the GPU, which matters little while the J616s node ships disabled.

Not in this PR:

  • Sharing the region names (shared-l2 vs l2-pagetables; both are the firmware kernel window's L2 page). Boot loaders fill these regions by name (ours does, from gfx-shared-l2-region), so renaming now would make an installed loader's GPU fill fail on the next kernel. I'd do it together with an m1n1 T6040 dt_set_gpu, so the name changes once, in the tree and in the loaders.
  • The leakage coefficients.
  • m1n1 filling fw-text. Our loader fills it from segment-ranges[0] today, and that dt_set_gpu would do the same.

Tested: J616s, macOS 26.6.2 boot firmware, our loader filling the GPU node from the ADT. Every boot since 7.3.0-m4.17 logs GPU firmware build: Apple GFX 25G83 for T6040 (normalized loaded image), with the desktop on the GPU. KUnit (asahi, QEMU) 120/120 on the daily tree. This branch builds on 420a1c8 with no new warnings, and the binding and the J616s DTB pass dt_binding_check/CHECK_DTBS. The final fwid lookup (a known build checked at its own offsets) was checked against a dump of the J616s TEXT: same digest and offsets.

Base: integration/aurora (420a1c8f5). Built with W=1 (CONFIG_DRM_ASAHI=m, both with and without CONFIG_DRM_ASAHI_G16): the same warnings as the base, none in the files touched here. checkpatch --strict clean, apart from the generic MAINTAINERS note for the new fwid.{rs,c} (drm/asahi has no MAINTAINERS entry).

🤖 Generated with Claude Code

jgoyvaerts and others added 4 commits October 24, 2026 13:27
The driver identifies the loaded GPU firmware build from its text
segment (ADT gfx-asc segment-ranges[0]). Allow it as a sixth reserved
region, fw-text, after the five the T6040 GPU already names.

Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
Assisted-by: LLM
The driver identifies the loaded GPU firmware build from its text
segment (ADT gfx-asc segment-ranges[0]). Add it as the fw-text reserved
region of the GPU, after the five regions it already has. Like them, it
holds this unit's address until a boot loader fills it in.

Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
Assisted-by: LLM
The T6040 selected its firmware build only by apple,firmware-version,
the macOS release the boot loader reports. That says which build to
expect, not that it is the build loaded: a loader can write the version
for a boot firmware it merely recognises, and the init-data hash covers
only the driver's own constants.

The G16 backend already proves its build from the loaded TEXT: the
SHA-256 of the image with the entropy bytes of its GKTS and ECAP records
zeroed, plus the segment sizes. Move that check out of g16 into a shared
fwid module with its SHA-256 helper, built for every asahi build. A
build entry names the offsets of its two entropy records, which are
checked and zeroed there, as G16 did; an unknown image is reported with
the records found by their tags, so its digest is stable across boots
and a new variant is one more entry. G16 uses it as before.

A G17 firmware build now carries its image identity, and the T6040
refuses the GPU unless the fw-text region holds the 25G83 image it was
written for (measured on a J616s, macOS 26.6.2), with the DATA size of
the fw-data region. A tree without fw-text no longer gets the GPU; the
J616s tree ships it disabled until a boot loader fills it in.

Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
Assisted-by: LLM
Cover the shared identity code moved out of G16 with synthetic TEXT.
Entropy changes must preserve the normalized digest, non-entropy changes
must change it, malformed records must be refused, and measurement must
leave its input unchanged. No firmware image is included in the tests.

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

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

I checked the G16 extraction against the old identity path, both entropy offsets, size checks, failure paths and the placement of the T6040 check before firmware-visible writes. The J616s GPU remains disabled in the shipped tree. The existing Gravity credit and GPL-only helper remain intact; the moved identity implementation introduces no additional Gravity code.

I pushed Ryan fixup da42c7c with synthetic TEXT tests. They check that entropy changes preserve the digest, other changes alter it, malformed records are rejected and measurement preserves its input. They pass in the 86/86 Asahi KUnit run. The apple-dcp host tests pass 63/63. The fixup is checkpatch-clean; the original extraction has only the generic new-file MAINTAINERS reminder.

The first defconfig plus asahi.config WERROR build passed. Final universal builds are still running, and #438 needs the common-config review. This is not merge-ready until those gates finish. I have no new J616s runtime result of my own.

@RyanTheTide

Copy link
Copy Markdown
Contributor

I re-read the PR body, reviews and both comment lists. There are currently no inline review threads or new replies here. The loaded-TEXT identity point is resolved at da42c7c, including the appended synthetic normalization tests. Those tests pass in Asahi KUnit 86/86. My current verdict remains not merge-ready until the final universal build and the common-config review in #438 are complete. I am applying the agreed review/build-only scope to the M4-only runtime path.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Final software gates now pass on the combined tree containing these heads and the proposed common config correction in #438. Both defconfig plus asahi.config and the Fedora-base recipe build Image, modules and DTBs with WERROR enabled. The Fedora recipe also covers KUNIT=m. Every requested asahi.config setting survives resolution. Asahi KUnit passes 86/86 and apple-dcp host tests pass 63/63. The targeted J713/J616s binding and DTB checks have no diagnostics.

The identity code and synthetic tests pass. This remains not merge-ready on the common-config review dependency in #438. The M4 runtime path retains the agreed review/build-only scope.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Final qualification for da42c7c. The combined test source is 031f7dec92a1bef6b72509b08c5c597f50474adb, tree 36854d3a72e4efdf2c352166498ab436adaf3c48.

Both defconfig plus asahi.config and the Fedora-base shipping recipe pass the full Image/modules/DTB build with WERROR enabled. Every requested fragment value survives olddefconfig. Asahi KUnit passes 86/86, apple-dcp host tests pass 63/63, and targeted J713/J616s binding/DTB checks have no diagnostics. Strict source-style checks pass; commit sign-offs are checked separately. The attribution audit found no new material Gravity implementation blocks. Existing GPL-2.0-only Cody Ho and Niklas Sheth credit is preserved.

Ryan fixup da42c7c adds the synthetic identity tests, which pass. The M4-only runtime path follows the agreed review/build-only scope. No code hold remains. Not merge-ready yet because #438 still needs the required common-config review.

Resolve the conflict with aurora-silicon#442 in drivers/gpu/drm/asahi/g16/hw.rs. The
8-core J713 entry from aurora-silicon#442 moves to the shared FirmwareBuild and names
both entropy records at the same offsets as the first T8132 entry. The
old G16 identity zeroed the same two records at those offsets before
hashing, so its recorded digest stays valid.

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

Copy link
Copy Markdown
Contributor

This branch conflicted with #442 in g16/hw.rs. I pushed a merge of integration/aurora (e5dad6d): the 8-core J713 entry from #442 moves to the shared FirmwareBuild with both entropy offsets (0x5c8df, 0x5c9c2), the same records the old G16 identity zeroed, so its digest stays valid. Your commits are unchanged.

Gates on integration/aurora 653c489 with #394, #435, #436, #446 (the carried #445), #427 and #428 merged (test tree 4582b72703d5), without #438:

  • Universal recipe (Fedora asahi base, asahi.config, olddefconfig, LLVM=1, CONFIG_DRM_WERROR=y): Image, modules and DTBs build with no warnings, and all 130 asahi.config settings survive.
  • KUnit asahi 84/84, drm/apple display set 212/212.
  • apple-dcp host selftests 62/63, the same as the base (dwc3-teardown fails there too).
  • dt_binding_check and CHECK_DTBS clean for the touched bindings and the J616s, J713, J700, M1 and M2 DTBs.

J616s (M4 Pro, 26.6.2 firmware): this kernel boots like the daily one. Wi-Fi, Bluetooth, audio devices, PMP, NVMe, cpufreq and cpuidle all match, with no DART faults or SErrors and no IRQ-safe genpd warnings. With the T6041 display handoff it also drives the internal panel. The Neo smoke boot of the same image is queued.

The #438 config review doesn't hold this up: these gates were built without #438. The J616s GPU stays disabled in the tree.

Resolve the Makefile conflict with aurora-silicon#395: keep the shared fwid.o and add
the G15 glue object. G15 has its own identity and SHA-256 helper, so
the move of the G16 identity into fwid does not touch it.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide
RyanTheTide merged commit 18012be into aurora-silicon:integration/aurora Oct 25, 2026
RyanTheTide added a commit that referenced this pull request Oct 25, 2026
Include the qualified M4 Pro/Max display and GPU identity updates from #435, #427, #428 and #446 on top of the existing consolidation. Regate this final tree before publication; earlier-head gate results do not qualify it.

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

Assisted-by: LLM
erikwb pushed a commit to erikwb/linux that referenced this pull request Oct 28, 2026
Treat the OS version as a candidate-order hint. Continue to require an
exact admitted loaded TEXT image and preserve aurora-silicon#453's images list. This
extends Jonathan Goyvaerts' shared identity work.

Originally-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
Link: aurora-silicon#428

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
erikwb pushed a commit to erikwb/linux that referenced this pull request Oct 28, 2026
Wire the reader into probe and firmware construction, validating OPPs and
enabled cores before firmware starts. Use the maps, leakage and power
ceiling in the 25G83 objects, replacing bin-specific output hashes with
layout and host encoder checks. Keep the Neo path unchanged.

The old ceiling declaration remains only for the hardware-default
reference removed by the next patch. Firmware uses the calibration.

Retain GPL-2.0-only and the Gravity Linux encoder attribution to Cody Ho
and Niklas Sheth. The original T6040 work is by Jonathan Goyvaerts.

Originally-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
Link: aurora-silicon#428
Link: https://github.com/GravityLinux/linux

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
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