#risc-v #vcpu #hypervisor

nightly no-std riscv_vcpu

ArceOS-Hypervisor riscv vcpu module

3 releases

Uses new Rust 2024

0.1.2 Sep 8, 2025
0.1.1 Sep 6, 2025
0.1.0 Sep 4, 2025

#1009 in Embedded development

Download history 93/week @ 2025-08-30 347/week @ 2025-09-06 51/week @ 2025-09-13 79/week @ 2025-09-20 103/week @ 2025-09-27 41/week @ 2025-10-04 22/week @ 2025-10-11

253 downloads per month

GPL-3.0-or-later OR Apache-2…

66KB
1.5K SLoC

Rust 1K SLoC // 0.1% comments GNU Style Assembly 240 SLoC // 0.2% comments

riscv_vcpu

riscv64 virtual CPU (vCPU) implementation for hypervisors. This crate provides the core vCPU structure and virtualization-related interface support specifically designed for the riscv64 architecture.

CI [License]

Overview

riscv_vcpu implements a minimal RISC-V Virtual CPU (VCPU) abstraction layer compliant with the RISC-V Hypervisor Extension (RVH). Designed for embedded hypervisors and educational use, it can operates in no_std environments.

Features

  • Complete vCPU Implementation: Full virtual CPU structure for riscv64 guests
  • Exception Handling: Comprehensive trap and exception handling for virtualized environments
  • EPT (Extended Page Tables): Memory virtualization support
  • VMCS Management: Virtual Machine Control Structure operations
  • Per-CPU Support: Efficient per-CPU data structures and management
  • No-std Compatible: Works in bare-metal and embedded environments

Usage

Add this to your Cargo.toml:

[dependencies]
riscv_vcpu = "0.1"

Basic Usage

use riscv_vcpu::{RISCVVCpu, RISCVVCpuCreateConfig, has_hardware_support};

// Check if hardware virtualization is supported
if has_hardware_support() {
    // Create vCPU configuration
    let config = RISCVVCpuCreateConfig::default();
    
    // Create and configure the virtual CPU
    let vcpu = RISCVVCpu::new(config)?;
    
    // Run the virtual CPU
    vcpu.run()?;
}
  • ArceOS - An experimental modular OS (or Unikernel)
  • AxVisor - Hypervisor implementation

License

This project is dual-licensed under either:

at your option.

Dependencies

~7.5MB
~122K SLoC