Skip to contentSkip to conversation

mklinux v7.0-mk6: multikernel Linux, now on RISC-V

ANNOUNCE Cong Wang 1 participant 1 message Dec 2 RISC-V

lore
Share & tools
lore

Cong Wang

author
#0 lore raw

Hi all,

mklinux v7.0-mk6 is out, together with kerf 0.6.0. mklinux is an out-of-tree branch of Linux that lets one machine run several Linux kernels side by side without a hypervisor. A host kernel sets aside a pool of CPUs, memory and PCI devices, loads another kernel into it with kexec_file_load() and starts it on those CPUs. Each kernel then runs natively on its own share of the machine. The kernels talk over shared-memory rings and IPIs, which carry a console, AF_VSOCK and PCI config space access, and a kernel can take the whole machine over from its host, which is what kernel upgrade and crash recovery are built on. kerf is the user-space tool that drives all of this.

This release is 88 patches on top of v7.0-mk5, and the tree is 419 patches on top of v7.0.

What is new
===========

RISC-V
Multikernel now runs on RISC-V as well as x86_64 and arm64. Harts are started, confirmed stopped and released through SBI HSM, and every started hart enters through a fence.i stub. An Image is loaded with kexec_file_load() and boots from a device tree the host builds for it. The doorbell is an SBI IPI. A spawned kernel takes its MSIs in the IMSIC files of its own harts, and the IOMMU of a lent device is given those files. A kernel is forced down through an SBI SSE software event where firmware has it, which reaches a hart with interrupts masked, and with the doorbell otherwise. RISC-V memory hot-remove learned to split the linear map leaves a partial removal ends in.

Foreign CPUs
The pool is defined over the machine and not over the host, so it can hold CPUs the host kernel has no logical CPU for, such as the heterogeneous cores of a SpacemiT K3, and an instance can be started on them. They join the pool without being asked for, and the root device tree shows them as cpus-unclaimed with one node per kind under /cpu-kinds. Every CPU of an instance must be of one kind. On RISC-V the harts the device tree leaves out are discovered through SBI.

AMD IOMMU
What VT-d got in v7.0-mk5 now holds on AMD. The host describes its IOMMUs to another kernel and writes the remapping entries of a lent function, a spawned kernel remaps its interrupts behind the host's IOMMUs, and a kernel that took the machine over claims them. On both vendors a spawned kernel's interrupts are remapped behind a bridge's alias.

Kernel file descriptors
kexec_file_load() returns a file descriptor for the kernel it loads an image for, and KEXEC_FILE_MK_OPEN returns one for any instance that exists. An instance is started, halted and inspected through ioctls on it. A start can bring its own command line, which replaces the loaded one for that run, so boot parameters change without loading the image again. A graceful halt waits as long as its caller says.

Isolation
Root in a spawned kernel can no longer reach the rest of the machine through /dev/mem, /dev/port, iopl(), ioperm() or TIOCSSERIAL, until that kernel has fenced its host and taken the machine over. An instance gets a message ring to the host only if it asks for one, so a static partition that no kernel can message can be created.

Devices
The PCI functions of an IOMMU group are lent together, with one owner and one domain, and a group that holds a bridge is not lent. An instance can read the expansion ROM of a function lent to it, which a GPU driver needs for its video BIOS.

Faulty CPUs
A core that dies of an AMD core parity error is marked in its park cells, which every later kernel on the machine inherits. A kernel that takes over shows the marked CPUs to user space in a multikernel,faults node, so that it can leave them out.

kerf 0.6.0
Spawned kernels can be locked down. "kerf start --lockdown" boots one at either of the kernel's two lockdown levels, and "--deny" adds individual confidentiality restrictions on top of integrity, enforced inside the spawned kernel by kerf-init with a BPF LSM program before the entrypoint runs. Everything that is a boot parameter is now chosen per run on "kerf start": lockdown, console, network, entrypoint and extra parameters. kerf runs on RISC-V hosts, and the new "kerf cpus" lists every CPU with its physical ID, its NUMA node and who holds it.

ABI change
==========

The reboot() commands that started and halted an instance are removed, and so is /proc/kimage. A loader has to use the descriptor that kexec_file_load() returns and its ioctls: KEXEC_MK_IOC_START, KEXEC_MK_IOC_HALT, KEXEC_MK_IOC_INFO and KEXEC_MK_IOC_CMDLINE. A spawned kernel can fence its host, with KEXEC_MK_IOC_FENCE, only when the host started it with KEXEC_MK_START_MAY_FENCE. A running instance cannot be unloaded.

kerf 0.6.0 uses the descriptor, so it needs v7.0-mk6, and kerf 0.5.0 does not work on v7.0-mk6. Its command line changed as well: the network and console options moved from "kerf load" to "kerf start", and a spawned kernel now powers off when its entrypoint exits, as a container does. The kerf release page has the full list.

Getting it
==========

  git:      https://github.com/multikernel/linux.git, tag v7.0-mk6
  release:  https://github.com/multikernel/linux/releases/tag/v7.0-mk6
  kerf:     https://github.com/multikernel/kerf/releases/tag/v0.6.0
  docs:     Documentation/multikernel/ in the tree

The release page has the full change list and deb and rpm packages for x86_64 and arm64, built with the Ubuntu 26.04 generic config plus CONFIG_MULTIKERNEL=y.

Known limitations
=================

- A RISC-V instance gets PCI devices only, no platform devices, as on arm64.
- There are no prebuilt packages for RISC-V yet; the kernel has to be built from the tag.
- The prebuilt packages have no debug info, hence no BTF, and are not Secure Boot signed. "kerf start --deny" needs BPF LSM and BTF in the spawned kernel, so it needs a kernel built with them.
- The in-tree DAXFS is removed; it is maintained as an out-of-tree module.

Testing, bug reports and review are all welcome, on the list or in the issue tracker at https://github.com/multikernel/linux/issues.

Thanks,
Cong