blog.rust.gay

Multikernel Linux reaches arm64 without a hypervisor

Cong Wang announced mklinux v7.0-mk5 on November 17. The project is an out-of-tree branch of Linux that lets one machine run several Linux kernels side by side without a hypervisor. The new release adds arm64 support to a design that previously worked only on x86_64.

The pitch is easy to misread. This is not containers, and it is not KVM with a different logo. Each kernel runs natively on its own share of CPUs, memory and PCI devices. The host carves out those resources, loads the guest kernel with kexec_file_load(), and starts it on the assigned CPUs. The kernels talk over shared-memory rings and inter-processor interrupts.

That is a different isolation model from a hypervisor. It is also a different set of problems, which is what makes the arm64 work interesting.

Native kernels on leased hardware

The host kernel keeps a pool of CPUs, memory and PCI devices. A spawned kernel gets a slice of each. The host loads the new kernel image with kexec_file_load(), builds a device tree for it on arm64, and starts it on the CPUs it was given. From that point, the spawned kernel runs natively, not as a guest under a hypervisor.

The kernels still need to communicate. mklinux uses shared-memory rings and IPIs to carry a console, AF_VSOCK and PCI config-space access. A kernel can also take the whole machine over from its host. That takeover path is the basis for kernel upgrade and crash recovery: the new kernel starts, takes the hardware, and the old one steps aside.

The appeal is performance and simplicity. There is no VM exit, no second-stage address translation for the kernel's own memory, and no hypervisor to schedule. The cost is that isolation depends on the leases being correct. If a spawned kernel can reach memory or a device it was not given, the model fails in a way that a hypervisor's boundary would have caught.

What arm64 required

The arm64 port is more than a recompile. CPUs are started, confirmed off and released through PSCI, ARM's standard power and boot interface. The host builds a device tree for the spawned kernel, loads an Image with kexec_file_load(), and boots it from that tree.

Interrupts are the harder part. A spawned kernel is a tenant of the GICv3. It leaves the distributor and LPI setup to the host and initializes only the redistributors and CPU interfaces for its own CPUs. That split is necessary because the distributor is global; if a tenant reprogrammed it, the host and every other tenant would be affected.

A spawned kernel gets PCI devices only, with MSIs routed through whichever host ITS serves the device. Platform devices are not handed over, because every SPI goes through the one GIC distributor that stays with the host. That is a real limitation, not a temporary bug. An arm64 instance can drive a PCI NIC or accelerator, but it cannot take over an embedded controller or a platform device that depends on a shared interrupt.

Shutdown also needed architecture-specific work. Where firmware supports it, a kernel is forced down through SDEI event 0, which reaches a CPU even when every exception is masked. Without SDEI, the host uses a stop IPI. An arm64 spawn must boot with pseudo-NMIs (irqchip.gicv3_pseudo_nmi=1) so the host can stop it reliably when SDEI is not available.

Memory hot-remove had to learn a new trick as well. On arm64, removing a partial linear-map leaf now has to split the leaf or refuse the removal, and free the page tables and vmemmap that become empty. That is the kind of detail that only shows up when a kernel can hand memory back to a host that is still running.

Isolation is in the leases

The most important part of the design is not the boot path. It is the device lease.

When a PCI function is lent to another kernel, the host keeps it on a stub driver, the same pattern vfio-pci and xen-pciback use. Everything the host sets up for that function hangs off one lease. When the lease ends, the function is reset while it is still confined.

DMA is confined through the IOMMU to the memory of the kernel that drives the device, on arm64 with SMMUv3 and on x86 with VT-d. The mapping follows the tenant kernel's memory as it grows and shrinks. That last part is what makes the lease usable for a real kernel: a static mapping would break as soon as the tenant allocated more memory.

Interrupt remapping gets similar treatment. On VT-d, the host leaves alone the units another kernel drives, lends each spawned kernel a block of interrupt-remapping entries, and checks every entry written into it. A kernel that took the machine over can claim the units of its fenced host without turning translation off.

Chained takeover extends the model. A kernel that took over from its host becomes instance 0, can online the memory it adopted as kernel memory, and can arm and hand over to a successor. That can happen repeatedly. On x86, parked CPUs no longer wait on slots owned by one kernel; there is one park table for the machine with a cell per CPU, so any kernel can find and wake a parked CPU.

Each parent/child pair also has its own rings. A kernel that dies in the middle of a send can wedge its own link, but not every other link in the machine. These are small design choices that add up to a system that can survive a tenant failure without taking the host down.

The limits

The arm64 port is real, but it is not a drop-in replacement for a hypervisor.

The first limit is device coverage. An arm64 instance gets PCI devices only. No platform devices, no shared SPI, no embedded controllers. That rules out a lot of arm64 hardware before the kernel even boots.

The second is the boot requirement. Pseudo-NMIs are needed when SDEI is absent, which adds a firmware and configuration dependency. The prebuilt packages also have no debug info, hence no BTF, and they are not Secure Boot signed. None of that matters for a lab; all of it matters for a product.

The third is the ABI change. The multikernel flag and instance ID moved to the upper half of the kexec_file_load() flags, as KEXEC_FILE_MULTIKERNEL (0x80000000) and KEXEC_FILE_MK_ID_MASK (0x7fff0000). The old values collided with KEXEC_FILE_NO_CMA and KEXEC_FILE_FORCE_DTB. A loader built against v7.0-mk4 or earlier has to be rebuilt. The user-space tool, kerf 0.5.0, uses the new layout.

The fourth is the obvious one: this is out-of-tree. The tree is 330 patches on top of v7.0, with 114 of them new in this release. That is a lot of code to carry, and out-of-tree patches have a way of drifting away from the mainline.

Why not just use a hypervisor?

The obvious question is why anyone would run several kernels natively when KVM already does isolation well. The answer is cost and control, not a claim that hypervisors are bad.

A hypervisor adds a second layer of scheduling and address translation. VM exits cost time, passthrough devices need IOMMU setup, and the guest kernel is a guest: it does not own the hardware. For a tenant that just needs a Linux environment, that is a good trade. For a workload that wants to run a full kernel on bare metal, the hypervisor is overhead.

Multikernel removes that layer but keeps a boundary. The boundary is the lease: a fixed set of CPUs, a memory range, and a set of PCI functions with IOMMU confinement. The host still owns the machine and can stop a tenant. The tenant still runs natively.

The trade-off is that the boundary is thinner. A hypervisor has decades of hardening around device emulation and memory isolation. Multikernel relies on the host's IOMMU and the correctness of the lease code. That is why the arm64 port spends so much effort on SMMUv3, interrupt remapping and device reset. The model is only as good as those pieces.

What it is for

The clearest use case is kernel upgrade and crash recovery. A new kernel can be started alongside the old one, take over the machine, and leave the old kernel behind as a fallback. That is attractive for systems that cannot afford a reboot window, and it is the use case the takeover path was built for.

The second is tenant kernels: a machine that runs several independent Linux instances without a hypervisor, each with its own device lease. That is closer to a cloud model than a container model, but it is not a general-purpose replacement for VMs. The device limitations and the out-of-tree status keep it in the research and appliance space for now.

The third is testing. A multikernel host can run a new kernel next to a known-good one and compare behavior on the same hardware. That is useful for driver development and for anyone who has ever debugged a regression that only appears on real devices.

Conclusion

mklinux 7.0-mk5 is a substantial piece of systems work. The arm64 port required PSCI startup, GICv3 tenancy, SDEI and stop-IPI shutdown, memory hot-remove changes, and an ABI fix. The device-lease and IOMMU work is what makes the model plausible rather than a demo.

It is not a hypervisor replacement, and the project does not claim it is. It is a different point in the design space: native kernels, explicit leases, no VM exits. If that point matters for your upgrade or isolation problem, the release page has the patches, the kerf tool and deb/rpm packages for x86_64 and arm64. If it does not, the arm64 limitations are a good reason to wait.

Sources


← back to posts