Skip to content

hal/pmap: unify pmap_isAllowed implementation#799

Open
etiaro wants to merge 1 commit into
masterfrom
etiaro/pmap-allowed
Open

hal/pmap: unify pmap_isAllowed implementation#799
etiaro wants to merge 1 commit into
masterfrom
etiaro/pmap-allowed

Conversation

@etiaro

@etiaro etiaro commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Description

Following the function signature, ensure that whole region is allowed according to given pmap structure on all MPU-enabled targets.

Introduce edge-case check when region overflows to 0 but map is not aligned to the end of address space

Motivation and Context

Ongoing work on simple improvements to syscall safety.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (refactoring, style fixes, git/CI config, submodule management, no code logic changes)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: (list targets here).

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

  • This PR needs additional PRs to work (list the PRs, preferably in merge-order).
  • I will merge this PR by myself when appropriate.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates the pmap_isAllowed function across ARMv7-M, ARMv7-R, and ARMv8-M architectures to handle potential arithmetic overflows when validating memory ranges. The review comments correctly identify a critical issue where if map->end is 0U (representing the top of memory), the check addr_end > map->end will incorrectly evaluate to true for any non-zero addr_end, leading to false negatives. The reviewer provides code suggestions to only perform this check when map->end is not 0U.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread hal/armv7m/pmap.c Outdated
Comment thread hal/armv7r/pmap.c Outdated
Comment thread hal/armv8m/pmap.c Outdated
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown

Unit Test Results

10 860 tests  ±0   10 190 ✅ ±0   53m 6s ⏱️ -23s
   670 suites ±0      670 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit 9d173c0. ± Comparison against base commit 6d78d3a.

♻️ This comment has been updated with latest results.

@etiaro etiaro force-pushed the etiaro/pmap-allowed branch from 3af28f5 to 9d173c0 Compare June 26, 2026 11:59
@etiaro

etiaro commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates the pmap_isAllowed function across the armv7m, armv7r, and armv8m architectures to improve arithmetic overflow checks and boundary handling when validating memory regions. Specifically, it ensures that addr_end is allowed to be 0 (representing the top of memory) and correctly checks if the address range exceeds the map's end. Additionally, the resolution of the memory map is now deferred until after checking if the MPU is enabled in the armv7r and armv8m implementations. There are no review comments, so no further feedback is provided.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@etiaro etiaro marked this pull request as ready for review June 26, 2026 12:29
@etiaro etiaro requested review from a team, agkaminski and jmaksymowicz June 26, 2026 12:29
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