@@ -876,19 +876,17 @@ impl<H: AxVCpuHal> VmxVcpu<H> {
876876/// Get ready then vmlaunch or vmresume.
877877macro_rules! vmx_entry_with {
878878 ( $instr: literal) => {
879- unsafe {
880- naked_asm!(
881- save_regs_to_stack!( ) , // save host status
882- "mov [rdi + {host_stack_size}], rsp" , // save current RSP to Vcpu::host_stack_top
883- "mov rsp, rdi" , // set RSP to guest regs area
884- restore_regs_from_stack!( ) , // restore guest status
885- $instr, // let's go!
886- "jmp {failed}" ,
887- host_stack_size = const size_of:: <GeneralRegisters >( ) ,
888- failed = sym Self :: vmx_entry_failed,
889- // options(noreturn),
890- )
891- }
879+ naked_asm!(
880+ save_regs_to_stack!( ) , // save host status
881+ "mov [rdi + {host_stack_size}], rsp" , // save current RSP to Vcpu::host_stack_top
882+ "mov rsp, rdi" , // set RSP to guest regs area
883+ restore_regs_from_stack!( ) , // restore guest status
884+ $instr, // let's go!
885+ "jmp {failed}" ,
886+ host_stack_size = const size_of:: <GeneralRegisters >( ) ,
887+ failed = sym Self :: vmx_entry_failed,
888+ // options(noreturn),
889+ )
892890 }
893891}
894892
@@ -920,15 +918,14 @@ impl<H: AxVCpuHal> VmxVcpu<H> {
920918 ///
921919 /// The return value is a dummy value.
922920 unsafe extern "C" fn vmx_exit ( & mut self ) -> usize {
923- unsafe {
924- naked_asm ! (
925- save_regs_to_stack!( ) , // save guest status, after this, rsp points to the `VmxVcpu`
926- "mov rsp, [rsp + {host_stack_top}]" , // set RSP to Vcpu::host_stack_top
927- restore_regs_from_stack!( ) , // restore host status
928- "ret" ,
929- host_stack_top = const size_of:: <GeneralRegisters >( ) ,
930- ) ;
931- }
921+ // it's not necessary to use another `unsafe` here, as Rust now do not require it in naked functions.
922+ naked_asm ! (
923+ save_regs_to_stack!( ) , // save guest status, after this, rsp points to the `VmxVcpu`
924+ "mov rsp, [rsp + {host_stack_top}]" , // set RSP to Vcpu::host_stack_top
925+ restore_regs_from_stack!( ) , // restore host status
926+ "ret" ,
927+ host_stack_top = const size_of:: <GeneralRegisters >( ) ,
928+ ) ;
932929 }
933930
934931 fn vmx_entry_failed ( ) -> ! {
@@ -1055,10 +1052,13 @@ impl<H: AxVCpuHal> VmxVcpu<H> {
10551052 }
10561053 } ;
10571054
1055+ // TODO: handle APIC access.
1056+ let _ = write;
1057+
1058+ self . advance_rip ( exit_info. exit_instruction_length as _ ) ?;
1059+
10581060 unimplemented ! ( "apic access" ) ;
10591061 // TODO
1060-
1061- self . advance_rip ( exit_info. exit_instruction_length as _ )
10621062 }
10631063
10641064 fn handle_vmx_preemption_timer ( & mut self ) -> AxResult {
0 commit comments