# SkyIOS: iOS 16 on a Redmi Note 10 Pro, and a Metal Driver for the Adreno 618

> XNU and the iPhone X's iOS 16 userland boot on a Snapdragon 732G phone. I made CoreAnimation render on the Adreno 618: a Rust GPU driver inside XNU, a fake Apple Metal device, and an offline AIR to ir3 shader pipeline. From 7 fps to 55.

- Author: Maulana Sodiqin (https://msdqn.dev)
- Published: Nov 20, 2026
- Updated: Nov 20, 2026
- URL: https://blog.msdqn.dev/blog/skyios-ios-on-android-metal-driver-adreno
- Tags: ios, xnu, metal, gpu, adreno, rust, reverse-engineering

There is a Redmi Note 10 Pro on my desk that boots Apple's XNU kernel and the unmodified iOS 16.7.16 userland from an iPhone X. It shows the lock screen, the home screen, Control Center and Settings. Since this week, every pixel of that UI is drawn by the phone's Adreno 618 GPU through a Metal driver I wrote, instead of by the CPU.

This post covers how the port works and how I built the GPU side: about 4,000 lines of Rust running inside XNU to power up and drive the Adreno, and about 3,500 lines of Objective-C that convince CoreAnimation it is talking to an Apple GPU. The project is called SkyIOS, and the code is at [github.com/maulanasdqn/skyios](https://github.com/maulanasdqn/skyios).

<img src="https://raw.githubusercontent.com/maulanasdqn/skyios/main/docs/images/lockscreen-0112a.png" width="260" alt="iOS 16 lock screen on a Redmi Note 10 Pro"> <img src="https://raw.githubusercontent.com/maulanasdqn/skyios/main/docs/images/homescreen-0113t.png" width="260" alt="iOS 16 home screen on a Redmi Note 10 Pro">

> [!warning]
> This is a research project, not a usable phone. Security is off, there is no cellular, audio or camera, and flashing it erases Android user data.

## Where it started

SkyIOS is a fork of [ios-sweet](https://github.com/dipa-studio/ios-sweet) by dipa-studio. In October, that project did the part most people would call impossible: it got XNU booting on a Snapdragon phone and brought the iOS userland all the way up to SpringBoard. About 230 commits landed between October 14 and October 23. I forked it on November 14, and the 222 commits since then are mine.

To understand the GPU work, you need to know how the port boots and what it was missing, so here is the short version.

### The hardware and why it fits

| | Redmi Note 10 Pro (`sweet`) |
| --- | --- |
| SoC | Snapdragon 732G (SM7150) |
| CPU | 2× Cortex-A76 + 6× Cortex-A55, ARMv8.2 |
| RAM | ~3.95 GiB usable (upper DDR bank at `0x100000000`) |
| GPU | Adreno 618 |
| Panel | 1080×2400 |
| Interrupts | GICv3, 19.2 MHz timer |

The key detail is that ARMv8.2 has no pointer authentication (PAC). Modern Apple kernels are built for `arm64e`, which uses PAC. So the kernel is built as plain `arm64` with a custom machine config called `SWEET` (16K pages, GICv3, `-march=armv8.2-a+crypto`). The userland comes from the iPhone X because its A11 chip also predates PAC. Every binary in that IPSW is plain arm64, so it runs on these Kryo cores without changes.

### The boot chain

Nothing is flashed to the boot partition. The phone's own Xiaomi bootloader starts a temporary image over USB:

```
Stock Xiaomi bootloader (unlocked)
  → fastboot boot shim-boot.img          (temporary, nothing flashed)
    → skyios-shim (Rust, no_std)
      → XNU + Apple Device Tree + boot-args
        → UFS → HFS+ root → dyld → launchd → SpringBoard
```

`shim-boot.img` is an ordinary Android boot image. The bootloader thinks it is starting a Linux kernel, but the "kernel" is a small shim and the "ramdisk" is XNU. The shim copies the Mach-O segments to their physical addresses, builds an Apple Device Tree (ADT) and XNU's `boot_args`, and jumps:

```rust
core::arch::asm!("dsb sy", "ic iallu", "dsb sy", "isb", options(nostack));
let entry: extern "C" fn(u64) -> ! = core::mem::transmute(entry_pa as usize);
entry(ba_pa)
```

The ADT is generated, not copied. It is how XNU learns about the machine, and it is also how the phone pretends to be an iPhone X: root `compatible` is `D22AP, iPhone10,3`, the display node reports a 1125×2436 canvas, and `/chosen` carries the values that make activation take its local path with no Apple servers.

One of my first changes in the fork was rewriting the shim and the host tooling in Rust. The shim had been C, and the tools were Python scripts. The new `skyios` CLI (about 4,200 lines) was checked byte for byte against the Python output before the Python was deleted.

### Building XNU without the closed parts

Apple publishes XNU's source, but an Apple device kernel also links closed pieces: corecrypto, the trust cache, AMFI, the platform expert, performance counters. The kernel is built on GitHub's macOS runners with [blacktop/darwin-xnu-build](https://github.com/blacktop/darwin-xnu-build) (xnu-8796, the iOS 16 era), plus a patch series that is now 123 patches long. Many of the early patches exist to fill holes:

| Missing piece | Replacement |
| --- | --- |
| Kernel PRNG (registered by closed corecrypto) | HMAC-SHA256 DRBG |
| AES, MD5, SHA-1/384/512 | BearSSL, compiled without SIMD |
| pthread kernel extension | Apple's open-source libpthread |
| HFS+ | Apple's open-source hfs |
| Platform expert | `SweetPlatformExpert`, driven by the ADT |
| AMFI | A built-in MAC policy that trusts every signed binary on the root |

The debugging story deserves its own post. This phone has no serial port, since the debug UART pins are wired to SPI. In the first days, the only output was text drawn on the panel, read from photos and blurry videos. Later came a 4 MiB log ring written to the end of `userdata` and read back from recovery, a USB Ethernet link with a live kernel console, and screenshots captured into a reserved disk area.

By October 18, the home screen worked. But it was rendered entirely by the CPU.

## Why the GPU mattered

iOS draws its UI with CoreAnimation, and CoreAnimation on iOS 16 expects Metal. With no GPU, `backboardd` (the process that composites every frame) fell back to software rendering. The numbers were bad:

- 6 to 7 frames per second while touching the screen
- `backboardd` using up to 330% CPU
- Taps registering as long presses, because SpringBoard's main thread was too late to see the touch-up before the 0.5 s long-press timer fired

You can tune the scheduler and block noisy daemons, and I did both. But a phone UI rendered on eight mobile cores does not get to 60 fps. The Adreno 618 had to work, and iOS had to believe it was a Metal GPU.

That breaks into three problems:

1. **Power the GPU on and make it execute commands** from inside XNU, with no Linux driver to lean on.
2. **Expose it to userspace** the way an Apple GPU is exposed, so Metal loads a driver for it.
3. **Translate what CoreAnimation asks for**, meaning Metal pipelines and draws, into Adreno command streams and shaders.

## Rust inside XNU

I wrote the kernel side in Rust. With no debugger, one bad pointer in a driver corrupts memory silently and the phone reboots with no clue why. The GPU code juggles ring buffers, DMA, SMMU page tables and fences, and that is exactly where C bugs hide for weeks.

`skyios-kernel` is a `no_std` static library linked straight into the kernel. The target spec is the important part: XNU is Mach-O, and kernel code may not touch floating point or SIMD registers.

```json
{
  "binary-format": "mach-o",
  "abi": "softfloat",
  "features": "+v8a,+strict-align,-neon",
  "panic-strategy": "abort",
  "relocation-model": "static",
  "disable-redzone": true
}
```

It is built with nightly `-Z build-std=core,compiler_builtins`, and the build script rejects the archive if it has any undefined symbol other than the `sweet_rs_*` hooks and `mem*`. One line in XNU's makefiles links it into the kernel:

```make
LD_KERNEL_ARCHIVES = $(LDFLAGS_KERNEL_SDK) -lfirehose_kernel $(SWEET_RUST_LIB)
```

The boundary with the kernel is a small set of C functions written in the XNU patches: MMIO mapping (`ml_io_map`), boot-arg parsing, delays, sleeping, spawning kernel threads, contiguous DMA allocation (`kmem_alloc_contig` + `kvtophys`) and cache maintenance to the point of coherency. Rust exports the other direction: `sweet_rs_gpu_blit`, `sweet_rs_gpu_compose`, `sweet_rs_gpu_wait`, and the `sweet_rs_gpu_user_*` functions that userspace submissions go through.

## Powering up the Adreno

The Adreno 618 is not one device. It has a GPU core (GX), a small Cortex-M3 power controller called the GMU that runs its own firmware, a command processor (CP) that runs Qualcomm's SQE microcode, and an SMMU in front of all of it. Linux's `drm/msm` driver was my reference, but it assumes clock, regulator, interconnect and firmware frameworks that do not exist in XNU. Everything had to be done with raw register writes.

The bring-up is split into stages behind a boot arg, `sweetgpu=N`, so a bad stage could be skipped without rebuilding:

| Stage | What happens | Proof it worked |
| --- | --- | --- |
| 1 | GCC clock branches, CX power domain, GMU clock at 200 MHz | GMU registers read back |
| 2 | Write `a618_gmu.bin` into the GMU's instruction memory and reset it | `FW_INIT_RESULT == 0xbabeface` |
| 3 | Program RSC/PDC, vote the GX and MX rails, turn on GX | First RBBM register read |
| 4 | Map GMU memory in the SMMU, start HFI | GMU firmware version reported |
| 5 | Load SQE, start the ring, run commands | A scratch register changes |

Each stage meant several boots. The first GPU commit was on November 14. GX first powered on November 15, on boot `0103g`.

### The GMU firmware assert

Stage 3 failed in a way that took the most digging. After asking the GMU to bring the GPU out of slumber, the request timed out and `GMU2HOST_INTR_INFO` read `0x00800000`, which means `CM3_FAULT`: the GMU firmware had crashed.

There is no documentation for this firmware, so I disassembled it. I built a Thumb disassembly with `clang --target=thumbv7m-none-eabi` and an `.incbin` of the blob. Then I found the firmware's fault handler and dumped the record it writes into data memory at `0x1e00`: a `0xdead5aab` marker, then r4 to r11, sp, pc and lr. The registers pointed at a function that ends like this:

```
ldrb  r1, [r0, #0x14]
lsls  r1, r1, #31
bne   ok
bkpt  #0          @ ITCM 0x3482
```

The firmware was hitting a deliberate breakpoint because bit 0 of one word in a boot struct was zero. Tracing which register fills that word led to `GMU_RPMH_CTRL`. The end of Linux's `a6xx_gmu_power_config` sets the RPMh interface, LLC, DDR, MX, CX and GFX vote enable bits in that register, and my port had skipped it. One write fixed it:

```rust
const RPMH_CTRL_ENABLE: u32 = (1 << 0) | (1 << 4) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11);
gmu.write(GMU_RPMH_CTRL, gmu.read(GMU_RPMH_CTRL) | RPMH_CTRL_ENABLE);
```

A second bug was hiding behind it. The power controller sends rail votes to an RPMh address that is looked up in `cmd-db`, a table the bootloader leaves in memory. My code used the `gfx.lvl` address `0x30090` from the SC7180 (another chip with an Adreno 618). Dumping cmd-db on this phone showed `gfx.lvl` at `0x30050`. Same GPU, different SoC, different address.

### HFI v1

Once the GMU runs, the kernel talks to it over HFI: shared-memory queues for commands, responses and debug messages. This GMU firmware speaks the old v1 protocol, and four bugs stalled it:

- The queue table was filled in **after** telling the GMU to initialize HFI, so it read an empty table.
- Queues were read through a stale CPU cache, and the ack sequence number came from the wrong word.
- The performance table listed frequencies in MHz. The firmware wants kHz.
- I sent a `START` message, which only exists in v2. The v1 firmware never acks it.

Linux has a comment about that last one, and I copied it into `hfi.rs` so I would not make the mistake twice:

```rust
// a6xx_hfi_start_v1(): the legacy (v1) GMU gets no HFI message after
// TEST until the next boot; START is a v2 message and is never acked here
```

The GPU first came up at about 9.6 MHz. Setting the clock uses the legacy DCVS registers, not HFI:

```rust
gmu.write(GMU_DCVS_ACK_OPTION, 0);
gmu.write(GMU_DCVS_PERF_SETTING, (3u32 << 28) | perf_index);
gmu.write(GMU_DCVS_BW_SETTING, 0xff);
gmu.write(GMU_HOST2GMU_INTR_SET, 1 << OOB_DCVS_SET);
```

Performance index 4 is 430 MHz. I checked it against hardware counters: 4,743,293 CP cycles in 211,800 ticks of the 19.2 MHz always-on counter works out to 430 MHz.

## The first GPU command

The command processor reads PM4 packets from a ring buffer. There are two packet types that matter. Type 4 writes registers, and type 7 runs an opcode. Each header carries parity bits, and getting them wrong makes the CP reject the packet:

```rust
fn pkt4(reg: u32, cnt: u32) -> u32 {
    (4 << 28) | cnt | (parity(cnt) << 7) | ((reg & 0x3ffff) << 8) | (parity(reg) << 27)
}
fn pkt7(op: u32, cnt: u32) -> u32 {
    (7 << 28) | cnt | (parity(cnt) << 15) | ((op & 0x7f) << 16) | (parity(op) << 23)
}
```

The ring is 32 KiB. After `CP_ME_INIT`, the first real command writes `0x5ca1ab1e` to `CP_SCRATCH0` and `0xc0ffee01` to memory. When both values showed up, the log printed `FIRST GPU COMMAND EXECUTED` on boot `0110a`, November 15.

Then the next problem showed up. A 2D fill wrote 0 out of 1536 pixels, even though every register read back with the right value.

The GPU was still in **secure mode**. Qualcomm boots the Adreno so it can only touch protected memory until a signed "zap shader" is loaded through TrustZone. Writing the trust register directly hung the CPU thread. The fix was to do it the way Linux does: call TrustZone with Qualcomm's SMC interface (peripheral ID 13), hand it the `a615_zap` firmware, let it authenticate and reset the GPU, then send `CP_SET_SECURE_MODE(0)` from the ring. After that, `RBBM_SECVID_TRUST_CNTL` went from 1 to 0 and the fill wrote every pixel.

That same day, the GPU presented its first frame to the panel, at 34 ms per frame. That was the clock at 9.6 MHz. At 430 MHz, the same full-screen copy takes about 1.9 ms.

### SMMU and memory

Every GPU memory access goes through the Adreno SMMU. The kernel builds AArch64 stage-1 page tables for two streams: the GPU in context bank 0, and the GMU (stream ID 5) in context bank 4. The GPU address space is laid out by hand:

| IOVA | Contents |
| --- | --- |
| `0x0100_0000` | SQE firmware, ring buffer, scratch and fences |
| `0x4000_0000` | Panel framebuffer |
| `0x8000_0000` | Surfaces |
| `0xc000_0000` | User buffers (512 MiB) |

There are no GPU interrupts yet. Fences are a `CP_EVENT_WRITE` with `CACHE_FLUSH_TS` that writes a sequence number to memory, and the kernel polls that word every 2 µs, with a 1 second timeout. Polling is crude, but it is easy to reason about when you are debugging from log files.

User submissions are wrapped in protected mode, using the same register protection table as Linux, so userspace command buffers cannot reprogram the GPU's privileged registers:

```rust
ring.emit(pkt7(CP_SET_PROTECTED_MODE, 1)); ring.emit(1);
ring.emit(pkt7(CP_INDIRECT_BUFFER, 3));
ring.emit(iova as u32); ring.emit((iova >> 32) as u32); ring.emit(dwords);
ring.emit(pkt7(CP_SET_PROTECTED_MODE, 1)); ring.emit(0);
```

## Pretending to be an Apple GPU

A working GPU in the kernel is not enough. iOS has to find it and load a Metal driver.

I found out how by disassembling `_MTLRegisterDevices` in the iOS 16.7.16 dyld shared cache. Metal searches IOKit for services matching `IOAcceleratorES`, reads two properties, `MetalPluginName` and `MetalPluginClassName`, and loads `/System/Library/Extensions/<name>.bundle`. On a real iPhone X, that bundle is `AGXMetalA11.bundle`. The class it names must subclass `_MTLDevice`, and Metal calls `initWithAcceleratorPort:` on it.

So the kernel publishes a service that says to load a different bundle:

```cpp
setProperty("MetalPluginName", "SkyAdrenoMetal");
setProperty("MetalPluginClassName", "SkyAdrenoMetalDevice");
char procs[128] = "skyios-accel-test";
(void)PE_parse_boot_argn("sweetmetal_procs", procs, sizeof(procs));
setProperty("SkyMetalProcs", procs);
```

`SkyAdrenoAccel` is the kernel driver behind it. Its user client has a small set of selectors: info, allocate, free, submit, wait, log, import an IOSurface by ID, and submit with a list of surfaces to flush. That is the whole interface between the Metal driver and the GPU.

The userspace side is `SkyAdrenoMetal.bundle`. It has no headers for Apple's private `_MTLDevice`, so it builds the device class at runtime:

- `objc_allocateClassPair(NSClassFromString(@"_MTLDevice"), …)` creates `SkyAdrenoMetalDevice`, which adopts `MTLDevice` and `MTLDeviceSPI`.
- Constants like the feature profile are copied from what `AGXA11FamilyDevice` reports, so CoreAnimation takes the same code paths as on an iPhone X. `name` returns `Adreno 618 (SkyIOS)`.
- `resolveInstanceMethod:` logs every selector it does not implement, once, and installs a stub that returns nil. This was how I found what CoreAnimation actually calls: boot, read the list, implement the next missing method.

Which GPU families you claim matters a lot. With `Apple4`, CoreAnimation tried to build tile-shading pipelines that the Adreno cannot run, and aborted. With no Apple family at all, it drew nothing. Claiming `Apple1` to `Apple3` plus `Common1` and `Common2` is the setting that works.

Encoders append PM4 packets to a buffer. `commit` copies it into a GPU allocation, submits it, and waits for the fence on a dispatch queue that then runs the completion handlers. IOSurfaces, which is how every layer and window in iOS shares pixels, are imported into the GPU address space once per process.

## Shaders: from Apple's AIR to Adreno's ir3

This was the biggest piece of work. Metal shaders ship as AIR, Apple's LLVM-based intermediate format, and CoreAnimation's live in a metallib inside QuartzCore. The Adreno runs ir3, Qualcomm's ISA, and the only open compiler for it is in Mesa. There is no path from one to the other, so I built one, offline:

1. **Specialize.** `airspec.py` takes one QuartzCore shader function and one set of function constants, and runs Apple's `air-opt -O2` to fold them in.
2. **Lift.** `air2glsl.py` (about 1,000 lines) translates the specialized AIR into GLSL 4.50.
3. **Compile.** `glslangValidator` turns the GLSL into SPIR-V. A small tool built inside the Mesa tree compiles that with Mesa's ir3 compiler, and borrows the register setup from gallium's `fd6_program.cc`.
4. **Embed.** `genprogs.py` writes the results into `SkyPrograms.h`, a 12,000-line generated table.

At runtime, the driver looks up a pipeline by its vertex and fragment keys and gets a ready-made Adreno program. 82 of the 86 programs CoreAnimation needs on the lock and home screens compile. The test suite still uses six shaders I assembled by hand from raw instruction words, including the first one that ever ran: a fragment shader that writes solid red.

The first Metal render-encoder triangle ran on November 16. CoreAnimation's first real draws executed on the Adreno on November 18. On November 20 at 09:52, the full lock screen and home screen rendered correctly through CoreAnimation, on the GPU, with compiled shaders.

## The bugs that cost the most time

**The CP hang that was not at IB 57.** The GPU hung partway through a frame, and the CP's state said it was at indirect buffer 57. That number turned out to be the prefetch position, not the packet it was executing. I added a `CP_MEM_WRITE` progress marker after every draw, and the last marker pointed at a framebuffer-fetch draw: a shader sampling the 64×64 target it was drawing into. Adreno cannot read and write the same target in one draw. The first fix was fixed-function blending (`ONE`, `ONE_MINUS_SRC_ALPHA`). The general fix is `fbCopy`, which copies the color attachment with the 2D engine before the draw, between cache flushes.

**The whole phone froze.** Mapping GPU buffers into a process with `kIOMapWriteCombineCache` hung the entire phone, not just the GPU. The fix was cached mappings plus explicit cache clean and invalidate around every submit and wait.

**The GPU died after 8 frames, permanently.** The SMMU was configured to stall on a fault, and nothing ever resumed it. Clearing `CFCFG` makes faults abort instead, so the GPU survives a bad access, logs it, and the kernel retries once. The access itself was a `CP_LOAD_STATE6` header where the texture count had been shifted into the state type field.

**Faults at address 0 in Settings.** Settings allocates far more buffers than the lock screen. The 128 MiB user window filled up, then the 320 buffer slots ran out, uploads silently returned 0, and the GPU read from address 0. Now the window is 512 MiB, there are 2,048 slots, and a draw whose upload failed is skipped instead of submitted.

**Stuck at 10.4 frames per second.** The GPU was fast, but QuartzCore kept presenting at 10.4 swaps per second. It paces itself from an `IOMFBDisplayRefresh` property that this display driver never published. Publishing it (16.667 ms) got to 39 per second. Then I changed submissions to flush only the surfaces a command buffer actually used, instead of every surface, and that got to 54.

## Where it stands

| | Before (CPU) | Now (Adreno 618) |
| --- | --- | --- |
| Renderer | CoreAnimation software fallback | CoreAnimation Metal renderer |
| Frame rate | 6–7 fps while touching | 52–57 swaps/s |
| GPU clock | n/a | 430 MHz |
| Full-screen present | n/a | ~1.9 ms |

The code from these eight days:

| Part | Language | Lines |
| --- | --- | --- |
| GPU kernel driver (`skyios-kernel`) | Rust | ~4,070 |
| Metal driver bundle (`skyios-metal`) | Objective-C | ~3,470 |
| AIR to ir3 shader pipeline (`tools/air-spec`) | Python, C++ | ~2,200 |
| Host CLI (`skyios-tool`) | Rust | ~4,200 |
| XNU patches 0083–0121 | C, C++ | |

Still unfinished:

- **Arbitrary shaders.** Only the precompiled CoreAnimation programs work. An app that brings its own Metal shaders gets nothing yet, because there is no on-device AIR compiler.
- **Extended-range color.** The driver turns off CoreAnimation's 10-bit framebuffer, and the `BGRA10_XR` formats are not handled.
- **A missing clock.** Reusing the framebuffer-fetch scratch memory between command buffers makes the lock screen's clock text disappear, and I do not know why yet. For now each command buffer gets fresh scratch memory, which costs about 5 ms of CPU.
- **Everything without a driver:** Wi-Fi (a Rust ath10k driver for the WCN3990 exists, but hangs while setting up its SMMU), Bluetooth, cellular, audio, camera and sensors. The touch controller also sometimes stops reporting.

## What I learned

The GPU worked once I stopped guessing. Nearly every breakthrough came from reading something the hardware already said: the GMU's fault record, cmd-db's real addresses, the CP's prefetch counter, a property QuartzCore was looking for. Disassembling firmware and Apple's frameworks was slower than trying things, but each one ended a guessing loop that had already eaten several boots.

The other lesson is that Metal is an interface, not magic. Apple's driver model is just IOKit properties, a bundle path and an Objective-C class. If you answer the questions CoreAnimation asks, and translate its shaders into something your GPU runs, iOS draws on hardware Apple never made.

All the code is at [github.com/maulanasdqn/skyios](https://github.com/maulanasdqn/skyios). The October work that made it possible is at [dipa-studio/ios-sweet](https://github.com/dipa-studio/ios-sweet).
