Skip to content

Commit 5541ff3

Browse files
committed
Allow unmapping existing mapped ranges in the guest
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>
1 parent ab8f7a4 commit 5541ff3

File tree

4 files changed

+4
-0
lines changed

4 files changed

+4
-0
lines changed

src/hyperlight_common/src/arch/amd64/vmem.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ unsafe fn map_page<
456456
0 | // R/W - Cow page is never writable
457457
PAGE_PRESENT // P - this entry is present
458458
}
459+
MappingKind::Unmapped => 0,
459460
};
460461
unsafe {
461462
write_entry_updating(op, r.update_parent, r.entry_ptr, pte);

src/hyperlight_common/src/vmem.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ pub struct CowMapping {
196196

197197
#[derive(Debug, PartialEq, Clone, Copy)]
198198
pub enum MappingKind {
199+
Unmapped,
199200
Basic(BasicMapping),
200201
Cow(CowMapping),
201202
/* TODO: What useful things other than basic mappings actually

src/hyperlight_host/src/mem/mgr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ fn mapping_kind_to_flags(kind: &MappingKind) -> (MemoryRegionFlags, MemoryRegion
6565
}
6666
(flags, MemoryRegionType::Scratch)
6767
}
68+
MappingKind::Unmapped => (MemoryRegionFlags::empty(), MemoryRegionType::Snapshot),
6869
}
6970
}
7071

src/hyperlight_host/src/sandbox/snapshot.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ impl Snapshot {
468468
writable: false,
469469
executable: bm.executable,
470470
}),
471+
MappingKind::Unmapped => continue,
471472
};
472473
let new_gpa = phys_seen.entry(mapping.phys_base).or_insert_with(|| {
473474
let new_offset = snapshot_memory.len();

0 commit comments

Comments
 (0)