Skip to content

Commit 6788c09

Browse files
zhenggenlijinxia
authored andcommitted
hv: bug fix on operating spin_lock
In vioapic emulating code, the vioapic spinlock is taken twice in the same context. Signed-off-by: Zheng, Gen <gen.zheng@intel.com> Reviewed-by: Yin Fengwei <fengwei.yin@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com> Signed-off-by: Zheng, Gen <gen.zheng@intel.com>
1 parent ff05a6e commit 6788c09

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

hypervisor/arch/x86/guest/vioapic.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ vioapic_read(struct vioapic *vioapic, uint32_t addr)
266266
/*
267267
* version 0x20+ ioapic has EOI register. And cpu could write vector to this
268268
* register to clear related IRR.
269+
* Due to the race between vcpus, ensure to do VIOAPIC_LOCK(vioapic) &
270+
* VIOAPIC_UNLOCK(vioapic) by caller.
269271
*/
270272
static void
271273
vioapic_write_eoi(struct vioapic *vioapic, uint32_t vector)
@@ -278,7 +280,6 @@ vioapic_write_eoi(struct vioapic *vioapic, uint32_t vector)
278280
pr_err("vioapic_process_eoi: invalid vector %u", vector);
279281
}
280282

281-
VIOAPIC_LOCK(vioapic);
282283
pincount = vioapic_pincount(vm);
283284
for (pin = 0U; pin < pincount; pin++) {
284285
rte = vioapic->rtbl[pin];
@@ -298,9 +299,11 @@ vioapic_write_eoi(struct vioapic *vioapic, uint32_t vector)
298299
vioapic_send_intr(vioapic, pin);
299300
}
300301
}
301-
VIOAPIC_UNLOCK(vioapic);
302302
}
303303

304+
/* Due to the race between vcpus, ensure to do VIOAPIC_LOCK(vioapic) &
305+
* VIOAPIC_UNLOCK(vioapic) by caller.
306+
*/
304307
static void
305308
vioapic_write(struct vioapic *vioapic, uint32_t addr, uint32_t data)
306309
{
@@ -387,12 +390,9 @@ vioapic_write(struct vioapic *vioapic, uint32_t addr, uint32_t data)
387390
"ioapic pin%hhu: recalculate vlapic trigger-mode reg",
388391
pin);
389392

390-
VIOAPIC_UNLOCK(vioapic);
391-
392393
foreach_vcpu(i, vioapic->vm, vcpu) {
393394
vcpu_make_request(vcpu, ACRN_REQUEST_TMR_UPDATE);
394395
}
395-
VIOAPIC_LOCK(vioapic);
396396
}
397397

398398
/*

0 commit comments

Comments
 (0)