Skip to content

feat(mm): implemented on-demand paging support for lazy stack growth (user faults only)#126

Merged
FlareCoding merged 3 commits into
masterfrom
pr/on-demand-paging
May 26, 2026
Merged

feat(mm): implemented on-demand paging support for lazy stack growth (user faults only)#126
FlareCoding merged 3 commits into
masterfrom
pr/on-demand-paging

Conversation

@FlareCoding
Copy link
Copy Markdown
Owner

@FlareCoding FlareCoding commented May 26, 2026

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 call mm::handle_user_pf before delivering SIGSEGV. The handler only resolves not-present faults on VMA_FLAG_STACK VMAs (allocates, zeros, maps a page; concurrent faults on the same page are treated as success).

MM_MAP_LAZY skips eager physical mapping in mm_context_map_anonymous; USER_STACK_MAX_PAGES (8 MiB) defines the stack reservation. create_user_task maps a large lazy stack VMA plus an eager top window for argv/envp setup. validate_user_range pre-faults missing lazy pages so kernel copy_*_user does not fault on unmapped PTEs.

mm_context and mapping lifecycle APIs move from vma.cpp into mm/mm.cpp and mm/mm.h; VMA helpers stay in vma with 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.

cursor[bot]

This comment was marked as resolved.

@FlareCoding FlareCoding force-pushed the pr/on-demand-paging branch from d2e6ab0 to 1882297 Compare May 26, 2026 06:03
cursor[bot]

This comment was marked as resolved.

@FlareCoding FlareCoding merged commit ab1fd6e into master May 26, 2026
15 checks passed
@FlareCoding FlareCoding deleted the pr/on-demand-paging branch May 26, 2026 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant