kvm: add kvm crate to safely use kvm

This change adds a library that makes the usage of kvm safe. Features
that are in this initial patch are:
- checking for kvm extensions
- creating vms and vcpus
- adding memory regions
- accessing cpu registers
- running vcpus
- using kvm_run structure on kvm exit
- registering ioevents and irqevents

TEST=cargo test [--target=armv7a-cros-linux-gnueabi]
BUG=chromium:711556

Change-Id: I1f18aad0341ef5129bc5504e9419a3c422d8bdfd
Reviewed-on: https://chromium-review.googlesource.com/478551
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
4 files changed
tree: a0e96663e2e7ba837d2a137b42321f9fb0c0a064
  1. kvm/
  2. kvm_sys/
  3. sys_util/
  4. .gitignore
  5. LICENSE
  6. README.md
README.md

Chrome OS KVM

This component, known as crosvm, runs untrusted operating systems along with virtualized devices. No actual hardware is emulated. This only runs VMs through the Linux's KVM interface. What makes crosvm unique is a focus on safety within the programming language and a sandbox around the virtual devices to protect the kernel from attack in case of an exploit in the devices.

Overview

The crosvm source code is organized into crates, each with their own unit tests. These crates are:

  • kvm-sys low-level (mostly) auto-generated structures and constants for using KVM
  • kvm unsafe, low-level wrapper code for using kvm-sys
  • crosvm the top-level binary front-end for using crosvm

Usage

Currently there is no front-end, so the best you can do is run cargo test in each crate.