Apr 26, 2025by Benjamin Gallois

Part_0: Building a Minimal Hypervisor in Rust

🛠️ Part_0: Building a Minimal Hypervisor in Rust

In the next three blog posts, we will focus on building a simple hypervisor using Rust on Linux! Instead of using existing high-level frameworks, we'll start from the very basics, enabling VMX directly through a Rust-written Linux kernel module and work our way up to a working, simple virtual machine launch. In this series, we will learn a lot about how hypervisors work, how to compile the Linux kernel, and what tools are available to integrate Rust in the kernel.

📚 Part_1: Writing Your First Linux Kernel Module in Rust

We'll start by setting up a basic Rust kernel module. This is the first step to interacting directly with CPU features like VMX. We will first see how to compile the kernel, write a simple module in Rust, execute it, and see the result.

🧠 Part_2: Enabling Intel VMX in a Rust Kernel Module

Next, we'll explore how to activate virtualization features on Intel CPUs. For simplicity, our mock hypervisor will only focus on the Intel CPU. We'll check CPU capabilities, modify control registers, unlock MSRs, and finally enable VMX mode.

🚀 Part_3: Minimal VMLAUNCH

In this part, we will build upon our previous work, in which we successfully activated VMX operation inside our custom Rust Linux kernel module. The goal is to move one step further and become a real hypervisor by setting up a minimal guest environment, performing a VMLAUNCH to enter VMX non-root operation, and handling the first VMExit. At the end of this part, you will have a working (very) minimal hypervisor capable of launching a basic virtual machine context and trapping control back to the host — all written in pure Rust.