Skip to content

drm/asahi: g17: Log an unsupported firmware build only when none matches - #2585

Open
term-guy wants to merge 2 commits into
aurora-silicon:integration/aurorafrom
term-guy:g17-quiet-fw-identify
Open

term-guy wants to merge 2 commits into
aurora-silicon:integration/aurorafrom
term-guy:g17-quiet-fw-identify

Conversation

@term-guy

Copy link
Copy Markdown
Contributor

Problem

firmware_variant() tries each identified build in turn. Each try measured the loaded TEXT again, and a build that did not match logged unsupported GPU firmware build, supported: <that build> and GPU firmware image not admitted: EINVAL, even when the next build matched. With no apple,firmware-version on the GPU node (the installed aura doesn't write one on T8142), an M5 on macOS 27.2 logs those three errors for 26A428 before it admits 26B123. Raised on linux#2093.

Change

  • Measure the TEXT once, and try each build with Measured::find, which leaves the copy as it was.
  • Only when no build matches, log the measured identity and every supported build, then the existing Unsupported GPU firmware image line.
  • A matched build still logs GPU firmware build: ....
  • The TEXT is copied and hashed once per probe, not once per candidate build.

Testing

Mac17,2 J704 on the macOS 27.2 (26B123) stub, with #2093 (f41fdbe) underneath, five boots. Before, the probe logged:

aurora 582600000.gpu: unsupported GPU firmware build: TEXT 0x9c000 DATA 0x184000 entropy ... sha256 f957e359...
aurora 582600000.gpu: supported: 26A428 for T8142 G17G, primary then secondary
aurora 582600000.gpu: GPU firmware image not admitted: EINVAL
aurora 582600000.gpu: GPU firmware build: 26B123 for T8142 G17G, primary then secondary
aurora 582600000.gpu: GPU firmware: 27.2 (26B123), G17G

With this change:

aurora 582600000.gpu: GPU firmware build: 26B123 for T8142 G17G, primary then secondary
aurora 582600000.gpu: GPU firmware: 27.2 (26B123), G17G

Both roles acknowledged their InitData, and KDE ran on the GPU. The no-match path was checked by reading the code only.

AI-assisted, tested by me on the hardware.

firmware_variant() tries the identified builds in turn, the one the boot
loader's apple,firmware-version names first. Each try measured the
loaded TEXT again and, when it was not that build, logged
"unsupported GPU firmware build", the build it was not, and "GPU
firmware image not admitted: EINVAL", even when a later build then
matched. Without apple,firmware-version (the installed aura does not
write it on T8142), an M5 on macOS 27.2 logs three such errors for the
26A428 build before it admits 26B123.

Measure the TEXT once and try each build against that measurement
(Measured::find, which leaves the copy as it found it). Only when no
build matches, log the measured identity and every supported build,
before the existing "Unsupported GPU firmware image" line. A matched
build still logs "GPU firmware build: ...". The TEXT is now copied and
hashed once per probe rather than once per candidate build.

Assisted-by: LLM
Signed-off-by: termg <hello@termg.com>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Looks right. Measured::find() goes through digest_at(), which puts back the entropy bytes it zeroes (or hashes a separate copy when there are boot-filled ranges), so one measurement can be reused for every candidate.

Two small things:

  • A failure to find the fw-text/fw-data regions now returns from measure_text(dev)? (g17/mod.rs:1896) without a log line. Only EAGAIN is logged (:1945). Before, the same failure printed "GPU firmware image not admitted" and the probe ended in the "Unsupported GPU firmware image" line. A dev_err for the other errors in measure_text() would keep a mismatched DT or loader visible.
  • The no-match "supported:" list (:1924) walks every build's images. Builds that share an image with different core-layout configs, which firmware_variant() allows, print that image twice. Cosmetic.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

host-tests fails in g17-firmware-selection-tests.py: the test compiles the firmware-selection code from drivers/gpu/drm/asahi/g17/mod.rs against its own stub Build type, which still has a single image field. This PR's code now uses build.images (main.rs lines 64 and 89 of the generated harness), so rustc stops with E0609 no field images on type &Build and one E0599. Updating the harness's Build stub in tools/asahi/g17-firmware-selection-tests.py to the new images shape, in this PR, should make the suite build again. Locally: python3 -I tools/asahi/run-host-tests.py --only g17-firmware-selection.

Assisted-by: LLM (Claude:Opus 5.5)

…hared measurement

Follow-ups to "Log an unsupported firmware build only when none matches":

- measure_text() logged only EAGAIN. A missing fw-text or fw-data region
  (a DT or boot loader mismatch) now returned from the probe silently,
  where before it printed "GPU firmware image not admitted". Log every
  other error too.
- The "supported:" list walked every build's images, so an image shared
  by builds that differ only in their core layout (as T6041 25G83 is)
  was listed once per build. List each image once.
- g17-firmware-selection-tests.py compiles firmware_variant() against
  stub types, and its Build stub still had a single `image` with an
  identify_image() stub, so the host test stopped building (E0609 "no
  field images"). Model the new shape instead: Build::images, a stub
  measure_text() and a Measured whose find() records each image it is
  tried against, so the existing checks on the order of the candidates
  still hold. The stub dev_info!/dev_err! now build their messages, so
  the log lines are type-checked as well.

Assisted-by: LLM
Signed-off-by: termg <hello@termg.com>
@term-guy

Copy link
Copy Markdown
Contributor Author

Thanks, all three in 974032a:

  • host-tests: the harness's Build stub now has images, with a stub measure_text() and a Measured whose find() records each image it is tried against, so the existing checks on the candidate order still hold. The stub dev_info!/dev_err! now build their messages, so the new log lines are type-checked too. python3 -I tools/asahi/run-host-tests.py --only g17-firmware-selection: ok.
  • silent measure_text() errors: every error other than EAGAIN (a missing or bad fw-text/fw-data region) now logs GPU firmware image not measured (fw-text/fw-data): <err>.
  • duplicate "supported:" lines: an image shared by several builds is listed once.

drivers/gpu/drm/asahi/ builds with no new warnings (LLVM, Rust).

AI-assisted (Assisted-by: LLM).

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-review of 974032a: Blockers: 1.

From our last comments:

  1. Resolved: a measure_text() error other than EAGAIN is now logged (drivers/gpu/drm/asahi/g17/mod.rs:1956-1962).
  2. Resolved: the "supported:" list skips an image already printed (mod.rs:1925-1929). The core::ptr::eq check removes a duplicate only when builds point at the same FirmwareBuild static, which is how a shared image is meant to be listed.
  3. Resolved: the Build stub in tools/asahi/g17-firmware-selection-tests.py now has images, plus a Measured stub that records each image it is tried against, so the candidate-order checks still run.

New:

  1. Both commits (876c53c and 974032a) carry an Assisted-by: LLM trailer. Please reword them so the human Signed-off-by is the only trailer. A note that an LLM helped belongs on the PR body's last line, as Assisted-by: LLM (<vendor>:<model>). The body currently ends with "AI-assisted, tested by me on the hardware."

HW row: J704 (macOS 27.2 stub, 26B123) booted on 974032a with no apple,firmware-version on the GPU node: only the GPU firmware build: / GPU firmware: lines, no not measured or unsupported lines, GPU in use by the desktop, 0 AVC, 0 failed units, 0 new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merge-train adversarial review (MERGETRAIN-LINUX2) at 974032a: NO BLOCKERS.

Code read only, nothing built here. Before the merge it still needs Dj's verdict at this head; the missing rows are listed below.

Full review

#2585 drm/asahi: g17: Log an unsupported firmware build only when none matches @974032a4

VERDICT: NO BLOCKERS

Checked on the merge (drivers/gpu/drm/asahi/g17/mod.rs merged :1882-1966, fwid.rs):

  • Measured::find() goes through digest_at() (fwid.rs:100-140). That restores the zeroed
    entropy bytes in place, or hashes a separate copy when boot_filled is non-empty, so reusing
    one measurement across candidates is sound.
  • fwid::identify() stays in use by g16/boot.rs:491, so there is no dead code.
  • measured.identity() gets every build's images to choose the boot-filled normalization, as
    before.
  • core::ptr::eq deduplicates only images that share the same static, which is the intent.
  • Host test tools/asahi/g17-firmware-selection-tests.py passes on the merge ("PASS G17
    selection ...").
  • No gate, param or Apple-internal name is added.

Nits:

  1. mod.rs merged :1896 Self::measure_text(dev)?: a measurement failure now aborts the probe
    with that error (EAGAIN/ENOMEM/EINVAL), where before it was ENODEV after "Unsupported GPU
    firmware image". It also drops the implicit re-measure: before, a transient EAGAIN (TEXT
    changed between the two copies) on the first candidate was retried by the next candidate's
    measurement. It is logged now (:1945-1962), so this is acceptable, but say it in the commit
    message.
  2. mod.rs merged :1902: "GPU firmware build: " is logged for each build whose image
    matches, before the core-layout check. A shared image whose first build's config does not
    admit the cores (T6041 25G83 style) logs the same line twice. That is cosmetic.
  3. Commit hygiene: both 876c53c and 974032a carry an Assisted-by: LLM trailer. They are
    already pushed, so per our rule they stay (NIT, not a blocker).

Missing rows:

  • J704 (T8142, 27.2/26B123) on 974032a itself. The five-boot row in the body predates the
    follow-up commit. It should show only the GPU firmware build:/GPU firmware: lines, the
    desktop on the GPU, and 0 new kernel errors.
  • Other Firmware::Identified configs that now take the single-measurement path: T6040 (J616s,
    hw/t6040.rs:69), T6041 (M4 Max, two builds sharing an image), T6050 (hw/t6050.rs). T8140 Neo
    (hw/t8140.rs:61) is Fixed and returns early. At least one boot on J616s, with no "not
    measured"/"unsupported" lines; ideally also an M4 Max to exercise the shared-image dedup.
  • The no-match path (wrong or absent firmware) was checked only by reading the code and the
    host stub. One boot with a deliberately unlisted build, or a KUnit case, would cover the new
    error output.

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

Pre-PR checklist review at 974032a49058: 1 blocker (§4 attribution), plus §5 evidence gap on the live head.

Code and Safety Audit (§1–§3, §6)

  • Clean functionally. Verified against drivers/gpu/drm/asahi/fwid.rs (digest_at() restores in-place zeroed entropy bytes and uses a separate KVVec copy when boot_filled is non-empty, and returns None before mutating on record-validation failure), so reusing a single Measured across candidate builds is sound.
  • fwid::identify() remains used by drivers/gpu/drm/asahi/g16/boot.rs:491 and is cfg_attr-guarded against dead-code warnings.
  • measure_text() logs both EAGAIN and other fw-text/fw-data errors, and tools/asahi/g17-firmware-selection-tests.py matches the new Build::images / Measured shape and type-checks the dev_info!/dev_err! format strings.
  • CI: host-tests is green.

Blockers

  1. §4 commit trailers: Both commits (876c53cc5d70, 974032a49058) include an Assisted-by: LLM trailer in the commit message. Per §4 of the pre-PR checklist, commits must carry human author/committer identity and human Signed-off-by: only, with zero Assisted-by: or AI trailers in commit messages (disclosure stays in the PR body only).

Non-blocking Nits

  • drivers/gpu/drm/asahi/g17/mod.rs:1927: core::ptr::eq(seen, image) relies on const-promoted slices from BUILD_25G83/BUILD_26B123 (hw/t6041.rs:75-196) sharing an address across uses, which Rust does not guarantee for const (unlike static). Comparing (seen.name, seen.text_sha256) (or promoting shared image arrays to static) would make deduplication guaranteed.
  • drivers/gpu/drm/asahi/g17/mod.rs:1902: GPU firmware build: {} is logged before the core_layout.cores check, so a shared image whose first matching build doesn't admit the probed core layout logs that line twice; logging it at :1916 alongside GPU firmware: {} would avoid the duplicate.
  • drivers/gpu/drm/asahi/g17/mod.rs:1896: Self::measure_text(dev)? now propagates measurement errors (EAGAIN/EINVAL/ENOMEM) directly instead of continuing and returning ENODEV (and no longer re-measures on a transient EAGAIN). This is reasonable and logged; worth mentioning in the commit message when dropping the commit trailers.

§5 Evidence Needed on Live Head

  • Re-prove on J704 (macOS 27.2 / 26B123, no apple,firmware-version) at the updated head (the 5-boot row predates 974032a4) showing only GPU firmware build: / GPU firmware:, desktop on GPU, and the regression row (0 SELinux denials, 0 failed units, 0 new kernel errors).
  • Ideally also one boot on another Firmware::Identified Mac (T6040/T6041/T6050) taking the single-measurement path.

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.

3 participants