@@ -178,18 +178,14 @@ pub(super) struct OciSnapshotConfig {
178178 /// Guest virtual address of the ELF entry point
179179 /// (`load_addr + e_entry - base_va`), preserved across the
180180 /// Initialise->Call transition. Fills `AT_ENTRY` in core dumps so
181- /// gdb resolves PIE symbols. Optional: snapshots written before
182- /// this field existed deserialize to `0`, which core-dump code
183- /// treats as unknown.
184- #[ serde( default ) ]
181+ /// gdb resolves PIE symbols.
185182 pub ( super ) original_entrypoint_addr : u64 ,
186183 /// Special registers captured from the paused vCPU, restored
187184 /// verbatim when resuming the call.
188185 pub ( super ) sregs : CommonSpecialRegisters ,
189- /// The MSRs saved in this snapshot. A missing or empty field restores the
190- /// destination baseline.
186+ /// The MSRs saved in this snapshot. An empty field restores the destination
187+ /// baseline.
191188 #[ cfg( target_arch = "x86_64" ) ]
192- #[ serde( default ) ]
193189 pub ( super ) msrs : Vec < MsrEntry > ,
194190 pub ( super ) layout : MemoryLayout ,
195191 /// Total size of the memory blob in bytes (including the guest
@@ -507,9 +503,8 @@ impl OciSnapshotConfig {
507503 ) ) ;
508504 }
509505
510- // ELF entry point GVA for `AT_ENTRY` in core dumps. 0 means
511- // unknown. Any other value must point inside the snapshot
512- // region, like `entrypoint_addr`.
506+ // ELF entry point GVA for `AT_ENTRY` in core dumps. It must point
507+ // inside the snapshot region, like `entrypoint_addr`.
513508 let snapshot_hi = code_lo
514509 . checked_add ( self . layout . snapshot_size as u64 )
515510 . ok_or_else ( || {
@@ -518,10 +513,7 @@ impl OciSnapshotConfig {
518513 self . layout. snapshot_size
519514 )
520515 } ) ?;
521- if self . original_entrypoint_addr != 0
522- && ( self . original_entrypoint_addr < code_lo
523- || self . original_entrypoint_addr >= snapshot_hi)
524- {
516+ if self . original_entrypoint_addr < code_lo || self . original_entrypoint_addr >= snapshot_hi {
525517 return Err ( crate :: new_error!(
526518 "snapshot original entrypoint addr {:#x} is outside the snapshot region [{:#x}, {:#x})" ,
527519 self . original_entrypoint_addr,
@@ -666,10 +658,10 @@ mod tests {
666658 assert_eq ! ( restored. msrs, original. msrs) ;
667659 }
668660
669- /// A config JSON with no MSR state deserializes to an empty set .
661+ /// A config JSON with no MSR state is rejected .
670662 #[ cfg( target_arch = "x86_64" ) ]
671663 #[ test]
672- fn config_without_msrs_deserializes_to_empty_set ( ) {
664+ fn config_without_msrs_is_rejected ( ) {
673665 let with = gating_config_with_msrs ( Some ( vec ! [ MsrEntry {
674666 index: 0x10 ,
675667 value: 1 ,
@@ -678,8 +670,11 @@ mod tests {
678670 serde_json:: from_slice ( & serde_json:: to_vec ( & with) . unwrap ( ) ) . unwrap ( ) ;
679671 assert ! ( json. as_object_mut( ) . unwrap( ) . remove( "msrs" ) . is_some( ) ) ;
680672
681- let restored: OciSnapshotConfig = serde_json:: from_value ( json) . unwrap ( ) ;
682- assert ! ( restored. msrs. is_empty( ) ) ;
673+ let err = serde_json:: from_value :: < OciSnapshotConfig > ( json)
674+ . err ( )
675+ . expect ( "config without msrs should fail to deserialize" )
676+ . to_string ( ) ;
677+ assert ! ( err. contains( "missing field `msrs`" ) , "got: {err}" ) ;
683678 }
684679
685680 /// Every `ParameterType` survives the round-trip through its serde
@@ -767,7 +762,7 @@ mod tests {
767762 cpu_vendor : CpuVendor :: current ( ) ,
768763 stack_top_gva : 0x2000 ,
769764 entrypoint_addr : SandboxMemoryLayout :: BASE_ADDRESS as u64 ,
770- original_entrypoint_addr : 0 ,
765+ original_entrypoint_addr : SandboxMemoryLayout :: BASE_ADDRESS as u64 ,
771766 sregs : distinct_sregs ( ) ,
772767 #[ cfg( target_arch = "x86_64" ) ]
773768 msrs : Vec :: new ( ) ,
@@ -850,7 +845,7 @@ mod schema_pin {
850845 "cpu_vendor": "intel",
851846 "stack_top_gva": 3735928559,
852847 "entrypoint_addr": 8192,
853- "original_entrypoint_addr": 0 ,
848+ "original_entrypoint_addr": 4096 ,
854849 "sregs": {
855850 "cs": {
856851 "base": 1,
@@ -1036,7 +1031,7 @@ mod schema_pin {
10361031 "cpu_vendor": "intel",
10371032 "stack_top_gva": 3735928559,
10381033 "entrypoint_addr": 8192,
1039- "original_entrypoint_addr": 0 ,
1034+ "original_entrypoint_addr": 4096 ,
10401035 "sregs": {
10411036 "tcr_el1": 1,
10421037 "mair_el1": 2,
0 commit comments