90. A guard page under the per-CPU secondary stacks
Raised 2026-08-03, from the stack inventory of milestone 84 (stack high-water), which found the
asymmetry rather than
assumed the symmetry. The boot stack has a guard page below it, and so does every dynamic thread
stack. The per-CPU secondary stacks are a plain
array in .bss with kernel data directly beneath. A secondary that runs deep does not fault; it
scribbles.
Milestone 84's high-water assertion (secondary limit 16 KiB against 64 KiB stacks) is the only
tripwire, and it is honest about its own reach. The instrument is cfg(test), so a release build
carries no protection at all. The assertion fires after the damage on the run that finally
goes deep, not before it. A guard page fails the first overflowing access instead, at the cost of
one unmapped page of address space per CPU and zero physical frames.
The work: move the secondary stacks out of .bss into a dedicated region with an unmapped page
below each stack, on both ISAs (ยง19 (architectural parity is a tenet)). The mechanism is the same
one the boot stack already uses, so
this is extending an existing pattern, not inventing one. Prove the guard exists by walking the page
tables in a test and asserting the mapping is absent. Do not overflow a kernel stack on purpose: a
test that faults the kernel to pass would be a test the suite cannot survive.
Milestone 84's numbers say the secondaries run at 12% (8.5 KiB of 64), so the guard is insurance,
not a fix for a near-miss. The honest framing is that this closes the one place where the
kernel's stack story says "trust the tripwire" instead of "the MMU catches it".
Scope note
Sizing stays as it is: 64 KiB per secondary was not the finding, the missing guard was. If the region move makes shrinking cheap, record the option; do not take it here. The thread-stack and boot-stack guards are prior art in this tree; cite where the pattern lives when extending it.
Follow-on
- Refused. Shrinking the 64 KiB per-CPU secondary stacks, which the region move made tempting to fold in. The scope note refused it in advance and the measurement backs the refusal: milestone 84 puts the secondaries at 12% of their stacks (8.5 KiB of 64), so the missing guard was the finding and the sizing was not. Taking both at once would have made a stack-depth regression and a guard regression indistinguishable in one commit. Milestone 454 (design/roadmap/0454-the-stack-sizes-nobody-has-sized.md) carries this refusal.
Index row
Milestone 84's instrument found the asymmetry: the boot stack and every thread stack sit above a
guard page, and the per-CPU secondaries sit above .bss, so a deep secondary silently corrupts
kernel data. The high-water assertion is the only tripwire today, and it is cfg(test): a release
build has nothing. Move the stacks over a hole and prove the hole by walking the tables