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:
@@ -17,7 +17,7 @@ use crate::manifest::{Device, Program, Scope};
|
||||
use crate::spawn::Spawner;
|
||||
use crate::supervise::{MAX_SUPERVISED, Supervised};
|
||||
|
||||
const USER_STACK_TOP: StackPointer = StackPointer::from_raw(0x10000);
|
||||
const USER_STACK_TOP: StackPointer = StackPointer::from_raw(types::layout::STACK_TOP);
|
||||
const MAX_SERVED: usize = 8;
|
||||
|
||||
fn perms(list: &[Permission]) -> PermissionSet {
|
||||
|
||||
@@ -7,14 +7,12 @@ use types::bounded::{CapSlot, PageCount};
|
||||
use types::budget::Limits;
|
||||
|
||||
const PAGE_SIZE: usize = 4096;
|
||||
const USER_CODE_BASE: usize = 0x10000;
|
||||
/// A program's stack, below its image, unless its manifest says more.
|
||||
pub(crate) const STACK_PAGES: usize = 4;
|
||||
/// A program's stack (see `types::layout`), unless init's table says more.
|
||||
pub(crate) const STACK_PAGES: usize = 8;
|
||||
/// An app's: drawing (tiny-skia, fontdue) takes more than 16 KiB.
|
||||
pub(crate) const APP_STACK_PAGES: usize = 8;
|
||||
/// The most there is room for under the image, above the arguments page
|
||||
/// (page 0 stays unmapped).
|
||||
const MAX_STACK_PAGES: usize = (USER_CODE_BASE - types::start_arg::ARGS_VA) / PAGE_SIZE - 1;
|
||||
pub(crate) const APP_STACK_PAGES: usize = 16;
|
||||
/// The most the stack's band holds, leaving a guard page at its bottom.
|
||||
const MAX_STACK_PAGES: usize = types::layout::STACK_BAND / PAGE_SIZE - 1;
|
||||
const CREATE_CAP: CapSlot = CapSlot::const_new(0);
|
||||
/// Where a program file is read through on its way into a process, a
|
||||
/// chunk at a time, so a program may be any size.
|
||||
@@ -102,7 +100,7 @@ fn load_from(file: &mut Stream, limits: Limits, stack_pages: usize) -> Option<Lo
|
||||
let process_cap = syscall::create_process(CREATE_CAP, limits)?;
|
||||
let filled = elf_info.segments().all(|segment| load_segment(file, process_cap, segment).is_some())
|
||||
&& (0..stack_pages).all(|i| {
|
||||
let dst = VirtualAddress::from_raw(USER_CODE_BASE - (stack_pages - i) * PAGE_SIZE);
|
||||
let dst = VirtualAddress::from_raw(types::layout::STACK_TOP - (stack_pages - i) * PAGE_SIZE);
|
||||
PageCount::new(1).and_then(syscall::request_pages).is_some_and(|va| {
|
||||
syscall::map_page(process_cap, va, dst, false);
|
||||
true
|
||||
|
||||
Reference in New Issue
Block a user