roadmap SUPERSEDED

717. x86_64's double fault runs on a stack of its own

Overtaken by milestone 915 (NMI, double fault and machine check run on their own stacks): kernel/src/arch/x86_64/ist.rs allocates the per-core stacks and calls set_interrupt_stack for the double fault. The text below is the block as filed.

Title and slug are drafts. Raised at calef's request, from the first of two findings in notes/ci.md. The second is the sibling proposal x86_64 names a kernel stack overflow the way aarch64 and riscv64 do. Title and slug are drafts.

The finding

The double-fault safety net is documented, selected by the IDT, and never installed.

So a double fault today loads rsp from TSS.ist[0] == 0. The CPU cannot push its frame there, and the result is a triple fault. The runner passes -no-reboot (NO_REBOOT in helpers/qemu-runner-x86_64.sh), so under QEMU that is a silent exit with no report; on a real machine it is a reboot. The comment on exceptions::initialize (its doc comment in exceptions.rs) states the intent exactly: a handler pushing onto the same broken stack "triple-faults". The code does not deliver it.

The commonest trigger is the one the IST exists for: a kernel stack overflow whose exception frame push lands in the guard page (the 48-byte frame needs room the stack no longer has).

What the other two architectures do

Neither has a double fault, so neither can reset the machine for this. They fail differently and each is recorded:

Both ports eventually print. x86_64 resets. That is the parity gap this closes (ยง19 (architectural parity is a tenet)).

Proposal

  1. Allocate one stack per core for the double fault, in its own region with an unmapped guard page below it. It must not be the interrupt stack (interrupt_stack.rs): set_interrupt_stack's Safety contract (in segments.rs) forbids two vectors sharing an IST stack, and a double fault taken while the interrupt-stack handler runs is exactly that case.
  2. Call set_interrupt_stack(IST_DOUBLE_FAULT, top) on every core, after segments::initialize has loaded that core's TSS (set_interrupt_stack indexes by cpu::id()).
  3. Give vector 8 its own body that prints a fault report from that stack and halts. It prints the frame (rip, rsp, cs, ss, rflags; the error code is architecturally zero) and does not return. The report is deliberately minimal and takes no lock and no allocator.
  4. Exempt vector 8 from x86_trap_dispatch's interrupt-stack move, the way NMI is exempted (exceptions.rs::x86_trap_dispatch): interrupt_stack.rs::top_for_trap would otherwise find rsp outside the interrupt-stack region and move the handler off the IST stack onto a different one. This is read from the code, not measured.

The guard-page naming (is the faulting rsp or address in a kernel stack's guard page, and whose) belongs to the sibling proposal and is what makes this report useful rather than merely present.

Proof plan

Prior art outside the tree

Read from source on 2026-10-03 (UTC):

Cost, risk, reversibility

What it unblocks

The sibling proposal's most common case. A kernel stack overflow with rsp near the bottom reaches the double fault before it can reach the page-fault handler, so its report is only seen through this stack.

Index row

x86_64's IDT gate for vector 8 selects IST slot 1, but the TSS entry is zero and never installed. Proposed: give the double fault a stack of its own so the safety net exists.