Skip to content

Conversation

@simongdavies
Copy link
Contributor

This commit changes the Hyperlight API so that every sandbox is created from a snapshot. This is useful for several reasons; most immediately, in the same commit, note that it allows us to avoid precommitting to a size for the page table region, so we no longer need to estimate that region's size.

This PR also makes the map_region function private so that all the new types related to paging do not have to be exposed publicly, whilst this function is used by hyperlight-wasm, it needs to be updated to use simpler public types.

@simongdavies simongdavies added kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. Guest-COW PRs that form part of the Guest-COW change labels Dec 18, 2025
@simongdavies simongdavies force-pushed the create-sandbox-from-snapshot branch 3 times, most recently from ae23c59 to 3e631b0 Compare December 18, 2025 16:57
@danbugs danbugs requested a review from Copilot December 18, 2025 17:54
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 refactors the Hyperlight sandbox creation architecture to use snapshots as the foundation for all sandbox instances. The key motivation is to eliminate the need to pre-estimate page table sizes, as the page tables are now created during snapshot creation with the exact size needed.

Key Changes:

  • All sandboxes are now created from snapshots via Snapshot::from_env()
  • Page table setup moved from runtime to snapshot creation time
  • map_region function made private (Linux-only)
  • Memory layout base address changed from 0x0 to 0x1000
  • New GuestPageTableBuffer now tracks physical base address
  • Added comprehensive tests for snapshot-based sandbox creation

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
src/hyperlight_host/src/sandbox/snapshot.rs Added from_env() to create snapshots from guest binaries; now stores layout and load info
src/hyperlight_host/src/sandbox/uninitialized.rs Refactored new() to use snapshots internally; added from_snapshot() private method
src/hyperlight_host/src/sandbox/uninitialized_evolve.rs Simplified hypervisor setup using pre-computed snapshot values
src/hyperlight_host/src/mem/mgr.rs Replaced load_guest_binary_into_memory() with from_snapshot(); removed set_up_shared_memory()
src/hyperlight_host/src/mem/layout.rs Changed base address to 0x1000; added PT offset/size tracking; moved page table region to end
src/hyperlight_host/src/mem/memory_region.rs Added trait-based MemoryRegion_<K> to support guest-only and host-guest regions
src/hyperlight_host/src/sandbox/initialized_multi_use.rs Made map_region() private and Linux-only; reused snapshot counter
src/hyperlight_host/src/testing/mod.rs Removed helper functions now superseded by snapshot-based approach
src/hyperlight_guest_bin/src/paging.rs Added physical-to-virtual translation for snapshot page tables
src/hyperlight_common/src/layout.rs New module defining SNAPSHOT_PT_GVA constant for page table virtual address

@simongdavies simongdavies force-pushed the create-sandbox-from-snapshot branch 2 times, most recently from 0005ea8 to 04e136b Compare December 18, 2025 22:23
Copy link
Contributor

@ludfjig ludfjig left a comment

Choose a reason for hiding this comment

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

I haven't analyzed every diff with great detail, but in general LGTM. I agree with Copilot's reivew comments though

simongdavies and others added 2 commits December 19, 2025 19:59
This commit changes the Hyperlight API so that every sandbox is
created from a snapshot. This is useful for several reasons; most
immediately, in the same commit, note that it allows us to avoid
precommitting to a size for the page table region, so we no longer
need to estimate that regin's size.

Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
Co-authored-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
@simongdavies simongdavies force-pushed the create-sandbox-from-snapshot branch from 5ddab8f to fae2961 Compare December 19, 2025 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Guest-COW PRs that form part of the Guest-COW change kind/enhancement For PRs adding features, improving functionality, docs, tests, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants