From 473d31c073e078841966da11f146c54d5f50d068 Mon Sep 17 00:00:00 2001 From: "Li, Fei1" Date: Mon, 4 Mar 2019 23:47:28 +0800 Subject: [PATCH] hv: vlapic: add vector check for x2apic SELF IPI Set when the local APIC detects an illegal vector (one in the range 0 to 15) in the message that it is sending. This occurs as the result of a write to the ICR (in both xAPIC and x2APIC modes) or to SELF IPI register (x2APIC mode only) with an illegal vector. Tracked-On: #1842 Signed-off-by: Li, Fei1 Acked-by: Eddie Dong --- hypervisor/arch/x86/guest/vlapic.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hypervisor/arch/x86/guest/vlapic.c b/hypervisor/arch/x86/guest/vlapic.c index c8689ba97..078587a50 100644 --- a/hypervisor/arch/x86/guest/vlapic.c +++ b/hypervisor/arch/x86/guest/vlapic.c @@ -2456,9 +2456,14 @@ static void vlapic_x2apic_self_ipi_handler(struct acrn_vlapic *vlapic) struct acrn_vcpu *target_vcpu; lapic = &(vlapic->apic_page); - vector = lapic->self_ipi.v & 0xFFU; + vector = lapic->self_ipi.v & APIC_VECTOR_MASK; target_vcpu = vlapic->vcpu; - vlapic_set_intr(target_vcpu, vector, LAPIC_TRIG_EDGE); + if (vector < 16U) { + vlapic_set_error(vlapic, APIC_ESR_SEND_ILLEGAL_VECTOR); + dev_dbg(ACRN_DBG_LAPIC, "Ignoring invalid IPI %u", vector); + } else { + vlapic_set_intr(target_vcpu, vector, LAPIC_TRIG_EDGE); + } } int32_t apic_write_vmexit_handler(struct acrn_vcpu *vcpu)