@@ -61,7 +61,6 @@ use std::time::Duration;
61
61
use libc:: { c_void, siginfo_t} ;
62
62
use timerfd:: { ClockId , SetTimeFlags , TimerFd , TimerState } ;
63
63
64
- use arch:: x86_64;
65
64
use device_manager:: legacy:: LegacyDeviceManager ;
66
65
use device_manager:: mmio:: MMIODeviceManager ;
67
66
use devices:: virtio;
@@ -822,7 +821,7 @@ impl Vmm {
822
821
memory_model:: GuestMemoryError :: MemoryNotInitialized ,
823
822
) ) ?
824
823
<< 20 ;
825
- let arch_mem_regions = x86_64 :: arch_memory_regions ( mem_size) ;
824
+ let arch_mem_regions = arch :: arch_memory_regions ( mem_size) ;
826
825
self . guest_memory =
827
826
Some ( GuestMemory :: new ( & arch_mem_regions) . map_err ( StartMicrovmError :: GuestMemory ) ?) ;
828
827
Ok ( ( ) )
@@ -842,11 +841,11 @@ impl Vmm {
842
841
. ok_or ( StartMicrovmError :: GuestMemory (
843
842
memory_model:: GuestMemoryError :: MemoryNotInitialized ,
844
843
) ) ?;
844
+
845
845
// 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.
848
847
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 ) ;
850
849
851
850
self . attach_block_devices ( & mut device_manager) ?;
852
851
self . attach_net_devices ( & mut device_manager) ?;
@@ -1105,7 +1104,7 @@ impl Vmm {
1105
1104
. vm_config
1106
1105
. vcpu_count
1107
1106
. ok_or ( StartMicrovmError :: VcpusNotConfigured ) ?;
1108
- x86_64 :: configure_system (
1107
+ arch :: configure_system (
1109
1108
vm_memory,
1110
1109
kernel_config. cmdline_addr ,
1111
1110
cmdline_cstring. to_bytes ( ) . len ( ) + 1 ,
@@ -1406,7 +1405,7 @@ impl Vmm {
1406
1405
let kernel_file = File :: open ( kernel_image_path) . map_err ( |_| {
1407
1406
VmmActionError :: BootSource ( ErrorKind :: User , BootSourceConfigError :: InvalidKernelPath )
1408
1407
} ) ?;
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 ) ;
1410
1409
cmdline
1411
1410
. insert_str ( kernel_cmdline. unwrap_or ( String :: from ( DEFAULT_KERNEL_CMDLINE ) ) )
1412
1411
. map_err ( |_| {
@@ -1419,7 +1418,7 @@ impl Vmm {
1419
1418
let kernel_config = KernelConfig {
1420
1419
kernel_file,
1421
1420
cmdline,
1422
- cmdline_addr : GuestAddress ( x86_64 :: layout :: CMDLINE_START ) ,
1421
+ cmdline_addr : GuestAddress ( arch :: CMDLINE_START ) ,
1423
1422
} ;
1424
1423
self . configure_kernel ( kernel_config) ;
1425
1424
@@ -1881,12 +1880,12 @@ mod tests {
1881
1880
let kernel_path = String :: from ( kernel_file_temp. path ( ) . to_path_buf ( ) . to_str ( ) . unwrap ( ) ) ;
1882
1881
let kernel_file = File :: open ( kernel_path) . unwrap ( ) ;
1883
1882
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 ) ;
1885
1884
assert ! ( cmdline. insert_str( DEFAULT_KERNEL_CMDLINE ) . is_ok( ) ) ;
1886
1885
let kernel_cfg = KernelConfig {
1887
1886
cmdline,
1888
1887
kernel_file,
1889
- cmdline_addr : GuestAddress ( x86_64 :: layout :: CMDLINE_START ) ,
1888
+ cmdline_addr : GuestAddress ( arch :: CMDLINE_START ) ,
1890
1889
} ;
1891
1890
self . configure_kernel ( kernel_cfg) ;
1892
1891
}
@@ -2450,7 +2449,7 @@ mod tests {
2450
2449
2451
2450
let guest_mem = vmm. guest_memory . clone ( ) . unwrap ( ) ;
2452
2451
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 ) ;
2454
2453
assert ! ( vmm. attach_block_devices( & mut device_manager) . is_ok( ) ) ;
2455
2454
assert ! ( vmm. get_kernel_cmdline_str( ) . contains( "root=/dev/vda" ) ) ;
2456
2455
@@ -2474,7 +2473,7 @@ mod tests {
2474
2473
2475
2474
let guest_mem = vmm. guest_memory . clone ( ) . unwrap ( ) ;
2476
2475
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 ) ;
2478
2477
assert ! ( vmm. attach_block_devices( & mut device_manager) . is_ok( ) ) ;
2479
2478
assert ! ( vmm
2480
2479
. get_kernel_cmdline_str( )
@@ -2502,7 +2501,7 @@ mod tests {
2502
2501
2503
2502
let guest_mem = vmm. guest_memory . clone ( ) . unwrap ( ) ;
2504
2503
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 ) ;
2506
2505
assert ! ( vmm. attach_block_devices( & mut device_manager) . is_ok( ) ) ;
2507
2506
// Test that kernel commandline does not contain either /dev/vda or PARTUUID.
2508
2507
assert ! ( !vmm. get_kernel_cmdline_str( ) . contains( "root=PARTUUID=" ) ) ;
@@ -2536,7 +2535,7 @@ mod tests {
2536
2535
2537
2536
let guest_mem = vmm. guest_memory . clone ( ) . unwrap ( ) ;
2538
2537
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 ) ;
2540
2539
2541
2540
// test create network interface
2542
2541
let network_interface = NetworkInterfaceConfig {
@@ -2578,8 +2577,7 @@ mod tests {
2578
2577
// Test valid kernel path and invalid cmdline.
2579
2578
let kernel_file = NamedTempFile :: new ( ) . expect ( "Failed to create temporary kernel file." ) ;
2580
2579
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 ( ) ;
2583
2581
assert ! ( vmm
2584
2582
. configure_boot_source( kernel_path. clone( ) , Some ( invalid_cmdline) )
2585
2583
. is_err( ) ) ;
@@ -2633,14 +2631,14 @@ mod tests {
2633
2631
2634
2632
let guest_mem = vmm. guest_memory . clone ( ) . unwrap ( ) ;
2635
2633
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 ) ;
2637
2635
2638
2636
let dummy_box = Box :: new ( DummyDevice { dummy : 0 } ) ;
2639
2637
// Use a dummy command line as it is not used in this test.
2640
2638
let _addr = device_manager
2641
2639
. register_device (
2642
2640
dummy_box,
2643
- & mut kernel_cmdline:: Cmdline :: new ( x86_64 :: layout :: CMDLINE_MAX_SIZE ) ,
2641
+ & mut kernel_cmdline:: Cmdline :: new ( arch :: CMDLINE_MAX_SIZE ) ,
2644
2642
Some ( scratch_id. clone ( ) ) ,
2645
2643
)
2646
2644
. unwrap ( ) ;
0 commit comments