From 4b9b0c5512741992847db7fd837703834046d1fe Mon Sep 17 00:00:00 2001 From: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com> Date: Tue, 5 Aug 2025 16:21:44 -0700 Subject: [PATCH] Remove Ptr, RawPtr, GuestPtr, Offset, AddressSpace, GuestAddressSpace Certain drivers used RawPtr and others used u64. To unify these in preperation for a refactor, they are replaced them with u64 instead. The removed types were mostly unused and provided minimal benefit over a simple u64. In the future we should think about introducing some type to abstract over phys/virtual addresses etc instead. Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com> --- src/hyperlight_host/src/error.rs | 5 - .../src/hypervisor/hyperv_linux.rs | 33 +- .../src/hypervisor/hyperv_windows.rs | 17 +- src/hyperlight_host/src/hypervisor/kvm.rs | 20 +- src/hyperlight_host/src/hypervisor/mod.rs | 8 +- src/hyperlight_host/src/mem/exe.rs | 5 +- src/hyperlight_host/src/mem/mgr.rs | 49 +-- src/hyperlight_host/src/mem/mod.rs | 7 - src/hyperlight_host/src/mem/ptr.rs | 244 -------------- src/hyperlight_host/src/mem/ptr_addr_space.rs | 56 ---- src/hyperlight_host/src/mem/ptr_offset.rs | 310 ------------------ .../src/sandbox/initialized_multi_use.rs | 7 +- .../src/sandbox/uninitialized_evolve.rs | 67 +--- 13 files changed, 73 insertions(+), 755 deletions(-) delete mode 100644 src/hyperlight_host/src/mem/ptr.rs delete mode 100644 src/hyperlight_host/src/mem/ptr_addr_space.rs delete mode 100644 src/hyperlight_host/src/mem/ptr_offset.rs diff --git a/src/hyperlight_host/src/error.rs b/src/hyperlight_host/src/error.rs index c07f9857f..6bf8ed025 100644 --- a/src/hyperlight_host/src/error.rs +++ b/src/hyperlight_host/src/error.rs @@ -39,7 +39,6 @@ use thiserror::Error; #[cfg(target_os = "windows")] use crate::hypervisor::wrappers::HandleWrapper; use crate::mem::memory_region::MemoryRegionFlags; -use crate::mem::ptr::RawPtr; /// The error type for Hyperlight operations #[derive(Error, Debug)] @@ -196,10 +195,6 @@ pub enum HyperlightError { #[error("Failure processing PE File {0:?}")] PEFileProcessingFailure(#[from] goblin::error::Error), - /// Raw pointer is less than base address - #[error("Raw pointer ({0:?}) was less than the base address ({1})")] - RawPointerLessThanBaseAddress(RawPtr, u64), - /// RefCell borrow failed #[error("RefCell borrow failed")] RefCellBorrowFailed(#[from] BorrowError), diff --git a/src/hyperlight_host/src/hypervisor/hyperv_linux.rs b/src/hyperlight_host/src/hypervisor/hyperv_linux.rs index cc7528610..79d79dd74 100644 --- a/src/hyperlight_host/src/hypervisor/hyperv_linux.rs +++ b/src/hyperlight_host/src/hypervisor/hyperv_linux.rs @@ -77,7 +77,6 @@ use super::{HyperlightExit, Hypervisor, InterruptHandle, LinuxInterruptHandle, V use crate::HyperlightError; use crate::hypervisor::get_memory_access_violation; use crate::mem::memory_region::{MemoryRegion, MemoryRegionFlags}; -use crate::mem::ptr::{GuestPtr, RawPtr}; use crate::mem::shared_mem::HostSharedMemory; use crate::sandbox::SandboxConfiguration; #[cfg(feature = "trace_guest")] @@ -313,7 +312,7 @@ pub(crate) struct HypervLinuxDriver { page_size: usize, vm_fd: VmFd, vcpu_fd: VcpuFd, - orig_rsp: GuestPtr, + orig_rsp: u64, entrypoint: u64, interrupt_handle: Arc, mem_mgr: Option>, @@ -347,9 +346,9 @@ impl HypervLinuxDriver { #[instrument(skip_all, parent = Span::current(), level = "Trace")] pub(crate) fn new( mem_regions: Vec, - entrypoint_ptr: GuestPtr, - rsp_ptr: GuestPtr, - pml4_ptr: GuestPtr, + entrypoint_ptr: u64, + rsp_ptr: u64, + pml4_ptr: u64, config: &SandboxConfiguration, #[cfg(gdb)] gdb_conn: Option>, #[cfg(crashdump)] rt_cfg: SandboxRuntimeConfig, @@ -380,7 +379,7 @@ impl HypervLinuxDriver { #[cfg(gdb)] let (debug, gdb_conn) = if let Some(gdb_conn) = gdb_conn { let mut debug = MshvDebug::new(); - debug.add_hw_breakpoint(&vcpu_fd, entrypoint_ptr.absolute()?)?; + debug.add_hw_breakpoint(&vcpu_fd, entrypoint_ptr)?; // The bellow intercepts make the vCPU exit with the Exception Intercept exit code // Check Table 6-1. Exceptions and Interrupts at Page 6-13 Vol. 1 @@ -419,7 +418,7 @@ impl HypervLinuxDriver { vm_fd.map_user_memory(mshv_region) })?; - Self::setup_initial_sregs(&mut vcpu_fd, pml4_ptr.absolute()?)?; + Self::setup_initial_sregs(&mut vcpu_fd, pml4_ptr)?; let interrupt_handle = Arc::new(LinuxInterruptHandle { running: AtomicU64::new(0), @@ -453,7 +452,7 @@ impl HypervLinuxDriver { vcpu_fd, sandbox_regions: mem_regions, mmap_regions: Vec::new(), - entrypoint: entrypoint_ptr.absolute()?, + entrypoint: entrypoint_ptr, orig_rsp: rsp_ptr, interrupt_handle: interrupt_handle.clone(), mem_mgr: None, @@ -585,7 +584,7 @@ impl Hypervisor for HypervLinuxDriver { #[instrument(err(Debug), skip_all, parent = Span::current(), level = "Trace")] fn initialise( &mut self, - peb_addr: RawPtr, + peb_addr: u64, seed: u64, page_size: u32, mem_mgr: MemMgrWrapper, @@ -604,11 +603,11 @@ impl Hypervisor for HypervLinuxDriver { let regs = StandardRegisters { rip: self.entrypoint, - rsp: self.orig_rsp.absolute()?, + rsp: self.orig_rsp, rflags: 2, //bit 1 of rlags is required to be set // function args - rdi: peb_addr.into(), + rdi: peb_addr, rsi: seed, rdx: page_size.into(), rcx: max_guest_log_level, @@ -662,13 +661,13 @@ impl Hypervisor for HypervLinuxDriver { #[instrument(err(Debug), skip_all, parent = Span::current(), level = "Trace")] fn dispatch_call_from_host( &mut self, - dispatch_func_addr: RawPtr, + dispatch_func_addr: u64, #[cfg(gdb)] dbg_mem_access_fn: DbgMemAccessHandlerWrapper, ) -> Result<()> { // Reset general purpose registers, then set RIP and RSP let regs = StandardRegisters { - rip: dispatch_func_addr.into(), - rsp: self.orig_rsp.absolute()?, + rip: dispatch_func_addr, + rsp: self.orig_rsp, rflags: 2, //bit 1 of rlags is required to be set ..Default::default() }; @@ -1245,9 +1244,9 @@ mod tests { } const MEM_SIZE: usize = 0x3000; let gm = shared_mem_with_code(CODE.as_slice(), MEM_SIZE, 0).unwrap(); - let rsp_ptr = GuestPtr::try_from(0).unwrap(); - let pml4_ptr = GuestPtr::try_from(0).unwrap(); - let entrypoint_ptr = GuestPtr::try_from(0).unwrap(); + let rsp_ptr = 0; + let pml4_ptr = 0; + let entrypoint_ptr = 0; let mut regions = MemoryRegionVecBuilder::new(0, gm.base_addr()); regions.push_page_aligned( MEM_SIZE, diff --git a/src/hyperlight_host/src/hypervisor/hyperv_windows.rs b/src/hyperlight_host/src/hypervisor/hyperv_windows.rs index 0fc701a13..02bf2dffe 100644 --- a/src/hyperlight_host/src/hypervisor/hyperv_windows.rs +++ b/src/hyperlight_host/src/hypervisor/hyperv_windows.rs @@ -60,7 +60,6 @@ use crate::hypervisor::fpu::FP_CONTROL_WORD_DEFAULT; use crate::hypervisor::get_memory_access_violation; use crate::hypervisor::wrappers::WHvGeneralRegisters; use crate::mem::memory_region::{MemoryRegion, MemoryRegionFlags}; -use crate::mem::ptr::{GuestPtr, RawPtr}; use crate::mem::shared_mem::HostSharedMemory; #[cfg(feature = "trace_guest")] use crate::sandbox::TraceInfo; @@ -281,7 +280,7 @@ pub(crate) struct HypervWindowsDriver { processor: VMProcessor, _surrogate_process: SurrogateProcess, // we need to keep a reference to the SurrogateProcess for the duration of the driver since otherwise it will dropped and the memory mapping will be unmapped and the surrogate process will be returned to the pool entrypoint: u64, - orig_rsp: GuestPtr, + orig_rsp: u64, interrupt_handle: Arc, mem_mgr: Option>, host_funcs: Option>>, @@ -361,7 +360,7 @@ impl HypervWindowsDriver { processor: proc, _surrogate_process: surrogate_process, entrypoint, - orig_rsp: GuestPtr::try_from(RawPtr::from(rsp))?, + orig_rsp: rsp, sandbox_regions: mem_regions, mmap_regions: Vec::new(), interrupt_handle: interrupt_handle.clone(), @@ -600,7 +599,7 @@ impl Hypervisor for HypervWindowsDriver { #[instrument(err(Debug), skip_all, parent = Span::current(), level = "Trace")] fn initialise( &mut self, - peb_address: RawPtr, + peb_address: u64, seed: u64, page_size: u32, mem_mgr: MemMgrWrapper, @@ -618,10 +617,10 @@ impl Hypervisor for HypervWindowsDriver { let regs = WHvGeneralRegisters { rip: self.entrypoint, - rsp: self.orig_rsp.absolute()?, + rsp: self.orig_rsp, // function args - rdi: peb_address.into(), + rdi: peb_address, rsi: seed, rdx: page_size.into(), rcx: max_guest_log_level, @@ -655,13 +654,13 @@ impl Hypervisor for HypervWindowsDriver { #[instrument(err(Debug), skip_all, parent = Span::current(), level = "Trace")] fn dispatch_call_from_host( &mut self, - dispatch_func_addr: RawPtr, + dispatch_func_addr: u64, #[cfg(gdb)] dbg_mem_access_hdl: DbgMemAccessHandlerWrapper, ) -> Result<()> { // Reset general purpose registers, then set RIP and RSP let regs = WHvGeneralRegisters { - rip: dispatch_func_addr.into(), - rsp: self.orig_rsp.absolute()?, + rip: dispatch_func_addr, + rsp: self.orig_rsp, rflags: 1 << 1, // eflags bit index 1 is reserved and always needs to be 1 ..Default::default() }; diff --git a/src/hyperlight_host/src/hypervisor/kvm.rs b/src/hyperlight_host/src/hypervisor/kvm.rs index 26eae3e25..1c908823c 100644 --- a/src/hyperlight_host/src/hypervisor/kvm.rs +++ b/src/hyperlight_host/src/hypervisor/kvm.rs @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -use std::convert::TryFrom; use std::fmt::Debug; use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; use std::sync::{Arc, Mutex}; @@ -44,7 +43,6 @@ use super::{HyperlightExit, Hypervisor, InterruptHandle, LinuxInterruptHandle, V use crate::HyperlightError; use crate::hypervisor::get_memory_access_violation; use crate::mem::memory_region::{MemoryRegion, MemoryRegionFlags}; -use crate::mem::ptr::{GuestPtr, RawPtr}; use crate::mem::shared_mem::HostSharedMemory; use crate::sandbox::SandboxConfiguration; #[cfg(feature = "trace_guest")] @@ -294,7 +292,7 @@ pub(crate) struct KVMDriver { page_size: usize, vcpu_fd: VcpuFd, entrypoint: u64, - orig_rsp: GuestPtr, + orig_rsp: u64, interrupt_handle: Arc, mem_mgr: Option>, host_funcs: Option>>, @@ -356,8 +354,6 @@ impl KVMDriver { (None, None) }; - let rsp_gp = GuestPtr::try_from(RawPtr::from(rsp))?; - let interrupt_handle = Arc::new(LinuxInterruptHandle { running: AtomicU64::new(0), cancel_requested: AtomicBool::new(false), @@ -389,7 +385,7 @@ impl KVMDriver { page_size: 0, vcpu_fd, entrypoint, - orig_rsp: rsp_gp, + orig_rsp: rsp, next_slot: mem_regions.len() as u32, sandbox_regions: mem_regions, mmap_regions: Vec::new(), @@ -473,7 +469,7 @@ impl Hypervisor for KVMDriver { #[instrument(err(Debug), skip_all, parent = Span::current(), level = "Trace")] fn initialise( &mut self, - peb_addr: RawPtr, + peb_addr: u64, seed: u64, page_size: u32, mem_mgr: MemMgrWrapper, @@ -492,10 +488,10 @@ impl Hypervisor for KVMDriver { let regs = kvm_regs { rip: self.entrypoint, - rsp: self.orig_rsp.absolute()?, + rsp: self.orig_rsp, // function args - rdi: peb_addr.into(), + rdi: peb_addr, rsi: seed, rdx: page_size.into(), rcx: max_guest_log_level, @@ -573,13 +569,13 @@ impl Hypervisor for KVMDriver { #[instrument(err(Debug), skip_all, parent = Span::current(), level = "Trace")] fn dispatch_call_from_host( &mut self, - dispatch_func_addr: RawPtr, + dispatch_func_addr: u64, #[cfg(gdb)] dbg_mem_access_fn: DbgMemAccessHandlerWrapper, ) -> Result<()> { // Reset general purpose registers, then set RIP and RSP let regs = kvm_regs { - rip: dispatch_func_addr.into(), - rsp: self.orig_rsp.absolute()?, + rip: dispatch_func_addr, + rsp: self.orig_rsp, ..Default::default() }; self.vcpu_fd.set_regs(®s)?; diff --git a/src/hyperlight_host/src/hypervisor/mod.rs b/src/hyperlight_host/src/hypervisor/mod.rs index 53b721c7c..6e88d5ff4 100644 --- a/src/hyperlight_host/src/hypervisor/mod.rs +++ b/src/hyperlight_host/src/hypervisor/mod.rs @@ -73,7 +73,6 @@ use gdb::VcpuStopReason; #[cfg(gdb)] use self::handlers::{DbgMemAccessHandlerCaller, DbgMemAccessHandlerWrapper}; -use crate::mem::ptr::RawPtr; use crate::mem::shared_mem::HostSharedMemory; use crate::sandbox::host_funcs::FunctionRegistry; use crate::sandbox::mem_access::handle_mem_access; @@ -142,7 +141,7 @@ pub(crate) trait Hypervisor: Debug + Send { #[allow(clippy::too_many_arguments)] fn initialise( &mut self, - peb_addr: RawPtr, + peb_addr: u64, seed: u64, page_size: u32, mem_mgr: MemMgrWrapper, @@ -174,7 +173,7 @@ pub(crate) trait Hypervisor: Debug + Send { /// Returns `Ok` if the call succeeded, and an `Err` if it failed fn dispatch_call_from_host( &mut self, - dispatch_func_addr: RawPtr, + dispatch_func_addr: u64, #[cfg(gdb)] dbg_mem_access_fn: DbgMemAccessHandlerWrapper, ) -> Result<()>; @@ -542,7 +541,6 @@ pub(crate) mod tests { return Ok(()); } - use crate::mem::ptr::RawPtr; use crate::sandbox::host_funcs::FunctionRegistry; #[cfg(gdb)] use crate::sandbox::mem_access::dbg_mem_access_handler_wrapper; @@ -564,7 +562,7 @@ pub(crate) mod tests { )?; // Set up required parameters for initialise - let peb_addr = RawPtr::from(0x1000u64); // Dummy PEB address + let peb_addr = 0x1000u64; // Dummy PEB address let seed = 12345u64; // Random seed let page_size = 4096u32; // Standard page size let host_funcs = Arc::new(Mutex::new(FunctionRegistry::default())); diff --git a/src/hyperlight_host/src/mem/exe.rs b/src/hyperlight_host/src/mem/exe.rs index 064d58cde..e71cdd544 100644 --- a/src/hyperlight_host/src/mem/exe.rs +++ b/src/hyperlight_host/src/mem/exe.rs @@ -21,7 +21,6 @@ use std::sync::Arc; use std::vec::Vec; use super::elf::ElfInfo; -use super::ptr_offset::Offset; use crate::Result; // This is used extremely infrequently, so being unusually large for PE @@ -94,9 +93,9 @@ impl ExeInfo { ExeInfo::Elf(_) => DEFAULT_ELF_HEAP_RESERVE, } } - pub fn entrypoint(&self) -> Offset { + pub fn entrypoint(&self) -> u64 { match self { - ExeInfo::Elf(elf) => Offset::from(elf.entrypoint_va()), + ExeInfo::Elf(elf) => elf.entrypoint_va(), } } pub fn loaded_size(&self) -> usize { diff --git a/src/hyperlight_host/src/mem/mgr.rs b/src/hyperlight_host/src/mem/mgr.rs index e33c4b08d..620d0da3e 100644 --- a/src/hyperlight_host/src/mem/mgr.rs +++ b/src/hyperlight_host/src/mem/mgr.rs @@ -30,8 +30,6 @@ use super::layout::SandboxMemoryLayout; use super::memory_region::MemoryRegion; #[cfg(feature = "init-paging")] use super::memory_region::{DEFAULT_GUEST_BLOB_MEM_FLAGS, MemoryRegionType}; -use super::ptr::{GuestPtr, RawPtr}; -use super::ptr_offset::Offset; use super::shared_mem::{ExclusiveSharedMemory, GuestSharedMemory, HostSharedMemory, SharedMemory}; use super::shared_mem_snapshot::SharedMemorySnapshot; use crate::sandbox::SandboxConfiguration; @@ -69,9 +67,9 @@ pub(crate) struct SandboxMemoryManager { /// The memory layout of the underlying shared memory pub(crate) layout: SandboxMemoryLayout, /// Pointer to where to load memory from - pub(crate) load_addr: RawPtr, + pub(crate) load_addr: u64, /// Offset for the execution entrypoint from `load_addr` - pub(crate) entrypoint_offset: Offset, + pub(crate) entrypoint_offset: u64, /// How many memory regions were mapped after sandbox creation pub(crate) mapped_rgns: u64, } @@ -85,8 +83,8 @@ where fn new( layout: SandboxMemoryLayout, shared_mem: S, - load_addr: RawPtr, - entrypoint_offset: Offset, + load_addr: u64, + entrypoint_offset: u64, ) -> Self { Self { layout, @@ -110,12 +108,12 @@ where #[cfg(feature = "init-paging")] pub(crate) fn set_up_shared_memory( &mut self, - mem_size: u64, - regions: &mut [MemoryRegion], - ) -> Result { - let rsp: u64 = self.layout.get_top_of_user_stack_offset() as u64 - + SandboxMemoryLayout::BASE_ADDRESS as u64 - + self.layout.stack_size as u64 + mem_size: usize, + regions: &[MemoryRegion], + ) -> Result { + let rsp = self.layout.get_top_of_user_stack_offset() + + SandboxMemoryLayout::BASE_ADDRESS + + self.layout.stack_size // TODO: subtracting 0x28 was a requirement for MSVC. It should no longer be // necessary now, but, for some reason, without this, the `multiple_parameters` // test from `sandbox_host_tests` fails. We should investigate this further. @@ -148,9 +146,6 @@ where // We need one PT for every 2MB of memory that is mapped // We can use the memory size to calculate the number of PTs we need // We round up mem_size/2MB - - let mem_size = usize::try_from(mem_size)?; - let num_pages: usize = mem_size.div_ceil(AMOUNT_OF_MEMORY_PER_PT); // Create num_pages PT with 512 PTEs @@ -329,15 +324,14 @@ impl SandboxMemoryManager { )?; let mut shared_mem = ExclusiveSharedMemory::new(layout.get_memory_size()?)?; - let load_addr: RawPtr = RawPtr::try_from(layout.get_guest_code_address())?; - + let load_addr = layout.get_guest_code_address(); let entrypoint_offset = exe_info.entrypoint(); let offset = layout.get_code_pointer_offset(); { // write the code pointer to shared memory - let load_addr_u64: u64 = load_addr.clone().into(); + let load_addr_u64 = load_addr as u64; shared_mem.write_u64(offset, load_addr_u64)?; } @@ -345,12 +339,12 @@ impl SandboxMemoryManager { // `unwind_guest` feature is enabled. #[allow(clippy::let_unit_value)] let load_info = exe_info.load( - load_addr.clone().try_into()?, + load_addr, &mut shared_mem.as_mut_slice()[layout.get_guest_code_offset()..], )?; Ok(( - Self::new(layout, shared_mem, load_addr, entrypoint_offset), + Self::new(layout, shared_mem, load_addr as u64, entrypoint_offset), load_info, )) } @@ -411,14 +405,14 @@ impl SandboxMemoryManager { SandboxMemoryManager { shared_mem: hshm, layout: self.layout, - load_addr: self.load_addr.clone(), + load_addr: self.load_addr, entrypoint_offset: self.entrypoint_offset, mapped_rgns: 0, }, SandboxMemoryManager { shared_mem: gshm, layout: self.layout, - load_addr: self.load_addr.clone(), + load_addr: self.load_addr, entrypoint_offset: self.entrypoint_offset, mapped_rgns: 0, }, @@ -450,15 +444,8 @@ impl SandboxMemoryManager { /// Get the address of the dispatch function in memory #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] pub(crate) fn get_pointer_to_dispatch_function(&self) -> Result { - let guest_dispatch_function_ptr = self - .shared_mem - .read::(self.layout.get_dispatch_function_pointer_offset())?; - - // This pointer is written by the guest library but is accessible to - // the guest engine so we should bounds check it before we return it. - - let guest_ptr = GuestPtr::try_from(RawPtr::from(guest_dispatch_function_ptr))?; - guest_ptr.absolute() + self.shared_mem + .read::(self.layout.get_dispatch_function_pointer_offset()) } /// Reads a host function call from memory diff --git a/src/hyperlight_host/src/mem/mod.rs b/src/hyperlight_host/src/mem/mod.rs index 1bcc03eae..394ec7537 100644 --- a/src/hyperlight_host/src/mem/mod.rs +++ b/src/hyperlight_host/src/mem/mod.rs @@ -25,13 +25,6 @@ pub mod memory_region; /// Functionality that wraps a `SandboxMemoryLayout` and a /// `SandboxMemoryConfig` to mutate a sandbox's memory as necessary. pub mod mgr; -/// Structures to represent pointers into guest and host memory -pub mod ptr; -/// Structures to represent memory address spaces into which pointers -/// point. -pub(super) mod ptr_addr_space; -/// Structures to represent an offset into a memory space -pub mod ptr_offset; /// A wrapper around unsafe functionality to create and initialize /// a memory region for a guest running in a sandbox. pub mod shared_mem; diff --git a/src/hyperlight_host/src/mem/ptr.rs b/src/hyperlight_host/src/mem/ptr.rs deleted file mode 100644 index 66e379df4..000000000 --- a/src/hyperlight_host/src/mem/ptr.rs +++ /dev/null @@ -1,244 +0,0 @@ -/* -Copyright 2025 The Hyperlight Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -use std::ops::Add; - -use tracing::{Span, instrument}; - -use super::ptr_addr_space::{AddressSpace, GuestAddressSpace}; -use super::ptr_offset::Offset; -use crate::Result; -use crate::error::HyperlightError::{self, CheckedAddOverflow, RawPointerLessThanBaseAddress}; - -/// A representation of a raw pointer inside a given address space. -/// -/// Use this type to distinguish between an offset and a raw pointer -#[derive(Debug, Clone, Eq, PartialEq)] -pub struct RawPtr(u64); - -impl From for RawPtr { - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn from(val: u64) -> Self { - Self(val) - } -} - -impl Add for RawPtr { - type Output = RawPtr; - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn add(self, rhs: Offset) -> RawPtr { - let val = self.0 + u64::from(rhs); - RawPtr(val) - } -} - -impl TryFrom for RawPtr { - type Error = HyperlightError; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] - fn try_from(val: usize) -> Result { - let val_u64 = u64::try_from(val)?; - Ok(Self::from(val_u64)) - } -} - -impl TryFrom for usize { - type Error = HyperlightError; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] - fn try_from(val: RawPtr) -> Result { - Ok(usize::try_from(val.0)?) - } -} - -impl From for u64 { - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn from(val: RawPtr) -> u64 { - val.0 - } -} - -impl From<&RawPtr> for u64 { - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn from(val: &RawPtr) -> u64 { - val.0 - } -} - -/// Convenience type for representing a pointer into the guest address space -pub(crate) type GuestPtr = Ptr; - -impl TryFrom for GuestPtr { - type Error = HyperlightError; - /// Create a new `GuestPtr` from the given `guest_raw_ptr`, which must - /// be a pointer in the guest's address space. - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] - fn try_from(raw: RawPtr) -> Result { - GuestPtr::from_raw_ptr(GuestAddressSpace::new()?, raw) - } -} - -impl TryFrom for GuestPtr { - type Error = HyperlightError; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] - fn try_from(val: Offset) -> Result { - let addr_space = GuestAddressSpace::new()?; - Ok(Ptr::from_offset(addr_space, val)) - } -} - -impl TryFrom for GuestPtr { - type Error = HyperlightError; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] - fn try_from(val: i64) -> Result { - let offset = Offset::try_from(val)?; - GuestPtr::try_from(offset) - } -} - -impl TryFrom for i64 { - type Error = HyperlightError; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] - fn try_from(val: GuestPtr) -> Result { - let offset = val.offset(); - i64::try_from(offset) - } -} - -/// A pointer into a specific `AddressSpace` `T`. -#[derive(Debug, Copy, Clone)] -pub(crate) struct Ptr { - addr_space: T, - offset: Offset, -} - -impl std::cmp::PartialEq for Ptr { - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn eq(&self, other: &Self) -> bool { - other.addr_space == self.addr_space && other.offset == self.offset - } -} - -impl std::cmp::Eq for Ptr {} -#[instrument(skip_all, parent = Span::current(), level= "Trace")] -fn cmp_helper(left: &Ptr, right: &Ptr) -> std::cmp::Ordering { - // We know both left and right have the same address space, thus - // they have the same base, so we can get away with just comparing - // the offsets and assume we're in the same address space, practically - // speaking. - left.offset.cmp(&right.offset) -} - -#[allow(clippy::non_canonical_partial_ord_impl)] -impl std::cmp::PartialOrd for Ptr { - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn partial_cmp(&self, other: &Self) -> Option { - Some(cmp_helper(self, other)) - } -} - -impl std::cmp::Ord for Ptr { - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn cmp(&self, other: &Self) -> std::cmp::Ordering { - cmp_helper(self, other) - } -} - -impl Ptr { - /// Create a new pointer in the given `AddressSpace` `addr_space` - /// from the given pointer `raw_ptr`. Returns `Ok` if subtracting - /// the base address from `raw_ptr` succeeds (i.e. does not overflow) - /// and a `Ptr` can be successfully created - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] - fn from_raw_ptr(addr_space: T, raw_ptr: RawPtr) -> Result> { - let offset = raw_ptr - .0 - .checked_sub(addr_space.base()) - .ok_or_else(|| RawPointerLessThanBaseAddress(raw_ptr, addr_space.base()))?; - Ok(Self { - addr_space, - offset: Offset::from(offset), - }) - } - - /// Create a new `Ptr` into the given `addr_space` from the given - /// `offset`. - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn from_offset(addr_space: T, offset: Offset) -> Ptr { - Self { addr_space, offset } - } - - /// Get the base address for this pointer - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn base(&self) -> u64 { - self.addr_space.base() - } - - /// Get the offset into the pointer's address space - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - pub(super) fn offset(&self) -> Offset { - self.offset - } - - /// Get the absolute value for the pointer represented by `self`. - /// - /// This function should rarely be used. Prefer to use offsets - /// instead. - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] - pub(crate) fn absolute(&self) -> Result { - let offset_u64: u64 = self.offset.into(); - self.base() - .checked_add(offset_u64) - .ok_or_else(|| CheckedAddOverflow(self.base(), offset_u64)) - } -} - -impl Add for Ptr { - type Output = Ptr; - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn add(self, rhs: Offset) -> Self::Output { - Self { - addr_space: self.addr_space, - offset: self.offset + rhs, - } - } -} - -impl TryFrom> for usize { - type Error = HyperlightError; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] - fn try_from(val: Ptr) -> Result { - let abs = val.absolute()?; - Ok(usize::try_from(abs)?) - } -} - -#[cfg(test)] -mod tests { - use super::{GuestPtr, RawPtr}; - use crate::mem::layout::SandboxMemoryLayout; - const OFFSET: u64 = 1; - - #[test] - fn ptr_basic_ops() { - { - let raw_guest_ptr = RawPtr(OFFSET + SandboxMemoryLayout::BASE_ADDRESS as u64); - let guest_ptr = GuestPtr::try_from(raw_guest_ptr).unwrap(); - assert_eq!( - OFFSET + SandboxMemoryLayout::BASE_ADDRESS as u64, - guest_ptr.absolute().unwrap() - ); - } - } -} diff --git a/src/hyperlight_host/src/mem/ptr_addr_space.rs b/src/hyperlight_host/src/mem/ptr_addr_space.rs deleted file mode 100644 index 24c0479e7..000000000 --- a/src/hyperlight_host/src/mem/ptr_addr_space.rs +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright 2025 The Hyperlight Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -use tracing::{Span, instrument}; - -use super::layout::SandboxMemoryLayout; -use crate::Result; - -/// A representation of a specific address space -pub trait AddressSpace: std::cmp::Eq { - /// The base address for this address space - fn base(&self) -> u64; -} - -/// The address space for the guest executable -#[derive(Debug, Clone, Copy, Eq, PartialEq)] -pub(crate) struct GuestAddressSpace(u64); -impl GuestAddressSpace { - /// Create a new instance of a `GuestAddressSpace` - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] - pub(super) fn new() -> Result { - let base_addr = u64::try_from(SandboxMemoryLayout::BASE_ADDRESS)?; - Ok(Self(base_addr)) - } -} -impl AddressSpace for GuestAddressSpace { - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn base(&self) -> u64 { - self.0 - } -} - -#[cfg(test)] -mod tests { - use super::{AddressSpace, GuestAddressSpace}; - use crate::mem::layout::SandboxMemoryLayout; - - #[test] - fn guest_addr_space_base() { - let space = GuestAddressSpace::new().unwrap(); - assert_eq!(SandboxMemoryLayout::BASE_ADDRESS as u64, space.base()); - } -} diff --git a/src/hyperlight_host/src/mem/ptr_offset.rs b/src/hyperlight_host/src/mem/ptr_offset.rs deleted file mode 100644 index a8105ed70..000000000 --- a/src/hyperlight_host/src/mem/ptr_offset.rs +++ /dev/null @@ -1,310 +0,0 @@ -/* -Copyright 2025 The Hyperlight Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -use std::cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd}; -use std::convert::From; -use std::ops::{Add, Sub}; - -use tracing::{Span, instrument}; - -use crate::Result; -use crate::error::HyperlightError; - -/// An offset into a given address space. -/// -/// Use this type to distinguish between an offset and a raw pointer -#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd)] -pub(crate) struct Offset(u64); - -impl Offset { - /// Get the offset representing `0` - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - #[allow(dead_code)] - pub(super) fn zero() -> Self { - Self::default() - } - - /// round up to the nearest multiple of `alignment` - #[allow(dead_code)] - pub(super) fn round_up_to(self, alignment: u64) -> Self { - let remainder = self.0 % alignment; - let multiples = self.0 / alignment; - match remainder { - 0 => self, - _ => Offset::from((multiples + 1) * alignment), - } - } -} - -impl Default for Offset { - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn default() -> Self { - Offset::from(0_u64) - } -} - -impl From for Offset { - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn from(val: u64) -> Self { - Self(val) - } -} - -impl From<&Offset> for u64 { - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn from(val: &Offset) -> u64 { - val.0 - } -} - -impl From for u64 { - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn from(val: Offset) -> u64 { - val.0 - } -} - -impl TryFrom for i64 { - type Error = HyperlightError; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] - fn try_from(val: Offset) -> Result { - Ok(i64::try_from(val.0)?) - } -} - -impl TryFrom for Offset { - type Error = HyperlightError; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] - fn try_from(val: i64) -> Result { - let val_u64 = u64::try_from(val)?; - Ok(Offset::from(val_u64)) - } -} - -impl TryFrom for Offset { - type Error = HyperlightError; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] - fn try_from(val: usize) -> Result { - Ok(u64::try_from(val).map(Offset::from)?) - } -} - -/// Convert an `Offset` to a `usize`, returning an `Err` if the -/// conversion couldn't be made. -impl TryFrom<&Offset> for usize { - type Error = HyperlightError; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] - fn try_from(val: &Offset) -> Result { - Ok(usize::try_from(val.0)?) - } -} - -impl TryFrom for usize { - type Error = HyperlightError; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] - fn try_from(val: Offset) -> Result { - usize::try_from(&val) - } -} - -impl Add for Offset { - type Output = Offset; - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn add(self, rhs: Offset) -> Offset { - Offset::from(self.0 + rhs.0) - } -} - -impl Add for Offset { - type Output = Offset; - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn add(self, rhs: usize) -> Offset { - Offset(self.0 + rhs as u64) - } -} - -impl Add for usize { - type Output = Offset; - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn add(self, rhs: Offset) -> Offset { - rhs.add(self) - } -} - -impl Add for Offset { - type Output = Offset; - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn add(self, rhs: u64) -> Offset { - Offset(self.0 + rhs) - } -} - -impl Add for u64 { - type Output = Offset; - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn add(self, rhs: Offset) -> Offset { - rhs.add(self) - } -} - -impl Sub for Offset { - type Output = Offset; - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn sub(self, rhs: Offset) -> Offset { - Offset::from(self.0 - rhs.0) - } -} - -impl Sub for Offset { - type Output = Offset; - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn sub(self, rhs: usize) -> Offset { - Offset(self.0 - rhs as u64) - } -} - -impl Sub for usize { - type Output = Offset; - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn sub(self, rhs: Offset) -> Offset { - rhs.sub(self) - } -} - -impl Sub for Offset { - type Output = Offset; - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn sub(self, rhs: u64) -> Offset { - Offset(self.0 - rhs) - } -} - -impl Sub for u64 { - type Output = Offset; - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn sub(self, rhs: Offset) -> Offset { - rhs.sub(self) - } -} - -impl PartialEq for Offset { - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn eq(&self, other: &usize) -> bool { - match usize::try_from(self) { - Ok(offset_usize) => offset_usize == *other, - _ => false, - } - } -} - -impl PartialOrd for Offset { - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn partial_cmp(&self, rhs: &usize) -> Option { - match usize::try_from(self) { - Ok(offset_usize) if offset_usize > *rhs => Some(Ordering::Greater), - Ok(offset_usize) if offset_usize == *rhs => Some(Ordering::Equal), - Ok(_) => Some(Ordering::Less), - Err(_) => None, - } - } -} - -impl PartialEq for Offset { - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn eq(&self, rhs: &u64) -> bool { - u64::from(self) == *rhs - } -} - -impl PartialOrd for Offset { - #[instrument(skip_all, parent = Span::current(), level= "Trace")] - fn partial_cmp(&self, rhs: &u64) -> Option { - let lhs: u64 = self.into(); - match lhs > *rhs { - true => Some(Ordering::Greater), - false if lhs == *rhs => Some(Ordering::Equal), - false => Some(Ordering::Less), - } - } -} - -#[cfg(test)] -mod tests { - use proptest::prelude::*; - - use super::Offset; - - proptest! { - #[test] - fn i64_roundtrip(i64_val in (i64::MIN..i64::MAX)) { - let offset_res = Offset::try_from(i64_val); - - if i64_val < 0 { - assert!(offset_res.is_err()); - } else { - assert!(offset_res.is_ok()); - let offset = offset_res.unwrap(); - let ret_i64_val = { - let res = i64::try_from(offset); - assert!(res.is_ok()); - res.unwrap() - }; - assert_eq!(i64_val, ret_i64_val); - } - } - #[test] - fn usize_roundtrip(val in (usize::MIN..usize::MAX)) { - let offset = Offset::try_from(val).unwrap(); - assert_eq!(val, usize::try_from(offset).unwrap()); - } - - #[test] - fn add_numeric_types(usize_val in (usize::MIN..usize::MAX), u64_val in (u64::MIN..u64::MAX)) { - let start = Offset::default(); - { - // add usize to offset - assert_eq!(usize_val, usize::try_from(start + usize_val).unwrap()); - } - { - // add u64 to offset - assert_eq!(u64_val, u64::from(start + u64_val)); - } - } - } - - #[test] - fn round_up_to() { - let offset = Offset::from(0); - let rounded = offset.round_up_to(4); - assert_eq!(rounded, offset); - - let offset = Offset::from(1); - let rounded = offset.round_up_to(4); - assert_eq!(rounded, Offset::from(4)); - - let offset = Offset::from(3); - let rounded = offset.round_up_to(4); - assert_eq!(rounded, Offset::from(4)); - - let offset = Offset::from(4); - let rounded = offset.round_up_to(4); - assert_eq!(rounded, Offset::from(4)); - - let offset = Offset::from(5); - let rounded = offset.round_up_to(4); - assert_eq!(rounded, Offset::from(8)); - } -} diff --git a/src/hyperlight_host/src/sandbox/initialized_multi_use.rs b/src/hyperlight_host/src/sandbox/initialized_multi_use.rs index 671dbe7db..8d2490a0c 100644 --- a/src/hyperlight_host/src/sandbox/initialized_multi_use.rs +++ b/src/hyperlight_host/src/sandbox/initialized_multi_use.rs @@ -41,7 +41,6 @@ use crate::hypervisor::{Hypervisor, InterruptHandle}; #[cfg(unix)] use crate::mem::memory_region::MemoryRegionType; use crate::mem::memory_region::{MemoryRegion, MemoryRegionFlags}; -use crate::mem::ptr::RawPtr; use crate::mem::shared_mem::HostSharedMemory; use crate::metrics::maybe_time_and_emit_guest_call; use crate::{HyperlightError, Result, log_then_return}; @@ -60,7 +59,7 @@ pub struct MultiUseSandbox { pub(super) _host_funcs: Arc>, pub(crate) mem_mgr: MemMgrWrapper, vm: Box, - dispatch_ptr: RawPtr, + dispatch_ptr: u64, #[cfg(gdb)] dbg_mem_access_fn: DbgMemAccessHandlerWrapper, /// If the current state of the sandbox has been captured in a snapshot, @@ -79,7 +78,7 @@ impl MultiUseSandbox { host_funcs: Arc>, mgr: MemMgrWrapper, vm: Box, - dispatch_ptr: RawPtr, + dispatch_ptr: u64, #[cfg(gdb)] dbg_mem_access_fn: DbgMemAccessHandlerWrapper, ) -> MultiUseSandbox { Self { @@ -408,7 +407,7 @@ impl MultiUseSandbox { .write_guest_function_call(&buffer)?; self.vm.dispatch_call_from_host( - self.dispatch_ptr.clone(), + self.dispatch_ptr, #[cfg(gdb)] self.dbg_mem_access_fn.clone(), )?; diff --git a/src/hyperlight_host/src/sandbox/uninitialized_evolve.rs b/src/hyperlight_host/src/sandbox/uninitialized_evolve.rs index 5db2722ef..6448a0938 100644 --- a/src/hyperlight_host/src/sandbox/uninitialized_evolve.rs +++ b/src/hyperlight_host/src/sandbox/uninitialized_evolve.rs @@ -30,8 +30,6 @@ use crate::hypervisor::Hypervisor; use crate::mem::exe::LoadInfo; use crate::mem::layout::SandboxMemoryLayout; use crate::mem::mgr::SandboxMemoryManager; -use crate::mem::ptr::{GuestPtr, RawPtr}; -use crate::mem::ptr_offset::Offset; use crate::mem::shared_mem::GuestSharedMemory; #[cfg(any(feature = "init-paging", target_os = "windows"))] use crate::mem::shared_mem::SharedMemory; @@ -66,7 +64,7 @@ where Arc>, MemMgrWrapper, Box, - RawPtr, + u64, ) -> Result, { let (hshm, mut gshm) = u_sbox.mgr.build(); @@ -82,11 +80,7 @@ where let mut rng = rand::rng(); rng.random::() }; - let peb_addr = { - let peb_u64 = u64::try_from(gshm.layout.peb_address)?; - RawPtr::from(peb_u64) - }; - + let peb_addr = gshm.layout.peb_address as u64; let page_size = u32::try_from(page_size::get())?; #[cfg(gdb)] @@ -111,12 +105,7 @@ where return Err(new_error!("Dispatch function address is null")); } - transform( - u_sbox.host_funcs, - hshm, - vm, - RawPtr::from(dispatch_function_addr), - ) + transform(u_sbox.host_funcs, hshm, vm, dispatch_function_addr) } #[instrument(err(Debug), skip_all, parent = Span::current(), level = "Trace")] @@ -141,41 +130,15 @@ pub(crate) fn set_up_hypervisor_partition( #[cfg(any(crashdump, gdb))] rt_cfg: &SandboxRuntimeConfig, _load_info: LoadInfo, ) -> Result> { + let regions = mgr.layout.get_memory_regions(&mgr.shared_mem)?; + #[cfg(feature = "init-paging")] - let rsp_ptr = { - let mut regions = mgr.layout.get_memory_regions(&mgr.shared_mem)?; - let mem_size = u64::try_from(mgr.shared_mem.mem_size())?; - let rsp_u64 = mgr.set_up_shared_memory(mem_size, &mut regions)?; - let rsp_raw = RawPtr::from(rsp_u64); - GuestPtr::try_from(rsp_raw) - }?; + let rsp_ptr = { mgr.set_up_shared_memory(mgr.shared_mem.mem_size(), ®ions)? } as u64; #[cfg(not(feature = "init-paging"))] - let rsp_ptr = GuestPtr::try_from(Offset::from(0))?; - let regions = mgr.layout.get_memory_regions(&mgr.shared_mem)?; - let base_ptr = GuestPtr::try_from(Offset::from(0))?; - let pml4_ptr = { - let pml4_offset_u64 = u64::try_from(SandboxMemoryLayout::PML4_OFFSET)?; - base_ptr + Offset::from(pml4_offset_u64) - }; - let entrypoint_ptr = { - let entrypoint_total_offset = mgr.load_addr.clone() + mgr.entrypoint_offset; - GuestPtr::try_from(entrypoint_total_offset) - }?; + let rsp_ptr = 0; - if base_ptr != pml4_ptr { - log_then_return!( - "Error: base_ptr ({:#?}) does not equal pml4_ptr ({:#?})", - base_ptr, - pml4_ptr - ); - } - if entrypoint_ptr <= pml4_ptr { - log_then_return!( - "Error: entrypoint_ptr ({:#?}) is not greater than pml4_ptr ({:#?})", - entrypoint_ptr, - pml4_ptr - ); - } + let pml4_ptr = SandboxMemoryLayout::PML4_OFFSET as u64; + let entrypoint_ptr = mgr.load_addr + mgr.entrypoint_offset; // Create gdb thread if gdb is enabled and the configuration is provided #[cfg(gdb)] @@ -227,9 +190,9 @@ pub(crate) fn set_up_hypervisor_partition( Some(HypervisorType::Kvm) => { let hv = crate::hypervisor::kvm::KVMDriver::new( regions, - pml4_ptr.absolute()?, - entrypoint_ptr.absolute()?, - rsp_ptr.absolute()?, + pml4_ptr, + entrypoint_ptr, + rsp_ptr, config, #[cfg(gdb)] gdb_conn, @@ -251,9 +214,9 @@ pub(crate) fn set_up_hypervisor_partition( let hv = crate::hypervisor::hyperv_windows::HypervWindowsDriver::new( regions, mgr.shared_mem.raw_mem_size(), // we use raw_* here because windows driver requires 64K aligned addresses, - pml4_ptr.absolute()?, - entrypoint_ptr.absolute()?, - rsp_ptr.absolute()?, + pml4_ptr, + entrypoint_ptr, + rsp_ptr, HandleWrapper::from(mmap_file_handle), #[cfg(gdb)] gdb_conn,