Skip to content

Commit e8d5a49

Browse files
yonghuahjren1
authored andcommitted
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 <yonghua.huang@intel.com>
1 parent 121d14a commit e8d5a49

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

hypervisor/arch/x86/interrupt.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,25 @@ int interrupt_window_vmexit_handler(struct vcpu *vcpu)
266266

267267
int external_interrupt_vmexit_handler(struct vcpu *vcpu)
268268
{
269-
int vector = exec_vmread(VMX_EXIT_INT_INFO) & 0xFF;
269+
uint32_t intr_info;
270270
struct intr_ctx ctx;
271271

272-
ctx.vector = vector;
272+
intr_info = exec_vmread(VMX_EXIT_INT_INFO);
273+
if ((!(intr_info & VMX_INT_INFO_VALID)) ||
274+
(((intr_info & VMX_INT_TYPE_MASK) >> 8)
275+
!= VMX_INT_TYPE_EXT_INT)) {
276+
pr_err("Invalid VM exit interrupt info:%x", intr_info);
277+
VCPU_RETAIN_RIP(vcpu);
278+
return -EINVAL;
279+
}
280+
281+
ctx.vector = intr_info & 0xFF;
273282

274283
dispatch_interrupt(&ctx);
275284

276285
VCPU_RETAIN_RIP(vcpu);
277286

278-
TRACE_2L(TRC_VMEXIT_EXTERNAL_INTERRUPT, vector, 0);
287+
TRACE_2L(TRC_VMEXIT_EXTERNAL_INTERRUPT, ctx.vector, 0);
279288

280289
return 0;
281290
}

0 commit comments

Comments
 (0)