Skip to content

CoW follow-up work#1315

Open
syntactically wants to merge 8 commits intomainfrom
lm/cow-wasm-work
Open

CoW follow-up work#1315
syntactically wants to merge 8 commits intomainfrom
lm/cow-wasm-work

Conversation

@syntactically
Copy link
Member

This starts to move to actually take advantage of the fact that snapshots are now RO by not copying them all the time (although they still aren't loadable-from-disk). It also includes a few other tweaks to improve snapshot creation.

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.

LGTM! Note I notcied cargo test --features gdb -p hyperlight-host -- hypervisor::gdb::tests::mem_access_tests::test_mem_access_write fails, are we fine with this? Unsure if it fails on main.

Btw this is awesome

snapshots/restore/large time:   [56.654 µs 58.220 µs 60.077 µs]
                        change: [−99.864% −99.829% −99.779%] (p = 0.00 < 0.05)
                        Performance has improved.

@syntactically syntactically added the kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. label Mar 18, 2026
For historical reasons, PEB setup still happened when an uninitialised
sandbox was created, instead of happening at snapshot time, which is
far more sensible. This removes the need for the snapshot memory to be
writable during initialisation.

Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
Whenever we are not running with certain features that still require
legacy writable access to the snapshot region (currently:
nanvix-unstable, gdb), map the snapshot region directly into the VM.
This lays the groundwork for sharing a single snapshot memory between
multiple VMs.

Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
Previously, if a sandbox mapped one physical page to multiple virtual
addresses, taking a snapshot would duplicate the page. This commit
changes the logic around snapshots to keep track of the physical pages
that have been encountered during the virtual memory traversal so far,
and ensure that the same page is not copied multiple times.  Note that
this does not (yet) track the contents of pages to allow
de-duplicating them---it merely ensures that two mappings of the same
physical address do not result in needless duplication.

Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
Previously, the page table manipulation interfaces exported for the
use of guests did not permit unmapping an existing mapped range. This
commit improves that situation, by adding an "unmapped" mapping type,
which code can use to request that a remap operation make a region
not-present.

Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
Silence spurious panic warning

Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
Address review comments

Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
@syntactically
Copy link
Member Author

LGTM! Note I notcied cargo test --features gdb -p hyperlight-host -- hypervisor::gdb::tests::mem_access_tests::test_mem_access_write fails, are we fine with this? Unsure if it fails on main.

As far as I can tell this test was causing UB (causing a write to happen to an mmap region, which other threads may be reading from based on the contract we documented for mmap regions), so I think it is correct to fail. We could get rid of / rewrite it, but if it already isn't in CI for some reason I'd rather do that later.

Fix clippy warnings with all features enabled

Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
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

None yet

Development

Successfully merging this pull request may close these issues.

3 participants