From f0d2291fe2acc87918d8e2c65042602163c8132c Mon Sep 17 00:00:00 2001 From: Yu Wang Date: Wed, 1 Aug 2018 08:31:23 +0000 Subject: [PATCH] hv: vioapic: check vector prior to irr in EOI write emulation Check the vector first to avoid unnecessary irr check. Signed-off-by: Yu Wang Acked-by: Anthony Xu --- hypervisor/arch/x86/guest/vioapic.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/hypervisor/arch/x86/guest/vioapic.c b/hypervisor/arch/x86/guest/vioapic.c index e524a702e..11df521eb 100644 --- a/hypervisor/arch/x86/guest/vioapic.c +++ b/hypervisor/arch/x86/guest/vioapic.c @@ -284,10 +284,8 @@ vioapic_write_eoi(struct vioapic *vioapic, uint32_t vector) for (pin = 0U; pin < pincount; pin++) { rte = vioapic->rtbl[pin]; - if ((rte.full & IOAPIC_RTE_REM_IRR) == 0UL) { - continue; - } - if ((rte.u.lo_32 & IOAPIC_RTE_LOW_INTVEC) != vector) { + if (((rte.u.lo_32 & IOAPIC_RTE_LOW_INTVEC) != vector) || + ((rte.full & IOAPIC_RTE_REM_IRR) == 0UL)) { continue; } @@ -492,12 +490,11 @@ vioapic_process_eoi(struct vm *vm, uint32_t vector) /* notify device to ack if assigned pin */ for (pin = 0U; pin < pincount; pin++) { rte = vioapic->rtbl[pin]; - if ((rte.full & IOAPIC_RTE_REM_IRR) == 0UL) { - continue; - } - if ((rte.u.lo_32 & IOAPIC_RTE_LOW_INTVEC) != vector) { + if (((rte.u.lo_32 & IOAPIC_RTE_LOW_INTVEC) != vector) || + ((rte.full & IOAPIC_RTE_REM_IRR) == 0UL)) { continue; } + ptdev_intx_ack(vm, pin, PTDEV_VPIN_IOAPIC); } @@ -508,10 +505,8 @@ vioapic_process_eoi(struct vm *vm, uint32_t vector) VIOAPIC_LOCK(vioapic); for (pin = 0U; pin < pincount; pin++) { rte = vioapic->rtbl[pin]; - if ((rte.full & IOAPIC_RTE_REM_IRR) == 0UL) { - continue; - } - if ((rte.u.lo_32 & IOAPIC_RTE_LOW_INTVEC) != vector) { + if (((rte.u.lo_32 & IOAPIC_RTE_LOW_INTVEC) != vector) || + ((rte.full & IOAPIC_RTE_REM_IRR) == 0UL)) { continue; }