LekKit / RVVM

The RISC-V Virtual Machine
GNU General Public License v3.0
938 stars 65 forks source link
c emulation emulator emulators instruction-decoding jit linux risc risc-v riscv riscv-emulator riscv-linux riscv-simulator riscv32 riscv64 rvvm tracing-jit translation virtual-machine vm
![RVVM Logo](https://github.com/user-attachments/assets/a8d241eb-ebe9-4ceb-a31f-8fd452db75e6 "The “RISC-V” trade name is a registered trade mark of RISC-V International. AmazDooM font is licensed under CC BY-NC 3.0. If you're a designer and have a better logo idea, please open an issue!") [![version](https://img.shields.io/badge/version-0.7--git-brightgreen?style=for-the-badge)](#-installing) [![Build](https://img.shields.io/github/actions/workflow/status/LekKit/RVVM/build.yml?branch=staging&style=for-the-badge)](https://github.com/LekKit/RVVM/actions/workflows/build.yml) [![Codacy grade](https://img.shields.io/codacy/grade/c77cc7499a784cd293fde58641ce3e46?logo=codacy&style=for-the-badge)](https://app.codacy.com/gh/LekKit/RVVM/dashboard) [![Demo](https://img.shields.io/badge/Check%20it%20out-WASM%20Demo-red?style=for-the-badge)](https://lekkit.github.io/test/index.html) [![Wiki](https://img.shields.io/badge/Wiki-brightgreen?style=for-the-badge)](https://github.com/LekKit/RVVM/wiki)

RVVM - The RISC-V Virtual Machine

RVVM is a virtual machine / emulator for RISC-V guests, which emphasizes on performance, security, lean code and portability. It already runs a lot of guest operating systems, including Linux, Haiku, FreeBSD, OpenBSD, etc. It also aims to run RISC-V applications on a foreign-arch host without full OS guest & isolation (Userland emulation).

Main features

📦 Installing

Artifacts AUR Build

🛠 Building

Currently builds using GNU Make (recommended) or CMake and is extremely portable.

git clone https://github.com/LekKit/RVVM
cd RVVM
make
cd release.linux.x86_64
./rvvm_x86_64 -h

Alternatively, you can use CMake:

git clone https://github.com/LekKit/RVVM
cd RVVM
cmake -S. -Bbuild
cmake --build build --target all
cd build
./rvvm -h

See the wiki page for advanced build manual like cross-compilation.

🚀 Running

Example: Launches a dual-core VM with 2 GiB of RAM, 1280x720 display.

Runs OpenSBI + U-Boot firmware, EFI guest from drive.img. Forwards host 127.0.0.1:2022 into guest SSH port.

rvvm fw_payload.bin -i drive.img -m 2G -smp 2 -res 1280x720 -portfwd tcp/127.0.0.1:2022=22

Argument explanation:

[fw_payload.bin]    Initial M-mode firmware, OpenSBI + U-Boot in this case
-i  drive.img       Attach preferred storage image (Currently as NVMe)
-m 2G               Memory amount (may be suffixed by k/M/G), default 256M
-smp 2              Amount of cores, single-core machine by default
-res 1280x720       Set display(s) resolution
-portfwd 8080=80    Port forwarding (Extended: tcp/127.0.0.1:8080=80)
 . . .
-rv32               Enable 32-bit RISC-V, 64-bit by default
-v                  Verbose mode
-h                  Extended help

See wiki page for recommended guest firmware/images and full argument explanation.

⚖️ License

The librvvm library is licensed under non-viral MPL 2.0 license.

If you wish to use librvvm as a component of a larger, non-GPL compliant project (permissive, etc), you are free
to do so in any form (Static linkage, binary distribution, modules) as long as you comply with the MPL 2.0 license.

The RVVM Manager and Linux userland emulator (rvvm and rvvm-user) binaries are licensed under the GPL 3.0
license, since they are intended for end-users. All the heavy lifting is done by librvvm anyways.

Source file headers should be gradually fixed to reflect this.

🎉 Contributions

PRs are welcome Achievements Working on
LekKit RVVM API & infrastructure
RV64IMAFDC interpreter, MMU/IRQs/Priv/etc
RVJIT Compiler, X86/RISC-V backends
NVMe, RTL8169, VFIO, many tiny devices
Userspace network
Rework of PCIe, PLIC, etc
Networking, Userspace emulation
COW blk-dedup image format
New CPU features & JIT optimizations
cerg2010cerg2010 Important fixes, RV64 groundwork, FPU
Initial PLIC & PCI, PS2 HID, ATA, OC Ethernet
ARM/ARM64 RVJIT backends
Testing, Assistance
Mr0maks Initial C/M/Zicsr extensions, initial UART, VM debugger
ARM32 mul/div JIT intrinsics
-
0xCatPKG Userspace network & API improvements
Extended testing & portability fixes
HD Audio
X547 Haiku GUI, I2C HID, Userland API assistance Guest Haiku support, UserlandVM
iyzsong OpenBSD & PLIC fixes, Chardev API
nebulka1 Relative input mode

🔍 TODO

The RISC-V trade name is a registered trade mark of RISC-V International.