Skip to content

test(libkernel): skip the mapping above the system-reserved range when a host region holds it - #29181

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
magnub:test/kernel-fixed-reservation-skip-host-region
Dec 5, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
magnub:test/kernel-fixed-reservation-skip-host-region

Conversation

@magnub

@magnub magnub commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

What

CheckFixedReservationOverPartlyMappedRange (#27457) ends by mapping one flexible page at 0x1000000000, right after the system-reserved range, and checking that a reservation straddling the boundary fails. Under Rosetta on Apple silicon that page is never available: the process starts with sealed mappings (maximum protection none) at 0xfc0000000–0x1000000000 and 0x1000000000–0x7000000000, which macOS reports as /usr/libexec/rosetta/runtime. The arena records them as host regions, so the fixed map throws "fixed guest mapping 0x1000000000+0x4000 overlaps a host region in the guest arena" and guest_memory aborts.

That last part of the check now runs only when the arena has no host region at 0x1000000000, using GuestArenaHostRegionOverlaps_nid_postfix on Windows and GuestArenaOverlapsHostRegion_nid_no_patch elsewhere, as CheckArenaHintInsideHostRegion already does. Linux and Windows, where that page is guest memory, run it as before.

Tested

Apple M1 Pro, macOS 27.0.1, Apple clang 21.0.0, x86_64 build under Rosetta 2, on main cec4943 with the macOS build fixes #11049, #26739, #27739, #27767, #27843 and #27639 merged locally so that main builds.

  • guest_memory: aborts on main (2/2) with the error above; passes 3/3 with this change.
  • A temporary probe walking mach_vm_region from 0x7f0000000 to 0x1400000000 showed the two sealed ranges above at the same addresses in all three runs, and GuestArenaOverlapsHostRegion_nid_no_patch(0x1000000000, 0x4000) returned true each time.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

https://claude.ai/code/session_012LL9hfx4BY6MbUCYMduDAQ

Summary by CodeRabbit

  • Tests
    • Updated host-end reservation checks to account for whether the target page overlaps a host region, with platform-specific checks on Windows and other platforms.
    • Mapping and straddling-reservation assertions now run only when the page does not overlap a host region.

@coderabbitai

coderabbitai Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Guest memory test

Layer / File(s) Summary
Host-end overlap guard
core/libs/tests/GuestMemory.cpp
The test uses platform-specific queries to check for host-region overlap at hostEnd. It skips the mapping and straddling-reservation assertions when overlap is detected.

Suggested reviewers: herolias, marczx10, jjenkx

Change: Other

Merge Risk: Minimal · up to 8cceb

This is a test-only change that stops guest_memory from aborting where host mappings cover the fixed address, as on Rosetta. The checks still run on Linux and Windows. Merge risk is minimal.

Security architecture risk: Minimal · up to 8cceb

The test skips the fixed mapping and straddling-reservation checks when an existing host mapping occupies the target page. Production guest-memory behavior is unchanged.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2fbe762d-ba98-4b66-9aef-167a8ad05bc4
Commits

Reviewing files that changed from the base of the PR and between a30a8c2 and 8cceba0.

Files selected for processing: 1

  • core/libs/tests/GuestMemory.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed — looks good

The change skips the boundary mapping assertions when the target page overlaps a host region, while retaining them when the page is available.

What I ran

Reviewed head 8cceba0529d5e892b863e04361be755c8ab5c779; base: main (no merged preview). I inspected the prepared diff and the changed file’s relevant code and callers with repo_read.py. No tests or builds were run.

Results

Check Result Note
Diff and source review passed One changed file reviewed
Runtime tests not run Author-reported results not reproduced
Build not run No build attempted

Negative control

Not run; no assertion mutation was made.

Findings

Blocking

None.

Non-blocking

None.

Sources

Not verified

The reported Apple silicon/Rosetta runs and the Linux and Windows runtime behavior were not independently verified. Reviewed core/libs/tests/GuestMemory.cpp; files.json lists no excluded files.

To get this to a good state

Nothing is required.

@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 16372 core/libs/tests/GuestMemory.cpp
PR 20978 core/libs/tests/GuestMemory.cpp
PR 21569 core/libs/tests/GuestMemory.cpp
PR 24034 core/libs/tests/GuestMemory.cpp
PR 28264 core/libs/tests/GuestMemory.cpp

@oneandonlydean
oneandonlydean merged commit d972cfa into boykopovar:main Dec 5, 2026
11 checks passed
@magnub
magnub deleted the test/kernel-fixed-reservation-skip-host-region branch December 6, 2026 09:55
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