@@ -864,24 +864,20 @@ impl SandboxMemoryManager<HostSharedMemory> {
864864#[ cfg( test) ]
865865#[ cfg( all( not( feature = "i686-guest" ) , target_arch = "x86_64" ) ) ]
866866mod tests {
867- use hyperlight_common:: vmem:: { MappingKind , PAGE_TABLE_SIZE } ;
868867 use hyperlight_testing:: sandbox_sizes:: { LARGE_HEAP_SIZE , MEDIUM_HEAP_SIZE , SMALL_HEAP_SIZE } ;
869868 use hyperlight_testing:: simple_guest_as_string;
870869
871870 use crate :: GuestBinary ;
872- use crate :: mem:: memory_region:: MemoryRegionFlags ;
873871 use crate :: sandbox:: SandboxConfiguration ;
874872 use crate :: sandbox:: snapshot:: Snapshot ;
875873
876- /// Verify page tables for a given configuration.
877- /// Creates a Snapshot and verifies every page in every region has correct PTEs .
874+ /// Build a Snapshot for the given configuration and verify the
875+ /// NULL page is not mapped in its page tables .
878876 fn verify_page_tables ( name : & str , config : SandboxConfiguration ) {
879877 let path = simple_guest_as_string ( ) . expect ( "failed to get simple guest path" ) ;
880878 let snapshot = Snapshot :: from_env ( GuestBinary :: FilePath ( path) , config)
881879 . unwrap_or_else ( |e| panic ! ( "{}: failed to create snapshot: {}" , name, e) ) ;
882880
883- let regions = snapshot. regions ( ) ;
884-
885881 // Verify NULL page (0x0) is NOT mapped
886882 assert ! (
887883 unsafe { hyperlight_common:: vmem:: virt_to_phys( & snapshot, 0 , 1 ) }
@@ -890,57 +886,6 @@ mod tests {
890886 "{}: NULL page (0x0) should NOT be mapped" ,
891887 name
892888 ) ;
893-
894- // Verify every page in every region
895- for region in regions {
896- let mut addr = region. guest_region . start as u64 ;
897-
898- while addr < region. guest_region . end as u64 {
899- let mapping = unsafe { hyperlight_common:: vmem:: virt_to_phys ( & snapshot, addr, 1 ) }
900- . next ( )
901- . unwrap_or_else ( || {
902- panic ! (
903- "{}: {:?} region: address 0x{:x} is not mapped" ,
904- name, region. region_type, addr
905- )
906- } ) ;
907-
908- // Verify identity mapping (phys == virt for low memory)
909- assert_eq ! (
910- mapping. phys_base, addr,
911- "{}: {:?} region: address 0x{:x} should identity map, got phys 0x{:x}" ,
912- name, region. region_type, addr, mapping. phys_base
913- ) ;
914-
915- // Verify kind is Basic
916- let MappingKind :: Basic ( bm) = mapping. kind else {
917- panic ! (
918- "{}: {:?} region: address 0x{:x} should be kind basic, got {:?}" ,
919- name, region. region_type, addr, mapping. kind
920- ) ;
921- } ;
922-
923- // Verify writable
924- let actual = bm. writable ;
925- let expected = region. flags . contains ( MemoryRegionFlags :: WRITE ) ;
926- assert_eq ! (
927- actual, expected,
928- "{}: {:?} region: address 0x{:x} has writable {}, expected {} (region flags: {:?})" ,
929- name, region. region_type, addr, actual, expected, region. flags
930- ) ;
931-
932- // Verify executable
933- let actual = bm. executable ;
934- let expected = region. flags . contains ( MemoryRegionFlags :: EXECUTE ) ;
935- assert_eq ! (
936- actual, expected,
937- "{}: {:?} region: address 0x{:x} has executable {}, expected {} (region flags: {:?})" ,
938- name, region. region_type, addr, actual, expected, region. flags
939- ) ;
940-
941- addr += PAGE_TABLE_SIZE as u64 ;
942- }
943- }
944889 }
945890
946891 #[ test]
0 commit comments