Skip to content

Conversation

@sunhaosheng
Copy link
Contributor

VmIo Lazy Allocation Failure

Files:

  • core/src/mm.rs
  • api/src/io.rs
  • api/src/mm.rs

Bug Description:
When the kernel tried to read/write user memory that was lazily allocated but not yet faulted in, the operation would fail with AccessDenied instead of triggering page fault handling.

Fix:
Added retry logic with page population:

  1. First attempt the read/write
  2. If failed, calculate the faulting address from the failure offset
  3. Call populate_area to ensure the pages are allocated
  4. Retry the read/write operation

When kernel reads/writes user memory that is lazily allocated but not
yet faulted in, user_copy (assembly function) uses exception table to
handle page faults and returns failure instead of triggering the
kernel's page fault handler.

Fix: Add retry logic in VmIo read/write:
1. First attempt the read/write via user_copy
2. If failed, calculate the faulting address from failure offset
3. Call populate_area() to ensure pages are allocated
4. Retry the read/write operation

Also changed ELF segment mapping to use populate=true for immediate
allocation to avoid retry overhead during early execution.
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.

2 participants