Repository navigation
kboot: gpu: hand the M4 (T8132) GPU to Linux on the 27.2 firmware - #379
Conversation
t604x_gpu_fw_segments() picks the GPU firmware layout from the ADT's
shape: gfx-asc segment-ranges __TEXT and __DATA, or those and a
__DATA_SHARED_RO right after __DATA that /arm-io/sgx
gfx-data-shared-ro-{base,size} describe (the 27.2 firmware). Nothing in
it is T604x-specific, and the M4 (T8132) handoff needs the same choice.
Rename it gpu_fw_layout(), declare it and its result in kboot.h, and
also return the segment list and count, which the T8132 handoff
publishes per segment. The checks and the T6040/T6041 fills are
unchanged; their host tests take the struct from kboot.h.
Signed-off-by: Diljit Singh <hey@djdev.me>
On macOS 27.2 (26B123) iBoot loads the G16G firmware as three gfx-asc
segments: __TEXT (0x64000), __DATA (0xd0000) and a 32 KiB
__DATA_SHARED_RO right after __DATA, which /arm-io/sgx describes as
gfx-data-shared-ro-{base,size}. The J773g's ADT gives them the flags 1,
0x10 and 0. The M4 handoff required exactly two segments named
__TEXT;__DATA and admitted boards other than the J713 only on 26.6.2,
so Linux booted from a 27.2 volume got no GPU.
Take the layout from gpu_fw_layout(), the helper the T6040/T6041 fills
use, so the ADT's shape chooses it:
- Two segments, as before: names __TEXT;__DATA, flags 1 and 0, two
firmware segment VAs and flags, apple,g16-handoff-version 1.
- Three segments: names __TEXT;__DATA;__DATA_SHARED_RO, flags 1, 0x10
and 0, gpu-fw-data covering __DATA and the shared-RO tail (as on
T6041), three firmware segment VAs and flags,
apple,g16-handoff-version 2.
Both keep the identity remap, consecutive firmware VAs from
0xfffffc0000000000, 16 KiB alignment, the 42-bit bound and the pairwise
overlap checks. Boards other than the J713 now also take the handoff on
27.2; the J713 still takes it on any release.
The new host test runs both layouts with one J773g's values: on 26.6.2
the regions aura published from its ADT, on 27.2 its iBoot ADT.
Signed-off-by: Diljit Singh <hey@djdev.me>
|
Hardware row from the 13" M4 MacBook Air (J713, Mac16,12, 8-core G16G, macOS 27.2 / mBoot-20457.41.3): the 27.2 handoff in this PR works. ESP Stage 2 built from
How far the GPU itself gets is kernel-side and tracked on Details
Assisted-by: LLM (Claude:Opus 5.5) |
|
The Assisted-by: LLM (Claude:Opus 5.5) |
RyanTheTide
left a comment
There was a problem hiding this comment.
One point under the project's pre-PR checklist (no model or firmware-version gating), not raised so far:
src/kboot_gpu_m4.c:66-68 still admits the handoff by board and OS release. Boards other than the J713 get it only when os_firmware.version is V26_6_2 or V27_2, and the J713 (apple,j713) gets it on any release. Everything else in this PR already selects by the hardware description. gpu_fw_layout() takes the layout from the ADT's shape and refuses any other shape, the segment names and flags are checked per layout, and a driver that doesn't know apple,g16-handoff-version refuses before it maps anything. So the release check adds no safety. It only means every new release, and every board other than the J713, needs another entry here.
Please drop the os_firmware.version clause and the apple,j713 exception. Select the handoff by the apple,agx-t8132 GPU node (already checked on the same line) and an ADT /arm-io/gfx-asc layout that gpu_fw_layout() accepts. When either is missing or the shape is unknown, keep today's return -1: no GPU handoff is published and the Mac boots on the framebuffer. The host test's "27.0 on the J773g" and "unknown release" refusals would then become "unknown ADT shape" refusals.
Assisted-by: LLM (Claude:Opus 5.5)
…yout The M4 handoff was selected by chip, by board (J713) and by the OS release (26.6.2 or 27.2). Select it by what the machine describes instead: a GPU node compatible with apple,agx-t8132, and a gfx-asc firmware layout that gpu_fw_layout() accepts. Any other shape keeps the GPU off and the Mac on its framebuffer. A DT whose GPU node is not the T8132 GPU is left untouched for its own handoff. The host tests now publish the 27.2 layout on 27.0 and the 26.6.2 layout on an unknown release, and refuse unknown ADT shapes on either. The reservation lookup takes uint64_t, as fdt_get_mem_rsv() does, so it builds where u64 is not unsigned long long. Signed-off-by: Diljit Singh <hey@djdev.me>
RyanTheTide
left a comment
There was a problem hiding this comment.
No blockers. Re-review of b2ba5cd against 897ec66.
The point from our last review is resolved. src/kboot_gpu_m4.c:70 and :183 now select the handoff only by the apple,agx-t8132 GPU node, and gpu_fw_layout() plus the per-layout segment names and flags (:115-138) pick the contract. The chip, apple,j713 and os_firmware.version clauses are gone, and a missing node or an unknown shape still ends in return -1: no handoff properties, GPU disabled, framebuffer boot. The host tests now cover that: 27.0 and an unknown release are published when their ADT shape is valid, and refused when it isn't. The uint64_t change for fdt_get_mem_rsv() fixes the macOS host build we reported.
Also checked on this head. Short or missing ADT props all fail closed: read_exact() needs the exact length, segment-names must match byte for byte, segment-ranges must be 2 or 3 entries, and the shared-RO/RW pair goes through ADT_GETPROP size checks. The stale apple,g16-handoff-version is deleted before any refusal path can return. This handoff publishes no perf states or voltages, so it adds no safety constants. A GPU node for a different GPU is now left untouched (fault 12) and doesn't get disabled; that's correct, since that GPU's own fill owns it.
Two non-blocking nits:
src/kboot_gpu_m4.c:84-91still compares the sgx/gfx-asc register windows and the four IRQs to fixed values. This fails closed and isn't a selection gate, but it is the last per-chip table in this path. If you touch it again, compare the ADT values with the DT/gpunode's ownregandinterruptsinstead of constants.tests/python/test_m4_gpu_handoff.py:78-79: the comment says gpu_fw_layout() rejects fault 11. It's the per-layout flags check inpublish_gpu_m4()that refuses it, because two segments with<1 0x10>pass gpu_fw_layout().
Hardware row: the J713 run in the body predates this head. Re-run it on a Stage 2 built from b2ba5cd on the J713, 27.2, default cmdline. Pass if the boot log shows "published M4 G16 memory resources (3 firmware segments)", /gpu has apple,g16-handoff-version = <2>, dEQP-VK smoke has 0 failures, and 3/3 warm reboots come up with 0 GPU faults.
Assisted-by: LLM (Claude:Opus 5.5)
|
Row on the M4 Air (J713, macOS 27.2 stub) for b2ba5cd: one aura-try Stage 2 one-shot of the J713's configured aura plus only this commit (so the gate is the only change against its default), default kernel, stock command line.
Not covered by this row: warm reboots on this head (a one-shot boots once), and the Stage 2 console line itself (Linux sees its result, the DT property above). Assisted-by: LLM (Claude:Opus 5.5) |
|
J773g (Mac mini M4, macOS 27.2 / 26B123 firmware) row on head b2ba5cd: PASS
Still pending: the J713 re-run on b2ba5cd and review. Assisted-by: LLM (Claude:Opus 5.5) |
|
The J713 re-run on b2ba5cd is the row in our comment just above (10:49Z): PASS, Assisted-by: LLM (Claude:Opus 5.5) |
RyanTheTide
left a comment
There was a problem hiding this comment.
Approving b2ba5cd. The handoff is now chosen only by the apple,agx-t8132 GPU node and an ADT firmware layout gpu_fw_layout() accepts (no chip, board or OS-release gate), anything else boots on the framebuffer, and missing or short ADT properties fail safe. Proven on two Macs on 27.2: our J713 one-shot (gate the only change against its default: apple,g16-handoff-version = <2>, G16 READY, dEQP-VK smoke 5/5, 0 firmware crashes) and the J773g row (console published M4 G16 memory resources (3 firmware segments), Vulkan smoke PASS); CI green. Non-blocking nits from our earlier comment still stand (fixed sgx/gfx-asc register values at kboot_gpu_m4.c:84-91, the fault-11 test comment).
Assisted-by: LLM (Claude:Opus 5.5)
The M4 (T8132, G16G) GPU handoff now works with the macOS 27.2 (26B123) firmware layout as well as 26.6.2. Until now, Linux booted from a 27.2 volume on a J773g (Mac mini) got no GPU. The Linux G16 driver is moving to the 26B123 firmware ABI; this is the boot side.
What changed in 27.2
On 27.2, iBoot loads the G16G firmware as three
/arm-io/gfx-ascsegments instead of two. The extra one is a 32 KiB__DATA_SHARED_ROplaced right after__DATA, which/arm-io/sgxdescribes asgfx-data-shared-ro-{base,size}. This is the same shape T6041 has on 27.2 (#373). From the J773g's own iBoot ADT on 26B123:__TEXT__DATA__DATA_SHARED_ROsegment-namesis__TEXT;__DATA;__DATA_SHARED_RO, andgfx-data-shared-rw-{base,size}are 0. The UAT regions, the sgx and gfx-asc register windows and the IRQs are the same as on 26.6.2.What this does
t604x_gpu_fw_segments()becomesgpu_fw_layout(), declared inkboot.h. It also returns the segment list and its count. T6040, T6041 and now T8132 all use it, and its checks and the T6040/T6041 fills are unchanged.kboot_gpu_m4.c) takes its layout from that helper, so the ADT's shape chooses it:__TEXT;__DATA, flags<1 0>,gpu-fw-data=__DATA,apple,g16-handoff-version= 1.__TEXT;__DATA;__DATA_SHARED_RO, flags<1 0x10 0>.gpu-fw-datacovers__DATAand the shared-RO tail, as on T6041.apple,firmware-segment-vasandapple,firmware-segment-flagsget three entries, andapple,g16-handoff-version= 2. A version-1 driver refuses this contract before it maps anything.apple,agx-t8132, and a/arm-io/gfx-ascfirmware layout thatgpu_fw_layout()accepts. Any other shape keeps the GPU off and the Mac on its framebuffer. The earlier chip, J713 and OS-release (26.6.2/27.2) clauses are gone. A DT whose GPU node is not the T8132 GPU is left untouched for its own handoff.Why the ADT shape decides: as Ryan asked on #373, the layout follows the hardware description (the segment count and the sgx
gfx-data-shared-ropair), not the machine or the release it was tested on. A two-segment ADT on 27.2 still gets version 1, and a three-segment ADT on the J713 gets version 2.What Linux sees on a J773g on 27.2 (live ADT values):
/gpu:apple,g16-handoff-version = <2>,apple,firmware-segment-vas = <0xfffffc0000000000 0xfffffc0000064000 0xfffffc0000134000>,apple,firmware-segment-flags = <1 0x10 0>/reserved-memory/gpu-fw-text:0x10000d04000 + 0x64000/reserved-memory/gpu-fw-data:0x100011a4000 + 0xd8000(__DATA0xd0000 +__DATA_SHARED_RO0x8000)uat-ttbs,uat-pagetables,uat-handoff,uat-shared-l2: unchanged. There are no new nodes ormemory-region-names, and the six memreserves match.Tests
tests/python/test_t8132_gpu_fill.py, 28 cases, with the failure model written down first. It fails on main, where the 27.2 layout is refused, and passes here. Vectors:test_m4_gpu_handoff.py,test_t6040_gpu_fill.pyandtest_t6041_gpu_fill.pynow take the helper and its struct from the source. Intest_m4_gpu_handoff.py, the J715-on-26.6 refusal is now an unknown-ADT-shape refusal, and a GPU node of another GPU is left untouched. All pass, as do the G15 and T6031 host runners that include this file.uint64_t, asfdt_get_mem_rsv()does, for the macOS host build whereu64is notunsigned long long.Checks (run locally: Actions macOS runners are out)
Each check below was run on this head, rebased on main c879917, and on c879917 itself.
make format-checkwith clang-format 20.1.8: clean.make rustfmt-check: clean.tools/stage1_size.shwith clang (USE_CLANG=1 BUILDSTD=1 BUILTIN_LOGO=aurora, 4 flavours): all link. Shipping Stage 1 headroom is 16608 B (main 16624 B, so this costs 16 B; the floor is 4096). secure-audit and secure-enforce: 147800 B. dev-audit: 16416 B.RELEASE=1 CHAINLOADING=1 BUILTIN_LOGO=aurora, thenESP_STAGE2=1): both build. aura.bin is 1638400 / 3997696 B, the same as main.test_t8132_gpu_fill,test_m4_gpu_handoff,test_t6040_gpu_fill,test_t6041_gpu_fill) pass with gcc and clang, and also on the first commit alone.test_m3_defaults_optoutx7,test_smp_legacy_rvbarx2,test_chainload_run_base,test_payload_cpu_policy,test_siliconforest_handoff,test_smp_timeouts). Those are host-only: clang 23 warnings and an updater-script path.Hardware
Assisted-by: LLM (Claude:Opus 5.5)