@@ -15,7 +15,6 @@ limitations under the License.
1515*/
1616
1717use std:: cmp:: Ordering ;
18- use std:: sync:: { Arc , Mutex } ;
1918
2019use hyperlight_common:: flatbuffer_wrappers:: function_call:: {
2120 FunctionCall , validate_guest_function_call_buffer,
@@ -34,7 +33,6 @@ use super::ptr::{GuestPtr, RawPtr};
3433use super :: ptr_offset:: Offset ;
3534use super :: shared_mem:: { ExclusiveSharedMemory , GuestSharedMemory , HostSharedMemory , SharedMemory } ;
3635use super :: shared_mem_snapshot:: SharedMemorySnapshot ;
37- use crate :: HyperlightError :: NoMemorySnapshot ;
3836use crate :: sandbox:: SandboxConfiguration ;
3937use crate :: sandbox:: uninitialized:: GuestBlob ;
4038use crate :: { Result , log_then_return, new_error} ;
@@ -73,9 +71,6 @@ pub(crate) struct SandboxMemoryManager<S> {
7371 pub ( crate ) load_addr : RawPtr ,
7472 /// Offset for the execution entrypoint from `load_addr`
7573 pub ( crate ) entrypoint_offset : Offset ,
76- /// A vector of memory snapshots that can be used to save and restore the state of the memory
77- /// This is used by the Rust Sandbox implementation (rather than the mem_snapshot field above which only exists to support current C API)
78- snapshots : Arc < Mutex < Vec < SharedMemorySnapshot > > > ,
7974}
8075
8176impl < S > SandboxMemoryManager < S >
9590 shared_mem,
9691 load_addr,
9792 entrypoint_offset,
98- snapshots : Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ,
9993 }
10094 }
10195
@@ -277,33 +271,6 @@ where
277271 snapshot. restore_from_snapshot ( & mut self . shared_mem )
278272 }
279273
280- /// this function will create a memory snapshot and push it onto the stack of snapshots
281- /// It should be used when you want to save the state of the memory, for example, when evolving a sandbox to a new state
282- pub ( crate ) fn push_state ( & mut self ) -> Result < ( ) > {
283- let snapshot = self . snapshot ( ) ?;
284- self . snapshots
285- . try_lock ( )
286- . map_err ( |e| new_error ! ( "Error locking at {}:{}: {}" , file!( ) , line!( ) , e) ) ?
287- . push ( snapshot) ;
288- Ok ( ( ) )
289- }
290-
291- /// this function restores a memory snapshot from the last snapshot in the list but does not pop the snapshot
292- /// off the stack
293- /// It should be used when you want to restore the state of the memory to a previous state but still want to
294- /// retain that state, for example after calling a function in the guest
295- pub ( crate ) fn restore_state_from_last_snapshot ( & mut self ) -> Result < ( ) > {
296- let snapshots: std:: sync:: MutexGuard < ' _ , Vec < SharedMemorySnapshot > > = self
297- . snapshots
298- . try_lock ( )
299- . map_err ( |e| new_error ! ( "Error locking at {}:{}: {}" , file!( ) , line!( ) , e) ) ?;
300- let last = snapshots. last ( ) ;
301- let Some ( snapshot) = last else {
302- log_then_return ! ( NoMemorySnapshot ) ;
303- } ;
304- snapshot. restore_from_snapshot ( & mut self . shared_mem )
305- }
306-
307274 /// Sets `addr` to the correct offset in the memory referenced by
308275 /// `shared_mem` to indicate the address of the outb pointer and context
309276 /// for calling outb function
@@ -428,14 +395,12 @@ impl SandboxMemoryManager<ExclusiveSharedMemory> {
428395 layout : self . layout ,
429396 load_addr : self . load_addr . clone ( ) ,
430397 entrypoint_offset : self . entrypoint_offset ,
431- snapshots : Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ,
432398 } ,
433399 SandboxMemoryManager {
434400 shared_mem : gshm,
435401 layout : self . layout ,
436402 load_addr : self . load_addr . clone ( ) ,
437403 entrypoint_offset : self . entrypoint_offset ,
438- snapshots : Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ,
439404 } ,
440405 )
441406 }
0 commit comments