Skip to content

Prevents size underflow in page iteration loop#44

Closed
Godones wants to merge 1 commit into
arceos-org:devfrom
Godones:dev
Closed

Prevents size underflow in page iteration loop#44
Godones wants to merge 1 commit into
arceos-org:devfrom
Godones:dev

Conversation

@Godones

@Godones Godones commented Apr 1, 2026

Copy link
Copy Markdown

Ensures that a default 4K page size is returned when an entry is not present, avoiding potential underflow when the page size exceeds the remaining region.

Copilot AI review requested due to automatic review settings April 1, 2026 08:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the protect_region page-iteration loop for 64-bit page tables to avoid usize underflow when the page size exceeds the remaining region size.

Changes:

  • Removes the assert!(page_size as usize <= size) in protect_region (64-bit).
  • Decrements size by min(page_size, size) to ensure loop termination without underflow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread page_table_multiarch/src/bits64.rs
Comment thread page_table_multiarch/src/bits64.rs Outdated
Ensures that a default 4K page size is returned when an entry
is not present, avoiding potential underflow when the page size exceeds the remaining region.

Signed-off-by: Godones <chenlinfeng25@outlook.com>
@Godones Godones closed this Apr 2, 2026
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.

3 participants