-
Notifications
You must be signed in to change notification settings - Fork 163
Description
Summary
HyperlightVm::map_region does not check whether a new guest address range overlaps with an already-mapped region. The VirtualMachine::map_memory safety contract explicitly requires non-overlapping regions, but map_region does not enforce this precondition. On WHP, overlapping mappings return a cryptic HRESULT (confirmed — WHvMapGpaRange2 rejects the call and the error is wrapped as a generic WindowsError). On KVM and MSHV, the behaviour is kernel/hypervisor-version-dependent and may range from an explicit error to silent shadowing of the previous mapping, risking data corruption.
Current Behaviour
HyperlightVm::map_region (in src/hyperlight_host/src/hypervisor/hyperlight_vm.rs) validates page alignment of guest and host addresses, assigns a unique slot, and calls the platform-specific map_memory. It does not check the new guest_region against existing entries in self.mmap_regions.
The existing mapped regions are readily available via self.mmap_regions (a Vec<(u32, MemoryRegion)>), so adding the check is straightforward.