@@ -29,11 +29,13 @@ use axvcpu::{AxVCpu, AxVCpuExitReason, AxVCpuHal};
2929use cpumask:: CpuMask ;
3030
3131use crate :: config:: { AxVMConfig , PhysCpuList } ;
32- use crate :: vcpu:: { AxArchVCpuImpl , AxVCpuCreateConfig } ;
32+ use crate :: vcpu:: AxArchVCpuImpl ;
3333use crate :: { AxVMHal , has_hardware_support} ;
3434
35+ #[ cfg( target_arch = "riscv64" ) ]
36+ use crate :: vcpu:: AxVCpuCreateConfig ;
3537#[ cfg( target_arch = "aarch64" ) ]
36- use crate :: vcpu:: get_sysreg_device;
38+ use crate :: vcpu:: { AxVCpuCreateConfig , get_sysreg_device} ;
3739
3840const VM_ASPACE_BASE : usize = 0x0 ;
3941const VM_ASPACE_SIZE : usize = 0x7fff_ffff_f000 ;
@@ -202,15 +204,18 @@ impl<H: AxVMHal, U: AxVCpuHal> AxVM<H, U> {
202204 hart_id : vcpu_id as _ ,
203205 dtb_addr : dtb_addr. unwrap_or_default ( ) . as_usize ( ) ,
204206 } ;
205- #[ cfg( target_arch = "x86_64" ) ]
206- let arch_config = AxVCpuCreateConfig :: default ( ) ;
207207
208208 vcpu_list. push ( Arc :: new ( VCpu :: new (
209209 self . id ( ) ,
210210 vcpu_id,
211211 0 , // Currently not used.
212212 phys_cpu_set,
213+ #[ cfg( target_arch = "aarch64" ) ]
213214 arch_config,
215+ #[ cfg( target_arch = "riscv64" ) ]
216+ arch_config,
217+ #[ cfg( target_arch = "x86_64" ) ]
218+ ( ) ,
214219 ) ?) ) ;
215220 }
216221
@@ -273,9 +278,14 @@ impl<H: AxVMHal, U: AxVCpuHal> AxVM<H, U> {
273278 ) ?;
274279 }
275280
281+ #[ cfg( target_arch = "aarch64" ) ]
276282 let mut devices = axdevice:: AxVmDevices :: new ( AxVmDeviceConfig {
277283 emu_configs : inner_mut. config . emu_devices ( ) . to_vec ( ) ,
278284 } ) ;
285+ #[ cfg( not( target_arch = "aarch64" ) ) ]
286+ let devices = axdevice:: AxVmDevices :: new ( AxVmDeviceConfig {
287+ emu_configs : inner_mut. config . emu_devices ( ) . to_vec ( ) ,
288+ } ) ;
279289
280290 #[ cfg( target_arch = "aarch64" ) ]
281291 {
@@ -336,8 +346,6 @@ impl<H: AxVMHal, U: AxVCpuHal> AxVM<H, U> {
336346 passthrough_timer : passthrough,
337347 }
338348 } ;
339- #[ cfg( not( target_arch = "aarch64" ) ) ]
340- let setup_config = <AxArchVCpuImpl < U > as axvcpu:: AxArchVCpu >:: SetupConfig :: default ( ) ;
341349
342350 let entry = if vcpu. id ( ) == 0 {
343351 inner_mut. config . bsp_entry ( )
@@ -350,7 +358,10 @@ impl<H: AxVMHal, U: AxVCpuHal> AxVM<H, U> {
350358 vcpu. setup (
351359 entry,
352360 inner_mut. address_space . page_table_root ( ) ,
361+ #[ cfg( target_arch = "aarch64" ) ]
353362 setup_config,
363+ #[ cfg( not( target_arch = "aarch64" ) ) ]
364+ ( ) ,
354365 ) ?;
355366 }
356367 info ! ( "VM setup: id={}" , self . id( ) ) ;
@@ -639,7 +650,10 @@ impl<H: AxVMHal, U: AxVCpuHal> AxVM<H, U> {
639650 let size = core:: mem:: size_of :: < T > ( ) ;
640651
641652 // Ensure the address is properly aligned for the type.
642- if gpa_ptr. as_usize ( ) % core:: mem:: align_of :: < T > ( ) != 0 {
653+ if !gpa_ptr
654+ . as_usize ( )
655+ . is_multiple_of ( core:: mem:: align_of :: < T > ( ) )
656+ {
643657 return ax_err ! ( InvalidInput , "Unaligned guest physical address" ) ;
644658 }
645659
0 commit comments