From a1e324cbfd365ffcf0139dae74484e9798d12805 Mon Sep 17 00:00:00 2001 From: Yonghua Huang Date: Mon, 7 May 2018 18:43:42 +0800 Subject: [PATCH] refine external interrupt VM exit handler - According to Intel SDM 24.9.2,Vol3, should check the validity of "VM-exit interruption information" before extracting the vector of interrupt. Signed-off-by: Yonghua Huang --- arch/x86/interrupt.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/x86/interrupt.c b/arch/x86/interrupt.c index 989e798ab..16b510517 100644 --- a/arch/x86/interrupt.c +++ b/arch/x86/interrupt.c @@ -266,16 +266,25 @@ int interrupt_window_vmexit_handler(struct vcpu *vcpu) int external_interrupt_vmexit_handler(struct vcpu *vcpu) { - int vector = exec_vmread(VMX_EXIT_INT_INFO) & 0xFF; + uint32_t intr_info; struct intr_ctx ctx; - ctx.vector = vector; + intr_info = exec_vmread(VMX_EXIT_INT_INFO); + if ((!(intr_info & VMX_INT_INFO_VALID)) || + (((intr_info & VMX_INT_TYPE_MASK) >> 8) + != VMX_INT_TYPE_EXT_INT)) { + pr_err("Invalid VM exit interrupt info:%x", intr_info); + VCPU_RETAIN_RIP(vcpu); + return -EINVAL; + } + + ctx.vector = intr_info & 0xFF; dispatch_interrupt(&ctx); VCPU_RETAIN_RIP(vcpu); - TRACE_2L(TRC_VMEXIT_EXTERNAL_INTERRUPT, vector, 0); + TRACE_2L(TRC_VMEXIT_EXTERNAL_INTERRUPT, ctx.vector, 0); return 0; }