fix: stacks at top of user VA in own 1 MiB band (guard, heap kept below), 8/16 pages default; kernel fault msg names pid, kind, flags stack overflow; flaky OVERFLOW + spawntest/test-qemu check it

This commit is contained in:
2026-10-28 16:03:06 +01:00
parent 18e8b3ecb8
commit 495bf03484
12 changed files with 93 additions and 22 deletions

View File

@@ -72,7 +72,14 @@ impl<P: Platform> Kernel<P> {
fn first_fit_from(&self, pid: ProcessId, from: usize, pages: usize) -> Option<VirtualAddress> {
let mut candidate = from;
while Self::in_user_window(VirtualAddress::from_raw(candidate), pages) {
// Never into the stack's band (`types::layout`).
let below_stacks = |c: usize| {
c.checked_add(pages * PAGE_SIZE)
.is_some_and(|end| end <= types::layout::HEAP_END)
};
while Self::in_user_window(VirtualAddress::from_raw(candidate), pages)
&& below_stacks(candidate)
{
let va = VirtualAddress::from_raw(candidate);
match (0..pages).find(|&i| self.is_mapped(pid, page_at(va, i))) {
None => return Some(va),