Skip to content

vphone-linux v0.6

Latest

Choose a tag to compare

@YahiaAngelo YahiaAngelo released this 25 Nov 14:54

vphone-linux now runs on Apple Silicon Macs running Linux. On an M1 Pro with Omarchy-M, the iPhone's CPU cores run natively under KVM instead of being emulated. The VM boots to the home screen with the GPU, and apps, Safari and its JavaScript JIT run. x86_64 hosts keep TCG as before.

KVM on Apple Silicon

Setup is in docs/KVM.md. You need:

  • a patched kernel, linux-aurora-kvm, which installs as its own boot entry and leaves linux-aurora as the default;
  • two host settings: udmabuf limits, and a Mesa heap setting in ~/.drirc;
  • ACCEL=kvm when you run the VM:
ACCEL=kvm SMP=6 MEM=6G GFX=1 WINDOW=1 VSOCK=vhost CID=3 ./run-vphone.sh vms/<name>
  • What runs natively: the boot ROM, LLB, iBoot, SPTM, TXM, XNU and sepOS, on six vCPUs. QEMU emulates Apple's GXF/SPRR and PAC, and models the two GICv3s (the AP's and the SEP's). This is adapted from ChefKiss Inferno's KVM backend.

  • Speed on an M1 Pro, plugged in: vphoned answers about 60 s after QEMU starts. The guest benchmark (tools/guestbench) takes about 2.5 s; the first KVM boot took 6.1 s.

  • The kernel handles the hottest traps itself, through an area shared with QEMU, instead of exiting to QEMU:

    • GXF world switches (genter/gexit) and PAC key writes;
    • SPRR register reads;
    • leaf page-table stores;
    • TTBR0 switches between processes;
    • the JIT's write/execute toggles.

    Each of these has a VR_NO_* switch to turn it off for comparisons.

  • Stability: a soak of 16 boots, each with 6 Safari launches, came through clean: no panics, no frozen screens, and vphoned up at the end of every boot.

iOS app development on the Mac

xtool apps build on the Mac itself and run in the VM. Get the toolchain from omarchy-apple-dev's installer, as described in docs/APP-DEVELOPMENT.md. A sample SwiftUI app rebuilt in 4 s and reinstalled and relaunched in about 1 s. CPU-bound code in the VM runs at the host's native speed; code that touches a lot of new memory runs 2–4× slower. examples/PerfTest is a small benchmark app that measures this on your own machine, next to a native host build of the same code.

Prebuilt kernel

Attached to this release:

  • linux-aurora-kvm-7.2.11.aurora16-1-aarch64.pkg.tar.xz: the kernel package, which saves you the hour-long build. Install it with sudo pacman -U, then follow docs/KVM.md from "Reboot".
  • linux-aurora-kvm-7.2.11.aurora16-1-src.tar.xz: its complete source, GPL-2.0. That is the pinned linux-aurora tree (commit bed544bd), plus our patch and the package files it was built with.
  • SHA256SUMS.

GPU on Asahi

Asahi's Vulkan driver (Honeykrisp) can't import host memory, only dma-bufs. metal2vulkan now builds no-copy buffers over dma-bufs of guest RAM, made with /dev/udmabuf. It also handles framebuffer fetch and raster order groups without a pixel interlock, and samples varyings at the pixel centre. The streaks in the bottom-right of the wallpaper are fixed.

For all hosts

  • reims-vgpu and metal2vulkan moved to a newer upstream base. Our patches carry over, including v0.5's home-screen icon fix. Checked on the x86_64 PC: unlock in about 165 s; Safari, Settings, Maps and Calendar launch; icons, wallpaper and widgets match v0.5.
  • build.sh configures QEMU afresh when reims-vgpu's C header changes. Before, an existing qemu/build kept QEMU's old answer about optional GPU-library features.
  • Disk overlays: if a VM directory has a Disk.qcow2 overlay, run-vphone.sh boots from it and opens Disk.img read-only.
  • Tools:
    • tools/guestbench builds without the Darwin SDK and runs one phase at a time;
    • kvm/boot-loop.sh boots in a loop with hang diagnostics;
    • kvm/panic-stackshot.py takes a stackshot of every guest process.

Setup and VM creation

  • vphone-cli 2.17.1 (#77). The Linux build of vphone-cli moves from 2.14.2 to 2.17.1. This fixes cfw install hanging forever (#69), and unblocks #48 and #59, which need vphone-cli 2.16.1 or later. An existing setup keeps its 2.14.2 VPhone.bundle until you remove ~/vphone-setup-work/vphone-release/app/VPhone.bundle.
  • Fedora 45 (#76, fixes #72). Every link step failed with "Could not parse output of ld -version_details", because Fedora 45's binutils snapshot prints a version form that Swift 6.4.1's build system doesn't recognise. linux-create/build.sh now links with the toolchain's lld there.
  • Arch rustup (#76, fixes #68). setup.sh sets rustup default stable when Arch's rustup has no default toolchain ("rustup could not choose a version of cargo to run").

Known issues (Apple Silicon)

  • Layered icons after Home: after you leave an app, Safari's compass needle and the front gear of Settings can lose their fill until iOS redraws them, which takes up to about a minute. The cause is not found yet; it follows GPU completion latency with four or more vCPUs.
  • vphoned can stop answering on about one boot in 15–20 (seen in earlier builds, not in the final soak). Input goes through vphoned, so the screen looks frozen. Quit QEMU and boot again.
  • Rebuild the kernel whenever its patch changes. QEMU checks the kernel's fast-path version (KVM_CAP_ARM_APPLE_FAST) and refuses to start on a kernel from another commit, telling you to rebuild it.
  • No reboot from inside the guest: quit QEMU and start it again.
  • Tested hardware: only an M1 Pro with 16 GB RAM. The VM uses about 10 GB of it: 6 GB for the guest and about 4 GB for the GPU stack.
  • Battery: on battery the Mac runs about 40% slower.