roadmap BUILT

315. A port revoke that reaches every core

Finding 4 of milestone 313 (the security audit that was due since August). calef ruled §153 (how a two-core x86_64 test earns its place), the decision file, on 2026-09-18: close this milestone first, then default NIFE_SMP to 2. Both halves are done, and the second is the verification of the first.

What it owed, and what landed

  1. The broadcast. arch::x86_64::segments::revoke_port_grant_everywhere resets this core's TSS I/O permission bitmap and then tells every other online core to do the same, over the TLB shootdown's NMI (mmu::revoke_port_grant_others). sched::delete_port_range_caps_impl calls it in place of the core-local reset.
  2. The default flip. helpers/qemu-runner-x86_64.sh defaults NIFE_SMP to 2.

The defect was reproduced before it was fixed

The scope had already shrunk while the decision was open: this block once said the test was the deliverable and would be the first port test able to observe the revocation window. Milestone 316 found that the test already existed. user::x86_port_tests::a_revoked_holder_faults_on_its_next_port_write became that observer the moment 316 gave it a working two-core substrate.

7 of 12 full two-core runs is 316's campaign figure. This lane established its own, on the same host (patagonia, no induced load), against the filtered leg cargo xtask test --arch x86_64 --test x86_port at NIFE_SMP=2:

campaign runs failures
filtered, uninstrumented 12 3
filtered, instrumented 30 2

Every failure was the same assertion at the same line, x86_port_tests.rs's left: 2, right: 1. The child's out was permitted and it exited cleanly (EVENT_EXIT) where the test demands a fault. The filtered leg runs three tests rather than 326, which is why its rate is lower than the full suite's; it is the same failure.

What actually raced, with the evidence

PortRange::REVOKE deletes the capability from every thread's table and clears the cached grant (thread::Thread::port_range_grant) under sched::IPC_TABLES, then resets the TSS bitmap. The reset was core-local, which was the whole machine when DECISIONS §152 (the port-range capability) recorded it and stopped being so when smp::seat_cpus_from_acpi made this port multi-core.

A core's bitmap permits a range only while the thread holding it is the thread running there. So the window needs the holder to be running on another core at the instant of the revoke. The test's own shape produces exactly that: it starts the child, revokes, and sends the wake. When the send lands before the child reaches its RECV the child's RECV returns without ever switching away. So the grant core 1 installed at switch-in is still installed when the out executes. Core 0's reset never touched it.

Measured rather than argued. A temporary snapshot of INSTALLED_PORT_GRANT, taken at the revoke and read by the test after the outcome arrived:

what the snapshot said at the revoke runs outcome
revoker on cpu 0, cpu 1 holds a grant 2 both failed (EVENT_EXIT)
revoker on cpu 1, cpu 0 holds a grant 5 all passed
no core holds a grant 27 all passed
revoker on cpu 0, cpu 1 holds a grant 1 passed (the holder switched away in time)

A remote core holding the grant is necessary and not sufficient, which is exactly what a window of "until that core's next context switch" predicts.

The fix, and the one thing that makes it sound

The remote half rides mmu::shoot_down_others' protocol rather than a new one. SHOOTDOWN_KIND says which step the round is for and SHOOTDOWN_VA carries a packed (base, count) instead of an address. The acknowledgement mask, the single-round lock and the NMI delivery are the parts that are hard to get right. There is now no second copy of them to keep in step. The NMI is forced rather than preferred for the same reason it was for a page (notes/x86-tlb-shootdown.md): the target core is routinely spinning for IPC_TABLES with interrupts masked, because the revoker is holding it.

Broadcasting alone would not have been enough, and this is the part that is not in the proposal. The far end writes a TSS from an NMI handler, at an arbitrary instruction boundary. Two windows stay open if nothing else changes: a core can read a grant the sweep has already cleared and install it after the broadcast, and the NMI can land in the middle of that install. Both shut on one rule, now stated at segments::set_port_range_grant_on: a core's port bitmap is written only by a thread holding sched::IPC_TABLES, or by an NMI that such a thread sent.

Making it true took moving schedule's install_port_grant inside the locked region (it read the grant under the lock and installed it after) and delete_current_cap's core-local reset with it. The cost on a machine where nothing holds a port is one compare inside the critical section instead of one outside it, because set_port_range_grant returns after a single comparison when the grant has not changed.

delete_current_cap owes no broadcast: the thread dropping its own capability is the thread whose grant is installed, and it is running on this core, so this core is the only core to tell.

What proves it

user::x86_port_tests::a_revoked_holder_faults_on_its_next_port_write at two cores, which failed before the change and passes after it, on the counts in the tables above. It is a gate rather than a measurement now: two cores is the default, so it runs on every script/test --arch x86_64. So does user::tests::an_asid_flush_reaches_the_other_cores, the TLB-shootdown test from milestone 161 (the x86_64 kernel port), which had been verified by hand and gated by nothing.

BUGS

Follow-on

Index row

PortRange::REVOKE cleared the capability table and the cached grants but reset the TSS I/O bitmap on the revoker's core only, which was the whole machine when DECISIONS §152 recorded it and stopped being so when smp::seat_cpus_from_acpi made x86 multi-core. A revoked holder running on another core kept COM1 until that core's next context switch. Milestone 313's audit accepted the window on reasoning, and at two cores it was red in 7 of 12 full runs of the test written to see it. This lane reproduced it (3 of 12, then 2 of 30 on a filtered leg), named the cause with a snapshot of INSTALLED_PORT_GRANT taken at the revoke that read "revoker on cpu 0, cpu 1 holds a grant" on both captured failures. It was closed by broadcasting the reset over the TLB shootdown's NMI with a kind tag on the existing protocol. The half the proposal did not have is that broadcasting alone leaves the window reopenable. schedule read the grant under IPC_TABLES and installed it after. So a core could install a grant the sweep had already cleared. The NMI could land inside that install. Moving the install under the lock gives one rule instead, stated at the writer, that every TSS bitmap write is made by a holder of IPC_TABLES or by an NMI one sent. NIFE_SMP defaults to 2 as the closing step per DECISIONS §153, which makes both this test and milestone 161's TLB-shootdown test gates rather than things somebody verified by hand.