Repository navigation
Add untyped split, a task status call and supervision of the terminal and the vault - #12
Merged
Merged
Conversation
- `UNTYPED_SPLIT` carves a child untyped of whole granules out of an untyped and touches no memory - A child yields exactly as many objects as it has granules, and a revoke gives its memory back to the child - `BAD_SIZE` is the new error for a count of zero - Host tests and the random model of `k0-cap` cover children - The root task builds a task from a slab twice at boot and checks the reuse Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
- `TCB_STATUS` returns not started, alive or ended for the holder of a `Tcb` capability and writes nothing - It gives no reason for the end, and the kernel tells nobody on its own - The boot self tests ask it wherever a task is made, blocks, exits, faults or is torn down Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
- The new crate `k0-sup` holds the policy and is tested on the host - Each service is built from its own slab and its own range of root slots, so a restart costs no slot and no memory - The root task asks every second tick whether a service ended and starts it again at most 3 times per boot - A vault that ended is erased first and comes back without a seed and without a key - The two hostile tasks are the first two starts of the terminal seat, so the restart path runs at every boot Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
- The design notes describe `UNTYPED_SPLIT`, `TCB_STATUS` and how the root task supervises the terminal and the vault - `SECURITY.md` says what a child untyped bounds and what it does not, and that a vault that is started again has no key - The usage notes list the lines the supervisor prints and what each means for the operator - A new figure shows the seats and the restart path - Test counts and marker lists follow the code, in English and in Korean Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Adds a way to give a task a bounded amount of memory, a way to ask whether a task ended, and with both of them supervision of the terminal and the vault. Until now an untyped capability could not be split, so a task that got one got all of it, and the terminal and the vault stayed dead if they died.
UNTYPED_SPLIT(system call 19) cuts a child untyped of a given number of granules out of an untyped capability. It touches no memory, allocates nothing in the kernel and runs in constant time. Every object is one granule, so a task that holds only a child of n granules gets exactly n objects from it. A child cannot be copied, can be moved into the CNode of another task, and can be split again.RETYPEdoes, and the documents now say so.TCB_STATUS(system call 20) tells the holder of aTcbcapability whether the task has not started, is alive or has ended. It writes nothing and gives no reason for the end. The kernel still tells nobody on its own. This is the first call whose successful result inx0can be something other than 0.terminal, the root task no longer blocks for ever afterroot: service started. At every second tick it asksTCB_STATUSfor the terminal and the vault. Each service is built from its own slab (a child untyped of 16 granules) and its own fixed range of root CNode slots, so a restart costs no slot and no memory. A service that ended is taken back and started again at most 3 times per boot, after waits of at least 2, 8 and 32 ticks.INIT, so after a vault restart there is no key until the next boot. When the terminal is down for good, a vault that is still up is stopped and erased.k0-sup: the policy of the supervisor. It isno_std, forbidsunsafe, has no dependencies and makes no system call. The loop in service and the self-test at boot call the same function.BAD_SIZE(-27).RETYPEis unchanged and bootinfo stays at version 5.SECURITY.md, the usage notes and the threat model describe all of this in English and in Korean, with one new figure.What this does not do: a child untyped bounds memory, not time. The kernel is still not preemptible, a revoke is as long as the number of capabilities it removes, and a restartable revoke is not part of this change. The vault is not in a domain of its own yet.
How it was tested
tools/host-test.shtools/qemu-boot-test.shDetails:
k0-mm. It was not run locally, and CI ran it.k0-caphas 71 (54 before): 17 new tests of the split, and the random model now splits, splits children and reuses the range of a child.k0-suphas 20 new tests on a mock host, among them 4000 random histories with five different limits.k0-vaulthas 2 more in each configuration andk0-abi1 more.tools/boot-matrix.shpass locally (Apple M5 Pro, QEMU 11.1.3,K0_MATRIX_HVF=1), 11 of them under HVF.tools/qemu-boot-test.shruns as the judge of its pass rows, and theterm*rows also run the scripted session oftools/term-test.py. The run was made atcf8b2d1. The one commit after it changes only documents and a figure.root: untyped split tests passandroot: tcb status tests pass. A terminal image also printsroot: terminal restart test pass, androot: vault restart test passwhen a vault is built in. These run the retire, erase and rebuild code of the supervisor on the real kernel before the service starts.k0_cap::splitwere tried, and each fails at least one host test. None of them is in this branch.Not covered:
root: supervision overare covered only by the host tests ofk0-supwith a mock host. The boot self-test runs retire and rebuild with one restart per service and without waits.root: vault erased before exitandroot: vault not erasedhave no test.sys_untyped_splitandsys_tcb_statusare in the kernel binary, which has no host tests. They are covered by the boot self-tests.Security notes
unsafe fn,k0_cap::split, with five blocks inside, and two new blocks inkernel/src/syscall.rs(the call intosplitand the read of one TCB state field through the kernel alias, without making a reference). The root task has new blocks for volatile reads and writes of frames it mapped itself. Each has its// SAFETY:comment.k0-supforbidsunsafe.UNTYPED_SPLITtakes a count that the caller controls. It is multiplied by the granule and added to the watermark with checked arithmetic, a count of 0 is refused before the slots are looked at, and a refused call changes nothing. The call writes two slots and no memory.TCB_STATUSreads one state field of the TCB and writes nothing.Tcbcapabilities carry no rights, so every holder may ask.RETYPEmust returnEXHAUSTED. The operator response frame is zeroed as well. If a check of the root task fails after the vault got its seed, the root task tries the same erase before it exits.k0-supis a new crate in the workspace with no dependencies, andvendor/is untouched.AI assistance
The design, the code, the tests and the documents in this pull request were made with Claude (Anthropic). Claude agents drafted and reviewed the design. The English documents were drafted in part by a Claude agent that was stopped before it finished. They were then completed and checked against the code, and the Korean documents and the figure were written, in the main session. The scope and the design decisions were chosen by the maintainer. The results under "How it was tested" are from real runs on the machine named there.
Contributor License Agreement
CLA signaturescheck shows who still needs to sign.