Kwast Save

Rust operating system running WebAssembly as userspace in ring 0

Project README

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

  • make
  • grub-mkrescue (you might also need to install xorriso)
  • qemu-system-x86_64
  • Rust and Cargo
  • Optionally wasm-strip (from wabt), which reduces the binary size

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

  • Simple PS/2 server & similar small servers
  • Run basic programs
  • SMP

Built with

Similar projects

  • Nebulet - A microkernel that implements a WebAssembly "usermode" that runs in Ring 0
  • wasmjit - Small Embeddable WebAssembly Runtime
  • cervus - A WebAssembly subsystem for Linux
Open Source Agenda is not affiliated with "Kwast" Project. README Source: kwast-os/kwast
Stars
140
Open Issues
9
Last Commit
3 years ago
Repository
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating