Skip to content

kerf: Run on RISC-V hosts and handle CPUs the host never booted - #24

Merged
congwang-mk merged 2 commits into
mainfrom
riscv-porting
Nov 24, 2026
Merged

congwang-mk merged 2 commits into
mainfrom
riscv-porting

Conversation

@congwang-mk

Copy link
Copy Markdown
Contributor

Summary

Two commits that let kerf run on RISC-V hosts, including machines whose device tree leaves some CPUs out of the host.

Support RISC-V hosts

  • riscv64 uses the generic syscall table, as arm64 does, so kexec_file_load is 294 and reboot is 142. kerf used to fall back to the x86_64 numbers with a warning.
  • A hart's physical ID is its hart ID. /proc/cpuinfo only has it for online harts, but the device tree node keeps it in reg for a hart given to the pool, which is where kerf already reads an arm64 MPIDR from. Only the name in messages changes.

Show and keep the pool's CPUs the host never booted

  • The kernel finds CPUs the host's device tree leaves out when the pool is first set up, keeps them in the pool, and lists them under cpus-unclaimed in the root device tree. Where the CPUs are not all alike, /cpu-kinds says which are of which kind. kerf now reads both.
  • --cpus keeps meaning host CPUs: every request carries the unclaimed ones along, and so does a replayed dump.
  • A pool with none of the host's CPUs is no longer an error, since it can still hold unclaimed ones.
  • An instance whose CPUs are of more than one kind is refused, with a clearer message than the kernel would give.
  • kerf show lists the unclaimed CPUs and, where there is more than one kind, the CPUs of each.

Testing

  • pytest tests: 618 passed, 1 skipped
  • New cases in test_parser_pool.py, test_validator.py, test_init_reconcile.py and test_topology.py

🤖 Generated with Claude Code

riscv64 uses the generic syscall table, as arm64 does, so kexec_file_load
is 294 and reboot 142 there too; kerf fell back to the x86_64 numbers
with a warning.

A hart's physical ID is its hart ID, which /proc/cpuinfo only has for
online harts. Its device tree node keeps it in reg for a hart given to
the pool as well, which is where kerf already reads an arm64 MPIDR
from, so only the name in messages changes.

Signed-off-by: Cong Wang <cwang@multikernel.io>
A machine can have CPUs the host's device tree leaves out, the cores of
another kind where there are two. The kernel finds them when the pool
is first set up and keeps them in the pool from then on, listed under
cpus-unclaimed in the root device tree. Where the CPUs are not all
alike, /cpu-kinds says which are of which kind.

Read both. The unclaimed CPUs need not be asked for and cannot be given
back, so --cpus keeps meaning host CPUs: every request carries the
unclaimed ones along, and so does a replayed dump, which lists those
of the machine it was taken on. A pool with none of the host's CPUs is
no longer an error, as it can still hold unclaimed ones, which kerf
only learns of once the pool exists.

One kernel runs on one kind of CPU only. Refuse an instance whose CPUs
are of more than one kind, which the kernel would refuse as well, with
less to say about why.

kerf show lists the unclaimed CPUs and, where there is more than one
kind, the CPUs of each.

Signed-off-by: Cong Wang <cwang@multikernel.io>
@congwang-mk
congwang-mk merged commit 4e916cb into main Nov 24, 2026
8 checks passed
@congwang-mk
congwang-mk deleted the riscv-porting branch November 24, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant