11use core:: marker:: PhantomData ;
22
3- use aarch64_cpu:: registers:: { CNTHCTL_EL2 , HCR_EL2 , SP_EL0 , SPSR_EL1 , VTCR_EL2 } ;
3+ use aarch64_cpu:: registers:: * ;
44use axaddrspace:: { GuestPhysAddr , HostPhysAddr , device:: SysRegAddr } ;
55use axerrno:: AxResult ;
66use axvcpu:: { AxArchVCpu , AxVCpuExitReason , AxVCpuHal } ;
7- use tock_registers:: interfaces:: { ReadWriteable , Readable , Writeable } ;
87
98use crate :: TrapFrame ;
109use crate :: context_frame:: GuestSystemRegisters ;
@@ -75,7 +74,7 @@ impl<H: AxVCpuHal> axvcpu::AxArchVCpu for Aarch64VCpu<H> {
7574
7675 type SetupConfig = Aarch64VCpuSetupConfig ;
7776
78- fn new ( vm_id : usize , vcpu_id : usize , config : Self :: CreateConfig ) -> AxResult < Self > {
77+ fn new ( _vm_id : usize , _vcpu_id : usize , config : Self :: CreateConfig ) -> AxResult < Self > {
7978 let mut ctx = TrapFrame :: default ( ) ;
8079 ctx. set_argument ( config. dtb_addr ) ;
8180
@@ -94,13 +93,13 @@ impl<H: AxVCpuHal> axvcpu::AxArchVCpu for Aarch64VCpu<H> {
9493 }
9594
9695 fn set_entry ( & mut self , entry : GuestPhysAddr ) -> AxResult {
97- debug ! ( "set vcpu entry:{:?}" , entry ) ;
96+ debug ! ( "set vcpu entry:{entry :?}" ) ;
9897 self . set_elr ( entry. as_usize ( ) ) ;
9998 Ok ( ( ) )
10099 }
101100
102101 fn set_ept_root ( & mut self , ept_root : HostPhysAddr ) -> AxResult {
103- debug ! ( "set vcpu ept root:{:#x}" , ept_root ) ;
102+ debug ! ( "set vcpu ept root:{ept_root :#x}" ) ;
104103 self . guest_system_regs . vttbr_el2 = ept_root. as_usize ( ) as u64 ;
105104 Ok ( ( ) )
106105 }
@@ -237,7 +236,7 @@ impl<H: AxVCpuHal> Aarch64VCpu<H> {
237236 ///
238237 /// When a VM-Exit happens when guest's vCpu is running,
239238 /// the control flow will be redirected to this function through `return_run_guest`.
240- #[ naked]
239+ #[ unsafe ( naked) ]
241240 unsafe extern "C" fn run_guest ( & mut self ) -> usize {
242241 // Fixes: https://github.com/arceos-hypervisor/arm_vcpu/issues/22
243242 //
@@ -246,25 +245,23 @@ impl<H: AxVCpuHal> Aarch64VCpu<H> {
246245 // original `run_guest` with the current naked one, we eliminate the dummy code path of the
247246 // original version, and ensure that the compiler does not perform any unexpected return
248247 // value optimization.
249- unsafe {
250- core:: arch:: naked_asm!(
251- // Save host context.
252- save_regs_to_stack!( ) ,
253- // Save current host stack top to `self.host_stack_top`.
254- //
255- // 'extern "C"' here specifies the aapcs64 calling convention, according to which
256- // the first and only parameter, the pointer of self, should be in x0:
257- "mov x9, sp" ,
258- "add x0, x0, {host_stack_top_offset}" ,
259- "str x9, [x0]" ,
260- // Go to `context_vm_entry`.
261- "b context_vm_entry" ,
262- // Panic if the control flow comes back here, which should never happen.
263- "b {run_guest_panic}" ,
264- host_stack_top_offset = const core:: mem:: size_of:: <TrapFrame >( ) ,
265- run_guest_panic = sym Self :: run_guest_panic,
266- ) ;
267- }
248+ core:: arch:: naked_asm!(
249+ // Save host context.
250+ save_regs_to_stack!( ) ,
251+ // Save current host stack top to `self.host_stack_top`.
252+ //
253+ // 'extern "C"' here specifies the aapcs64 calling convention, according to which
254+ // the first and only parameter, the pointer of self, should be in x0:
255+ "mov x9, sp" ,
256+ "add x0, x0, {host_stack_top_offset}" ,
257+ "str x9, [x0]" ,
258+ // Go to `context_vm_entry`.
259+ "b context_vm_entry" ,
260+ // Panic if the control flow comes back here, which should never happen.
261+ "b {run_guest_panic}" ,
262+ host_stack_top_offset = const core:: mem:: size_of:: <TrapFrame >( ) ,
263+ run_guest_panic = sym Self :: run_guest_panic,
264+ ) ;
268265 }
269266
270267 /// This function is called when the control flow comes back to `run_guest`. To provide a error
@@ -342,7 +339,7 @@ impl<H: AxVCpuHal> Aarch64VCpu<H> {
342339 return Ok ( exit_reason) ;
343340 }
344341
345- return result;
342+ result
346343 }
347344 Ok ( AxVCpuExitReason :: SysRegWrite { addr, value } ) => {
348345 if let Some ( exit_reason) =
@@ -351,9 +348,9 @@ impl<H: AxVCpuHal> Aarch64VCpu<H> {
351348 return Ok ( exit_reason) ;
352349 }
353350
354- return result;
351+ result
355352 }
356- r => return r,
353+ r => r,
357354 }
358355 }
359356
@@ -371,7 +368,7 @@ impl<H: AxVCpuHal> Aarch64VCpu<H> {
371368
372369 match ( addr, write) {
373370 ( SYSREG_ICC_SGI1R_EL1 , true ) => {
374- debug ! ( "arm_vcpu ICC_SGI1R_EL1 write: {:#x}" , value ) ;
371+ debug ! ( "arm_vcpu ICC_SGI1R_EL1 write: {value :#x}" ) ;
375372
376373 // TODO: support RangeSelector
377374
@@ -397,8 +394,7 @@ impl<H: AxVCpuHal> Aarch64VCpu<H> {
397394 let target_list = value & 0xffff ;
398395
399396 debug ! (
400- "arm_vcpu ICC_SGI1R_EL1 write: aff3:{:#x} aff2:{:#x} aff1:{:#x} intid:{:#x} target_list:{:#x}" ,
401- aff3, aff2, aff1, intid, target_list
397+ "arm_vcpu ICC_SGI1R_EL1 write: aff3:{aff3:#x} aff2:{aff2:#x} aff1:{aff1:#x} intid:{intid:#x} target_list:{target_list:#x}"
402398 ) ;
403399
404400 Ok ( Some ( AxVCpuExitReason :: SendIPI {
0 commit comments