ApexRift

A from-scratch operating system written entirely in KernRift and booted on bare metal — x86_64 and arm64, under QEMU, on a real UEFI laptop and on a real phone. No Rust, no C, no libc, no host kernel.

ApexRift is an operating system created by Pantelis Christou.

apex > krc --arch=x86_64 --target=none --emit=arx /in.kr -o /out.arx
apex > sum /bin/krc && sum /out.arx
80c027220de82184 1161280 bytes (byte-identical ✓)

Self-hosting: krc compiles itself inside ApexRift, byte-identical to host ↓

157k lines of pure KernRift — zero C, Rust, libc, LLVM or host kernel in the OS image
2.82 s to self-compile krc.kr (3.4 MB) natively on a Redmi Note 8 Pro Cortex-A76 (vs 2.76 s on Android)
106 Mbps 5 GHz VHT80 WiFi LAN download (13.3 MB/s over 100 MiB, 0 dropped holes) on custom WPA2 + TCP
100% byte-identical self-host: krc compiled inside ApexRift matches host FNV-1a (80c027220de82184)

It Self-Hosts — Measured on Real Silicon

ApexRift compiles the KernRift compiler (krc.kr, 3.4 MB) inside ApexRift, and the result is byte-identical to the host build. Two matching checksums are the whole claim: the compiler that ran and the compiler it produced are the same program.

apexrift — ./tools/run-krc-in-apexrift.sh
apex > krc --arch=x86_64 --target=none --emit=arx /in.kr -o /out.arx
328971 tokens, 206242 nodes, 1157184 bytes -> /out.arx  (5490.00 ms)
apex > sum /bin/krc
sum: 80c027220de82184  1161280 bytes  /bin/krc
apex > sum /out.arx
sum: 80c027220de82184  1161280 bytes  /out.arx

Self-compile on physical hardware (Redmi Note 8 Pro vs Android)

Machine & OSCore / ClockSingle-target arm64 ELF
Desktop (x86_64, Linux)Ryzen 9 7900X0.55 s
Begonia — ApexRiftCortex-A55 @ 1175 MHz8.98 s
Begonia — ApexRift (cpufreq 1701)Cortex-A55 @ 1701 MHz (rated)6.32 s
Begonia — ApexRift (runon 600)Cortex-A76 @ 1085 MHz (bootloader)4.57 s
Begonia — ApexRift (runon 600 + cpufreq 2000 big)Cortex-A76 @ 2000 MHz (vendor top 2050)2.82 s
Begonia — Androidscheduler's choice2.76 s

Timed off the handset's 13 MHz hardware architectural counter (cntfrq_el0), reproduced within 6 ms across runs (docs/BENCHMARKS.md). On x86_64, ./run.sh provisions /bin/krc, /bin/kr, and a staged /bin/kernel.img on the virtio disk (supporting live kexec /bin/kernel.img go hot-swaps where the GOP framebuffer survives the swap).

Where It Runs

The artifact is a self-booting image that firmware, a phone bootloader, or qemu -kernel enters directly.

TargetHow It BootsProven By
x86_64 / QEMU qemu-system-x86_64 -kernel apexrift.img (Multiboot), or --emit=uefi → BOOTX64.EFI under OVMF ./test.sh
x86_64 / Real UEFI PCs USB stick written by tools/make-usb.sh, Secure Boot off, GOP framebuffer + +diag on-screen trace ASUS ROG Strix G18 (G815LW) laptop
arm64 / QEMU virt -kernel entered at EL1, GICv3, FDT parser, stage-1 MMU ./test-arm64.sh
arm64 / Redmi Note 8 Pro (“begonia”) Repacked Android boot image flashed with fastboot (MediaTek MT6785) Real handset: display, touch, UFS, USB, 5 GHz WiFi, Bluetooth 5.0, PMIC/DVFS

Verified before silicon: Morgana_VM. Morgana_VM (morgana-x86 and morgana-a64, ~24k LOC of KernRift) boots ApexRift's full UEFI path pixel-identical to OVMF and matches QEMU transcripts byte for byte. It halts and names any unknown instruction or unmodelled device access, models the physical laptop (--machine=g815) and handset (--machine=begonia) from measured boot reports, and runs a Stage-0 --preflight check on the phone itself as an ApexRift ARX before a kernel is allowed to kexec.

Phone boot images are never distributed. A begonia boot image carries the vendor's NT36672A touch firmware and stock Android boot headers, neither of which is ours to give away. To run ApexRift on a begonia you build the image yourself from files pulled off your own handset via tools/build-begonia-boot.sh.

Proof on Real Silicon

Unedited photographs of ApexRift running bare-metal on a physical Redmi Note 8 Pro (MediaTek MT6785) — 1080×2340 panel, NT36672A touch, on-screen QWERTY & symbol keyboard, EL1, and live MT6359 PMIC telemetry.

Verified Against Independent Oracles

Nothing in ApexRift is judged only by code written in the same tree. Every major subsystem is measured against an external reference implementation.

SubsystemIndependent OracleMeasured Result
On-device self-host (krc.kr, 3.4 MB) Android on the same Redmi Note 8 Pro 2.82 s vs 2.76 s (Cortex-A76 @ 2000 MHz, cntfrq_el0)
Custom DEFLATE (std/gzip.kr) zlib -9 & system gzip -t 4.5% smaller (1,616,196 B vs 1,691,927 B), round-trip verified
RiftCrypto & TLS 1.3 (crypto/) openssl s_server & live kernrift.org / curl Byte-identical HTTPS body checksum, real P-256/P-384 X.509 chains
Morgana_VM (morgana-x86 / a64) QEMU & OVMF UEFI firmware Byte-identical serial transcripts, pixel-identical UEFI GOP frame

Lessons paid for on silicon

System Layers

Backends are chosen at import time, never dispatched through nullable function pointers at runtime — a missing hardware backend is a link error before silicon is ever touched.

Userland & ARX ApexShell, krc.arx, kr.arx, System Monitor, arsh, std/ui.kr + Apex Sans Ring 3 / EL0
Syscall & Modules int 0x80 & SYSCALL/SYSRET (x86_64), SVC (arm64), signed kernel modules via versioned vtable Trap Gate
Core Subsystems ArFS (4 KiB blocks, fsck, redo journal) + AES-128-XTS, TCP/IP + TLS 1.3 + Roughtime, DEFLATE Ring 0 / EL1
Silicon & Boot UEFI / Multiboot / LK handoff, page tables, GICv3 / PIC+PIT, e1000, virtio-blk, UFS, MT6785 WiFi/BT, MT6359 PMIC Bare Metal

What Works Today

Boot, kexec & Watchdog

Multiboot and full UEFI (GOP framebuffer, memory map past 4 GiB, ExitBootServices onto own page tables). Live kexec hot-swap preserves the framebuffer across kernels; kstage verifies FNV-1a + length of disk bytes and arms hardware watchdog fallback (6300ESB / SoC WDT).

Hardware Isolation & W^X

Unprivileged execution at Ring 3 (iretq, int 0x80 & SYSCALL/SYSRET, SMEP, NX) and EL0 (EL2→EL1 drop, eret, svc #0, 4 KiB page splitting). Per-segment W^X, isolated user arena, fault containment, and runaway-loop watchdog preemption on both architectures.

ArFS Storage & AES-XTS

Block-structured filesystem: 4 KiB blocks, bitmap allocator, direct + single/double-indirect inodes up to 4 GiB per file. One dispatcher drives RAM disk, virtio-blk, and handset UFS with fault injection. Includes fsck / fsck fix, opt-in redo journal, and whole-volume AES-128-XTS (x86_64, confidentiality-only).

ARX & Signed Modules

Custom executable container (7F 41 52 58) emitted by krc --emit=arx with mandatory-table validation and FNV-1a integrity. Loadable kernel modules enter via a versioned service vtable and are signature-checked before load (modsig / modkey).

Apex Sans (From-Scratch Font)

Original stroke-designed typeface (tools/fonts/apexsans.strokes) and custom ARF1 binary glyph toolchain (~6k LOC, ~410 glyphs: Latin, Latin-1, Extended-A, monotonic & polytonic Greek, symbols) at 16/24/32 px. Renders 2 bpp 4-level AA via byte-by-byte reads safe even with MMU off on Device memory; mutation-gated (font_check.kr), Apache-2.0.

Apex UI (Immediate-Mode Toolkit)

Zero-import PIC ARX GUI toolkit (std/ui.kr, Apache-2.0) running unprivileged in Ring 3 / EL0: containers, labels, buttons, text fields, scroll lists, tab focus, clipping, and Apex Sans text. Traps strictly via four wrappers (surface_info, present, event_wait, clock); mutation-gated by ui_check.kr + mutate_ui.sh.

RiftCrypto & TLS 1.3

From-zero cryptography and TLS 1.3 suite (crypto/, 27 files, ~9.4k LOC): own bignum, RSA-2048/PSS, Ed25519, ECDSA P-256/P-384, X25519, ChaCha20-Poly1305, AES, SHA-1/256/512, HKDF, 54 KB DER/X.509 parser with chain validation and curated roots, plus Ed25519-signed Roughtime — verified byte-exact against openssl s_server and kernrift.org. Runs over e1000, USB CDC-EEM, and WiFi TCP (RFC 5681, SACK).

Graphical Shell & Dual I/O

Double-buffered 1024×768x32 compositor (QEMU ramfb) with draggable windows, focus/raise, taskbar clock, ApexShell terminal, and live System Monitor, plus 80×25 VGA fallback. Output goes to screen and serial simultaneously.

5 GHz WiFi & Bluetooth 5.0

On the MT6785 handset: 5 GHz VHT80 LAN WiFi measured at 13.3 MB/s (106 Mbps) download across 100 MiB (71,912 frames, 19,230 reordered, 0 holes dropped; 13.8 MB/s host-timed) and 6.66 MB/s (53.3 Mbps) upload (0 retransmits) with full WPA2 4-way handshake, DHCP, and boot-time join. Bluetooth 5.0: MCU boot, HCI, SSP pairing, persisted link keys, L2CAP, and RFCOMM.

arsh & kr-console

arsh is a custom authenticated remote shell (X25519 + Ed25519 + ChaCha20-Poly1305) over WiFi with pinned host key and client allow-list. kr-console (tools/krconsole.kr) is a pure-KernRift raw USB CDC-ACM console replacing Python: sets raw -echo termios in-process via ioctl(TCSETS), keeps timestamped session logs, and runs an unconditional syscall-ABI witness on every build.

From-Scratch USB Stack

Descriptor tables (usb_desc.kr), Chapter 9 enumeration (usb_ch9.kr), and byte pipes (usb_cdc.kr) proven on the x86 gate before touching MediaTek's mtu3.kr controller. Exposes both a raw CDC-ACM serial console (/dev/apexrift, no ADB) and CDC-EEM Ethernet over USB.

PMIC Telemetry & DVFS

MT6359 (PWRAP) and MT6360 (I2C5) decoded live on the handset: bat (VBAT/VSYS/IBAT/IBUS + integrated charge), temp (4 PMIC sensors off eFuse trim), vproc set against MediaTek's operating-point table, cpufreq, and an opt-in DVFS governor.

8-Core SMP & Run Queue

Brings up all 8 handset cores via PSCI CPU_ON (6× Cortex-A55 + 2× Cortex-A76), runs pinned jobs on big cores (runon 600), and ships a kernel spinlock (core/spin.kr), FIFO run queue (core/sched.kr), and cross-core SHA-256 verification (smpsha).

Custom DEFLATE & Zero Python

Own LZ77 + optimal shortest-path dynamic Huffman encoder (std/gzip.kr) — 4.5% smaller than zlib -9, round-trip verified by system gzip -t. Handset boot-image repacking runs purely in KernRift, verified byte-identical to the Python it replaced.

Boot Health, Crash Records & Evidence

Cross-boot health verdicts, known-good fallback slot (good), bad-image denylist (badlst), persistent crash records across warm reboots (rec, journal), fixed-RAM overlap audit (memclaim), and non-vacuous mutation gates.

Where It Is Going

The open engineering work, stated plainly without hand-waving.

Build, Boot & Test

Requires Linux x86_64, git, curl, make, xxd, and qemu-system-x86_64. The pinned KernRift compiler bootstraps itself until krc3 == krc4.

quick start — clone to interactive shell
$ git clone https://github.com/Pantelis23/ApexRift.git && cd ApexRift
$ ci/bootstrap-krc.sh   # build pinned KernRift compiler into ci/.krc/ (krc3 == krc4)
$ ./build.sh            # compile kernel, boot 6s in QEMU, print serial log
$ ./run.sh              # interactive shell with krc and kr already in /bin
verification gates
$ ./test.sh                         # x86_64 + arm64 gates against booted images
$ ./tools/run-krc-in-apexrift.sh    # self-host krc inside ApexRift & verify checksums
$ ./tools/run-uefi-probe.sh --shot  # UEFI + GOP framebuffer verification
$ APEX_NO_HANDSET=1 ./hardtest.sh   # flake, vacuity, stress & mutation campaigns

Engineering Records (docs/)

Over 1.4 MB of measured bring-up logs, protocol specs, and post-mortems in the repository — including the wrong turns and retracted hypotheses.

Licence

ApexRift is free software under GPL-3.0-only, with an explicit exception (LICENSE-EXCEPTION): programs using ApexRift only through its syscall or ARX service interface are not derivative works and may carry any licence their author chooses.

The app toolkit (std/ui.kr), program-side syscall shims, the Apex Sans font, and shared KernRift std/ files are Apache-2.0. Every source file carries an SPDX-License-Identifier header enforced by ./test.sh.

Bug Reports & Discussions