#18523·tinygrad

macOS TinyGPU over TB5 dock: RM's mid-boot BAR1 reprogram leaves established mappings stale (all-ones page-table reads); fresh IOConnectMapMemory64 reads valid — RESIZE_BAR re-map is the fix point

Author: ExcrotheCreated Sep 30, 2026Updated Sep 30, 2026

Title

macOS TinyGPU over TB5 dock: RM's mid-boot BAR1 reprogram leaves established mappings stale (all-ones page-table reads); fresh IOConnectMapMemory64 reads valid — RESIZE_BAR re-map is the fix point

Body

Summary

On macOS with the TinyGPU DriverKit system extension, GPU boot over a Thunderbolt 5 dock reaches GSP_INIT_DONE, then dies reading the root page-table entry as 0xFFFFFFFFFFFFFFFF through the established BAR1 mapping — the known "all-ones" signature of #15638. We ran the discriminator on the same faulted GPU state: a fresh mapping (new server process + new IOConnectMapMemory64, no GPU reset) reads valid data, and the page-table walk that failed every prior run completes and reaches NV90F1_CTRL_CMD_VASPACE_COPY_SERVER_RESERVED_PDES.

Conclusion: the RM firmware's mid-boot BAR1 window reprogram (around the reserved-PDES copy) invalidates established host mappings; the GPU, its window, and VRAM stay healthy. The tunnel replays config-space fine, so the dock looks guilty — but the mapping lifecycle is the fault site. The fix point already exists in the protocol: server.c's CMD_RESIZE_BAR is currently a noop. Patch below.

Environment

  • Mac Studio (Apple Silicon), macOS 27.0
  • TinyGPU.app + system extension org.tinygrad.tinygpu.driver2 1.0.0/3 (teamID 9YG3G8543N), approved/activated
  • tinygrad @ master 5b4f52860, Python 3.11 (macOS APL wiring restored locally per pre-#17984; #15652 registry keys applied for usb-devfmt boot)
  • Link S-3 TB5 dock (Intel TBT5 controller, fw 62.62), 80 Gb/s USB4v2 tunnel, GPU behind the dock's PCIe bridge
  • Cards: RTX 5070 (GB202, 10de:2f04) and RTX 3090 (GA102, 10de:2204), one at a time, same dock port

Measured behavior

Card First boot after dock power-cycle Later boots without a GPU power cycle
RTX 5070 (GB202) clean — Device["NV"] constructs, 3/3 runs all-ones fault at the PT walk, 3/3 — persists through PCIe FLR (dext ResetDevice)
RTX 3090 (GA102) all-ones fault at the PT walk, every run (also after FLR) same

Fault site: init_golden_image → mm.page_tables(...) → level_down → root PT entry read returns all-ones (the memory.py assert path).

Positive result first: GB202 completes boot from cold through this same dock — the stack fundamentally works over TB5. This issue is about the mapping lifecycle across the RM's BAR reprogram, which is what breaks warm re-boots (GB202) and first boots (GA102 here).

Root-cause evidence (the discriminator)

On a warm-faulted GB202 (all-ones through the established mapping, deterministic):

  1. Kill the TinyGPU server process; spawn a fresh server; fresh IOConnectMapMemory64 on the same GPU state (no reset, no replug).
  2. The same BAR1 offset through the fresh mapping reads valid data (0x0), not all-ones.
  3. Retrying the failed page-table walk through the fresh mapping: the walk completes and the boot proceeds to NV90F1_CTRL_CMD_VASPACE_COPY_SERVER_RESERVED_PDES — further than any prior run on this hardware.

So: established mappings go stale across the RM's mid-boot window reprogram; fresh mappings read the new window correctly. Killing the server is not a workaround — the GSP RPC ring lives in server-owned DMA sysmem registered through the same user client, so server death orphans the GSP (the fresh-map boot above then times out waiting for GSP RPC responses). The fix must re-map without tearing down the user client.

Additional negatives, measured: the fault survives PCIe function-level reset (ResetDevice → FLR → re-boot still faulted); the dext refuses a second user client during GSP init (so a "rescue server" mid-boot is not viable either).

Proposed fix (ready to PR)

server.c: implement the existing CMD_RESIZE_BAR (currently case CMD_RESIZE_BAR: break;) as unmap + fresh map, on the live connection:

c
case CMD_RESIZE_BAR: {
  // re-map on demand: the RM firmware reprograms BAR windows mid-boot
  // (NV90F1 COPY_SERVER_RESERVED_PDES); established mappings go stale
  // while the GPU and the new window stay healthy.
  if (req.bar >= MAX_BARS) { resp.status = 1; break; }
  if (g_bars[req.bar].addr)
    IOConnectUnmapMemory64(g_conn, req.bar, mach_task_self(), g_bars[req.bar].addr);
  g_bars[req.bar].addr = 0;
  resp.status = map_bar(req.bar, &resp) ? 1 : 0;
  break;
}

tinygrad side: on an all-ones 8-byte BAR read (the page-table signature), resize_bar(bar) once and retry the read.

Verification status: the dext's MapBar external method has no state precondition (callable at any time — read in the dext source, and a second user client maps BARs fine when the GPU is idle); the stale-vs-fresh mechanism is measured (above). We could not execute the patched server at runtime: a locally built binary cannot open the dext's user client without the com.apple.developer.driverkit.userclient-access entitlement (unentitled → kIOReturnNotPermitted; adhoc-signed-with-entitlement → killed at exec), so the fix needs an entitled build — i.e. this repo's signed app. The patch is small and the test procedure is below.

Reproduction

  1. Approved dext + app; NVIDIA GPU in a TB5 dock; macOS.
  2. Power-cycle the dock; Device["NV"] → GSP_INIT_DONE; on the cards above the boot dies at the first root-PT read (all-ones) — GA102 here faults on first boot; GB202 faults from the second boot on.
  3. Discriminator: kill the server, connect a fresh one (same GPU state) → the same read returns valid data; the walk completes.

Related

  • #15638 — GA102 + TB dock, same signature; this narrows the mechanism to per-mapping staleness across the RM's BAR reprogram (and shows GB202 cold-boots clean through a TB5 dock)
  • #15652 — usb-devfmt registry keys (used here to get GSP boot at all)
  • #17984 — removed the macOS APL device-selection wiring (restored locally to test; happy to PR that back too)

Happy to open the PR for the RESIZE_BAR implementation + the client-side retry, and to attach the full probe logs.

— (probes are scripted and reproducible; happy to share the harness)


Filed by Jacob Hawley. All probes are scripted and reproducible; run logs and probe scripts available on request.


Testing status (updated): the RESIZE_BAR implementation referenced above was submitted as #18524 without runtime testing (compile + mock-layer checks only — I don't have the signing capability to run a patched server), and that PR has been closed. The measurements in this issue stand on their own: they were taken on real hardware with the stock, entitled binary, and they describe the fault precisely — established mapping reads all-ones at the first PT walk; a fresh IOConnectMapMemory64 at the same GPU state reads valid data; the faulted walk completes through the fresh mapping. A fix submission will come only with hardware-run evidence attached.

— Jacob Hawley