roadmap BUILT

915. NMI, double fault and machine check run on their own stacks

Name: provisional. The number 915 is provisional until the merge queue lands it, and the title, the slug, the module kernel/src/arch/x86_64/ist.rs, the symbols isr_paranoid and x86_paranoid_dispatch, and every test name below are drafts. Branch milestone/915-nmi-double-fault-and-machine-check-run-on-their-own-stacks.

Reuse: none exists to take. The shape is Linux's x86_64 "paranoid entry" and its per-CPU IST stacks (arch/x86/entry/entry_64.S, arch/x86/kernel/dumpstack_64.c), read for the approach; the code is written against this kernel's own TrapFrame, per-CPU block and stack conventions, which no outside implementation shares.

What is true

On x86_64 the NMI (vector 2), the double fault (8) and the machine check (18) never run on the stack they interrupted.

aarch64 and riscv64 have no equivalent to build: neither takes an asynchronous exception on a stack the kernel did not choose. nifeos/nife:notes/stack.md, "Where an asynchronous exception lands, per architecture", has the reasoning for each.

How it is proven

Kernel tests in kernel/src/arch/x86_64/ist.rs, run on the x86_64 leg under PVH (two cores) and OVMF. Each claim carries a replayable falsification under kernel/falsifications/, and each went red when replayed with script/test --arch x86_64 --no-host --test <name> on 2026-10-13 (UTC).

test claim falsification
every_online_core_has_its_own_three_interrupt_stack_table_entries each online core's three IST entries are nonzero, inside that core's own stack for the vector, carry its per-CPU pointer, and are mapped install indexes the next core's stacks
every_interrupt_stack_table_guard_page_is_unmapped every IST guard page is a hole in the live kernel map the map covers the guards and verify stops checking
the_nmi_double_fault_and_machine_check_gates_select_their_own_stacks gates 8, 2 and 18 select entries 1, 2 and 3; no other gate selects any the NMI and machine-check gates swap entries
an_nmi_finds_its_per_cpu_block_whatever_the_gs_base_held a self-NMI sent while IA32_GS_BASE holds a decoy reads this core's per-CPU pointer isr_paranoid skips the GS write
an_nmi_leaves_the_gs_base_it_found that NMI returns with the decoy still in IA32_GS_BASE isr_paranoid skips the restore
the_ist_stack_region_is_the_size_the_linker_reserved the linker reserved at least what ist.rs lays out none: a layout check

BUGS

Follow-on

Index row

An NMI arrives on every TLB shootdown and can land in the two instructions syscall runs on the user's stack pointer, and a double fault happens when a stack is unusable. On x86_64 these vectors, and the machine check, switch to per-core stacks of their own and find the kernel's per-CPU block without trusting the interrupted state.