Module 11 · Lesson 73 of 107

ACRN and its device model

Trace how ACRN starts a User VM, assigns its resources, and serves its virtual devices from a Linux Service VM.

  • Beginner to advanced
  • 9 min read
  • 75 min lab
What you will need

Ubuntu 24.04 in WSL2 or a VM for reading and configuration review. For the boot lab, use a supported bare-metal Intel x86-64 system with VT-x and VT-d, a matching ACRN checkout and build environment, a compatible Linux Service VM with HSM, and a bootable Linux User VM image with virtio PCI support.

Your place in the module
By the end you can 4 objectives
  • Identify where hv, HSM, and acrn-dm execute.
  • Distinguish board inventory, scenario policy, and User VM launch settings.
  • Trace a User VM device request through the Device Model and explain where a vhost backend runs.
  • Verify a post-launched User VM and its virtio device from both guests.
Video coming soonACRN and its device model
The video for this lesson is being recorded. Read the lesson below in the meantime.
Recall first from Jailhouse cells and internals
  • The Linux instance that enables Jailhouse continues running in the root cell and manages inmate cells.
  • A cell configuration declares CPU, memory, and device assignments, and the inmate must match the resulting address map.
  • EPT or Arm stage-2 translation enforces cell memory permissions for CPU accesses.
01

Where the Service VM runs

4 min read

The last lesson covered Jailhouse's minimal cells. This lesson answers ACRN, a fuller reference hypervisor with an SOS, UOS, a device model and a config tool.

An automotive or industrial computer can have several operating systems running at once, even when the board has only one storage controller. One VM might run a Linux operator interface while another runs an RTOS control workload. Each needs a way to boot and access the devices its software expects. Project ACRN, a Linux Foundation project, provides a Type-1 reference hypervisor for this kind of system. Its architecture puts CPU and memory control in the hypervisor and lets a privileged Linux guest supply device services. ACRN introduction and software architecture

The ACRN hypervisor, often called hv, boots on the machine and runs in Intel VMX root mode. It controls vCPU execution, guest memory mappings and interrupt delivery. The Service VM, or SOS in older ACRN terminology, runs Linux in VMX non-root mode. A User VM, or UOS, also runs in non-root mode and has its own operating system. The Service VM has special permissions to manage post-launched User VMs and access the physical devices assigned to it. Its kernel can run with guest kernel privileges and still remain subject to the hypervisor's controls.

ACRN execution rolesIntel hardwareACRN hypervisorVMX root modeService VMPrivileged Linux guestHSMService VM kernelacrn-dmService VM userspaceUser VMGuest OS and workloadIntel hardwareACRN hypervisorVMX root modeService VMPrivileged Linux guestHSMService VM kernelacrn-dmService VM userspaceUser VMGuest OS and workload
The Service VM and User VM both run above hv, with the device model and HSM inside the Service VM

Think of the virtual machine as three sets of state. The vCPU model gives the guest execution contexts with their own register state, and hv runs those contexts on physical CPUs according to the scenario and scheduling configuration. The virtual interrupt model gives the guest a virtual local APIC and lets hv deliver an interrupt to the appropriate vCPU. The guest handles that interrupt with its own kernel. The virtual device model gives the guest devices to discover and drive, such as a virtio block controller on its virtual PCI bus. These responsibilities meet at I/O completion. The device backend finishes the work and requests notification, and the hypervisor delivers the virtual interrupt.

The Linux Hypervisor Service Module, or HSM, is the Service VM kernel driver that provides the /dev/acrn_hsm interface. The Device Model, or DM, is the acrn-dm userspace program in the Service VM. For a post-launched User VM, the DM uses HSM to request operations such as VM creation, memory setup and VM start. HSM can issue the corresponding hypercalls to hv and coordinate the delivery of I/O requests to userspace. A useful distinction during bring-up is that the process configuring the User VM runs under the SOS scheduler, while the code executing inside the User VM runs on its own vCPUs.

The lab uses a post-launched Linux User VM. The Service VM boots first for this workflow, and a launch command or script starts the DM after Linux is running. ACRN also supports pre-launched VMs whose startup is handled by the hypervisor using the built configuration. A scenario can use that option for a dedicated workload and use post-launch for another workload on the same board. When reading a scenario, identify how each VM starts before looking for a corresponding acrn-dm process.

02

How a User VM gets a device

4 min read

Suppose the post-launched User VM uses a virtual disk backed by a file in the Service VM. In the SOS, the file is accessible through the normal Linux storage stack. In the UOS, the kernel discovers a virtio block device presented by acrn-dm on the virtual PCI bus. A guest driver binds to it and issues block requests. The UOS can see the disk without knowing the name of the backing file or which physical storage controller the SOS uses. The physical controller and the virtual block device have distinct PCI identities.

For an emulated PCI register access that exits to hv and requires userspace handling, hv records a request in an I/O request buffer shared with the Service VM. HSM dispatches the request to the appropriate I/O client. For a userspace request, acrn-dm handles the access against its virtual device state and signals completion through HSM. For a read, the completed request carries the value that the guest should receive. The hypervisor can then resume the vCPU for a synchronous emulated access. This control path explains how a guest can probe a virtual PCI device even though the program providing its registers runs in another VM. ACRN I/O request handling

An emulated PCI readUser VMhvHSMacrn-dmTrapped PCIreadShared I/OrequestDispatch readComplete withvalueNotifycompletionResume withvalue1. User VM → hvTrapped PCI read2. hv → HSMShared I/O request3. HSM → acrn-dmDispatch read4. acrn-dm → HSMComplete with value5. HSM → hvNotify completion6. hv → User VMResume with value
A synchronous emulated device read from a User VM reaches the Device Model through hv and HSM

Virtio uses shared memory for a different purpose. The guest driver places descriptors in a virtqueue in guest memory. The backend accesses the guest buffers described by the queue through mappings made available for device service. For the virtual disk example, a read puts bytes into guest buffers and updates the used ring. A completion notification, when needed, lets the guest driver finish the request. The I/O request buffer carries control information for intercepted operations. The virtqueue and its buffers carry requests and data for a specific virtual device. Keeping those two uses of memory distinct helps explain why seeing PCI register traffic tells you little about the volume of disk data transferred.

Older ACRN material uses vHM, or Virtual Hypervisor Manager, for the Service VM kernel component involved in VM management and I/O request handling. This lesson uses HSM, the name used by the Linux kernel documentation and the interface inspected in the lab. The shared I/O request interface is communication between hv and the Service VM. A virtio device also connects a UOS frontend to a backend serving it through shared guest memory. For application data exchanged between VMs, the system needs a configured mechanism. For example, applications can communicate over virtio-net interfaces connected to the same Service VM network, or a configuration with inter-VM shared memory can expose a designated region to participating VMs. With a shared region, the communicating software still needs a protocol for ownership, visibility and notification.

Going deeperWhere a vhost backend runs

A supported ACRN virtio device, such as virtio-net with a Linux vhost-net backend, can delegate queue processing to the Service VM kernel. The Device Model still presents and configures the guest-facing device. For kernel-backed operation it supplies the backend with the queue and memory setup and arranges notification. The backend can handle packets using the virtqueues and the configured networking endpoint without calling the userspace emulation loop to process every packet. Guest device discovery and the virtio driver still work through the advertised transport.

A guest report showing a virtio network device establishes which interface the guest sees. The backend is selected in the Service VM, so establishing that vhost is in use requires evidence from the actual launch settings or device-model diagnostics for that VM. A system can have vhost support available and still run a particular virtio device with a userspace backend.

03

From board inventory to a booted scenario

4 min read

The configuration tool takes two kinds of input. Board XML describes the target's hardware, including its logical CPUs and PCI functions. Start from the matching board description when one is available or use the board inspector from your ACRN checkout on the target before booting the hypervisor. A board profile obtained from a VM describes the virtual hardware exposed to that VM. A scenario XML describes how ACRN will use the target, including the VM roles and resource assignments. The configuration tool validates the inputs and generates configuration consumed by the hypervisor build. The post-launched VM also needs launch settings for its Device Model, such as the guest image and virtual device definitions. Use the startup script generated by the tooling when available for your checkout, or the matching example launch script.

From XML to guest bootBoard andscenarioXMLGenerate configurationValidatehardwareandassignmentsBuildhypervisorBoot hv andSOSLaunch UserVMDeviceModel usesHSMBoard andscenarioXMLGenerate configurationValidatehardwareandassignmentsBuildhypervisorBoot hv andSOSLaunch UserVMDeviceModel usesHSM
The board inventory and scenario policy determine the build, and the Service VM launches the configured User VM

What does assigning a CPU mean in practice? The board inventory identifies available physical logical CPUs. The scenario's vCPU affinity restricts where a guest vCPU may run. Guest CPU numbering belongs to that VM, so a guest's CPU zero does not identify a specific target CPU by itself. Review the actual affinity assignment in the configuration. When a scenario reserves CPU resources for a dedicated VM, pick the relevant CPUs from the board topology and check the assignments for the other VMs against that reservation. Keep sufficient resources for the Service VM, which must run Linux and service the post-launched guest's I/O.

For PCI passthrough, identify the physical function by its address in the target's inventory. The configuration and launch settings designate the function for the receiving VM, and the system must keep the function available for assignment. In the DM-backed post-launched case the DM can help set up the guest's PCI view and request assignment. The guest then uses the hardware's own driver for the assigned function. A function the SOS depends on, such as the controller serving its boot storage, cannot be treated as freely available for assignment. The base lab uses a virtio block device so the SOS can retain its storage controller and service the guest disk through a backing image.

Use one ACRN checkout throughout configuration, build and boot. Create a scenario with a Service VM and a post-launched Linux UOS from a matching example, validate it against the target board XML, and save the inputs with your lab notes. Use that checkout's build procedure with the validated board and scenario selections. Install the resulting hypervisor image using the checkout's instructions for the lab target's bootloader, retain a boot entry for ordinary Linux, and boot into the ACRN entry. Have a console available during boot so you can tell whether hv starts and hands execution to the intended Linux Service VM. A compatible SOS kernel with HSM enabled and a DM built for that working environment are prerequisites for launching the UOS.

In the Service VM, ls -l /dev/acrn_hsm checks whether the expected device node is present. Its presence alone does not prove the DM can use it. Once you run the post-launch script with the intended guest image, ps -C acrn-dm -o pid,args lets you identify the process and compare its arguments with the script. In the User VM console, lspci -nnk can show the virtual PCI function, its numeric identifiers and the bound driver when one is present. For a virtio PCI disk, a PCI transport driver binds to the PCI function and the virtio block driver handles the block device exposed through that transport. lsblk lets you correlate the block device with the disk expected from the launch settings. These checks assume pciutils is installed in the Linux guest and the image has the required virtio PCI and block support.

The observations distinguish stages of bring-up. If the Service VM boots and the node is absent, check how Linux booted and whether its HSM driver is available. If the DM runs but the guest never reaches its console, inspect the DM diagnostics and the guest boot settings. If the UOS boots and sees a virtio PCI function but lacks the corresponding block device, check the PCI driver binding, the guest's virtio block support and the selected backend. Record the evidence separately for each VM so a physical PCI inventory from the SOS cannot be mistaken for the UOS device list.

The next lesson, “Why partition for safety and real time,” asks why a system designer would give some workloads dedicated resources while serving others through the Service VM.

Key takeaways

  • ACRN runs in VMX root mode and boots the Linux Service VM as a privileged guest.
  • For a post-launched User VM, acrn-dm requests VM operations through the Service VM's HSM driver.
  • Board XML describes the target hardware and scenario XML defines how the VMs use its resources.
  • A virtual device can use a userspace backend or, where supported, a kernel vhost backend while keeping the virtio interface visible to the guest.
Reflect
  1. Explain to a colleague, in two sentences: identify where hv, HSM, and acrn-dm execute.
  2. Which objective are you least sure about? Re-read that section, then do its exercise in the practice pack.
  3. What surprised you when you ran the commands yourself?
On a real board

Repeat the key commands on your Raspberry Pi or lab board over SSH or the serial console. Note anything that behaves differently from your PC, such as missing tools, a BusyBox shell or a read-only filesystem.

References and further reading

Official documentation first. Links checked when the lesson was published.

Find your next step

↑ ↓ to move · Enter to open · Esc to close