From 9a604ed00e97a278361705ea9a9650e724da2835 Mon Sep 17 00:00:00 2001 From: Jason Chen CJ Date: Mon, 28 May 2018 13:50:02 +0800 Subject: [PATCH] correct idt_vectoring_info handling filter out HW exception and NMI from idt_vectoring_info first: - queue HW exception through vcpu_queue_exception - make NMI request through vcpu_make_request this is a complement patch for previous commit "exception: refine exception injection path", here take care un-injected vectors for types HW exception & NMI, the previous commit take care SW exception & external interrupt. Signed-off-by: Jason Chen CJ Acked-by: Tian, Kevin --- hypervisor/arch/x86/vmexit.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hypervisor/arch/x86/vmexit.c b/hypervisor/arch/x86/vmexit.c index cba82e4ea5..d5af63f8c3 100644 --- a/hypervisor/arch/x86/vmexit.c +++ b/hypervisor/arch/x86/vmexit.c @@ -166,6 +166,23 @@ int vmexit_handler(struct vcpu *vcpu) /* Obtain interrupt info */ vcpu->arch_vcpu.idt_vectoring_info = exec_vmread(VMX_IDT_VEC_INFO_FIELD); + /* Filter out HW exception & NMI */ + if (vcpu->arch_vcpu.idt_vectoring_info & VMX_INT_INFO_VALID) { + uint32_t vector_info = vcpu->arch_vcpu.idt_vectoring_info; + uint32_t vector = vector_info & 0xff; + uint32_t type = (vector_info & VMX_INT_TYPE_MASK) >> 8; + uint32_t err_code = 0; + + if (type == VMX_INT_TYPE_HW_EXP) { + if (vector_info & VMX_INT_INFO_ERR_CODE_VALID) + err_code = exec_vmread(VMX_IDT_VEC_ERROR_CODE); + vcpu_queue_exception(vcpu, vector, err_code); + vcpu->arch_vcpu.idt_vectoring_info = 0; + } else if (type == VMX_INT_TYPE_NMI) { + vcpu_make_request(vcpu, ACRN_REQUEST_NMI); + vcpu->arch_vcpu.idt_vectoring_info = 0; + } + } /* Calculate basic exit reason (low 16-bits) */ basic_exit_reason = vcpu->arch_vcpu.exit_reason & 0xFFFF;