-
Notifications
You must be signed in to change notification settings - Fork 155
Create Sandboxes from Snapshots #1127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Create Sandboxes from Snapshots #1127
Conversation
ae23c59 to
3e631b0
Compare
There was a problem hiding this 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_regionfunction made private (Linux-only)- Memory layout base address changed from 0x0 to 0x1000
- New
GuestPageTableBuffernow 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 |
0005ea8 to
04e136b
Compare
ludfjig
left a comment
There was a problem hiding this 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
ea263cf to
5ddab8f
Compare
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>
5ddab8f to
fae2961
Compare
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_regionfunction 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.