feat(mm): implemented on-demand paging support for lazy stack growth (user faults only)#126
Merged
Conversation
d2e6ab0 to
1882297
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.
Note
High Risk
Changes trap handlers, address-space mapping, stack layout, and uaccess paths in privileged kernel code; incorrect fault handling or lazy mapping could crash tasks or leak memory.
Overview
Adds user-only on-demand paging for lazy stack growth: x86 and AArch64 trap handlers translate fault details into
mm::PF_FLAG_*and callmm::handle_user_pfbefore delivering SIGSEGV. The handler only resolves not-present faults onVMA_FLAG_STACKVMAs (allocates, zeros, maps a page; concurrent faults on the same page are treated as success).MM_MAP_LAZYskips eager physical mapping inmm_context_map_anonymous;USER_STACK_MAX_PAGES(8 MiB) defines the stack reservation.create_user_taskmaps a large lazy stack VMA plus an eager top window for argv/envp setup.validate_user_rangepre-faults missing lazy pages so kernelcopy_*_userdoes not fault on unmapped PTEs.mm_contextand mapping lifecycle APIs move fromvma.cppintomm/mm.cppandmm/mm.h; VMA helpers stay invmawith shared helpers exported. Call sites switch to#include "mm/mm.h".Reviewed by Cursor Bugbot for commit 0602957. Bugbot is set up for automated code reviews on this repo. Configure here.