notes

Porting to x86_64

Milestone 161, the third architecture, and the one milestone 20 named as the real test of whether arch/ is a hardware abstraction layer or an accident of two similar RISC machines. aarch64 and RISC-V share a device tree, weak memory ordering, a boot handoff in the width the kernel runs in, and a page-table shape. x86_64 shares none of those.

This note is what the port learned, in the order a reader needs it. That is how the machine is entered and what had to change above arch/ (very little, with the exceptions listed). Then the three things that genuinely do not fit the existing seam, and an honest account of what exists.

Status, and it is a partial port

Built, running, and gated: the boot path, the console, the GDT/TSS, the IDT and trap frame, the page-table format, the boot-handoff parser. The ACPI tables (the RSDP scan, the root-table walk with checksums, the MADT and the MCFG), the local APIC and a calibrated periodic timer. The frame allocator, the fine-grained W^X kernel page tables, the IO APIC and a routed device line. User address spaces, the system_call pair and ring 3, the scheduler, preemption, kernel threads and real ring-3 processes. The kernel's own test suite and a script/test leg, the address arithmetic, interrupt masking, the context switch, and the test exit. A boot under QEMU's q35 prints a tour and takes real hardware interrupts from the CPU's own timer and from a device. It builds and installs its own page tables, brings up the scheduler, and runs a kernel thread. It builds two processes out of untyped memory and runs them at CPL 3 (one invokes a capability and exits, one faults and its supervisor receives the fault), and halts.

And since 2026-08-24, userspace: every program in user/ compiles for x86_64-unknown-none, xtask packs the same archive RISC-V's leg does, QEMU's PVH loader hands it over as a module, and cfg(initial_ramdisk) is on. script/test --arch x86_64 runs 170 tests and skips 67, where it ran 97 and skipped 7 the day before.

Not built: VT-d and SMP bring-up, both loud unimplemented!()s in arch/x86_64/ that name themselves and why. What bounds this architecture now is not userspace but devices. No PCI bus is enumerated, so no virtio function of any kind is found. The console UART is in an I/O port space with no capability shape yet (DECISIONS §121). See "What a userspace still does not have here" below, and design/roadmap/0161-x86-64-kernel-port.md for the order the rest comes in.

Reproducing it

cargo build -p kernel --target x86_64-unknown-none
helpers/qemu-bounded.sh 20 qemu-system-x86_64 \
    -machine q35 -cpu max -smp 1 -m 256M -display none -serial stdio -no-reboot \
    -device isa-debug-exit,iobase=0xf4,iosize=0x04 \
    -kernel target/x86_64-unknown-none/debug/kernel

or, equivalently, cargo run -p kernel --target x86_64-unknown-none (the runner in .cargo/config.toml builds the same command line; bound it, because the kernel halts rather than exiting).

The tour it prints on 2026-08-24, with how to read it (the mmu line, the faulting child of each round, what changes from boot to boot), is in boot.md. It ends nife x86_64: boot complete, halting.

To run the kernel's own suite instead of the tour:

script/test --arch x86_64

To see a triple fault instead of a blank terminal, add -d int,cpu_reset -D /tmp/x86.log.

What the gates cover, and what they do not

script/lint runs clippy over the x86_64 kernel binary at -D warnings, which covers every line of arch/x86_64/ and every portable file compiled with target_arch = "x86_64". Three narrowings, each argued where the gate is (see script/lint):

There is a script/test leg: --arch x86_64, in xtask's test, and it runs by default alongside the other two. That sentence used to end "it builds nothing before it boots, because there is no userspace archive to pack and the runner attaches no disks", and every clause of it has since stopped being true: milestone 161 packed an archive, 164 added the FS server, 215 attached the first virtio-blk-pci disk and 303 the RedoxFS fixture. The leg now builds the FS server, the archive, and the nifefs, RedoxFS and NVMe images before it boots.

What had to change above arch/

This is the part that matters for the milestone-20 claim, so it takes the form of a list rather than a conclusion. Making the entire kernel compile for a third architecture took 42 compiler errors, every one of them "this arch:: name does not exist yet", and:

That is the whole diff above arch/. A new ISA was a new directory.

The appendices

notes/x86-port/ holds the measurements and reasons behind each part of milestone 161 (the x86_64 kernel port), one file each. None of them is needed to build, boot or test it.

appendix what it holds
boot.md Why the kernel boots by PVH and not Multiboot, the real-firmware path through uefi_loader, and the 32-bit trampoline into long mode.
acpi-and-pci.md The PVH memory map, the ACPI tables as q35 reports them, the discovery seam milestone 20 (a portable HAL) promised, and why a PCI function's interrupt is MSI-X rather than the legacy pin.
interrupts-and-the-fine-map.md The PIT-calibrated clock, the IO APIC and its legacy-interrupt trap, the W^X kernel page tables, and the direct map in blocks.
traps.md The IDT and its 256 stubs, the system call ABI and why it returns by iretq, the vector bands, MSI, the GDT and TSS, and port grants in the TSS bitmap.
ring-3.md Address spaces, swapgs, the system_call pair, and the hand-assembled probe that first ran at CPL 3.
scheduler.md The trap-path split, TSS.RSP0, the self-IPI, and four places portable code was wrong for a third architecture.
user-mode-runtime.md The ring-3 system call stubs, why rdtsc is ambient here, the CR4.PCE door that was closed, and cntfrq().
userspace.md How the archive arrives as a PVH module, the suite's skips by cause, and four latent bugs userspace found.
what-does-not-fit.md The four places the arch/ seam did not stretch, the segment-base bug, the SMP counting bug, and where TSO pays out.
the-port-range-tests.md Why each PortRange test runs a ring-3 out, checks the core it ran on, exits rather than reports, and narrows the rights.
cpu-state.md The control-register bits each core sets (PAT, SMEP, PCE), the port I/O gate, the boot CPU's id and the per-CPU pointer, the thread pointer, the FP and SSE unit, and the CPUID boot gates.
smp-bring-up.md INIT-SIPI-SIPI, the one trampoline page every secondary shares, and the timing of the wait for each core.
kernel-page-tables.md The two kernel bases, what the direct map claims and in which order, the 32-bit MMIO hole and the BAR window, the user address spaces without PCID, and the MMU's BUGS.
tco-watchdog.md The Intel TCO watchdog: the second timeout that resets the platform, the register map on ICH9 and the 200-series PCH with its sources, and its BUGS.

BUGS

Two boot-mode features that do not compile here

These are the scope notes §19 (architectural parity is a tenet) asks for, one for each gap helpers/lint_arch_parity.py allowlists, written 2026-10-08 (UTC). Neither has a plan. Under §71 (a limitation is promoted when it becomes a plan), each stays a BUGS entry until one of that section's triggers fires, and each names the one that would.

What a userspace still does not have here

The bound on everything above, listed because it is the next lane's brief rather than a caveat. Every item is a device or a toolchain, and none is user_mode_runtime any more.