184. Extend the std port (milestone 27) to x86_64
Milestone 27 (std on the native ABI) is built for aarch64 and riscv64; this is the third
architecture, following milestone 27's shape rather than re-deriving it. It needed no design fork:
the shape was already built twice.
What was built
- A third custom target,
targets/x86_64-unknown-nife.json. Milestone 164 did not produce one to share (both of its routes were refused, and its blocker turned out to be one build flag), so this is the only custom x86_64 userspace target in the tree. - The PAL's x86_64 arms in
patches/std-nife/overlay/std/src/sys/pal/nife/rt.rs:invoke,call,yield_now,exit,abort(ud2),now(rdtsc) andcntfrq, which reads the kernel's timebase page. The register lists and clobbers arecrates/user_mode_runtime's, copied rather than rewritten.counter_frequency_protocolis generated verbatim into the farm like every other contract the PAL reads, and it joins the farm's stamp. - An x86_64
_startshim insys/pal/nife/mod.rs(below). xtask:STD_TARGETShas three entries, the stamp hashes the new spec,initrd_x86packsstd_exerciser(andrgwhen it has been built), andtarget/strippedgets astd-x86tag so the three*-unknown-nifebuilds cannot overwrite each other's stripped copy.std_serviceservesSystemRngfromRDSEEDon x86_64 (milestone 162's instruction backend), because the x86_64 runner attaches no virtio-rng. The program cannot tell: its slot 6 is an endpoint either way.ripgrep_testscompiles on every architecture, andhelpers/build-ripgrep.shbuilds the third triple.
The target spec, and why each field differs from x86_64-unknown-none
It is the built-in x86_64-unknown-none spec with the kernel's assumptions taken out:
| Field | Chosen | Why |
|---|---|---|
code-model |
small |
The built-in kernel model assumes every symbol is in the top 2 GiB. A program linked at 0x40_0000 is not. It links anyway, because a low address also fits a sign-extended 32-bit displacement, which is why the no_std programs built on x86_64-unknown-none work; small is the model whose assumption is true. |
relocation-model |
static, no PIE |
The kernel's ELF loader maps at link addresses and applies no relocations. The built-in spec defaults to static-PIE, which .cargo/config.toml overrides by flag for the no_std programs; here it is in the spec, as on the other two nife targets. |
features |
-mmx,-sse,...,+soft-float |
Copied. A correctness requirement: kernel/src/arch/x86_64/ saves no FPU or SSE state on a context switch. |
rustc-abi |
softfloat |
Copied. Current nightlies refuse a soft-float x86 custom target without it. |
disable-redzone, data-layout, llvm-target, stack-probes, plt-by-default |
unchanged | Copied from the built-in spec. |
os, singlethread, executables, metadata.std |
as the other two nife specs | "os": "nife" is what selects the PAL through every dispatcher. |
What it delivered, measured
std_exerciser passes on x86_64, where it used to skip:
kernel::user::std_tests::a_whole_std_program_runs_on_the_native_abi ... ok, under QEMU's PVH loader
and again under OVMF firmware. The full gate is green on all three architectures: aarch64 321 passed,
2 skipped; riscv64 328 passed, 1 skipped; x86_64 206 passed, 69 skipped, in 275 tests. One test moved
from the skip column to the pass column (std_exerciser), and one entered the skip column
(ripgrep_tests, newly compiled on x86_64; see BUGS).
The pass is evidence, because breaking the arm turns it red. Swapping the x86_64 invoke arm's
result register from rdi to rsi and rerunning only that test fails it with
std_exerciser: a sink message the contract does not define: 0x10000000.
Soft-float is checked with a program that does float work, because zero xmm in std_exerciser
would prove nothing: it does no float arithmetic. A probe doing f64 and f32 arithmetic, built for
x86_64-unknown-nife, disassembles to 0 instructions naming an xmm, mm or x87 register and
9 calls into __adddf3, __muldf3, __divdf3, __subdf3, __mulsf3 and __floatundidf. The same
probe against a copy of the spec with +sse,+sse2 and no rustc-abi has 92 vector-register
instructions and no helper calls. The grep and the control are in notes/std/x86-64-target.md.
The abort sweep holds on three targets: std-aborts: 26 process-ending bodies across 82 compiled std sources, all accounted for.
Unmodified ripgrep 14.1.1 builds for x86_64-unknown-nife with zero source changes: a 4.1 MB ELF
(4,147,048 bytes), against 4.7 MB on aarch64 and 10.7 MB on riscv64. It does not run on x86_64 yet; see
BUGS.
The entry point is the one real divergence
The kernel enters ring 3 with rsp on a page boundary, so rsp % 16 == 0, while the x86-64 psABI
promises a function rsp % 16 == 8, as if a call had pushed a return address. aarch64 and RISC-V push
nothing on a call and have no such offset. So on x86_64 _start is a global_asm! stub that calls
the Rust entry and then ud2s, which makes the psABI's assumption true. Without SSE nothing faults on a
misaligned stack, so getting this wrong would have passed every test and stayed latent until someone
enabled a vector feature.
fs, net and thread on x86_64
| x86_64 | Why | |
|---|---|---|
allocation, stdio, Instant, SystemTime, SystemRng, env, process::exit |
wired and exercised | std_exerciser's transcript is byte-identical to the other two architectures' |
std::fs |
compiled, unexercised | The PAL has nothing architecture-specific in it. What is missing is a disk: fs_service::wire_servers finds its RedoxFS disk with virtio::find_block_device_n, which is virtio-mmio only, and q35 has no virtio-mmio bus; no x86_64 runner attaches a RedoxFS image either |
std::net |
compiled, unexercised | The x86_64 runner attaches no NIC |
thread::spawn |
Unsupported |
The same on every architecture: DECISIONS ยง105 declined it until a customer needs it |
A program that is granted neither a directory nor a network gets Unsupported from both on x86_64,
exactly as on the other two, and that is asserted: those are two lines of the transcript that passes.
BUGS
std::fs,std::netandripgrepare unexercised on x86_64. Not a gap in thestdport: the directory and socket servers have no device to serve from there.ripgrep_testsskips on x86_64 at "no RedoxFS disk attached" even whenrgis built, so whether its transcript matches the other two byte for byte is unknown, not known to match.design/fatal-risks/README.mdrisk 1 cannot yet be read as green on x86_64.- The
stdspawn needsRDSEEDon x86_64.std_servicepanics rather than skips on a CPU without it. The suite's-cpu maxhas it;NIFE_CPU=qemu64would not. - A zeroed timebase page reads as 1 GHz, matching
user_mode_runtime::cntfrq. Every std program today is spawned by the kernel'sload, which maps the real page, so this is unreached; a std program built bysupervision_protocol::build_child_spacewould read the placeholder and scaleInstantwrongly. This iscounter_frequency_protocol's recorded gap, reached one more way. rdtscis ambient to every x86_64 std program, inherited fromuser_mode_runtime::nowand milestone 75's open question rather than introduced here.
Follow-on
- Milestone 303. x86_64's FS service finds a RedoxFS disk over PCI, done 2026-09-16: the
virtio-mmio-only lookup in
wire_serversnow spans both buses, the runner attaches the-redoxfs.imgfixture as a secondvirtio-blk-pcifunction, and VT-d needed no new mechanism.std::fsruns andripgrepprints its transcript on x86_64, and the "no RedoxFS disk attached" group of skips is gone (208 / 69 to 237 / 40). - Recorded.
notes/ripgrep-on-nife.md's parity table now says the x86_64ripgrepbuilds and runs, anddesign/fatal-risks/README.mdrisk 1 is green on all three. The fatal-risk file itself still says two of three; updating it is the maintainer's, as it was here.
Prior art
Milestone 27's two targets and notes/std.md, copied rather than re-derived. Hermit, milestone 27's citation, applies identically.
Index row
std on x86_64: x86_64-unknown-nife (small code model, static, soft-float with no SSE state), the
PAL's x86_64 arms, and std_exerciser passing under QEMU where it used to skip, falsified by breaking an
arm. std::fs/std::net compile but have no server device on x86_64; unmodified ripgrep builds and
waits on a RedoxFS disk there.