feat(whp): support no-surrogate mode via HYPERLIGHT_MAX_SURROGATES=0#1578
feat(whp): support no-surrogate mode via HYPERLIGHT_MAX_SURROGATES=0#1578danbugs wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an optional Windows-only WHP mode (whp-no-surrogate) that bypasses the surrogate process for GPA mapping, intended for single-partition-per-process scenarios, and refactors shared-memory allocation to share validation/guard-page setup across allocation paths.
Changes:
- Introduces a new
whp-no-surrogatefeature flag inhyperlight-host. - Adds a
VirtualAlloc-backed shared memory allocation path (vsCreateFileMappingA) and maps GPAs viaWHvMapGpaRange(vs dynamically-loadedWHvMapGpaRange2through the surrogate). - Refactors Windows shared memory creation to reuse
validated_total_size()andset_guard_pages()helpers.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/hyperlight_host/src/mem/shared_mem.rs |
Adds DirectAlloc mapping mode + VirtualAlloc allocation path and refactors guard-page/size validation helpers. |
src/hyperlight_host/src/hypervisor/virtual_machine/whp.rs |
Adds feature-gated mapping path using WHvMapGpaRange and removes surrogate-process usage when enabled. |
src/hyperlight_host/Cargo.toml |
Declares the new whp-no-surrogate feature flag. |
ludfjig
left a comment
There was a problem hiding this comment.
Have you considered making this a runtime option instead, for example on SandboxConfiguration? If possible I think I would prefer it
Signed-off-by: danbugs <danilochiarlone@gmail.com>
35aaabf to
820c953
Compare
Had a chat w/ @simongdavies and modified this PR to integrate w/ |
HYPERLIGHT_MAX_SURROGATES=0, skip surrogate process creation entirely and useVirtualAlloc+WHvMapGpaRangeinstead ofCreateFileMappingA+ surrogate +WHvMapGpaRange2WHvMapGpaRangereturnsERROR_VID_PARTITION_ALREADY_EXISTSwhen called from multiple partitions in the same process)compute_surrogate_counts()now accepts 0 as a valid minimum, andsurrogates_disabled()checks the env var at runtimeWhpVm::surrogate_processis nowOption<SurrogateProcess>, withmap_memory/unmap_memorybranching at runtimeExclusiveSharedMemory::new()usesVirtualAlloc(via newDirectAllocationRAII type) when surrogates are disabled,CreateFileMappingAotherwise