Vesper is a capability-based single-address-space nanokernel, it tries to remain small and secure. To achieve this, kernel functionality is extremely limited - it provides only address space isolation and IPC, after bootup kernel does not allocate any memory itself.
Exokernel's distinctive trait is that it provides mechanisms but not policies. Vesper tries to move as many policy decisions as possible to the library OS.
-
Single-address-space is a mechanism for providing pointer transparency between processes. Sharing a buffer is nearly as simple as passing out its address. Even though single-address-space is not a basic requirement and may be seen as an imposed policy decision, it does provide mechanism for efficient data passing between protection domains. This is important for modern media-rich communications.
-
IPC is a mechanism providing secure interaction between processes.
-
Capabilities are a mechanism providing access rights control and universal authority delegation for OS objects.
-
Interrupts come from hardware, usually in privileged mode and kernel is responsible for translating them into invocations of the device drivers' handlers.
Scheduling can be viewed as the process of multiplexing the CPU resource between computational tasks. The schedulable entity of an operating system often places constraints both on the scheduling algorithms which may be employed and the functionality provided to the application. The recent gain in popularity of multi-threaded programming due to languages such as Modula-3 [Nelson 91] has led many operating system designers to provide kernel-level thread support mechanisms [Accetta 86, Rozier 90]. The kernel therefore schedules threads rather than processes. Whilst this reduces the functionality required in applications and usually results in more efficient processor context-switches, the necessary thread scheduling policy decisions must also be migrated into the kernel. As pointed out in [Barham 96], this is highly undesirable.
The desire to move such decisions out of the kernel make interesting variants where actual scheduling is performed by the user-level domain scheduler upon an upcall from the kernel. TBD
At the moment this is not a real-time kernel. It has a small number of potentially long-running kernel operations that are not preemptable (e.g., endpoint deletion and recycling, scheduling, frame and CNode initialisation). This may change in future versions.
Vesper has been influenced by the kernels in L4 family, notably seL4. Fawn and Nemesis provided inspiration for single-address-space and vertical integration of the applications.
MSRV: 1.61.0
We require cargo build --build-std feature (since 2020-07-15), compiler_builtins memory operations (since 2020-09-30) and const_fn_fn_ptr_basics feature (stable since Rust 1.61.0).
- Install tools:
cargo install just. - Install qemu (at least version 4.1.1):
brew install qemu. - Optionally install OpenOCD with RTT patches.
- Install aarch64 gdb:
brew install aarch64-elf-binutils
You can override invoked qemu, openocd and gdb by specifying full paths to them as env variables QEMU, OPENOCD and GDB, respectively.
You can override the name of mounted sdcard volume by specifying env variable VOLUME (it defaults to /Volumes/BOOT).
just setup-local-dev
This also fetches the git submodules: Wood, the Doom engine as a Vesper program, at userspace/wood (the vesper-doom repository), and inside it the SC-55 SoundFont Wood plays its music with; to fetch only them, run git submodule update --init --recursive.
just qemu
just device
One image boots on a Raspberry Pi 3, 4 and 5: it finds the board's hardware in the device
tree the firmware passes. It is built for a board set, by default rpi3+rpi4+rpi5, compiled
for the oldest core of the set; just boards=rpi4+rpi5 device builds for a smaller set.
On the device boot SD card you'll need a configuration file instructing RasPi to launch in 64-bit mode, from where the kernel is linked:
# config.txt
arm_64bit=1
kernel=kernel8.img
kernel_address=0x80000
tools/makesd builds a card for all three boards: in that directory,
just pull-firmware downloads the firmware and device trees into boot/,
just pull-bootable <name>.bin copies a kernel image from target/images
as kernel8.img, and just sdimage writes target/images/sdcard.img
(an MBR with a FAT32 boot partition holding boot/, as makesd.config
describes) to put on the card.
Connect a USB serial adapter to the board's console UART: GPIO 14 and 15 on the
Raspberry Pi 3 and 4, the debug connector (UART) on the Raspberry Pi 5. The recipes
use chainboot_serial (default /dev/ttyUSB0) for its port; set it before the
recipe name for any other adapter, with any of the recipes below:
just chainboot_serial=/dev/tty.usbmodem102 boot-board-test debug_kernel
Put chainboot on the card once, and then load kernels over the serial line without touching the card again:
just cb-sdimage # target/images/sdcard.img with chainboot as kernel8.img; write it to the card
just boot # build the kernel, send it to chainboot, stay as its serial console
just boot-board-test # the same for board-test, the drivers being brought up on the boards
chainofcommand waits for the board: power it on after starting the recipe. It loads
at chainboot_load_baud (default 1500000) and then stays on the line as a terminal.
Some more shortcuts:
just console # only a serial console, for a kernel booted from the card itself
just sdimage board-test-rpi3+rpi4+rpi5.bin # put a built image on the card instead of chainboot
just boot-board-test debug_kernel # a debug kernel: a component's panic message reaches the UART too
just extra_rustflags='--cfg test_boot_panic' boot-board-test debug_kernel
# also load a probe that panics on purpose and overflows a stack,
# to check that both reach the UART
just stacktrace=on boot-board-test debug_kernel
# with stack traces: a `backtrace: 0x… 0x…` line after a panic,
# an unexpected exception or a component's fault
just symbolize log-probe 0x400344 0x400050
# name the functions and lines of a backtrace's addresses, from
# that binary (a component's, `nucleus`, `board-test`) of the
# image built last; `symbolize_config=…` picks another one
stacktrace=on builds stack traces in. A trace follows the chain of frame records each
function keeps at its frame pointer, so the switch adds two flags to every cross-built crate:
--cfg stacktrace, which turns the trace code (libs/stacktrace) on, and
-C force-frame-pointers=yes, which keeps the frame records it reads. Frame pointers are a
compiler option for the whole crate, not something a cfg can switch per function, so the one
switch sets both. Without it the trace code compiles to nothing. Switching it, like
extra_rustflags, rebuilds the image configuration's crates.
For example, with the probe that panics on purpose and overflows a stack:
just chainboot_serial=/dev/tty.usbmodem102 stacktrace=on extra_rustflags='--cfg test_boot_panic' boot-board-test debug_kernel
A trace is a line of addresses, innermost first, after:
- a component's panic:
EL0 backtrace: …, after itsEL0 PANICKED:line; - a component's fault:
backtrace: …under the nucleus's⚠️line, starting at the faulting PC; - a nucleus panic:
nucleus panic backtrace: …, and an unexpected exception's register dump ends with one starting at its PC; - a Kickstart panic:
🥾 backtrace: ….
Then just symbolize <binary> <addresses…> names the functions and source lines, for example
just symbolize log-probe 0x400344 0x400050 0x400130. It reads the binary from the hardware
image configuration built last (symbolize_config=rpi3+rpi4+rpi5-debug_kernel picks one), and
uses aarch64-elf-addr2line (ADDR2LINE overrides it).
Kickstart prints its 🥾 lines on the UART from the start. The nucleus adds a few of
its own: 🧵 when a Thread first runs, 💤 when nothing is runnable for the first
time, ⚠️ for a fault and ⛔ when a fault handler stops a Thread. A nucleus panic
takes the UART over and dumps the registers. Components log through the log server,
whose lines carry a timestamp ([ 5.148328] I sdhci: …). These sources share
the UART, so their lines can cut into each other.
just test
just ocd
just gdb
If you launch OpenOCD or QEMU before (for example, via just qemu-gdb), then gdb shall connect to it and allow you to load the kernel binary directly into memory. Type load in gdb to do that.
just nm
You need to have Hopper and hopper cli helper installed.
just disasm
just
It will list all just commands with their short descriptions.
mainline, develop and released branches:
feature branchesare fluid development lines which may be discarded or merged intodevelop. Feature branches must be either merged or fast-forward merged ("landed") into develop. Squashing history during merge is not permitted - commits must be sorted and squashed as necessary before merge.developis currenly developed changes. History is recommended to be immutable, however mutations are possible in some cases. Feature branches are merged into develop for stabilisation, then develop is merged into the mainline.Developmust be either merged or fast-forward merged ("landed") intomainline. Squashing history during merge is not permitted - commits must be sorted as necessary before merge. Avoid direct commits to develop. It is recommended to perform stabilisation fixes in a separate branch and then landing it into develop.mainlineis for generally accepted changes. History is immutable, to record reversals make a revert commit with explanations why. Changes fromdevelopare merged or landed into the mainline after stabilisation.releasedbranch records points from mainline which were officially released. Mutations are not possible. Only non-fast-forward merges from mainline are acceptable. Releases are marked as annotated tags on this branch.
Based on Raspi3 tutorials by Andre Richter, which are in turn based on Raspi3 tutorials by bzt. Various references from OSDev Wiki and RaspberryPi.org manuals.
Individual files contain the following tag instead of the full license text.
SPDX-License-Identifier: BlueOak-1.0.0
This enables machine processing of license information based on the SPDX License Identifiers that are here available: http://spdx.org/licenses/
For more information please re-read.
