GithubHelp home page GithubHelp logo

rvm-tutorial-rcore's Introduction

RVM -- Rcore Virtual Machine

CI

An experimental hypervisor library written in Rust to build both type-1 and type-2 hypervisors.

Supported architecture: x86_64 (Intel VMX).

rustc info

  • current rustc -- rustc 1.56.0-nightly (08095fc1f 2021-07-26)
  • current rust-toolchain -- nightly

Basic usage

See the UEFI example for more details.

use rvm::*;

const ENTRY: u64 = 0x2000;

fn run_hypervisor() -> RvmResult {
    // create a guest physical memory set.
    let gpm = DefaultGuestPhysMemorySet::new();

    // create a guest.
    let guest = Guest::new(gpm)?;

    // create a vcpu.
    let mut vcpu = Vcpu::new(ENTRY, guest.clone())?;

    // map the guest physical memory region [0, 0x8000) to the host phyical
    // memory region [0xC0000, 0xC8000).
    let host_paddr = 0xC0000;
    guest.add_memory_region(0, 0x8000, Some(0xC0000))?;

    // I/O instructions with port 0x233-0x234 can cause VM exit and `vcpu.resume()`
    // to return.
    guest.set_trap(TrapKind::GuestTrapIo, 0x233, 2, None, 0xdeadbeef)?;

    // The bootstrap processor is in IA-32e mode and enabled paging, you need to
    // setup guest page table.
    setup_guest_page_table(host_paddr);

    // run the VCPU and block, until the specified traps occurs.
    let packet = vcpu.resume()?;

    // get the VCPU state.
    let state = vcpu.read_state()?;

    Ok(())
}

More examples

RVM is used as the hypervisor module of the following OSes:

It can also run in linux as a kernel module and replace the KVM hypervisor to support simple guest OSes such as uCore. See the ko example and rcore-vmm for more details.

Documents

rvm-tutorial-rcore's People

Contributors

kaitod avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.