New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

virtual-machine

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

virtual-machine

RISCV Virtual Machine with WASM and Node.js native support

latest
Source
npmnpm
Version
0.7.2
Version published
Maintainers
1
Created
Source

RISC-V Virtual Machine

A complete RISC-V 64-bit (RV64GC) virtual machine implementation in Rust, capable of running modern operating systems like Linux (xv6) and custom bare-metal kernels. It is designed to run both natively and in the browser via WebAssembly.

Features

  • Core: Full RV64GC instruction set implementation (IMAFDC + Zicsr + Zifencei).
  • Memory: Sv39 Virtual Memory Management Unit (MMU) with TLB.
  • Peripherals:
    • UART: 16550-compatible serial console.
    • PLIC: Platform-Level Interrupt Controller.
    • CLINT: Core Local Interruptor (Timer).
    • VirtIO: Block Device (Disk) and Network Device (Net).
  • Networking:
    • Native TAP interface support (Linux).
    • WebSocket backend for browser/cross-platform networking.
    • WebTransport backend for P2P connectivity.
  • Platform:
    • WASM: Compiles to WebAssembly for browser execution.
    • Native: Runs as a CLI application on Host OS.

Usage

CLI (Native)

Run the emulator from the command line:

# Run a kernel image
cargo run --release -- --kernel path/to/kernel

# Run with networking (WebSocket backend)
cargo run --release -- --kernel path/to/kernel --net-ws ws://localhost:8765

# Run with block device
cargo run --release -- --kernel path/to/kernel --disk path/to/fs.img

WebAssembly

The VM exposes a simple API for JavaScript integration:

import { WasmVm } from "virtual-machine";

// Initialize VM with kernel binary
const vm = new WasmVm(kernelBytes);

// Connect networking
vm.connect_network("ws://localhost:8765");

// Step execution
while (running) {
  vm.step();
}

Architecture

The VM follows a modular design:

  • cpu.rs: Instruction decoder and execution pipeline.
  • mmu.rs: Virtual address translation.
  • bus.rs: Memory mapping and device routing.
  • virtio.rs: VirtIO device implementations.
  • net.rs: Network backend abstraction.

Build

# Build native CLI
cargo build --release

# Build WASM package
wasm-pack build --target web

FAQs

Package last updated on 31 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts