Running Jailhouse on ARMv8: Bring-Up and Cells
In this article
Running Jailhouse on an ARMv8 board means partitioning the CPU cores, memory, and devices into isolated "cells" using a tiny hypervisor that runs directly on the hardware. This article explains what it takes to bring up Jailhouse on an ARMv8 system and how to create and manage cells, including the practical steps, common pitfalls, and configuration details.
What Is Jailhouse?
Jailhouse is a Linux-based partitioning hypervisor that runs on bare metal, not on top of an operating system. It separates the system into isolated domains called cells. The root cell is the Linux system that boots first and owns most hardware. Additional cells, called non-root cells, can be created to run bare-metal applications or other operating systems. On ARMv8, Jailhouse leverages the virtualization extensions (Virtualization Host Architecture, VHE) to run with minimal overhead. Unlike Type-2 hypervisors (like KVM), Jailhouse does not rely on a host OS for its core operation—it takes over after Linux has booted.
Bringing Up Jailhouse on ARMv8
Bring-up involves several stages: preparing the hardware, building the hypervisor, configuring the system, and loading the root cell. The following steps outline the typical process for an ARMv8 board (e.g., a Raspberry Pi 4, Xilinx ZCU102, or NVIDIA Jetson).
- Check hardware virtualization support: Ensure the ARMv8 CPU supports the Virtualization Extensions (typically ARMv8.1-VHE or later). Most 64-bit ARMv8 boards do, but some low-end SoCs may lack them.
- Build the hypervisor: Clone the Jailhouse source from the official repository, then cross-compile for your board. The build produces a
jailhouse.kokernel module and ajailhousebinary. - Prepare the device tree: Jailhouse uses a device tree to describe the hardware layout. You may need to modify the board's device tree to exclude memory regions that the hypervisor will manage.
- Load the hypervisor: Boot Linux, then insert the
jailhouse.komodule. This creates the root cell, which is the current Linux system. - Create a cell: Use the
jailhousecommand to enable a cell configuration file (e.g.,jailhouse cell enable mycell.cell). This assigns CPUs, memory, and devices to the new cell.
The key is that Jailhouse does not virtualize devices; it assigns them exclusively to cells. This means you must carefully plan which devices go to which cell.
Understanding ARMv8 Virtualization Extensions
ARMv8 introduces two exception levels for virtualization: EL2 (hypervisor) and EL1 (guest OS). Jailhouse runs at EL2, while the root cell Linux runs at EL1. The Virtualization Host Architecture (VHE) allows the hypervisor to run at EL2 with reduced overhead, but it also means the hypervisor must handle interrupts and memory management directly. On ARMv8.0 without VHE, Jailhouse runs at EL2 with a more traditional approach, which is slower but still functional. Most modern ARMv8 boards support VHE, but it's worth checking your SoC's manual.
Creating and Managing Cells
A cell is defined by a configuration file that specifies:
- CPUs: Which cores are assigned to the cell. These cores are removed from Linux's scheduler.
- Memory regions: Physical memory ranges that the cell can access. This memory is isolated from other cells.
- Devices: Which hardware devices (e.g., UART, GPIO, network controller) are assigned. The cell gets direct access to these devices.
To create a cell, you write a .cell file using the Jailhouse configuration format. The format is a binary structure that is generated from a text description using the jailhouse-config-create tool. For example, a simple cell might look like:
mem_regions = [
{ phys_start = 0x40000000, size = 0x100000, flags = 0 },
];
cpus = [ 1 ];
After enabling the cell, you can load a bare-metal binary into it using jailhouse cell load and start it with jailhouse cell start. The cell runs independently, and you can communicate with it via shared memory or virtual interrupts.
Common Pitfalls and Troubleshooting
Bringing up Jailhouse on ARMv8 can be tricky. Here are frequent issues and how to address them:
- Memory overlaps: If the cell's memory regions overlap with regions used by Linux, the hypervisor will refuse to load. Use the
jailhouse cell statscommand to check memory usage. - Device tree mismatches: The device tree passed to Linux must exclude memory and devices that will be assigned to cells. Otherwise, Linux may try to access them and cause a crash.
- Interrupt routing: On ARMv8, interrupts are routed via the Generic Interrupt Controller (GIC). Jailhouse must be configured to route interrupts to the correct cell. If a cell's device generates an interrupt that is not assigned, the system may hang.
- CPU hotplug: Jailhouse requires that CPUs assigned to a cell be removed from Linux's control. If the kernel does not support CPU hotplug, you may need to use a kernel command-line parameter like
maxcpus=1to limit the number of CPUs Linux uses.
Jailhouse vs. Other Hypervisors on ARMv8
Jailhouse is often compared to other open-source hypervisors like Xen or KVM. The main difference is that Jailhouse is a partitioning hypervisor, not a general-purpose one. It provides strong isolation and low overhead, but it cannot overcommit resources. Xen on ARMv8 can run multiple guest OSes with more flexibility, but it has a larger Trusted Computing Base (TCB). KVM is a Type-2 hypervisor that runs on top of Linux, which adds overhead but simplifies management. For safety-critical applications, Jailhouse is often preferred because of its minimal code size and predictable behavior.
Hardware Requirements and Board Support
Not every ARMv8 board is supported. The Jailhouse project maintains a list of supported boards, including the Raspberry Pi 4, Xilinx ZCU102, and NVIDIA Jetson TX2. The main requirements are:
- ARMv8 with virtualization extensions (EL2).
- Support for GICv2 or GICv3 interrupt controllers.
- Sufficient memory to partition.
- A device tree that can be modified to exclude resources.
If your board is not officially supported, you may need to write a custom configuration. This requires deep knowledge of the board's memory map and device addresses.
Safety and Security Considerations
Jailhouse is designed for safety-critical and security-sensitive applications. Because cells are isolated, a compromise in one cell does not affect others. However, misconfiguration can break this isolation. Always ensure that memory regions are correctly sized and that devices are assigned exclusively. Also, be aware that Jailhouse does not provide virtualized devices—if a cell needs a device that is shared, you must implement a communication mechanism (e.g., shared memory) yourself.
Frequently Asked Questions
Q: Can I run Linux inside a non-root cell? Yes, but it requires a bare-metal Linux kernel that can run without a hypervisor. You would need to build a kernel with the necessary drivers and configure it to use the assigned memory and devices.
Q: How do I communicate between cells? The common method is shared memory. You can reserve a memory region that is accessible to both cells and use a simple protocol (e.g., ring buffer) to exchange data. Jailhouse also supports virtual interrupts for signaling.
Q: What is the difference between a cell and a VM? A cell is a static partition of hardware resources. It cannot be resized or migrated. A VM, on the other hand, is a dynamic entity that can be created, destroyed, and moved. Jailhouse cells are fixed at configuration time.
Q: Does Jailhouse support device passthrough? Yes, that's its primary model. Devices are assigned to cells, and the cell gets direct access to the device's memory-mapped registers and interrupts. There is no emulation.
Q: Can I use Jailhouse on a 32-bit ARM board? No, Jailhouse is only supported on 64-bit ARM (ARMv8) and x86. The ARMv8 port is the focus of this article.
Q: What is the performance overhead of Jailhouse? The overhead is minimal, typically less than 2% for CPU-bound workloads. Since there is no device emulation, I/O performance is near-native.