@@ -232,9 +232,15 @@ pub(crate) struct SandboxMemoryLayout {
232232 pub ( crate ) init_data_permissions : Option < MemoryRegionFlags > ,
233233 /// The size of the scratch region in physical memory.
234234 pub ( crate ) scratch_size : usize ,
235- /// The size of the snapshot region in physical memory.
235+ /// Size of the primary guest memory region at `BASE_ADDRESS`
236+ /// (code, PEB, heap, init data). For a snapshot-backed layout
237+ /// this is also the guest-visible prefix of the host snapshot
238+ /// mapping.
236239 pub ( crate ) snapshot_size : usize ,
237- /// The size of the page tables (None if not yet set).
240+ /// Size of the page-table region. Sits at the tail of the host
241+ /// snapshot mapping but is never mapped to the guest from there.
242+ /// On restore the host copies it into scratch, where the guest
243+ /// sees it at `SNAPSHOT_PT_GVA`. `None` until page tables are built.
238244 pub ( crate ) pt_size : Option < usize > ,
239245}
240246
@@ -497,7 +503,12 @@ impl SandboxMemoryLayout {
497503 }
498504 }
499505
500- /// Sets the size of the memory region used for page tables
506+ /// Record the size of the page-table tail appended to the
507+ /// snapshot blob. The PT bytes live at the end of the blob and
508+ /// the host mapping, outside the guest mapping of the snapshot
509+ /// region, and are copied into the scratch region on restore.
510+ /// `snapshot_size` (the guest-visible prefix of the blob) is an
511+ /// independent field and must be set separately.
501512 #[ instrument( skip_all, parent = Span :: current( ) , level= "Trace" ) ]
502513 pub ( crate ) fn set_pt_size ( & mut self , size : usize ) -> Result < ( ) > {
503514 let min_fixed_scratch = hyperlight_common:: layout:: min_scratch_size (
@@ -508,8 +519,6 @@ impl SandboxMemoryLayout {
508519 if self . scratch_size < min_scratch {
509520 return Err ( MemoryRequestTooSmall ( self . scratch_size , min_scratch) ) ;
510521 }
511- let old_pt_size = self . pt_size . unwrap_or ( 0 ) ;
512- self . snapshot_size = self . snapshot_size - old_pt_size + size;
513522 self . pt_size = Some ( size) ;
514523 Ok ( ( ) )
515524 }
0 commit comments