feat(users): per-user sealed folders users/<id>/{home,apps,data,permissions}; storage SET_USER/LOCK/PURGE; init sign-in/sign-out loop (purge fresh/removed/guest, seed from factory, session start/stop); shell logout; pm user+system app shelves; terminal SIGNED_OUT; per-program stack (gatekeeper 12p); 128K load scratch
This commit is contained in:
@@ -8,12 +8,15 @@ use types::budget::Limits;
|
||||
|
||||
const PAGE_SIZE: usize = 4096;
|
||||
const USER_CODE_BASE: usize = 0x10000;
|
||||
const USER_STACK_PAGES: usize = 4;
|
||||
/// A program's stack, below its image, unless its manifest says more.
|
||||
pub(crate) const STACK_PAGES: usize = 4;
|
||||
/// The most there is room for under the image (page 0 stays unmapped).
|
||||
const MAX_STACK_PAGES: usize = USER_CODE_BASE / PAGE_SIZE - 1;
|
||||
const CREATE_CAP: CapSlot = CapSlot::const_new(0);
|
||||
/// Where a program file is read to before it is loaded (16 pages: the
|
||||
/// largest program init will load).
|
||||
const SCRATCH_VA: VirtualAddress = VirtualAddress::from_raw(0x30000);
|
||||
const SCRATCH_PAGES: u16 = 16;
|
||||
/// Where a program file is read to before it is loaded (32 pages: the
|
||||
/// largest program init will load; the gatekeeper is past 16).
|
||||
const SCRATCH_VA: VirtualAddress = VirtualAddress::from_raw(0x0120_0000);
|
||||
const SCRATCH_PAGES: u16 = 32;
|
||||
|
||||
pub(crate) struct LoadedProcess {
|
||||
pub(crate) process_cap: CapSlot,
|
||||
@@ -35,7 +38,9 @@ pub(crate) fn load_binary(
|
||||
scratch: &mut [u8],
|
||||
filename: &[u8],
|
||||
limits: Limits,
|
||||
stack_pages: usize,
|
||||
) -> Option<LoadedProcess> {
|
||||
let stack_pages = stack_pages.min(MAX_STACK_PAGES);
|
||||
let file_size = read_file(storage, scratch, filename)?;
|
||||
let elf_data = &scratch[..file_size];
|
||||
let elf_info = match elf::parse(elf_data) {
|
||||
@@ -71,10 +76,10 @@ pub(crate) fn load_binary(
|
||||
}
|
||||
}
|
||||
|
||||
for i in 0..USER_STACK_PAGES {
|
||||
for i in 0..stack_pages {
|
||||
let page_count = PageCount::new(1)?;
|
||||
let stack_va = syscall::request_pages(page_count)?;
|
||||
let dst = VirtualAddress::from_raw(USER_CODE_BASE - (USER_STACK_PAGES - i) * PAGE_SIZE);
|
||||
let dst = VirtualAddress::from_raw(USER_CODE_BASE - (stack_pages - i) * PAGE_SIZE);
|
||||
syscall::map_page(process_cap, stack_va, dst, false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user