
Recall first from Booting a Linux guest on ARM
- QEMU virt supplies the virtual hardware and generates a matching DTB for direct Linux boot.
- The virtio-blk-device and virtio-net-device options use virtio-mmio in this configuration.
- An executable /init can start a shell from initramfs before Linux mounts a disk root.
Who controls an ARM system running Xen
4 min readThe last lesson ran KVM on ARM. This lesson answers Xen, the other main hypervisor, and its dom0/domU split with the hypervisor holding EL2.
An AArch64 Linux kernel needs a description of the platform it is about to boot on. On a device-tree boot, the entry convention supplies the address of the device tree in x0. On a Xen system, the Linux kernel starting as dom0 needs a description that reflects the CPUs, memory, and devices it can actually use. Someone must prepare that description before Linux can even print its first message. That responsibility belongs to Xen. Booting AArch64 Linux
Xen is a bare-metal hypervisor. On ARM it runs at EL2 and controls the execution of domains. It schedules their virtual CPUs, establishes their stage-2 mappings, and handles exceptions routed to EL2. On x86, Xen runs at ring 0. With hardware virtualization enabled for a hardware-virtualized x86 guest, the CPU also distinguishes hypervisor and guest execution using a separate virtualization mode. Ring numbers alone describe privilege within those modes. On ARM, the relevant placement for this lesson is Xen at EL2, domain kernels at EL1, and their user programs at EL0.
A virtual machine managed by Xen, with its own virtual CPUs, memory, and platform configuration has a role as well as a CPU execution level. In the conventional setup, Xen creates domain zero during boot. Dom0 is the privileged control domain and usually runs Linux. Dom0 can request operations on other domains, such as creating one or inspecting its state. It also commonly runs Linux drivers for physical devices assigned to it. A domU is an unprivileged domain. Its kernel manages its own processes and the resources visible to that domain. Root inside a domU can administer that guest's Linux system, and Xen still enforces the domain boundary on requests that reach EL2.
Stage-2 translation applies to dom0 as well as to domU. For example, Linux in dom0 may map the registers of a physical controller assigned to it and drive that controller through its usual kernel driver. Xen must make the relevant device address range accessible to dom0. A domU whose stage-2 mappings lack that range cannot use the same registers by copying the address from the board documentation. Likewise, when a dom0 kernel accesses ordinary memory, the CPU still checks the domain's stage-2 mapping of the intermediate physical address. Dom0's authority to issue management requests and its ability to address memory follow different rules. Xen checks the former, and the CPU applies the translations Xen configures for the latter.
The ARM port uses an HVM-style model. Both kinds of domain run their kernels in hardware-virtualized EL1 and their user code in EL0. Xen on ARM has no classic PV CPU guest mode of the kind associated with early Xen on x86. You will still see the label PV driver on ARM. In that context, PV describes a guest-aware device interface. An ARM guest can execute its normal kernel code at EL1 and use a PV storage or network driver in the same boot. Knowing which meaning of PV is in use tells you whether a configuration choice concerns CPU execution or a device interface.
From firmware to dom0 and the toolstack
4 min readFollow a conventional dom0-first boot. Firmware or a bootloader starts the Xen image before the dom0 Linux kernel runs. A UEFI configuration can start Xen through its EFI entry point. A device-tree-based loader can enter Xen with boot information describing the physical machine and identifying the images staged in memory. In either case, the ARM boot path must make EL2 available to Xen. The files staged for the boot can include a dom0 kernel image and an initial ramdisk. Staging the kernel bytes and starting the kernel are distinct events.
Xen initializes its own execution environment, reserves the memory it needs, and creates dom0 with a set of virtual CPUs and guest-visible memory. It loads the dom0 kernel into the domain using the boot image and places any supplied initial ramdisk where the kernel can reach it. On the device-tree path, Xen prepares the tree that dom0 will receive and passes the Linux command line in the tree's /chosen/bootargs. Xen's own boot arguments configure the hypervisor. The dom0 boot arguments configure Linux. For example, a Linux root filesystem argument belongs to the command line that reaches the Linux kernel. This distinction matters when Xen reaches the first Linux instruction successfully and Linux later fails to mount its root filesystem.
Xen sets up the initial vCPU state and starts dom0 at the kernel entry point. On a direct AArch64 device-tree boot, x0 at that point holds the guest-visible address of the flattened device tree. Linux reads the description, initializes the CPUs and devices it has been told about, and starts userspace once its boot dependencies are available. Xen can already schedule vCPUs and enforce stage-2 mappings at this point. Those mechanisms have to be available for even the first dom0 instructions to execute.
Management programs in dom0 userspace form the software that translates an administrator's domain configuration and lifecycle requests into operations on a Xen system. xl is the Xen command-line management program built on libxl, the Xen toolstack library. In the xl workflow, xl create reads a domain configuration and asks the library to construct and start the domain. xl list queries domain state. XAPI is a management stack that provides an API and supports managing Xen hosts and guests in systems that deploy it. It is a separate management option from the xl command-line workflow.
Think through a domain creation request with a kernel image, a memory allocation, and a vCPU count. The toolstack reads those choices and coordinates construction of the guest. Xen performs the privileged domain operations and enforces the resources available to the new domain. The domU kernel begins in the vCPU context prepared for it and discovers the machine described for that domain. The toolstack's successful return and the guest's successful Linux boot are separate milestones. A domain can exist and have an initial vCPU while its Linux kernel is still starting.
The Xen hypercall ABI is one interface available once domain code is running. An AArch64 Linux kernel issuing a Xen hypercall places the hypercall number in x16, places its first argument in x0 if the call has one, and executes HVC #0xEA1. Xen handles the exception at EL2 and returns the result in x0. The register's meaning therefore depends on the entry point and the direction of the call. At Linux kernel entry in a device-tree boot, x0 holds the DT address. At the hypercall instruction, x0 can hold the first argument. On return from the hypercall, it holds the result. Keeping those three moments separate makes a register trace much easier to read.
In the usual boot sequence, a failure before dom0 kernel entry belongs to the firmware-to-Xen or Xen-to-dom0 handoff. Once dom0 Linux runs, its own boot arguments and platform description matter. Once the toolstack can create a domU, that guest has its own kernel entry and boot configuration to examine. It is possible for Xen and dom0 to work normally while a domU has a kernel or command line that cannot complete its own boot.
Platform descriptions and secondary CPUs
4 min readWith device tree, Xen starts from information about the physical platform, then supplies a description for each kind of domain. For dom0, Xen constructs a tree based on the host tree, adapting it to the resources visible to dom0. That tree can describe real devices assigned to the control domain as well as virtual interfaces. For a typical Linux domU built by the toolstack, the guest gets a generated device tree describing its virtual platform. The tree describes the memory and CPUs visible to that domain, along with the interfaces the guest kernel should discover. Guest boot arguments can be supplied in its own /chosen/bootargs, independently of the arguments used for dom0.
ACPI is another way to describe an ARM platform. On an ACPI-capable Xen boot using EFI, platform discovery begins with the firmware ACPI tables, and Xen supplies an ACPI view to dom0 on that path. With arm64 Linux, EFI provides the discovery path to the ACPI root pointer, and ACPI tables describe resources such as CPUs and interrupt controllers. The description made visible to a domain must agree with the resources Xen presents to it. The physical firmware tables describe the underlying machine and cannot serve as a general description of an arbitrary domU. For the ordinary toolstack-created ARM Linux domU discussed here, follow the generated device tree. ACPI on Arm systems
A platform description tells Linux which CPUs it can bring online and how to request their startup. On the device-tree path, the guest's description can advertise PSCI, the ARM Power State Coordination Interface, and identify hvc as the calling method. PSCI uses its own function identifiers. The PSCI call that brings another guest CPU online is distinct from a Xen hypercall using HVC #0xEA1, even though both interfaces can use an HVC instruction to enter EL2.
At initial kernel entry, the guest runs on its boot vCPU. During SMP bring-up, Linux asks PSCI to start a secondary CPU with CPU_ON. The request identifies a target CPU and provides a secondary entry address. In a domain, the target is a virtual CPU in that domain, and the entry address refers to guest-visible memory. Xen resolves the target against the calling domain's vCPUs, checks the request and the target's state, sets up the secondary vCPU to begin at the supplied entry point on success, and makes it runnable. The Xen scheduler then decides when and on which physical CPU the vCPU executes. A successful request can therefore precede the moment when the secondary kernel code actually runs.
The distinction matters even for dom0. Its Linux kernel can use the guest PSCI interface to start another dom0 vCPU. Bringing a physical secondary core online during Xen's own boot is a separate operation, which Xen can carry out through platform firmware on systems that use PSCI for physical CPU startup. A guest's virtual CPU identifier is interpreted in the guest's domain. Physical CPU placement is determined by Xen's scheduling and affinity configuration, so the identifier used in the Linux request does not select a physical core.
This sequence also explains how an SMP boot can fail after an otherwise successful start. A guest description might advertise only one vCPU, in which case Linux has no secondary CPU to start. If it describes additional vCPUs, Linux needs the correct PSCI calling method and a target that Xen recognizes in that domain. The presence of a CPU node, acceptance of the CPU_ON request, and arrival at the secondary entry point are three separate observations. A system that reaches userspace on its boot vCPU has already demonstrated that the initial kernel handoff works. Secondary startup then depends on the platform description, the PSCI operation, and the secondary kernel entry.
Dom0 and domU now have their own running kernels and a defined way to request operations from EL2. The next lesson, Hypercalls, grant tables and event channels, explains how domains make Xen requests, share selected memory, and signal one another.
Key takeaways
- Xen retains EL2 while ARM dom0 and domU kernels run at EL1 under stage-2 translation.
- Dom0 ordinarily runs the management toolstack and has privileges to request domain operations.
- On AArch64, Xen hypercalls use HVC #0xEA1, with the call number in x16 and the first argument in x0.
- Xen handles a guest PSCI CPU_ON request by preparing a vCPU in the calling domain.
Reflect
- Explain to a colleague, in two sentences: assign CPU, memory, and guest management responsibilities to Xen, dom0, and domU.
- Which objective are you least sure about? Re-read that section, then do its exercise in the practice pack.
- 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.