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.
Summary
HyperlightVm::map_regiondoes not check whether a new guest address range overlaps with an already-mapped region. TheVirtualMachine::map_memorysafety contract explicitly requires non-overlapping regions, butmap_regiondoes not enforce this precondition. On WHP, overlapping mappings return a cryptic HRESULT (confirmed —WHvMapGpaRange2rejects the call and the error is wrapped as a genericWindowsError). 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(insrc/hyperlight_host/src/hypervisor/hyperlight_vm.rs) validates page alignment of guest and host addresses, assigns a unique slot, and calls the platform-specificmap_memory. It does not check the newguest_regionagainst existing entries inself.mmap_regions.The existing mapped regions are readily available via
self.mmap_regions(aVec<(u32, MemoryRegion)>), so adding the check is straightforward.