roadmap BUILT

299. The x86 port-range capability: the serial console becomes a userspace driver

calef ruled option 1, the port-range capability, straight rather than sequencing through §149 (may the kernel answer on an endpoint)'s kernel thread (2026-09-15).

What was built. Object::PortRange(base, count) on the capability surface (semantics recorded in DECISIONS §152, provisional), enforced by the lazy TSS I/O-bitmap write on the context switch (arch::segments::set_port_grant, installed from sched::schedule). A switch that crosses no port holder costs one comparison and writes nothing (tss_iomap_lazy_nop, +216 ticks/iter over a bare switch). And a holder crossing writes only the bits that move, not the 8 KiB the naive always-write §121 (what a device capability is when the device has no page) priced at ~2,682 ns cost every switch (notes/benchmarks.md, 2026-09-15). Revocation (PortRange::REVOKE, and the kernel's own whole-machine sweep) deletes the capability, clears the cached grant, and resets the core's TSS, so a revoked holder faults on its next in/out. The x86 console and input drivers are userspace processes holding COM1's (0x3F8, 8) ports, delegated by the progenitor. swish reaches an interactive prompt on x86_64 over serial, its console served by the userspace driver's out, with zero processes trapping (the milestone-268 gap closed). Two load-bearing tests pass under QEMU (kernel/src/user/x86_port_tests.rs): a non-holder faults on out (and a holder's grant does not leak across the switch to it), and a revoked holder faults on its next out.

One scope note, recorded rather than hidden. The x86 input driver polls COM1 (reading the port it holds and yielding between reads) rather than blocking on the receive interrupt, because x86 does not yet route a device line (COM1's legacy IRQ 4) to a userspace waiter. The kernel delivers only self-directed vectors to a driver today (kernel/src/arch/x86_64/exceptions.rs). Output (the prompt, and everything the shell prints) is unaffected and interrupt-independent. Interrupt-driven x86 input, which routes IRQ 4 through the IO APIC to the input driver's Irq capability and lets it block, wants its own milestone. The register layout it will use is already in components/src/input.rs's x86 arm.

What this is

On aarch64 and riscv64 a device driver is a userspace process holding the device's registers as a memory-mapped capability. x86's legacy serial port has no page: COM1 is port I/O, reached only by in/out, which ring 3 cannot execute unless the CPU's TSS I/O permission bitmap allows it. §121 kept the driver in the kernel for that reason. §121's amendment reverses it: x86 gets a second kind of device capability, a port-range capability, so the serial console and input drivers move to userspace and "every driver is a userspace process" holds on x86 with no exception, matching seL4, Genode and L4Re.

What to build

  1. A port-range capability, a new Object kind naming a (base, count) range of I/O ports. This is system call surface (DECISIONS §10 (process model: capability-based, microkernel), §16 (object revocation)), the irreversible category, so it is designed against the one real consumer it has (the console driver) rather than in the abstract. Granularity is a port range because a 16550 is eight consecutive ports, and the semantics are the honest analogue of the mapping-based device capability the other two architectures already use.
  2. TSS I/O-bitmap enforcement on the context-switch path, the LAZY form. DECISIONS §121's own refinement (2026-08-25) is binding here: do not write the bitmap on every switch. Set the TSS iomap_base to a real bitmap only when a thread that holds a port capability is on either side of the switch. Every other thread switches with iomap_base pointing past the segment limit (no bitmap, all ports denied at ring 3). In a system where realistically one process holds a port capability, that is near-zero cost for the overwhelming majority of switches. The naive always-write was measured at ~2,682 ns/switch release (tss_iomap_switch, notes/benchmarks.md); this must not pay that on switches that do not involve a holder.
  3. Revocation. A revoked port capability must clear the bits and reach every CPU that might hold a stale bitmap, a shootdown in the shape of the TLB shootdown this tree already has. Enforced, not assumed: a test that a revoked holder faults on the next in/out.
  4. Move the x86 console and input drivers to userspace. They exist today as ring-3 stubs that trap on first port access (milestone 268's x86 boot builds them and they trap, which is the gap this closes). Grant each the port capability for its device's ports (3F8h-3FFh for COM1) at spawn, the way aarch64/riscv64 grant the UART's page. swish then reaches a userspace console server on x86 identical to the other two, and x86 boots to a prompt.

The first measurement, because §121 named it

Before the capability is wired to real drivers, take the number §121's refinement asked for. The lazy write's real cost, a per-thread "holds any port capability" bit checked on switch-in with the bitmap written only when set, timed against a bare switch, the way ipc_rtt and null_system_call are measured. This is not a second run of tss_iomap_switch (which prices the naive always-write); it prices what this milestone actually ships. script/bench --x86 is TCG-only on this host, so the number is statistical, not silicon cycles, and the block should say so.

The proof

swish reaches an interactive prompt on x86_64 under QEMU over serial, its console and input served by userspace drivers holding port capabilities, and a revoked capability makes its holder fault on the next port access. board-check's x86 leg reaches the prompt (the top rung milestone 268 left Outstanding on x86). Parity, per DECISIONS §19: the console is a userspace driver on all three architectures, no scope note.

What this does not do

BUGS

Follow-on

Index row

The x86 port-range capability. DECISIONS §121 was reversed 2026-09-15 once the serial console became the customer it had assumed away (a prompt on every architecture, headless x86 driven over serial). x86's console and input drivers move to userspace holding a (base, count) port capability enforced by the TSS I/O bitmap, lazily, so "every driver is a userspace process" holds on x86 with no exception. Consumes milestone 268/182's x86 userspace boot; reaches the x86 prompt that milestone left Outstanding.