• Stars
    star
    339
  • Rank 121,987 (Top 3 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created over 5 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

RISC-V hypervisor written in Rust

RVirt

Travis License Language

RVirt is an S-mode trap-and-emulate hypervisor for RISC-V. It is currently targeted at QEMU's virt machine type, but partially supports the HiFive Unleashed as well. It can run either on either the Berkeley Boot Loader or with its own (considerably faster) M-mode stub. It is powerful enough to run multiple instances of Linux as guest operating systems.

FAQ

How is RVirt different from other hypervisors like Firecracker, Cloud Hypervisor or xvisor?

All three of the other projects can only run on processors that have hardware virtualization extensions like Intel VT-x or RISC-V's planned H-extension. Firecracker and Cloud Hypervisor additionally depend on KVM (and by extension the entire Linux kernel). By contrast, RVirt doesn't need KVM or Linux and can run on any sufficiently powerful 64-bit RISC-V processor with an MMU.

Why RISC-V?

RISC-V is classically virtualizable which means that a hypervisor can rely on any privileged instruction triggering an illegal instruction fault when executed by the (unprivileged) guest OS. This is in contrast to other ISAs like x86 which have instructions that behave differently in user and kernel mode but never trap. Additionally, RISC-V has only 12 supervisor level control registers and only a handful of privileged instructions making the work to implement trap and emulate much more manageable.

Why Rust?

Why not? Rust is a pleasant language to work with and can directly target bare metal platforms. I was also excited by Rust's ability to guarantee memory safety for safe code, but I found the amount of unsafe code required for initialization and vm entry/exit partially negated this benefit.

Getting Started

For more detailed instructions, see the getting started guide.

Install Dependencies

$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
$ sudo apt-get install qemu-system-misc

Clone the repository

$ git clone https://github.com/mit-pdos/rvirt && cd rvirt

Download guest images

$ wget https://fedorapeople.org/groups/risc-v/disk-images/vmlinux
$ mv vmlinux fedora-vmlinux
$ wget https://fedorapeople.org/groups/risc-v/disk-images/stage4-disk.img.xz
$ unxz stage4-disk.img.xz

Compile and run

$ make qemu

This command launches an instance of QEMU with RVirt running inside and Linux running inside that. Once the boot process has completed you can SSH in through all the layers and directly interact with the guest (root password is 'riscv'):

$ ssh -p 10001 root@localhost

Current Status

RVirt supports running both inside an emulator and on real hardware and does runtime detection to learn what platform it is executing on. It has so far been tested with Fedora RISC-V builds, but may work with other distributions as well.

Supported Platforms

Tier 1: Boots fully and supports interaction via SSH / serial console

  • QEMU virt machine type

Tier 2: Boots partially but lacks driver support for block/network device to complete boot process

  • HiFive Unleashed board
  • QEMU sifiveu machine type

Correctness

  • Trap and emulate of privileged instructions (CSR related and SFENCE.VMA)
  • Shadow page tables
  • Update PTE accessed and dirty bits
  • Timers
  • Expose and/or emulate peripherals
  • Address lingering bugs in boot process

Functionality

In addition to being able to boot and run a single guest, RVirt also supports some features not needed for the correct virtualization of a single guest:

  • multiple guests
  • passthrough of virtio block and network devices
  • paravirtualized network devices backed by HiFive Unleashed's NIC (in progress)
  • multicore guests and inter-processor interrupts between them

Other features not used by Linux / not supported by current platforms are unlikely to be implemented:

  • ASID support
  • Sv48 or Sv57 guest page tables (only Sv39 currently allowed)
  • SR-IOV PCIe devices
  • 32-bit guests

More Repositories

1

xv6-public

xv6 OS
C
7,486
star
2

xv6-riscv

Xv6 for RISC-V
C
6,385
star
3

noria

Fast web applications through dynamic, partially-stateful dataflow
Rust
4,952
star
4

biscuit

Biscuit research OS
Go
2,420
star
5

xv6-riscv-book

Text describing xv6 on RISC-V
TeX
577
star
6

xv6-book

Commentary for xv6-public
Perl
238
star
7

fscq

FSCQ is a certified file system written and proven in Coq
Coq
232
star
8

xv6-riscv-fall19

6.S081/6.828 lab repo for fall 2019
C
195
star
9

perennial

Verifying concurrent crash-safe systems
Coq
134
star
10

6.828-qemu

qemu patched for debugging, used for 6.828
C
78
star
11

noria-ui

Web UI for Noria clusters
JavaScript
67
star
12

noria-mysql

MySQL/MariaDB protocol shim for Noria
Rust
66
star
13

go-journal

Verified, concurrent, crash-safe transaction system
Go
45
star
14

mcqc

A Gallina compiler with C++17 as an intermediate representation
Haskell
40
star
15

go-nfsd

Fast NFS server implemented using GoJournal
Go
38
star
16

ward

C++
30
star
17

daisy-nfsd

DaisyNFS is an NFS server verified using Dafny and Perennial.
Dafny
27
star
18

sigmaos

Go
25
star
19

scalefs

C
21
star
20

dsrg

Distributed Systems Reading Group
CSS
20
star
21

secfs-skeleton

Skeleton code for new 6.858 final project --- an encrypted and authenticated file system
Python
20
star
22

perflock

RWMutex for sharing of multicore machines.
C
15
star
23

vmvcc

Go
15
star
24

6.826-2017-labs

Coq
13
star
25

what

An improved version of `w`
Python
13
star
26

6.826-2020-labs

Lab assignments for 6.826
Coq
12
star
27

6.S060-labs

Programming labs for 6.S060 (Foundations of Computer Security).
Python
12
star
28

argosy

Proving crash safety for systems with layered recovery
Coq
11
star
29

cspec

Verifying concurrent code with layers and movers
Coq
11
star
30

6.826-2019-labs

Lab assignments for 6.826
Coq
10
star
31

gokv

Go
9
star
32

syndicate

Syndicate multiplexes several distributed master-slave applications onto a single cluster of machines.
Go
9
star
33

mailbot

Bot to send email notifications when pushing to GitHub
Shell
7
star
34

deepspec-pocs

Coq
6
star
35

6.1600-labs

Student lab assignments for MIT 6.1600
Python
6
star
36

spectrebench

C++
5
star
37

6.5660-lab-2023

Python
4
star
38

grove-artifact

Python
3
star
39

noria-benchmarks

Experiment scripts and results for Soup
Rust
3
star
40

6.1600-notes

TeX
3
star
41

perennial-examples

Examples verified using Perennial
Go
3
star
42

csail-events-slack

Simple Slack webhook for posting notifications about upcoming CSAIL seminars
Ruby
3
star
43

grove

Experiments in verifying distributed systems with Iris
2
star
44

6.566-lab-2024

Python
2
star
45

new-students

Welcome for new PDOS students to get access to the organization
1
star