kwast-os / kwast

Rust operating system running WebAssembly as userspace in ring 0
MIT License
159 stars 4 forks source link
kernel microkernel operating-system osdev rust webassembly x86-64

Kwast

MIT licensed Build Status

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.

Contents

Current status

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). Screenshot

Getting started

These instructions help you get started with building the source and getting it to run.

Requirements

Setting up a toolchain

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!

Building & Running

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

Short-term goals

Built with

Similar projects