diff --git a/hypervisor/arch/x86/virq.c b/hypervisor/arch/x86/virq.c index bae90339f..e800b7838 100644 --- a/hypervisor/arch/x86/virq.c +++ b/hypervisor/arch/x86/virq.c @@ -282,22 +282,26 @@ static int vcpu_inject_lo_exception(struct vcpu *vcpu) return 0; } +/* Inject external interrupt to guest */ void vcpu_inject_extint(struct vcpu *vcpu) { vcpu_make_request(vcpu, ACRN_REQUEST_EXTINT); } +/* Inject NMI to guest */ void vcpu_inject_nmi(struct vcpu *vcpu) { vcpu_make_request(vcpu, ACRN_REQUEST_NMI); } +/* Inject general protection exception(#GP) to guest */ void vcpu_inject_gp(struct vcpu *vcpu, uint32_t err_code) { vcpu_queue_exception(vcpu, IDT_GP, err_code); vcpu_make_request(vcpu, ACRN_REQUEST_EXCP); } +/* Inject page fault exception(#PF) to guest */ void vcpu_inject_pf(struct vcpu *vcpu, uint64_t addr, uint32_t err_code) { vcpu_set_cr2(vcpu, addr); @@ -305,6 +309,27 @@ void vcpu_inject_pf(struct vcpu *vcpu, uint64_t addr, uint32_t err_code) vcpu_make_request(vcpu, ACRN_REQUEST_EXCP); } +/* Inject invalid opcode exception(#UD) to guest */ +void vcpu_inject_ud(struct vcpu *vcpu) +{ + vcpu_queue_exception(vcpu, IDT_UD, 0); + vcpu_make_request(vcpu, ACRN_REQUEST_EXCP); +} + +/* Inject alignment check exception(#AC) to guest */ +void vcpu_inject_ac(struct vcpu *vcpu) +{ + vcpu_queue_exception(vcpu, IDT_AC, 0); + vcpu_make_request(vcpu, ACRN_REQUEST_EXCP); +} + +/* Inject stack fault exception(#SS) to guest */ +void vcpu_inject_ss(struct vcpu *vcpu) +{ + vcpu_queue_exception(vcpu, IDT_SS, 0); + vcpu_make_request(vcpu, ACRN_REQUEST_EXCP); +} + int interrupt_window_vmexit_handler(struct vcpu *vcpu) { uint32_t value32; diff --git a/hypervisor/include/arch/x86/irq.h b/hypervisor/include/arch/x86/irq.h index 7a677a3fe..fd8bba655 100644 --- a/hypervisor/include/arch/x86/irq.h +++ b/hypervisor/include/arch/x86/irq.h @@ -84,6 +84,9 @@ void vcpu_inject_extint(struct vcpu *vcpu); void vcpu_inject_nmi(struct vcpu *vcpu); void vcpu_inject_gp(struct vcpu *vcpu, uint32_t err_code); void vcpu_inject_pf(struct vcpu *vcpu, uint64_t addr, uint32_t err_code); +void vcpu_inject_ud(struct vcpu *vcpu); +void vcpu_inject_ac(struct vcpu *vcpu); +void vcpu_inject_ss(struct vcpu *vcpu); void vcpu_make_request(struct vcpu *vcpu, uint16_t eventid); int vcpu_queue_exception(struct vcpu *vcpu, uint32_t vector, uint32_t err_code);