RC RANDOM CHAOS

Devs reverse-engineer Apple's M4 GPU for Linux in a month, using an LLM as co-driver

· via Hacker News

Original source

Building a Linux GPU Driver for the M4 Mac Mini in One Month

Hacker News →

Two developers, Cody Ho and Niklas, built an OpenGL ES 3.0-conformant Linux GPU driver for Apple’s M4 Mac Mini and MacBook Neo in roughly a month—work that typically consumes years. The result already runs WebGL in Chrome and Firefox with working compositing and pushes Minecraft to 200fps. Because Apple’s silicon routes the kernel driver through GPU firmware running a custom RTOS (RTKit) rather than talking to hardware directly, the hard part was reconstructing the undocumented AGX firmware ABI. The team leaned on a hypervisor Ho previously built to capture live hardware traces, then wrote a clean-room implementation covering a custom shader compiler/IR, command stream builder, and a full Linux kernel driver.

The A18 Pro firmware ABI proved dramatically nastier than the M1/M2 that Asahi Lina famously cracked—roughly 1.5x the structs, twice the pointers, and a more convoluted work-submission path—largely because Apple split a conventional kernel driver in half and shuttles state through shared memory structs whose firmware-owned fields must never be touched. Provenance was a first-class concern: the developers say they never inspected Apple binaries, treated required blobs as opaque, had a third party document them, and published all their experiments so the clean-room claim can be independently audited.

The novel wrinkle is methodology. Ho used OpenAI’s Codex to drive the reverse-engineering loop—capture, replay, reconstruct—and it took the ‘replay macOS, then reproduce it’ strategy literally, snapshotting entire GPU memory state and whittling down copied pages until everything was built from source. The LLM stalled on genuinely hard problems (a 336MB compute capture it spent a week failing to untangle) and needed human intervention to pick earlier, cleaner capture points, but it also showed surprisingly good instincts about when to probe the hardware further. The code isn’t ready for end users yet, with Vulkan support and broader hardening still ahead.

Read the full article

Continue reading at Hacker News →

This is an AI-generated summary. Read the original for the full story.