Repository navigation
Conversation
This comment has been minimized.
This comment has been minimized.
The host wrote the flag to scratch-top metadata on every restore. A snapshot restored by a host with a different executable_heap feature mixed executable and non-executable heap pages. The guest copies the flag from the PEB at init, and snapshots keep it. Bump the snapshot ABI to 10. Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
Add SandboxConfiguration::set_executable_heap and SandboxBuilder::executable_heap. The executable_heap feature sets the default. Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
05d320c to
682e2cb
Compare
Benchmark ResultsMeasured commit: kvm / amd (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
kvm / intel (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
mshv3 / amd (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
mshv3 / intel (Linux) (✅ 1.65x)Top improvements
Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
hyperv-ws2025 / amd (Windows) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
hyperv-ws2025 / intel (Windows) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
Reported by |
There was a problem hiding this comment.
🟡 Changes recommended
The heap-execution test can reuse an already executable page, allowing it to pass despite incorrect permissions on newly faulted pages after restore.
1 open issue
What changed in this PR
This PR makes heap execution a per-sandbox setting and preserves it across snapshots. The guest reads the setting from the process environment block (PEB) at initialization, keeping heap permissions independent of the restoring host’s feature configuration.
Changes:
- Adds runtime configuration APIs, with the Cargo feature supplying the default.
- Stores the flag in the PEB and uses guest-owned state when mapping heap pages.
- Advances snapshot ABI to 10 and updates tests, version pins, and documentation.
| File | Description |
|---|---|
src/hyperlight_host/tests/snapshot_goldens/goldens_version.rs |
Pins goldens to v10.0. |
src/hyperlight_host/tests/integration_test.rs |
Tests runtime settings and snapshot preservation. |
src/hyperlight_host/src/sandbox/snapshot/tripwires.rs |
Pins expected ABI to 10. |
src/hyperlight_host/src/sandbox/snapshot/mod.rs |
Passes the configured flag into PEB creation. |
src/hyperlight_host/src/sandbox/snapshot/file/media_types.rs |
Sets snapshot ABI to 10. |
src/hyperlight_host/src/sandbox/snapshot/file/config.rs |
Updates serialized ABI test fixtures. |
src/hyperlight_host/src/sandbox/snapshot/file_tests.rs |
Updates ABI assertions and rejection expectations. |
src/hyperlight_host/src/sandbox/config.rs |
Defines the runtime setting and feature-based default. |
src/hyperlight_host/src/sandbox/builder.rs |
Exposes the builder setting and documents snapshot behavior. |
src/hyperlight_host/src/mem/mgr.rs |
Removes restore-time writes of the heap flag. |
src/hyperlight_host/src/mem/layout.rs |
Writes the configured flag into the PEB. |
src/hyperlight_host/src/hypervisor/hyperlight_vm/x86_64.rs |
Supplies the flag when constructing test memory. |
src/hyperlight_guest/src/layout.rs |
Removes the scratch-top flag accessor. |
src/hyperlight_guest_bin/src/lib.rs |
Copies the PEB flag into guest state before heap initialization. |
src/hyperlight_guest_bin/src/arch/amd64/exception/handle.rs |
Reads guest-owned permissions for heap faults. |
src/hyperlight_guest_bin/src/arch/aarch64/exception/handle.rs |
Reads guest-owned permissions for heap faults. |
src/hyperlight_common/src/mem.rs |
Adds the heap flag to the shared PEB structure. |
src/hyperlight_common/src/layout.rs |
Preserves scratch metadata alignment with padding. |
Justfile |
Clarifies the feature-enabled test command’s comment. |
docs/snapshot-versioning.md |
Documents ABI 10 and snapshot regeneration. |
CHANGELOG.md |
Records the runtime APIs and snapshot compatibility break. |
Review effort: Balanced
| .executable_heap(false) | ||
| .build() | ||
| .unwrap(); | ||
| let result: String = restored.call("ExecuteOnHeap", ()).unwrap(); |
|
I was hoping we could remove the PEB entirely. See #2030 |
|
I agree it would be nice to remove the PEB, but it seems like the right lifecycle for this. Maybe we can just add this as an extra argument to initialise and have it stashed in a different global or something? |
sounds good to me |

The host writes the executable heap flag to scratch-top metadata on every restore. Restoring a snapshot on a host with a different
executable_heapfeature mixes executable and non-executable heap pages.This PR moves the flag into the PEB. The guest copies it at init, and snapshots keep it.
It also adds
SandboxConfiguration::set_executable_heapandSandboxBuilder::executable_heap. The cargo feature applies to every sandbox in a process, while the setting lets each sandbox choose. The feature sets the default, and it can be removed later without losing the option. Consider removingexecutable_heaphost cargo feature (#2003) tracks that.Breaking: snapshot ABI 10.
Follows up on this review discussion.