Skip to content

Commit cfb2828

Browse files
fyin1lijinxia
authored andcommitted
hv: Avoid inject the same int to target vcpu multiple times
Once the specific interrupt is marked waiting for inject to target vcpu, we don't need to mark it again if the same interrupt is request to inject to same target vcpu. One example is UP SOS + SMP UOS. It's possible that different core of UOS try to notify SOS vcpu that there is ioreq pending. Signed-off-by: Yin Fengwei <fengwei.yin@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent fdd785d commit cfb2828

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

hypervisor/arch/x86/guest/vlapic.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ vlapic_set_intr_ready(struct vlapic *vlapic, uint32_t vector, bool level)
434434
struct lapic_regs *lapic;
435435
struct lapic_reg *irrptr, *tmrptr;
436436
uint32_t mask;
437-
int idx;
437+
uint32_t idx;
438438

439439
ASSERT(vector <= NR_MAX_VECTOR,
440440
"invalid vector %d", vector);
@@ -447,7 +447,7 @@ vlapic_set_intr_ready(struct vlapic *vlapic, uint32_t vector, bool level)
447447
return 0;
448448
}
449449

450-
if (vector < 16) {
450+
if (vector < 16U) {
451451
vlapic_set_error(vlapic, APIC_ESR_RECEIVE_ILLEGAL_VECTOR);
452452
dev_dbg(ACRN_DBG_LAPIC,
453453
"vlapic ignoring interrupt to vector %d", vector);
@@ -458,11 +458,12 @@ vlapic_set_intr_ready(struct vlapic *vlapic, uint32_t vector, bool level)
458458
return (*vlapic->ops.apicv_set_intr_ready)
459459
(vlapic, vector, level);
460460

461-
idx = vector / 32;
462-
mask = 1 << (vector % 32);
461+
idx = vector / 32U;
463462

464463
irrptr = &lapic->irr[0];
465-
atomic_set_int(&irrptr[idx].val, mask);
464+
/* If the interrupt is set, don't try to do it again */
465+
if (bitmap32_test_and_set((vector % 32U), &irrptr[idx].val))
466+
return 0;
466467

467468
/*
468469
* Verify that the trigger-mode of the interrupt matches with

0 commit comments

Comments
 (0)