Skip to content

feat: pass file mapping info via PEB with label support#1322

Merged
simongdavies merged 1 commit intohyperlight-dev:mainfrom
simongdavies:add-file-mapping-ga
Mar 19, 2026
Merged

feat: pass file mapping info via PEB with label support#1322
simongdavies merged 1 commit intohyperlight-dev:mainfrom
simongdavies:add-file-mapping-ga

Conversation

@simongdavies
Copy link
Contributor

Add FileMappingInfo struct (guest_addr, size, label) and file_mappings field to HyperlightPEB so file mapping metadata is communicated to the guest through the PEB. Space for MAX_FILE_MAPPINGS (32) entries is statically reserved after the PEB struct to avoid dynamic layout changes.

  • Add label parameter to map_file_cow (optional, defaults to filename)
  • Add shared memory overlap validation (full mapped range)
  • Add inter-mapping overlap detection
  • Add write_file_mapping_entry on SandboxMemoryManager
  • Add MAX_FILE_MAPPINGS limit enforcement at registration time
  • Update PEB region sizing in get_memory_regions and layout tests

@simongdavies simongdavies added the kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. label Mar 18, 2026
@ppenna ppenna added this to HL-NVX Mar 18, 2026
@ppenna ppenna moved this to In Progress in HL-NVX Mar 18, 2026
@danbugs danbugs requested a review from Copilot March 19, 2026 00:22
Copy link
Contributor

Copilot AI left a comment

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 extends the Hyperlight host↔guest ABI by adding file-mapping metadata (guest address, size, label) to the PEB, enabling guests to discover host-mapped files and their identities. It reserves space for a fixed-size FileMappingInfo array immediately after the PEB to keep the layout stable.

Changes:

  • Add FileMappingInfo + MAX_FILE_MAPPINGS and extend HyperlightPEB with a file_mappings descriptor.
  • Add optional label support to map_file_cow, validate mapping overlaps, and enforce the max mapping count.
  • Update memory layout sizing to reserve space for the PEB + mappings array, and write mapping entries into the PEB at map time / evolve time.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/hyperlight_host/src/sandbox/uninitialized_evolve.rs Writes file mapping metadata into the PEB during evolve for deferred mappings.
src/hyperlight_host/src/sandbox/uninitialized.rs Adds label parameter + limit/overlap validation for deferred file mappings.
src/hyperlight_host/src/sandbox/initialized_multi_use.rs Adds label parameter, validates overlaps, writes mapping metadata into the PEB, updates tests for new signature.
src/hyperlight_host/src/sandbox/file_mapping.rs Stores a fixed-size C-string label in prepared mappings and validates/truncates labels.
src/hyperlight_host/src/mem/mgr.rs Adds write_file_mapping_entry to write FileMappingInfo entries into the PEB’s reserved array.
src/hyperlight_host/src/mem/layout.rs Reserves space after the PEB for MAX_FILE_MAPPINGS entries and wires up PEB offsets/pointers.
src/hyperlight_host/examples/crashdump/main.rs Updates map_file_cow calls for the new label parameter.
src/hyperlight_common/src/mem.rs Adds shared ABI types/constants and extends HyperlightPEB with file_mappings.

You can also share your feedback on Copilot code review. Take the survey.

danbugs added a commit to nanvix/hyperlight that referenced this pull request Mar 19, 2026
Cherry-pick of hyperlight-dev#1322.

Add FileMappingInfo struct (guest_addr, size, label) and file_mappings
field to HyperlightPEB so file mapping metadata is communicated to the
guest through the PEB. Space for MAX_FILE_MAPPINGS (32) entries is
statically reserved after the PEB struct to avoid dynamic layout changes.

- Add label parameter to map_file_cow (optional, defaults to filename)
- Add shared memory overlap validation (full mapped range)
- Add inter-mapping overlap detection
- Add write_file_mapping_entry on SandboxMemoryManager
- Add MAX_FILE_MAPPINGS limit enforcement at registration time
- Update PEB region sizing in get_memory_regions and layout tests
Add FileMappingInfo struct (guest_addr, size, label) and file_mappings
field to HyperlightPEB so file mapping metadata is communicated to the
guest through the PEB. Space for MAX_FILE_MAPPINGS (32) entries is
statically reserved after the PEB struct to avoid dynamic layout changes.

- Add label parameter to map_file_cow (optional, defaults to filename)
- Add shared memory overlap validation (full mapped range)
- Add inter-mapping overlap detection
- Add write_file_mapping_entry on SandboxMemoryManager
- Add MAX_FILE_MAPPINGS limit enforcement at registration time
- Update PEB region sizing in get_memory_regions and layout tests

Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
Copy link
Contributor

@danbugs danbugs left a comment

Choose a reason for hiding this comment

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

LGTM to me. Just 2 questions and 1 nit.

@danbugs danbugs mentioned this pull request Mar 19, 2026
@simongdavies simongdavies merged commit 04ff075 into hyperlight-dev:main Mar 19, 2026
48 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in HL-NVX Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement For PRs adding features, improving functionality, docs, tests, etc.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants