A fast and secure RISC-V based virtual machine

Overview

PolkaVM

PolkaVM is a general purpose user-level RISC-V based virtual machine.

This project is still unfinished and is a very heavy work-in-progress! Do not use it in production!

Design goals

(Note: not all of these are currently true!)

  • Secure and sandboxed by default. The code running in the VM should run in a separate process, and should not be able to access the host system, even in the presence of an attacker with full remote code execution priviledges inside of the VM.
  • Fast to execute. The runtime performance of the code running in the VM should be competetive with state-of-art WebAssembly VMs, at least within the same order of magnitude.
  • Fast to compile, with guaranteed single-pass O(n) compilation. Loading new code into the VM should be near instanteneous.
  • Low memory footprint. Each concurrent instance of the VM should have a baseline memory overhead of no more than 128KB.
  • Small binaries. Programs compiled for this VM should take up as little space as possible.
  • No wasted virtual address space. The VM should not preallocate gigabytes of virtual address space for sandboxing purposes.
  • Fully deterministic. Given the same inputs and the same code the execution should always return exactly the same output.
  • Support for high performance asynchronous gas metering. Gas metering should be cheap, deterministic, and reasonably accurate.
  • Simple. It should be possible for a single programmer to write an interpreter fully compatible with this VM in less than a week.
  • Versioned operational semantics. Any future changes to the semantics that are observable by a guest program will be versioned, and will be explicitly opt-in.
  • Standarized. There should be a spec fully describing the guest-observable operational semantics of this VM.
  • Cross-platform. On unsupported OSes and platforms the VM will run in an interpreted mode.
  • Minimum external dependencies. The VM should be mostly self-contained, fast to compile, and resistant to supply-chain attacks.
  • Built-in tooling for debugging and performance profiling.

Non-goals

  • System level emulation. This VM will never be able to run a normal operating system.
  • Full support for architectures other than amd64 (also known as x86_64) and aarch64 (also known as arm64). Anything else will run in an interpreted mode.
  • Full support for operating systems other than Linux, macOS and Windows. On any other OS the VM will run in an interpreted mode.
  • Floating point support, SIMD, and other more niche RISC-V extensions. These could be added as an opt-in feature in the future if necessary, but this is not currently planned.
  • Support for full 32-register RISC-V ISA. This VM currently only targets the RV32EM.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

You might also like...
High Assurance Rust - A free book about developing secure and robust systems software.

High Assurance Rust - A free book about developing secure and robust systems software.

Secure mTLS and gRPC backed runtime daemon. Alternative to systemd. Written in Rust.

Auraed A runtime daemon written in Rust. Designed to run as pid 1 mTLS backed gRPC API over unix domain socket Run executables Run containers Run virt

On-the-fly machine code executing from Deno

jit from js Execute raw machine code from JavaScript. I hope you know what you're doing :) const inst = new Uint8Array([0xC3]); // ret const noop = ji

Fast and simple datetime, date, time and duration parsing for rust.

speedate Fast and simple datetime, date, time and duration parsing for rust. speedate is a lax† RFC 3339 date and time parser, in other words, it pars

fast rust implementation of online nonnegative matrix factorization as laid out in the paper "detect and track latent factors with online nonnegative matrix factorization"

ONMF status: early work in progress. still figuring this out. code still somewhat messy. api still in flux. fast rust implementation of online nonnega

A fast lean and clean modern constraint programming solver implementation (in rust)

MaxiCP-rs This project aims at implementing a fast, and clean constraint programming solver with a focus on correctness, simplicity, maintainability a

A fast, iterative, correct approach to Stackblur, resulting in a very smooth and high-quality output, with no edge bleeding

A fast, iterative, correct approach to Stackblur, resulting in a very smooth and high-quality output, with no edge bleeding. This crate implements a t

Simple and fast proxy checker that include protocol validation;

Open Proxies ⭐️ Leave me a start please ⭐️ it will motivate me to continue maintaining and adding futures About | Technologies | Requirements | Starti

A backend framework for building fast and flexible APIs rapidly.

Andromeda Andromeda is a backend framework for Rust, to simplify the development of the kinds of basic API services that we developers have to build s

Comments
  • Register value mismatch

    Register value mismatch

    Very nice project!

    I was playing with the example a bit and this error was thrown:

    Calling into the guest program (through typed function):
    [ERROR polkavm::tracer] Register value mismatch! Crosscheck interpreter has a0 = 0xc, actual execution has a0 = 0x6f
    thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error(Error { message: "execution trapped while calling 'add_numbers': execution trapped" })', examples/hosts/hello-world/src/main.rs:26:50
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    

    Reproduction

    cd /examples/hosts/hello-world;
    POLKAVM_TRACE_EXECUTION=1 POLKAVM_ALLOW_INSECURE=1 cargo run;
    
    opened by skunert 1
  • Disassembler cli

    Disassembler cli

    Hi there, cool project. Thought id give this a go as its easy enough for my first open source contribution.

    Solves: https://github.com/koute/polkavm/issues/34

    opened by f-gate 1
Owner
Koute
KSM: HTk3eccL7WBkiyxz1gBcqQRghsJigoDMD7mnQaz1UAbMpQV
Koute
High-order Virtual Machine (HVM) is a pure functional compile target that is lazy, non-garbage-collected and massively parallel

High-order Virtual Machine (HVM) High-order Virtual Machine (HVM) is a pure functional compile target that is lazy, non-garbage-collected and massivel

null 5.5k Jan 2, 2023
An experimental, well-documented and expansion-ready virtual machine written in Rust.

Notice ivm is undergoing a complete refactor. ivm ivm is a rich, well-documented virtual machine written in Rust. Pros Documentation everywhere. Every

Imajin 4 Jul 9, 2022
ARM TrustZone-M example application in Rust, both secure world side and non-secure world side

ARM TrustZone-M example application in Rust, both secure world side and non-secure world side; projects are modified from generated result of cortex-m-quickstart.

null 44 Dec 4, 2022
Wait, another virtual machine ?

WAVM WAVM, Wait, another virtual machine ?, is a register based 64 bits virtual machine written in Rust. It relies on 32 registers and 31 opcodes that

Wafelack 61 May 2, 2022
A traditional web forum built in Rust with modern technology to be fast, secure, scalable, and stable.

Volksforo A traditional web forum built in Rust with modern technology to be fast, secure, scalable, and stable. Stack Rust actix-web askama ScyllaDB

Josh 5 Mar 21, 2023
rusty-riscy is a performance testing and system resource monitoring tool written in Rust to benchmark RISC-V processors.

rusty-riscy rusty-riscy is a performance testing and system resource monitoring tool written in Rust to benchmark RISC-V processors. Objectives To cre

Suhas KV 4 May 3, 2022
Trying embedded Rust on the Pinecil GD32VF103 RISC-V device.

Pinecil GD32VF103 RISC-V Rust Demos My personal collection of Rust demos running on the PINE64 Pinecil portable soldering iron, featuring a GD32VF103T

alvinhochun 39 Nov 28, 2022
Low level access to T-Head Xuantie RISC-V processors

XuanTie Low level access to T-Head XuanTie RISC-V processors Contributing We welcome contribution! Please send an issue or pull request if you are rea

Luo Jia 30 Aug 24, 2022
Message Signaled Interrupts for RISC-V

RISC-V MSI Test in Rust Testing the new MSIs added by the draft Advanced Interrupt Architecture (AIA) specification. Blog Posts First blog post: 30-Ju

Stephen Marz 5 Jul 5, 2022
Repo for apps for the Pocket RISC-V core for Analogue Pocket/OpenFPGA. Multiple branches.

This is a repo meant to host Rust programs for agg23's Pocket RISC-V platform. While Rust can be built out of the openfpga-litex repo directly, this r

null 3 Dec 12, 2023