bk99.de entertain the web since 1997

Native Linux GPU driver for Apple M1

Summary

Asahi Lina describes the reverse engineering and architecture of the first native Apple M1 GPU kernel driver for Linux. The GPU firmware runs on an ARM64 coprocessor with Apple's RTKit. The prototype connected Mesa with real hardware via drm-shim and Python.

Ideas

  • Apple's GPU firmware takes over scheduling, preemption, power management and error handling.
  • Driver and firmware exchange complex structures via shared memory.
  • m1n1 records firmware communication and memory accesses for analysis.
  • A Python prototype speeds up experiments before the kernel implementation.
  • Rust models object lifetimes and firmware variants more safely than manual C.

Insights

  • Prototypes in high-level languages can deliver hardware insights faster than kernel code.
  • Firmware-centred hardware shifts reverse engineering from registers to protocols.
  • Memory safety becomes particularly important with foreign, barely validated pointer structures.

Facts

  • The driver had to manage more than a hundred interlinked structures.

Recommendations

  • Stabilise data models in prototypes before committing to a permanent kernel UAPI.
  • Test firmware versions separately and log every structural deviation.

References

Read the original article

Search the Web Archive