@@ -15,7 +15,6 @@ limitations under the License.
15
15
*/
16
16
17
17
use std:: cmp:: Ordering ;
18
- use std:: sync:: { Arc , Mutex } ;
19
18
20
19
use hyperlight_common:: flatbuffer_wrappers:: function_call:: {
21
20
FunctionCall , validate_guest_function_call_buffer,
@@ -34,7 +33,6 @@ use super::ptr::{GuestPtr, RawPtr};
34
33
use super :: ptr_offset:: Offset ;
35
34
use super :: shared_mem:: { ExclusiveSharedMemory , GuestSharedMemory , HostSharedMemory , SharedMemory } ;
36
35
use super :: shared_mem_snapshot:: SharedMemorySnapshot ;
37
- use crate :: HyperlightError :: NoMemorySnapshot ;
38
36
use crate :: sandbox:: SandboxConfiguration ;
39
37
use crate :: sandbox:: uninitialized:: GuestBlob ;
40
38
use crate :: { Result , log_then_return, new_error} ;
@@ -75,9 +73,6 @@ pub(crate) struct SandboxMemoryManager<S> {
75
73
pub ( crate ) entrypoint_offset : Offset ,
76
74
/// How many memory regions were mapped after sandbox creation
77
75
pub ( crate ) mapped_rgns : u64 ,
78
- /// A vector of memory snapshots that can be used to save and restore the state of the memory
79
- /// This is used by the Rust Sandbox implementation (rather than the mem_snapshot field above which only exists to support current C API)
80
- snapshots : Arc < Mutex < Vec < SharedMemorySnapshot > > > ,
81
76
}
82
77
83
78
impl < S > SandboxMemoryManager < S >
98
93
load_addr,
99
94
entrypoint_offset,
100
95
mapped_rgns : 0 ,
101
- snapshots : Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ,
102
96
}
103
97
}
104
98
@@ -288,39 +282,6 @@ where
288
282
Ok ( old_rgns - self . mapped_rgns )
289
283
}
290
284
291
- /// this function will create a memory snapshot and push it onto the stack of snapshots
292
- /// It should be used when you want to save the state of the memory, for example, when evolving a sandbox to a new state
293
- pub ( crate ) fn push_state ( & mut self ) -> Result < ( ) > {
294
- let snapshot = self . snapshot ( ) ?;
295
- self . snapshots
296
- . try_lock ( )
297
- . map_err ( |e| new_error ! ( "Error locking at {}:{}: {}" , file!( ) , line!( ) , e) ) ?
298
- . push ( snapshot) ;
299
- Ok ( ( ) )
300
- }
301
-
302
- /// this function restores a memory snapshot from the last snapshot in the list but does not pop the snapshot
303
- /// off the stack
304
- /// It should be used when you want to restore the state of the memory to a previous state but still want to
305
- /// retain that state, for example after calling a function in the guest
306
- ///
307
- /// Returns the number of memory regions mapped into the sandbox
308
- /// that need to be unmapped in order for the restore to be
309
- /// completed.
310
- pub ( crate ) fn restore_state_from_last_snapshot ( & mut self ) -> Result < u64 > {
311
- let snapshots = self
312
- . snapshots
313
- . try_lock ( )
314
- . map_err ( |e| new_error ! ( "Error locking at {}:{}: {}" , file!( ) , line!( ) , e) ) ?;
315
- let last = snapshots. last ( ) ;
316
- let Some ( snapshot) = last else {
317
- log_then_return ! ( NoMemorySnapshot ) ;
318
- } ;
319
- let old_rgns = self . mapped_rgns ;
320
- self . mapped_rgns = snapshot. restore_from_snapshot ( & mut self . shared_mem ) ?;
321
- Ok ( old_rgns - self . mapped_rgns )
322
- }
323
-
324
285
/// Sets `addr` to the correct offset in the memory referenced by
325
286
/// `shared_mem` to indicate the address of the outb pointer and context
326
287
/// for calling outb function
@@ -446,15 +407,13 @@ impl SandboxMemoryManager<ExclusiveSharedMemory> {
446
407
load_addr : self . load_addr . clone ( ) ,
447
408
entrypoint_offset : self . entrypoint_offset ,
448
409
mapped_rgns : 0 ,
449
- snapshots : Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ,
450
410
} ,
451
411
SandboxMemoryManager {
452
412
shared_mem : gshm,
453
413
layout : self . layout ,
454
414
load_addr : self . load_addr . clone ( ) ,
455
415
entrypoint_offset : self . entrypoint_offset ,
456
416
mapped_rgns : 0 ,
457
- snapshots : Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ,
458
417
} ,
459
418
)
460
419
}
0 commit comments