@@ -61,7 +61,6 @@ use std::time::Duration;
6161use libc:: { c_void, siginfo_t} ;
6262use timerfd:: { ClockId , SetTimeFlags , TimerFd , TimerState } ;
6363
64- use arch:: x86_64;
6564use device_manager:: legacy:: LegacyDeviceManager ;
6665use device_manager:: mmio:: MMIODeviceManager ;
6766use devices:: virtio;
@@ -822,7 +821,7 @@ impl Vmm {
822821 memory_model:: GuestMemoryError :: MemoryNotInitialized ,
823822 ) ) ?
824823 << 20 ;
825- let arch_mem_regions = x86_64 :: arch_memory_regions ( mem_size) ;
824+ let arch_mem_regions = arch :: arch_memory_regions ( mem_size) ;
826825 self . guest_memory =
827826 Some ( GuestMemory :: new ( & arch_mem_regions) . map_err ( StartMicrovmError :: GuestMemory ) ?) ;
828827 Ok ( ( ) )
@@ -842,11 +841,11 @@ impl Vmm {
842841 . ok_or ( StartMicrovmError :: GuestMemory (
843842 memory_model:: GuestMemoryError :: MemoryNotInitialized ,
844843 ) ) ?;
844+
845845 // Instantiate the MMIO device manager.
846- // 'mmio_base' address has to be an address which is protected by the kernel, in this case
847- // the start of the x86 specific gap of memory (currently hardcoded at 768MiB).
846+ // 'mmio_base' address has to be an address which is protected by the kernel.
848847 let mut device_manager =
849- MMIODeviceManager :: new ( guest_mem. clone ( ) , x86_64 :: get_32bit_gap_start ( ) as u64 ) ;
848+ MMIODeviceManager :: new ( guest_mem. clone ( ) , arch :: get_reserved_mem_addr ( ) as u64 ) ;
850849
851850 self . attach_block_devices ( & mut device_manager) ?;
852851 self . attach_net_devices ( & mut device_manager) ?;
@@ -1105,7 +1104,7 @@ impl Vmm {
11051104 . vm_config
11061105 . vcpu_count
11071106 . ok_or ( StartMicrovmError :: VcpusNotConfigured ) ?;
1108- x86_64 :: configure_system (
1107+ arch :: configure_system (
11091108 vm_memory,
11101109 kernel_config. cmdline_addr ,
11111110 cmdline_cstring. to_bytes ( ) . len ( ) + 1 ,
@@ -1406,7 +1405,7 @@ impl Vmm {
14061405 let kernel_file = File :: open ( kernel_image_path) . map_err ( |_| {
14071406 VmmActionError :: BootSource ( ErrorKind :: User , BootSourceConfigError :: InvalidKernelPath )
14081407 } ) ?;
1409- let mut cmdline = kernel_cmdline:: Cmdline :: new ( x86_64 :: layout :: CMDLINE_MAX_SIZE ) ;
1408+ let mut cmdline = kernel_cmdline:: Cmdline :: new ( arch :: CMDLINE_MAX_SIZE ) ;
14101409 cmdline
14111410 . insert_str ( kernel_cmdline. unwrap_or ( String :: from ( DEFAULT_KERNEL_CMDLINE ) ) )
14121411 . map_err ( |_| {
@@ -1419,7 +1418,7 @@ impl Vmm {
14191418 let kernel_config = KernelConfig {
14201419 kernel_file,
14211420 cmdline,
1422- cmdline_addr : GuestAddress ( x86_64 :: layout :: CMDLINE_START ) ,
1421+ cmdline_addr : GuestAddress ( arch :: CMDLINE_START ) ,
14231422 } ;
14241423 self . configure_kernel ( kernel_config) ;
14251424
@@ -1881,12 +1880,12 @@ mod tests {
18811880 let kernel_path = String :: from ( kernel_file_temp. path ( ) . to_path_buf ( ) . to_str ( ) . unwrap ( ) ) ;
18821881 let kernel_file = File :: open ( kernel_path) . unwrap ( ) ;
18831882
1884- let mut cmdline = kernel_cmdline:: Cmdline :: new ( x86_64 :: layout :: CMDLINE_MAX_SIZE ) ;
1883+ let mut cmdline = kernel_cmdline:: Cmdline :: new ( arch :: CMDLINE_MAX_SIZE ) ;
18851884 assert ! ( cmdline. insert_str( DEFAULT_KERNEL_CMDLINE ) . is_ok( ) ) ;
18861885 let kernel_cfg = KernelConfig {
18871886 cmdline,
18881887 kernel_file,
1889- cmdline_addr : GuestAddress ( x86_64 :: layout :: CMDLINE_START ) ,
1888+ cmdline_addr : GuestAddress ( arch :: CMDLINE_START ) ,
18901889 } ;
18911890 self . configure_kernel ( kernel_cfg) ;
18921891 }
@@ -2450,7 +2449,7 @@ mod tests {
24502449
24512450 let guest_mem = vmm. guest_memory . clone ( ) . unwrap ( ) ;
24522451 let mut device_manager =
2453- MMIODeviceManager :: new ( guest_mem. clone ( ) , x86_64 :: get_32bit_gap_start ( ) as u64 ) ;
2452+ MMIODeviceManager :: new ( guest_mem. clone ( ) , arch :: get_reserved_mem_addr ( ) as u64 ) ;
24542453 assert ! ( vmm. attach_block_devices( & mut device_manager) . is_ok( ) ) ;
24552454 assert ! ( vmm. get_kernel_cmdline_str( ) . contains( "root=/dev/vda" ) ) ;
24562455
@@ -2474,7 +2473,7 @@ mod tests {
24742473
24752474 let guest_mem = vmm. guest_memory . clone ( ) . unwrap ( ) ;
24762475 let mut device_manager =
2477- MMIODeviceManager :: new ( guest_mem. clone ( ) , x86_64 :: get_32bit_gap_start ( ) as u64 ) ;
2476+ MMIODeviceManager :: new ( guest_mem. clone ( ) , arch :: get_reserved_mem_addr ( ) as u64 ) ;
24782477 assert ! ( vmm. attach_block_devices( & mut device_manager) . is_ok( ) ) ;
24792478 assert ! ( vmm
24802479 . get_kernel_cmdline_str( )
@@ -2502,7 +2501,7 @@ mod tests {
25022501
25032502 let guest_mem = vmm. guest_memory . clone ( ) . unwrap ( ) ;
25042503 let mut device_manager =
2505- MMIODeviceManager :: new ( guest_mem. clone ( ) , x86_64 :: get_32bit_gap_start ( ) as u64 ) ;
2504+ MMIODeviceManager :: new ( guest_mem. clone ( ) , arch :: get_reserved_mem_addr ( ) as u64 ) ;
25062505 assert ! ( vmm. attach_block_devices( & mut device_manager) . is_ok( ) ) ;
25072506 // Test that kernel commandline does not contain either /dev/vda or PARTUUID.
25082507 assert ! ( !vmm. get_kernel_cmdline_str( ) . contains( "root=PARTUUID=" ) ) ;
@@ -2536,7 +2535,7 @@ mod tests {
25362535
25372536 let guest_mem = vmm. guest_memory . clone ( ) . unwrap ( ) ;
25382537 let mut device_manager =
2539- MMIODeviceManager :: new ( guest_mem. clone ( ) , x86_64 :: get_32bit_gap_start ( ) as u64 ) ;
2538+ MMIODeviceManager :: new ( guest_mem. clone ( ) , arch :: get_reserved_mem_addr ( ) as u64 ) ;
25402539
25412540 // test create network interface
25422541 let network_interface = NetworkInterfaceConfig {
@@ -2578,8 +2577,7 @@ mod tests {
25782577 // Test valid kernel path and invalid cmdline.
25792578 let kernel_file = NamedTempFile :: new ( ) . expect ( "Failed to create temporary kernel file." ) ;
25802579 let kernel_path = String :: from ( kernel_file. path ( ) . to_path_buf ( ) . to_str ( ) . unwrap ( ) ) ;
2581- let invalid_cmdline =
2582- String :: from_utf8 ( vec ! [ b'X' ; x86_64:: layout:: CMDLINE_MAX_SIZE + 1 ] ) . unwrap ( ) ;
2580+ let invalid_cmdline = String :: from_utf8 ( vec ! [ b'X' ; arch:: CMDLINE_MAX_SIZE + 1 ] ) . unwrap ( ) ;
25832581 assert ! ( vmm
25842582 . configure_boot_source( kernel_path. clone( ) , Some ( invalid_cmdline) )
25852583 . is_err( ) ) ;
@@ -2633,14 +2631,14 @@ mod tests {
26332631
26342632 let guest_mem = vmm. guest_memory . clone ( ) . unwrap ( ) ;
26352633 let mut device_manager =
2636- MMIODeviceManager :: new ( guest_mem. clone ( ) , x86_64 :: get_32bit_gap_start ( ) as u64 ) ;
2634+ MMIODeviceManager :: new ( guest_mem. clone ( ) , arch :: get_reserved_mem_addr ( ) as u64 ) ;
26372635
26382636 let dummy_box = Box :: new ( DummyDevice { dummy : 0 } ) ;
26392637 // Use a dummy command line as it is not used in this test.
26402638 let _addr = device_manager
26412639 . register_device (
26422640 dummy_box,
2643- & mut kernel_cmdline:: Cmdline :: new ( x86_64 :: layout :: CMDLINE_MAX_SIZE ) ,
2641+ & mut kernel_cmdline:: Cmdline :: new ( arch :: CMDLINE_MAX_SIZE ) ,
26442642 Some ( scratch_id. clone ( ) ) ,
26452643 )
26462644 . unwrap ( ) ;
0 commit comments