Memory management: per-process VA range, brk frontier tracking, noreserve/LOW_2G support#746
Open
wdcui wants to merge 1 commit intowdcui/stacked/pr5-fs-net-pipesfrom
Open
Conversation
18a148e to
121fe60
Compare
6448a31 to
046443d
Compare
541eb61 to
4722328
Compare
…erve/LOW_2G support - Vmem and PageManager accept a configurable VA range instead of always using the platform-wide TASK_ADDR_MIN..TASK_ADDR_MAX, enabling per-process address space partitioning. - Track brk_base and brk_frontier for correct heap management: brk_base prevents shrinking below the initial program break, brk_frontier tracks the actual page-aligned heap high-water mark. - Add CreatePagesFlags: FD_WRITABLE (shared file-backed VM_MAYWRITE), NORESERVE (sparse reservations), LOW_2G (MAP_32BIT ceiling). - VmArea gains noreserve field, propagated through all split/merge paths. - create_mapping uses a retry loop for non-fixed allocations when the host rejects an address inside the guest partition. - get_unmmaped_area supports require_low_2g and max_start narrowing. - handle_page_fault returns AllocationFailed instead of panicking. - VmemResizeError::OutOfRange triggers move_mappings fallback in remap.
4722328 to
2a84033
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends the memory management subsystem to support per-process virtual address ranges and adds several new capabilities needed by the host process sandbox.
Stack: PR 6 of N — depends on #745
Changes
Per-process VA range (
Vmem,PageManager)Vmem::new()andPageManager::new()accept aRange<usize>instead of always using the platform-wideTASK_ADDR_MIN..TASK_ADDR_MAXinsert_mapping,get_unmmaped_area,handle_page_fault) uses the configured range instead of platform constantsaddr_min/addr_maxonPageManagerfor lock-free bounds checksHeap (
brk) improvementsbrk_base: floor that prevents shrinking below the initial program breakbrk_frontier: page-aligned high-water mark that tracks the actual backed extent, replacing the oldbrk.next_multiple_of(PAGE_SIZE)computationensure_brk_past(): advances the floor/brk/frontier past non-heap mappings (e.g., trampolines)current_brk()/current_brk_frontier(): read-only accessorsNew
CreatePagesFlagsFD_WRITABLE(1<<7): shared file-backed mapping getsVM_MAYWRITEwhen the fd is writableNORESERVE(1<<8): sparse reservation without swap/commit upfrontLOW_2G(1<<9): constrain mapping below theMAP_32BIT2 GiB ceilingu8tou16Allocation robustness
create_mappingretry loop: non-fixed allocations that fail because the host rejected the address fall back to the next candidate VA instead of returning ENOMEM immediatelyinsert_mappingvalidates the platform-returned address is within the managed range; frees stray allocationsget_unmmaped_areasupportsrequire_low_2gandmax_startnarrowing for the retry loopVmemResizeError::OutOfRangetriggersmove_mappingsfallback inremap_pagesMiscellaneous
VmArea.noreservefield, propagated through all split/merge/copy pathsmay_flags_for_mappingconsidersfd_writableforVM_MAYWRITEhandle_page_faultreturnsAllocationFailedinstead of panickingVmemPageFaultHandler::HANDLE_USER_PAGE_FAULTSconst (defaultfalse)Files changed (8 files, +415/-96)
litebox/src/mm/linux.rslitebox/src/mm/mod.rslitebox/src/mm/tests.rslitebox_shim_linux/src/lib.rslitebox_shim_optee/src/lib.rslitebox_shim_linux/src/syscalls/mm.rslitebox_platform_linux_kernel/src/mm/tests.rslitebox_platform_lvbs/src/mm/tests.rsTesting
cargo build— cleancargo clippy --all-targets --all-features— cleancargo fmt --all -- --check— cleancargo nextest run --profile ci -E 'not test(nine_p)'— 208 passed, 15 failed (pre-existing TUN/EPERM), 34 skipped