@@ -29,6 +29,7 @@ use crate::func::host_functions::{HostFunction, register_host_function};
2929use crate :: func:: { ParameterTuple , SupportedReturnType } ;
3030#[ cfg( feature = "build-metadata" ) ]
3131use crate :: log_build_details;
32+ use crate :: mem:: dirty_page_tracking:: DirtyPageTracker ;
3233use crate :: mem:: exe:: ExeInfo ;
3334use crate :: mem:: memory_region:: { DEFAULT_GUEST_BLOB_MEM_FLAGS , MemoryRegionFlags } ;
3435use crate :: mem:: mgr:: { STACK_COOKIE_LEN , SandboxMemoryManager } ;
@@ -80,6 +81,7 @@ pub struct UninitializedSandbox {
8081 pub ( crate ) config : SandboxConfiguration ,
8182 #[ cfg( any( crashdump, gdb) ) ]
8283 pub ( crate ) rt_cfg : SandboxRuntimeConfig ,
84+ pub ( crate ) tracker : Option < DirtyPageTracker > ,
8385}
8486
8587impl crate :: sandbox_state:: sandbox:: UninitializedSandbox for UninitializedSandbox {
@@ -250,17 +252,15 @@ impl UninitializedSandbox {
250252 }
251253 } ;
252254
253- let mut mem_mgr_wrapper = {
254- let mut mgr = UninitializedSandbox :: load_guest_binary (
255- sandbox_cfg,
256- & guest_binary,
257- guest_blob. as_ref ( ) ,
258- ) ?;
255+ let ( mut mgr, tracker) = UninitializedSandbox :: load_guest_binary (
256+ sandbox_cfg,
257+ & guest_binary,
258+ guest_blob. as_ref ( ) ,
259+ ) ?;
259260
260- let stack_guard = Self :: create_stack_guard ( ) ;
261- mgr. set_stack_guard ( & stack_guard) ?;
262- MemMgrWrapper :: new ( mgr, stack_guard)
263- } ;
261+ let stack_guard = Self :: create_stack_guard ( ) ;
262+ mgr. set_stack_guard ( & stack_guard) ?;
263+ let mut mem_mgr_wrapper = MemMgrWrapper :: new ( mgr, stack_guard) ;
264264
265265 mem_mgr_wrapper. write_memory_layout ( ) ?;
266266
@@ -278,6 +278,7 @@ impl UninitializedSandbox {
278278 config : sandbox_cfg,
279279 #[ cfg( any( crashdump, gdb) ) ]
280280 rt_cfg,
281+ tracker : Some ( tracker) ,
281282 } ;
282283
283284 // If we were passed a writer for host print register it otherwise use the default.
@@ -308,7 +309,10 @@ impl UninitializedSandbox {
308309 cfg : SandboxConfiguration ,
309310 guest_binary : & GuestBinary ,
310311 guest_blob : Option < & GuestBlob > ,
311- ) -> Result < SandboxMemoryManager < ExclusiveSharedMemory > > {
312+ ) -> Result < (
313+ SandboxMemoryManager < ExclusiveSharedMemory > ,
314+ DirtyPageTracker ,
315+ ) > {
312316 let mut exe_info = match guest_binary {
313317 GuestBinary :: FilePath ( bin_path_str) => ExeInfo :: from_file ( bin_path_str) ?,
314318 GuestBinary :: Buffer ( buffer) => ExeInfo :: from_buf ( buffer) ?,
@@ -396,6 +400,7 @@ impl UninitializedSandbox {
396400 Ok ( ( ) )
397401 }
398402}
403+
399404// Check to see if the current version of Windows is supported
400405// Hyperlight is only supported on Windows 11 and Windows Server 2022 and later
401406#[ cfg( target_os = "windows" ) ]
0 commit comments