static
int
vmx_handle_exit(struct kvm_vcpu
*
vcpu, fastpath_t exit_fastpath)
{
int
ret
=
__vmx_handle_exit(vcpu, exit_fastpath);
/
/
...
return
ret;
}
static
int
__vmx_handle_exit(struct kvm_vcpu
*
vcpu, fastpath_t exit_fastpath)
{
/
/
...
exit_handler_index
=
array_index_nospec((u16)exit_reason.basic,
kvm_vmx_max_exit_handlers);
return
kvm_vmx_exit_handlers[exit_handler_index](vcpu);
}
/
/
退出处理例程返回<
=
0
,表示异常需要到用户层qemu进行进一步处理
/
/
退出处理例程返回值>
0
,表示内核层已经处理完,可继续执行
static
int
(
*
kvm_vmx_exit_handlers[])(struct kvm_vcpu
*
vcpu)
=
{
[EXIT_REASON_EXCEPTION_NMI]
=
handle_exception_nmi,
[EXIT_REASON_EXTERNAL_INTERRUPT]
=
handle_external_interrupt,
[EXIT_REASON_TRIPLE_FAULT]
=
handle_triple_fault,
[EXIT_REASON_NMI_WINDOW]
=
handle_nmi_window,
[EXIT_REASON_IO_INSTRUCTION]
=
handle_io,
[EXIT_REASON_CR_ACCESS]
=
handle_cr,
[EXIT_REASON_DR_ACCESS]
=
handle_dr,
[EXIT_REASON_CPUID]
=
kvm_emulate_cpuid,
[EXIT_REASON_MSR_READ]
=
kvm_emulate_rdmsr,
[EXIT_REASON_MSR_WRITE]
=
kvm_emulate_wrmsr,
[EXIT_REASON_INTERRUPT_WINDOW]
=
handle_interrupt_window,
[EXIT_REASON_HLT]
=
kvm_emulate_halt,
[EXIT_REASON_INVD]
=
kvm_emulate_invd,
[EXIT_REASON_INVLPG]
=
handle_invlpg,
[EXIT_REASON_RDPMC]
=
kvm_emulate_rdpmc,
[EXIT_REASON_VMCALL]
=
kvm_emulate_hypercall,
[EXIT_REASON_VMCLEAR]
=
handle_vmx_instruction,
[EXIT_REASON_VMLAUNCH]
=
handle_vmx_instruction,
[EXIT_REASON_VMPTRLD]
=
handle_vmx_instruction,
[EXIT_REASON_VMPTRST]
=
handle_vmx_instruction,
[EXIT_REASON_VMREAD]
=
handle_vmx_instruction,
[EXIT_REASON_VMRESUME]
=
handle_vmx_instruction,
[EXIT_REASON_VMWRITE]
=
handle_vmx_instruction,
[EXIT_REASON_VMOFF]
=
handle_vmx_instruction,
[EXIT_REASON_VMON]
=
handle_vmx_instruction,
[EXIT_REASON_TPR_BELOW_THRESHOLD]
=
handle_tpr_below_threshold,
[EXIT_REASON_APIC_ACCESS]
=
handle_apic_access,
[EXIT_REASON_APIC_WRITE]
=
handle_apic_write,
[EXIT_REASON_EOI_INDUCED]
=
handle_apic_eoi_induced,
[EXIT_REASON_WBINVD]
=
kvm_emulate_wbinvd,
[EXIT_REASON_XSETBV]
=
kvm_emulate_xsetbv,
[EXIT_REASON_TASK_SWITCH]
=
handle_task_switch,
[EXIT_REASON_MCE_DURING_VMENTRY]
=
handle_machine_check,
[EXIT_REASON_GDTR_IDTR]
=
handle_desc,
[EXIT_REASON_LDTR_TR]
=
handle_desc,
[EXIT_REASON_EPT_VIOLATION]
=
handle_ept_violation,
[EXIT_REASON_EPT_MISCONFIG]
=
handle_ept_misconfig,
[EXIT_REASON_PAUSE_INSTRUCTION]
=
handle_pause,
[EXIT_REASON_MWAIT_INSTRUCTION]
=
kvm_emulate_mwait,
[EXIT_REASON_MONITOR_TRAP_FLAG]
=
handle_monitor_trap,
[EXIT_REASON_MONITOR_INSTRUCTION]
=
kvm_emulate_monitor,
[EXIT_REASON_INVEPT]
=
handle_vmx_instruction,
[EXIT_REASON_INVVPID]
=
handle_vmx_instruction,
[EXIT_REASON_RDRAND]
=
kvm_handle_invalid_op,
[EXIT_REASON_RDSEED]
=
kvm_handle_invalid_op,
[EXIT_REASON_PML_FULL]
=
handle_pml_full,
[EXIT_REASON_INVPCID]
=
handle_invpcid,
[EXIT_REASON_VMFUNC]
=
handle_vmx_instruction,
[EXIT_REASON_PREEMPTION_TIMER]
=
handle_preemption_timer,
[EXIT_REASON_ENCLS]
=
handle_encls,
[EXIT_REASON_BUS_LOCK]
=
handle_bus_lock_vmexit,
};