@@ -27,18 +27,10 @@ use std::{any, cmp, result, str, thread};
2727use anyhow:: { Context , anyhow} ;
2828#[ cfg( any( target_arch = "aarch64" , target_arch = "riscv64" ) ) ]
2929use arch:: PciSpaceInfo ;
30- #[ cfg( not( target_arch = "x86_64" ) ) ]
31- use arch:: aarch64;
3230#[ cfg( target_arch = "x86_64" ) ]
3331use arch:: layout:: { KVM_IDENTITY_MAP_START , KVM_TSS_START } ;
3432#[ cfg( not( target_arch = "x86_64" ) ) ]
3533use arch:: uefi;
36- #[ cfg( all( feature = "kvm" , target_arch = "x86_64" ) ) ]
37- use arch:: x86_64:: MAX_SUPPORTED_CPUS_LEGACY ;
38- #[ cfg( feature = "tdx" ) ]
39- use arch:: x86_64:: tdx;
40- #[ cfg( feature = "tdx" ) ]
41- use arch:: x86_64:: tdx:: TdvfSection ;
4234use arch:: { EntryPoint , NumaNode , NumaNodes , get_host_cpu_phys_bits, layout} ;
4335use devices:: AcpiNotificationFlags ;
4436#[ cfg( target_arch = "aarch64" ) ]
@@ -145,7 +137,7 @@ pub enum Error {
145137
146138 #[ cfg( target_arch = "aarch64" ) ]
147139 #[ error( "Cannot load the UEFI binary in memory" ) ]
148- UefiLoad ( #[ source] aarch64:: uefi:: Error ) ,
140+ UefiLoad ( #[ source] arch :: aarch64:: uefi:: Error ) ,
149141
150142 #[ cfg( target_arch = "riscv64" ) ]
151143 #[ error( "Cannot load the UEFI binary in memory" ) ]
@@ -313,11 +305,11 @@ pub enum Error {
313305
314306 #[ cfg( feature = "tdx" ) ]
315307 #[ error( "Error parsing TDVF" ) ]
316- ParseTdvf ( #[ source] tdx:: TdvfError ) ,
308+ ParseTdvf ( #[ source] arch :: x86_64 :: tdx:: TdvfError ) ,
317309
318310 #[ cfg( feature = "tdx" ) ]
319311 #[ error( "Error populating TDX HOB" ) ]
320- PopulateHob ( #[ source] tdx:: TdvfError ) ,
312+ PopulateHob ( #[ source] arch :: x86_64 :: tdx:: TdvfError ) ,
321313
322314 #[ cfg( feature = "tdx" ) ]
323315 #[ error( "Error allocating TDVF memory" ) ]
@@ -1402,7 +1394,7 @@ impl Vm {
14021394 } ;
14031395
14041396 #[ cfg( all( feature = "kvm" , target_arch = "x86_64" ) ) ]
1405- if vm_config. lock ( ) . unwrap ( ) . max_apic_id ( ) > MAX_SUPPORTED_CPUS_LEGACY {
1397+ if vm_config. lock ( ) . unwrap ( ) . max_apic_id ( ) > arch :: x86_64 :: MAX_SUPPORTED_CPUS_LEGACY {
14061398 vm. enable_x2apic_api ( ) . unwrap ( ) ;
14071399 }
14081400
@@ -1919,7 +1911,9 @@ impl Vm {
19191911 . unwrap ( )
19201912 . get_vgic ( )
19211913 . map_err ( |_| {
1922- Error :: ConfigureSystem ( arch:: Error :: PlatformSpecific ( aarch64:: Error :: SetupGic ) )
1914+ Error :: ConfigureSystem ( arch:: Error :: PlatformSpecific (
1915+ arch:: aarch64:: Error :: SetupGic ,
1916+ ) )
19231917 } ) ?;
19241918
19251919 // PMU interrupt sticks to PPI, so need to be added by 16 to get real irq number.
@@ -1929,7 +1923,9 @@ impl Vm {
19291923 . unwrap ( )
19301924 . init_pmu ( AARCH64_PMU_IRQ + 16 )
19311925 . map_err ( |_| {
1932- Error :: ConfigureSystem ( arch:: Error :: PlatformSpecific ( aarch64:: Error :: VcpuInitPmu ) )
1926+ Error :: ConfigureSystem ( arch:: Error :: PlatformSpecific (
1927+ arch:: aarch64:: Error :: VcpuInitPmu ,
1928+ ) )
19331929 } ) ?;
19341930
19351931 arch:: configure_system (
@@ -2425,7 +2421,7 @@ impl Vm {
24252421 }
24262422
24272423 #[ cfg( feature = "tdx" ) ]
2428- fn extract_tdvf_sections ( & mut self ) -> Result < ( Vec < TdvfSection > , bool ) > {
2424+ fn extract_tdvf_sections ( & mut self ) -> Result < ( Vec < arch :: x86_64 :: tdx :: TdvfSection > , bool ) > {
24292425 use arch:: x86_64:: tdx:: * ;
24302426
24312427 let firmware_path = self
@@ -2447,7 +2443,7 @@ impl Vm {
24472443
24482444 #[ cfg( feature = "tdx" ) ]
24492445 fn hob_memory_resources (
2450- mut sorted_sections : Vec < TdvfSection > ,
2446+ mut sorted_sections : Vec < arch :: x86_64 :: tdx :: TdvfSection > ,
24512447 guest_memory : & GuestMemoryMmap ,
24522448 ) -> Vec < ( u64 , u64 , bool ) > {
24532449 let mut list = Vec :: new ( ) ;
@@ -2508,7 +2504,7 @@ impl Vm {
25082504 #[ cfg( feature = "tdx" ) ]
25092505 fn populate_tdx_sections (
25102506 & mut self ,
2511- sections : & [ TdvfSection ] ,
2507+ sections : & [ arch :: x86_64 :: tdx :: TdvfSection ] ,
25122508 guid_found : bool ,
25132509 ) -> Result < Option < u64 > > {
25142510 use arch:: x86_64:: tdx:: * ;
@@ -2694,7 +2690,7 @@ impl Vm {
26942690 }
26952691
26962692 #[ cfg( feature = "tdx" ) ]
2697- fn init_tdx_memory ( & mut self , sections : & [ TdvfSection ] ) -> Result < ( ) > {
2693+ fn init_tdx_memory ( & mut self , sections : & [ arch :: x86_64 :: tdx :: TdvfSection ] ) -> Result < ( ) > {
26982694 let guest_memory = self . memory_manager . lock ( ) . as_ref ( ) . unwrap ( ) . guest_memory ( ) ;
26992695 let mem = guest_memory. memory ( ) ;
27002696
@@ -3703,12 +3699,12 @@ mod unit_tests {
37033699 fn test_hob_memory_resources ( ) {
37043700 // Case 1: Two TDVF sections in the middle of the RAM
37053701 let sections = vec ! [
3706- TdvfSection {
3702+ arch :: x86_64 :: tdx :: TdvfSection {
37073703 address: 0xc000 ,
37083704 size: 0x1000 ,
37093705 ..Default :: default ( )
37103706 } ,
3711- TdvfSection {
3707+ arch :: x86_64 :: tdx :: TdvfSection {
37123708 address: 0x1000 ,
37133709 size: 0x4000 ,
37143710 ..Default :: default ( )
@@ -3732,12 +3728,12 @@ mod unit_tests {
37323728
37333729 // Case 2: Two TDVF sections with no conflict with the RAM
37343730 let sections = vec ! [
3735- TdvfSection {
3731+ arch :: x86_64 :: tdx :: TdvfSection {
37363732 address: 0x1000_1000 ,
37373733 size: 0x1000 ,
37383734 ..Default :: default ( )
37393735 } ,
3740- TdvfSection {
3736+ arch :: x86_64 :: tdx :: TdvfSection {
37413737 address: 0 ,
37423738 size: 0x1000 ,
37433739 ..Default :: default ( )
@@ -3759,12 +3755,12 @@ mod unit_tests {
37593755
37603756 // Case 3: Two TDVF sections with partial conflicts with the RAM
37613757 let sections = vec ! [
3762- TdvfSection {
3758+ arch :: x86_64 :: tdx :: TdvfSection {
37633759 address: 0x1000_0000 ,
37643760 size: 0x2000 ,
37653761 ..Default :: default ( )
37663762 } ,
3767- TdvfSection {
3763+ arch :: x86_64 :: tdx :: TdvfSection {
37683764 address: 0 ,
37693765 size: 0x2000 ,
37703766 ..Default :: default ( )
@@ -3787,22 +3783,22 @@ mod unit_tests {
37873783 // Case 4: Two TDVF sections with no conflict before the RAM and two
37883784 // more additional sections with no conflict after the RAM.
37893785 let sections = vec ! [
3790- TdvfSection {
3786+ arch :: x86_64 :: tdx :: TdvfSection {
37913787 address: 0x2000_1000 ,
37923788 size: 0x1000 ,
37933789 ..Default :: default ( )
37943790 } ,
3795- TdvfSection {
3791+ arch :: x86_64 :: tdx :: TdvfSection {
37963792 address: 0x2000_0000 ,
37973793 size: 0x1000 ,
37983794 ..Default :: default ( )
37993795 } ,
3800- TdvfSection {
3796+ arch :: x86_64 :: tdx :: TdvfSection {
38013797 address: 0x1000 ,
38023798 size: 0x1000 ,
38033799 ..Default :: default ( )
38043800 } ,
3805- TdvfSection {
3801+ arch :: x86_64 :: tdx :: TdvfSection {
38063802 address: 0 ,
38073803 size: 0x1000 ,
38083804 ..Default :: default ( )
@@ -3825,7 +3821,7 @@ mod unit_tests {
38253821 ) ;
38263822
38273823 // Case 5: One TDVF section overriding the entire RAM
3828- let sections = vec ! [ TdvfSection {
3824+ let sections = vec ! [ arch :: x86_64 :: tdx :: TdvfSection {
38293825 address: 0 ,
38303826 size: 0x2000_0000 ,
38313827 ..Default :: default ( )
@@ -3842,12 +3838,12 @@ mod unit_tests {
38423838
38433839 // Case 6: Two TDVF sections with no conflict with 2 RAM regions
38443840 let sections = vec ! [
3845- TdvfSection {
3841+ arch :: x86_64 :: tdx :: TdvfSection {
38463842 address: 0x1000_2000 ,
38473843 size: 0x2000 ,
38483844 ..Default :: default ( )
38493845 } ,
3850- TdvfSection {
3846+ arch :: x86_64 :: tdx :: TdvfSection {
38513847 address: 0 ,
38523848 size: 0x2000 ,
38533849 ..Default :: default ( )
@@ -3873,12 +3869,12 @@ mod unit_tests {
38733869
38743870 // Case 7: Two TDVF sections with partial conflicts with 2 RAM regions
38753871 let sections = vec ! [
3876- TdvfSection {
3872+ arch :: x86_64 :: tdx :: TdvfSection {
38773873 address: 0x1000_0000 ,
38783874 size: 0x4000 ,
38793875 ..Default :: default ( )
38803876 } ,
3881- TdvfSection {
3877+ arch :: x86_64 :: tdx :: TdvfSection {
38823878 address: 0 ,
38833879 size: 0x4000 ,
38843880 ..Default :: default ( )
@@ -3974,8 +3970,6 @@ mod unit_tests {
39743970#[ cfg( target_arch = "aarch64" ) ]
39753971#[ cfg( test) ]
39763972mod unit_tests {
3977- use arch:: aarch64:: fdt:: create_fdt;
3978- use arch:: aarch64:: layout;
39793973 use arch:: { DeviceType , MmioDeviceInfo } ;
39803974 use devices:: gic:: Gic ;
39813975
@@ -3985,7 +3979,10 @@ mod unit_tests {
39853979
39863980 #[ test]
39873981 fn test_create_fdt_with_devices ( ) {
3988- let regions = vec ! [ ( layout:: RAM_START , ( layout:: FDT_MAX_SIZE + 0x1000 ) as usize ) ] ;
3982+ let regions = vec ! [ (
3983+ arch:: aarch64:: layout:: RAM_START ,
3984+ ( arch:: aarch64:: layout:: FDT_MAX_SIZE + 0x1000 ) as usize ,
3985+ ) ] ;
39893986 let mem = GuestMemoryMmap :: from_ranges ( & regions) . expect ( "Cannot initialize memory" ) ;
39903987
39913988 let dev_info: HashMap < ( DeviceType , String ) , MmioDeviceInfo > = [
@@ -4022,7 +4019,7 @@ mod unit_tests {
40224019 let vm = hv. create_vm ( HypervisorVmConfig :: default ( ) ) . unwrap ( ) ;
40234020 let vgic_config = Gic :: create_default_config ( 1 ) ;
40244021 let gic = vm. create_vgic ( & vgic_config) . expect ( "Cannot create gic" ) ;
4025- create_fdt (
4022+ arch :: aarch64 :: fdt :: create_fdt (
40264023 & mem,
40274024 "console=tty0" ,
40284025 & [ 0 ] ,
0 commit comments