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:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user