Skip to content

Commit fd29e2c

Browse files
committed
fixup! Snapshot persistence to disk
1 parent 5ff4488 commit fd29e2c

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/hyperlight_host/src/hypervisor/hyperlight_vm/x86_64.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,14 +365,18 @@ impl HyperlightVm {
365365
) -> std::result::Result<(), RegisterError> {
366366
#[cfg(not(feature = "nanvix-unstable"))]
367367
{
368+
// Restore the full special registers from snapshot, but update CR3
369+
// to point to the new (relocated) page tables
368370
let mut sregs = *sregs;
369371
sregs.cr3 = cr3;
370372
self.pending_tlb_flush = true;
371373
self.vm.set_sregs(&sregs)?;
372374
}
373375
#[cfg(feature = "nanvix-unstable")]
374376
{
375-
let _ = (cr3, sregs);
377+
let _ = (cr3, sregs); // suppress unused warnings
378+
// TODO: This is probably not correct.
379+
// Let's deal with it when we clean up the nanvix-unstable feature
376380
self.vm
377381
.set_sregs(&CommonSpecialRegisters::standard_real_mode_defaults())?;
378382
}

src/hyperlight_host/src/hypervisor/surrogate_process.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ impl SurrogateProcess {
9494
Ok(oe.get().surrogate_base)
9595
}
9696
Entry::Vacant(ve) => {
97+
// Derive the page protection from the mapping type
9798
let page_protection = match mapping {
9899
SurrogateMapping::SandboxMemory => PAGE_READWRITE,
99100
SurrogateMapping::ReadOnlyFile => PAGE_READONLY,
@@ -122,6 +123,9 @@ impl SurrogateProcess {
122123
);
123124
}
124125

126+
// Only set guard pages for SandboxMemory mappings.
127+
// File-backed read-only mappings do not need guard pages
128+
// because the host does not write to them.
125129
if *mapping == SurrogateMapping::SandboxMemory {
126130
let mut unused_out_old_prot_flags = PAGE_PROTECTION_FLAGS(0);
127131

0 commit comments

Comments
 (0)