Rust Linux-compatible kernel
moss is a Unix-like, Linux-compatible kernel written in Rust and AArch64 assembly.
It features an asynchronous kernel core, a modular architecture abstraction layer, and binary compatibility with Linux userspace applications. Moss is currently capable of running a dynamically linked Arch Linux AArch64 userspace, including bash, BusyBox, coreutils, ps, top, and strace.
/proc/self/maps support.smalloc for boot allocations
and tracking memory reservations.One of the defining features of moss is its usage of Rust's async/await
model within the kernel context:
async functions, sleep-able
functions are prefixed with .await..interruptable() combinator, allowing
signals to interrupt the waiting future and appropriate action to be taken.fork(), execve(), clone(), and full process lifecycle management.devfs driver for kernel character device access.tmpfs driver for temporary file storage in RAM (rw).procfs driver for process and kernel information exposure.libkernel & Testingmoss is built on top of libkernel, a utility library designed to be
architecture-agnostic. This allows logic to be tested on a host machine (e.g.,
x86) before running on bare metal.
VA (Virtual), PA (Physical), and UA
(User) addresses.VMA management, generic page-based ring buffer (kbuf), and
waker sets.spinlock, mutex, condvar, per_cpu.usertest: A dedicated userspace test-suite to validate
syscall behavior in the kernel at run-time.You will need QEMU for AArch64 emulation, as well as wget, e2fsprogs, and jq for image creation.
We use just as a task runner to simplify common commands,
but you can also run the underlying commands directly if you prefer.
Additionally, you will need a version of the aarch64-none-elf toolchain installed.
To install aarch64-none-elf on any OS, download the appropriate release of aarch64-none-elf onto your computer,
unpack it, then export the bin directory to PATH (Can be done via running:
export PATH="~/Downloads/arm-gnu-toolchain-X.X.relX-x86_64-aarch64-none-elf/bin:$PATH", where X is the version number
you downloaded onto your machine, in your terminal).
sudo apt install qemu-system-aarch64 wget jq e2fsprogs just
brew install qemu wget jq e2fsprogs just
nix develop
To build the kernel and launch it in QEMU:
just run
If you don't have just installed, you can run the underlying commands directly:
# First time only (to create the image)
./scripts/create-image.sh
# Then, to run the kernel in QEMU
# By default it will launch into bash, which alpine doesn't have, however `ash` and `sh` are both available.
cargo run --release -- /bin/ash
The kernel runs off of moss.img.
This image is a minimal alpine rootfs with the addition of a custom usertest binary in /bin/usertest.
Because libkernel is architecturally decoupled, you can run the logic tests on
your host machine:
just test-unit
To run the userspace test suite in QEMU:
just test-userspace
or
cargo run -r -- /bin/usertest
If you've made changes to the usertests and want to recreate the image, you can run:
just create-image
or
./scripts/create-image.sh
moss is under active development. Current focus areas include:
Moss is an experimental kernel focused on exploring asynchronous design and Linux ABI compatibility in Rust.
Contributions are welcome! Whether you are interested in writing a driver, porting to x86, or adding syscalls.
Distributed under the MIT License. See LICENSE for more information.
No open issues yet, or sync has not completed.