Skip to content

Commit 473d31c

Browse files
lifeixwenlingz
authored andcommitted
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 <fei1.li@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent e5d3a49 commit 473d31c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

hypervisor/arch/x86/guest/vlapic.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2456,9 +2456,14 @@ static void vlapic_x2apic_self_ipi_handler(struct acrn_vlapic *vlapic)
24562456
struct acrn_vcpu *target_vcpu;
24572457

24582458
lapic = &(vlapic->apic_page);
2459-
vector = lapic->self_ipi.v & 0xFFU;
2459+
vector = lapic->self_ipi.v & APIC_VECTOR_MASK;
24602460
target_vcpu = vlapic->vcpu;
2461-
vlapic_set_intr(target_vcpu, vector, LAPIC_TRIG_EDGE);
2461+
if (vector < 16U) {
2462+
vlapic_set_error(vlapic, APIC_ESR_SEND_ILLEGAL_VECTOR);
2463+
dev_dbg(ACRN_DBG_LAPIC, "Ignoring invalid IPI %u", vector);
2464+
} else {
2465+
vlapic_set_intr(target_vcpu, vector, LAPIC_TRIG_EDGE);
2466+
}
24622467
}
24632468

24642469
int32_t apic_write_vmexit_handler(struct acrn_vcpu *vcpu)

0 commit comments

Comments
 (0)