AI-Generated Project: This kernel is being developed with significant AI assistance through the opencode platform. The development follows an iterative, research-oriented approach exploring Rust's capabilities for safe systems programming.
Phoenix aims to be a research-oriented, Linux-like kernel written entirely in Rust, exploring the boundaries of memory-safe systems programming while maintaining architectural similarity to the Linux kernel. Unlike traditional kernels, Phoenix leverages Rust's ownership model and type system to eliminate entire classes of memory safety bugs while providing similar capabilities and interfaces.
- Can Rust's safety guarantees be maintained in a production-quality kernel?
- How does a memory-safe kernel impact performance and complexity?
- What architectural adaptations are needed for Rust in kernel space?
- Can we achieve Linux-like capabilities with significantly safer code?
| Component | Status | Notes |
|---|---|---|
| Boot & MMU | β Complete | High-half addressing at 0xffffff8000000000, EL initialization |
| Memory Management | π Progressing | Linux-style memblock boot allocator + static 1GB mappings |
| Exception Handling | π Planned | Basic panic handler (WFE loop), no interrupt vectors |
| Device Drivers | π Planned | Hardcoded serial MMIO only |
| Process Management | π Future | Single execution flow, no scheduler |
| File Systems | π Future | No storage or file system support |
| Networking | π Future | No network stack |
Current Capabilities:
- β Boots on AArch64 from EL2 to EL1
- β Configures MMU with proper cache attributes
- β Operates in high-half virtual address space (Linux-compatible)
- β Simple serial output via MMIO
- β Multi-core filtering (primary core only)
- β Clean separation of host vs bare-metal compilation
- β Linux-style memblock boot-time allocator
- β Automatic kernel memory reservation
- β Thread-safe memory management with spin locks
Critical Limitations:
- β No dynamic buddy system allocator (only boot-time memblock)
- β No interrupt or exception handling
- β No concurrency or preemption
- β No hardware abstraction layer
- β No userspace/kernelspace separation
- Monolithic design similar to Linux kernel architecture
- High-half kernel at
0xffffff8000000000(39-bit VA space) - Minimal
unsafecode - only for necessary hardware interactions - Clean separation between architecture-specific and generic code
- Research-first approach - prioritizing safety and learnability over features
Kernel Virtual Base: 0xffffff8000000000
Load Offset: 0x80000
Kernel Virtual Start: 0xffffff8000080000
Page Size: 4KB (0x1000)
Stack Size: 64KB (0x10000)
- Assembly bootstrap (
boot.S): EL initialization, CPU configuration - MMU setup: Translation tables with 1GB block mappings
- Virtual switch: Jump to high-half address space
- BSS clearing: Zero-initialize uninitialized data
- Kernel entry: Call
kernel_main()in Rust
- Boot-time allocator: Linux-style memblock manages physical memory before buddy system
- Thread-safe: Global instance protected by
spin::Mutex - Automatic reservation: Kernel image memory automatically reserved on boot
- Core operations:
add(),reserve(),remove(),alloc()with alignment - Region merging: Adjacent memory regions automatically merged
- Fixed capacity: 128 regions limit to avoid dynamic allocation
# Install Rust toolchain
rustup target add aarch64-unknown-none
# Optional: Tools for inspection
cargo install cargo-binutils
rustup component add llvm-tools-preview
# For emulation (recommended)
brew install qemu # macOS
# or apt-get install qemu-system-arm # Ubuntu/Debian# For bare-metal AArch64 (primary target)
cargo build --target aarch64-unknown-none
# For development on host
cargo build
# Release build with optimizations
cargo build --target aarch64-unknown-none --release
# Check code without building
cargo check --target aarch64-unknown-none# Basic QEMU emulation
qemu-system-aarch64 \
-machine virt \
-cpu cortex-a57 \
-kernel target/aarch64-unknown-none/debug/phoenix \
-serial stdio \
-nographic
# With more memory and SMP (when supported)
qemu-system-aarch64 \
-machine virt \
-cpu cortex-a57 \
-smp 4 \
-m 2G \
-kernel target/aarch64-unknown-none/debug/phoenix \
-serial stdio \
-nographic# Run host-based tests
cargo test
# Run specific test
cargo test test_target_guard
# Verbose test output
cargo test -- --nocapturephoenix/
βββ src/
β βββ main.rs # Kernel entry point with conditional compilation
β βββ arch/ # Architecture-specific code
β β βββ mod.rs # Architecture selector
β β βββ aarch64/ # AArch64 implementation
β β βββ boot.S # Assembly boot code (175 lines)
β β βββ kernel.ld # Linker script (118 lines)
β β βββ mod.rs # AArch64 module with panic handler
β βββ mm/ # Memory management subsystem
β β βββ mod.rs # Memory module declaration
β β βββ memblock.rs # Linux-style boot-time allocator (505 lines)
β βββ (future: kernel/, drivers/, fs/, net/)
βββ .cargo/
β βββ config.toml # Target-specific rustflags
βββ build.rs # Build script tracking file changes
βββ Cargo.toml # Package configuration with spin dependency
βββ AGENTS.md # AI agent development guidelines
βββ README.md # This file
- Boot-time memory allocator (Linux-style memblock with spin locks)
- Dynamic memory allocator (buddy system + slab allocator)
- Exception vector table and interrupt controller driver (GIC)
- Timer subsystem with ARM Generic Timer
- Synchronization primitives (spinlocks, mutexes, RCU)
- Task management with process control blocks
- Scheduler (CFS implementation)
- System call interface and user/kernel transition
- Virtual memory manager with page fault handling
- Device driver framework with device tree parsing
- Block device layer and I/O scheduling
- File system layer (VFS with simple file systems)
- Character device abstraction (TTY, serial)
- Network stack (TCP/IP implementation)
- Socket API with BSD compatibility
- Module system for dynamic loading
- Security subsystems and debugging infrastructure
- Performance optimization and profiling
- SMP support for multi-core systems
- Power management features
- Comprehensive testing and validation
This project leverages AI coding agents through the opencode platform for:
- Architecture design and subsystem planning
- Code generation with safety-focused patterns
- Documentation and specification writing
- Testing strategy development
- Performance analysis and optimization suggestions
AI Contribution Guidelines:
- All AI-generated code is reviewed and validated
- Safety annotations are required for
unsafeblocks - Code follows established Rust bare-metal patterns
- Architecture decisions are documented in AGENTS.md
| Test Type | Tools | Purpose |
|---|---|---|
| Unit Tests | cargo test |
Host-based testing of Rust components |
| Integration Tests | QEMU | Bare-metal functionality validation |
| Fuzz Testing | cargo-fuzz |
Security and stability testing |
| Property Tests | proptest |
Invariant validation for core algorithms |
| Benchmarks | criterion |
Performance monitoring and regression detection |
- Theseus: an Experiment in Operating System Structure
- RedLeaf: Isolation and Communication in a Safe Operating System
Phoenix is a research-oriented project and welcomes contributions that align with our goals:
- Safety-first approach: Prefer safe Rust patterns over
unsafecode - Documentation: Code without documentation is incomplete
- Testing: New features require corresponding tests
- Architecture alignment: Follow Linux-like patterns when appropriate
Getting Started:
- Read AGENTS.md for development guidelines
- Check open issues for suitable tasks
- Discuss major changes via GitHub issues first
- Ensure code passes
cargo check --target aarch64-unknown-none
Licensed under the MIT License.
See LICENSE for the full license text.
- Linux kernel developers for architectural reference and inspiration
- Rust embedded working group for establishing bare-metal patterns
- QEMU developers for providing essential emulation capabilities
- OpenCode.ai for AI-assisted development infrastructure
- Academic researchers in safe systems programming whose work informs this project
- GitHub Issues: For bug reports and feature requests
- Research Discussions: Open GitHub discussions for architectural decisions
- Development Updates: Follow commit history for progress tracking
"The most profound technologies are those that disappear. They weave themselves into the fabric of everyday life until they are indistinguishable from it." - Mark Weiser
Phoenix aims to make safe systems software so reliable it becomes invisible infrastructure.