Skip to content

multikernel: take a halt notice only from the kernel that halted - #56

Merged
congwang-mk merged 1 commit into
multikernel:masterfrom
pro-utkarshM:fix/mk-halt-notice-sender
Nov 24, 2026
Merged

congwang-mk merged 1 commit into
multikernel:masterfrom
pro-utkarshM:fix/mk-halt-notice-sender

Conversation

@pro-utkarshM

@pro-utkarshM pro-utkarshM commented Nov 24, 2026 •

Copy link
Copy Markdown

MK_SYS_HALTED and MK_SYS_SHUTDOWN_ACK name the halted instance by the resource_id in their payload, and the host acts on that ID. A spawn can report the halt of a sibling that is still running: the host fences the sibling's device leases and moves it to LOADED, or ends its wait for the sibling's graceful halt early.

Since b296ae5 the handler knows which ring a message came in on. Drop a halt notice unless it comes from a child and names that child, as MK_SYS_SHUTDOWN already checks its sender. The notice stays in the ring slot, which the sender can still write, so after the check the handlers act on from->id instead of reading the payload again. The warning is rate limited.

Tested: RISC-V QEMU virt (aia=aplic-imsic, OpenSBI v1.8.1), #49 head b4be1bf with #55–#59 applied: graceful and forced halts, in-spawn poweroff and reboot all still settle the instance (28 spawns). A spoofed notice was not sent at runtime; that needs a modified spawn kernel. Builds on current master (fca2f47): x86_64 clang W=1 with no new warnings, also with PCI=n and with MULTIKERNEL=n; checkpatch --strict clean.

MK_SYS_HALTED and MK_SYS_SHUTDOWN_ACK name the halted instance by the
resource_id in their payload, and the host acts on that ID. A spawned
kernel can therefore report the halt of a sibling that is still
running: the host settles the sibling as halted, which fences its
device leases and moves it to LOADED, or completes the host's pending
wait for the sibling's graceful halt early.

Since commit b296ae5 ("multikernel: Tell message handlers which
kernel sent the message") the handler knows which ring a message came
in on. Drop a halt notice unless it comes from a child and names that
child, as MK_SYS_SHUTDOWN already checks its sender. The handler reads
the notice in the ring slot itself, which the sender can still write,
so act on the sender's ID rather than reading the payload again, and
rate limit the warning a misbehaving child can trigger at will.

Fixes: 00dde38 ("x86/multikernel: Return CPUs to the pool on spawn kernel halt")
Signed-off-by: Utkarsh Maurya <projects.utkarshMaurya@gmail.com>
@pro-utkarshM

Copy link
Copy Markdown
Author

Tested at runtime on RISC-V QEMU (#49 head + #55–#59), with a test-only hook letting spawn A send MK_SYS_HALTED naming running spawn B. Without this patch the host settled B to LOADED ("Instance 2 (b) halted, CPUs parking in pool") while B kept running, and mkctl halt 2 then failed with EINVAL. With it: "Instance 1 reported the halt of instance 2, ignored", B stays active, and halting B works.

@congwang-mk
congwang-mk merged commit 28450bf into multikernel:master Nov 24, 2026
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.

2 participants