Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ $ cargo build -p k0-kernel --features console --offline
$ tools/qemu-boot-test.sh # boot under QEMU and check the self-tests
```

`tools/host-test.sh` runs the tests of `k0-abi`, `k0-cap`, `k0-boot`, `k0-efi`, `k0-conin`, `k0-slice`, `k0-part`, `k0-vault` and `k0-term` on any host (415 tests on an AArch64 host, 327 elsewhere). `k0-slice` has 9 tests: they run the rule that decides whether a tick cuts the running task on a model of the scheduler. `k0-part` has 36 tests: they run the scheduler's decisions under a time partition table on a model of the kernel, check the arithmetic of tick instants, and compare the Rust code with the recorded results of a Lean model (see "Changing the scheduler core" below). It runs `k0-vault` twice, with and without the algorithm feature `vault-ed25519`, which gives 20 and 11 tests. It runs `k0-term` with and without the vault feature, which gives 24 and 21 tests. The tests of `k0-mm` contain AArch64 inline assembly, so they only run on an AArch64 host (Apple Silicon or Linux arm64). The script runs them for both the 4 KiB and the 16 KiB granule.
`tools/host-test.sh` runs the tests of `k0-abi`, `k0-cap`, `k0-boot`, `k0-efi`, `k0-conin`, `k0-slice`, `k0-part`, `k0-sup`, `k0-vault` and `k0-term` on any host (457 tests on an AArch64 host, 369 elsewhere). `k0-cap` has 71 tests, and 17 of them are about `UNTYPED_SPLIT`. `k0-sup` has 20 tests: they run the policy that supervises the terminal and the vault on a mock host. Three of them tie its log lines to the rest of the repository: one pins the wording that the documents quote, one checks that no line contains a word that `tools/qemu-boot-test.sh` reads as a failure, and one reads that word list from the script itself. So if you change `fail_re` in the script or the wording of a supervisor line, change the test and the documents with it. `k0-slice` has 9 tests: they run the rule that decides whether a tick cuts the running task on a model of the scheduler. `k0-part` has 36 tests: they run the scheduler's decisions under a time partition table on a model of the kernel, check the arithmetic of tick instants, and compare the Rust code with the recorded results of a Lean model (see "Changing the scheduler core" below). It runs `k0-vault` twice, with and without the algorithm feature `vault-ed25519`, which gives 22 and 13 tests. It runs `k0-term` with and without the vault feature, which gives 24 and 21 tests. The tests of `k0-mm` contain AArch64 inline assembly, so they only run on an AArch64 host (Apple Silicon or Linux arm64). The script runs them for both the 4 KiB and the 16 KiB granule.

`tools/qemu-boot-test.sh` boots the debug kernel, checks the boot log line by line in a fixed order, fails on any error marker, and stops QEMU as soon as the root task reports `root: sched tests pass`. Besides the pass lines, it expects `k0: kernel reserve ` before the `k0: untyped ` lines, `k0: idle (waiting for a timeout)` and `root: timeout tests pass` after `root: teardown tests pass`, and `root: kernel reserve tests pass` after `root: revocation tests pass`. Any line that starts with `k0: all tasks` is a failure. It also counts the timer tick lines between `root: teardown tests pass` and `root: timeout tests pass` and wants at least 4, because EL0 has no clock and this is how the lower bound of a timeout is checked. The timeout tests wait for real ticks, so a boot takes about 4 seconds longer than it did before. The time slice test runs twice (a task that got the CPU by `YIELD`, then one that got it by blocking) and takes about 4 seconds in all where the preemption test it replaced took about 1. It also expects `root: slice test yield pass` and `root: slice test block pass`, in this order, before `root: preempt test pass`. After that come `root: partition refusal pass` and `root: partition window pass`, and `root: partition sealed` comes before `root: sched tests pass`. The time partition test lets a table of 9 ticks run one round, so it adds about 15 seconds to every boot. If the host stalls QEMU for more than a second during it, the test runs once more and the script reports `boot-test: partition window retries: 1` without failing. `tools/boot-matrix.sh` runs such a boot row again and fails it when the second run needed the retry too. Set `K0_BOOT_TIMEOUT` (seconds) on slow machines. It reads the serial port, so it needs an image with a console driver. To test an image without console, use `K0_BOOT_MEMLOG`, `K0_BOOT_SERIAL=empty` and `K0_BOOT_CONSOLE_PAGE`, which are described in "Testing an image without console" in [USAGE.md](USAGE.md#testing-an-image-without-console).
`tools/qemu-boot-test.sh` boots the debug kernel, checks the boot log line by line in a fixed order, fails on any error marker, and stops QEMU as soon as the root task reports `root: sched tests pass`. Besides the pass lines, it expects `k0: kernel reserve ` before the `k0: untyped ` lines, `k0: idle (waiting for a timeout)` and `root: timeout tests pass` after `root: teardown tests pass`, and `root: kernel reserve tests pass` after `root: revocation tests pass`. `root: tcb status tests pass` comes after `root: fault isolation tests pass`, and `root: untyped split tests pass` comes between `root: timeout tests pass` and `root: revocation tests pass`. Any line that starts with `k0: all tasks` is a failure. It also counts the timer tick lines between `root: teardown tests pass` and `root: timeout tests pass` and wants at least 4, because EL0 has no clock and this is how the lower bound of a timeout is checked. The timeout tests wait for real ticks, so a boot takes about 4 seconds longer than it did before. The time slice test runs twice (a task that got the CPU by `YIELD`, then one that got it by blocking) and takes about 4 seconds in all where the preemption test it replaced took about 1. It also expects `root: slice test yield pass` and `root: slice test block pass`, in this order, before `root: preempt test pass`. After that come `root: partition refusal pass` and `root: partition window pass`, and `root: partition sealed` comes before `root: sched tests pass`. The time partition test lets a table of 9 ticks run one round, so it adds about 15 seconds to every boot. If the host stalls QEMU for more than a second during it, the test runs once more and the script reports `boot-test: partition window retries: 1` without failing. `tools/boot-matrix.sh` runs such a boot row again and fails it when the second run needed the retry too. Set `K0_BOOT_TIMEOUT` (seconds) on slow machines. It reads the serial port, so it needs an image with a console driver. To test an image without console, use `K0_BOOT_MEMLOG`, `K0_BOOT_SERIAL=empty` and `K0_BOOT_CONSOLE_PAGE`, which are described in "Testing an image without console" in [USAGE.md](USAGE.md#testing-an-image-without-console).

An image with the signing oracle (`vault` or `vault-ed25519`) has two more intended faults, so it prints 8 `k0: task fault` lines instead of 6. Run the test with `K0_BOOT_FAULTS=8` and require `root: oracle tests pass` with `K0_BOOT_REQUIRE`. The boot matrix has the rows `vault`, `vault-max`, `vault-el2`, `vault-16k`, `vault-no-alg`, `hvf-vault` and the static check `vault-symbols` for it, and 82 rows in total on a Mac with HVF and 71 in CI. The rows `input-*` and `term-*` cover console input and the terminal. A terminal image prints two more `k0: task fault` lines (8 without the vault, 10 with it), and `tools/term-test.py <image>` runs its scripted serial session. [USAGE.md](USAGE.md) describes the rows.
An image with the signing oracle (`vault` or `vault-ed25519`) has two more intended faults, so it prints 8 `k0: task fault` lines instead of 6. Run the test with `K0_BOOT_FAULTS=8` and require `root: oracle tests pass` with `K0_BOOT_REQUIRE`. The boot matrix has the rows `vault`, `vault-max`, `vault-el2`, `vault-16k`, `vault-no-alg`, `hvf-vault` and the static check `vault-symbols` for it, and 82 rows in total on a Mac with HVF and 71 in CI. The rows `input-*` and `term-*` cover console input and the terminal. A terminal image prints two more `k0: task fault` lines (8 without the vault, 10 with it), and `tools/term-test.py <image>` runs its scripted serial session. For a terminal image the boot test also expects `root: terminal restart test pass` before `root: service started`, and `root: vault restart test pass` before the seed line when a vault is built in. The session script fails when `root: ` appears in the output after the prompt, because the root task prints there only when a service ended. [USAGE.md](USAGE.md) describes the rows.

The default QEMU CPU model (`cortex-a72`) has no PAC, PAN or RNDR. To exercise those paths as well, boot on QEMU's `max` model and require the matching log lines. Any arguments after the kernel path are passed to QEMU. You can enter it as follows:

Expand Down Expand Up @@ -124,9 +124,10 @@ In the following table, you can see where each area is tested.
| Area | Host unit tests | Boot self-tests in the root task |
| --- | --- | --- |
| `k0-abi` constants and shared layouts | yes | indirectly |
| `k0-cap` untyped bootstrap and retype | yes | yes |
| `k0-cap` untyped bootstrap, retype and split | yes | yes |
| `k0-boot` DTB parser, PAC key derivation, root task image | yes, plus fuzzing | yes |
| `k0-vault` request state machine, protocol, policy and provider boundary | yes, with and without `vault-ed25519` | yes, in images built with `vault`, through `test_oracle` and the `vault*` rows of the boot matrix |
| `k0-sup` policy that supervises the terminal and the vault | yes, with a mock host | partly, in images built with `terminal`: the restart path runs before the service starts, with one restart per service and without waits. The timed loop in service has no test |
| `k0-efi` memory plan from the UEFI memory map, DTB rewrite, independent check, ACPI table reader and tree synthesis | yes, plus fuzzing | yes, through the `uefi-*` rows of the boot matrix |
| `loader` (UEFI application: firmware calls, cache flush, MMU off, jump) | no | yes, through the `uefi-*` rows, plus the static check `tools/pe-check.py` |
| `k0-mm` page tables and W^X attributes | yes, on AArch64 hosts | yes |
Expand Down
Loading