Skip to content

Add untyped split, a task status call and supervision of the terminal and the vault - #12

Merged
Quant-TheodoreFelix merged 4 commits into
mainfrom
untyped-split-supervision
Dec 4, 2026
Merged

Quant-TheodoreFelix merged 4 commits into
mainfrom
untyped-split-supervision

Conversation

@Quant-TheodoreFelix

@Quant-TheodoreFelix Quant-TheodoreFelix commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

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: 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.
  • Revoke and delete of a child: revoking a child gives its memory back to the child, not to the parent. Deleting a child gives nothing back to the parent until the parent has no descendants. Revoke does not zero memory, only RETYPE does, and the documents now say so.
  • Task status: TCB_STATUS (system call 20) tells the holder of a Tcb capability 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 in x0 can be something other than 0.
  • Supervision: in an image built with terminal, the root task no longer blocks for ever after root: service started. At every second tick it asks TCB_STATUS for 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.
  • A vault that ended: its slab is erased before anything else is made of it, by retyping all 16 granules as frames. The vault that is started in its place has no seed and no key and refuses 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.
  • New crate k0-sup: the policy of the supervisor. It is no_std, forbids unsafe, has no dependencies and makes no system call. The loop in service and the self-test at boot call the same function.
  • Interface: two new system call numbers and one new error, BAD_SIZE (-27). RETYPE is unchanged and bootinfo stays at version 5.
  • Documents: the design notes, 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.sh
  • tools/qemu-boot-test.sh
  • New or changed behavior has a test

Details:

  • Host tests: 457 pass on an AArch64 host at the head of this branch (415 before). The number for other hosts, 369, is that count without the 88 tests of k0-mm. It was not run locally, and CI ran it. k0-cap has 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-sup has 20 new tests on a mock host, among them 4000 random histories with five different limits. k0-vault has 2 more in each configuration and k0-abi 1 more.
  • Boot matrix: all 82 rows of tools/boot-matrix.sh pass locally (Apple M5 Pro, QEMU 11.1.3, K0_MATRIX_HVF=1), 11 of them under HVF. tools/qemu-boot-test.sh runs as the judge of its pass rows, and the term* rows also run the scripted session of tools/term-test.py. The run was made at cf8b2d1. The one commit after it changes only documents and a figure.
  • CI: the run for this pull request passed on both runners: the host tests (457 on the ARM runner, 369 on the other), and all 71 rows of the boot matrix with no retry of the window test. The jobs took 31 and 33 minutes of the 45 minute limit.
  • Boot self-tests: every image prints root: untyped split tests pass and root: tcb status tests pass. A terminal image also prints root: terminal restart test pass, and root: vault restart test pass when a vault is built in. These run the retire, erase and rebuild code of the supervisor on the real kernel before the service starts.
  • Broken code: eight deliberate breaks of k0_cap::split were tried, and each fails at least one host test. None of them is in this branch.
  • Release build: the release image with the 16 KiB granule that the CI image builds was built locally and has no error.

Not covered:

  • No committed test makes the real terminal or the real vault end during service. The waits, the budget of 3, the stop of the vault when the terminal is down and root: supervision over are covered only by the host tests of k0-sup with a mock host. The boot self-test runs retire and rebuild with one restart per service and without waits.
  • The erase of an ended vault is not read back in service. That a slab which was revoked and retyped reads as zero is checked on another slab, by the split self-test.
  • root: vault erased before exit and root: vault not erased have no test.
  • sys_untyped_split and sys_tcb_status are in the kernel binary, which has no host tests. They are covered by the boot self-tests.
  • Nothing ran on real hardware.

Security notes

  • Review: no independent review of the code ran before this pull request. The design was reviewed before the implementation, and the review of the code that was planned did not run. The two new system calls are reachable from EL0 in every image.
  • Unsafe: one new unsafe fn, k0_cap::split, with five blocks inside, and two new blocks in kernel/src/syscall.rs (the call into split and 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-sup forbids unsafe.
  • New kernel state reachable from EL0: UNTYPED_SPLIT takes 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_STATUS reads one state field of the TCB and writes nothing. Tcb capabilities carry no rights, so every holder may ask.
  • Trust boundaries touched: the system call boundary (two new calls). The root task stays trusted and is itself not supervised. No service gets an untyped: the slabs stay in the root task's CNode.
  • Key material: a vault that ended, or that is stopped because the terminal is down for good, is erased by retyping its whole slab, and a 17th RETYPE must return EXHAUSTED. 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.
  • Availability: whatever makes the terminal end, a fault included, makes the root task run the restart path, and a terminal that ends once more after its third restart stays down until the next boot. Supervision is polling, so an end is seen up to two ticks late, and a service that hangs without ending is not noticed. Losing the key when the vault ends is by design.
  • Dependencies: none from outside the workspace. k0-sup is a new crate in the workspace with no dependencies, and vendor/ is untouched.
  • Advisories: no status is changed here.

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

  • I have signed the CLA. If this is the first pull request that needs your signature, comment the sentence from CONTRIBUTING.md on this pull request. The CLA signatures check shows who still needs to sign.
  • Or: every change in this pull request is trivial as defined in section 12 of the CLA.

Quant-TheodoreFelix and others added 4 commits November 28, 2026 17:15
- `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>
@Quant-TheodoreFelix
Quant-TheodoreFelix merged commit 6230f48 into main Dec 4, 2026
3 checks passed
@Quant-TheodoreFelix
Quant-TheodoreFelix deleted the untyped-split-supervision branch December 4, 2026 11:29
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