Kwast (will be) an operating system, written in Rust, running WebAssembly. It uses a microkernel architecture for flexibility.
Since WebAssembly was designed to be a safe language, we can run it without having to use hardware usermode and multiple address spaces (optionally). Processes can be run in the same address space (multiple SIPs in a single hardware protection domain), or in seperate address spaces. This enables low-cost context switches, low-cost syscalls, and a microkernel design without a big performance hit. Another interesting thing is that it means the software is cross-platform and that the compiler could enable platform-specific optimisations.
For notes on Spectre, Meltdown and other related issues, see #10. An additional idea is to allow to use optional hardware protection domains in the future if requested.
Currently, it runs basic WebAssembly code in a basic multitasked environment. The heap uses a slab allocator design, and the virtual memory areas are managed by an AVL tree. For the ABI, I started with implementing WASI.
Here's a screenshot of a WASI compiled Rust program (userspace/wasm-test).
These instructions help you get started with building the source and getting it to run.
You can setup your toolchain using the following steps:
# (Inside the project root folder.)
# You'll need to get the rust nightly and install the wasi toolchain:
rustup component add rust-src
rustup target add wasm32-wasi
# You'll also need a cross-compile binutils, I wrote a bash script that builds this for you.
cd toolchain
./setup_cross_binutils.sh
Now you're ready to build and run the project!
There's currently a Makefile in the kernel
folder. The Makefile there provides some rules:
# (Inside the project root folder.)
make run # Builds iso and start a QEMU virtual machine
# If you don't want to run, but only build a bootable ISO:
make iso
# You can make a release build using:
make iso BUILD=release # (or run)
# You can run tests using
./run_tests
Cranelift - Code generator used to parse & run WebAssembly. Kwast uses a fork of Cranelift to let it work in a no_std environment.
To integrate Cranelift, wasmtime has been used as a reference implementation, which is licensed under the Apache License 2.0.
Spleen font - Spleen is a monospaced bitmap font licensed under the BSD 2-Clause "Simplified" License.