hv: Add check to ensure vcpu_make_request and signal_event are

consistent

Currently the vcpu_make_request and signal_event in vcpu_lock_instr_emulation
does not check whether target VCPU is up and running. This can cause
problems because when VCPU is created but not launched,
vcpu_make_request will not trigger wait_event on target VCPU, but
signal_event may still execute to reduce the counter.

This patch adds a check before vcpu_make_request and signal_event to
make sure the request and signal are issued after target VCPU is up.

Tracked-On: #6502
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
This commit is contained in:
Yifan Liu 2021-08-27 13:59:27 +08:00 committed by wenlingz
parent 25ed86e28f
commit e51837f96d
2 changed files with 3 additions and 3 deletions

View File

@ -45,7 +45,7 @@ void vcpu_kick_lock_instr_emulation(struct acrn_vcpu *cur_vcpu)
get_vm_lock(cur_vcpu->vm);
foreach_vcpu(i, cur_vcpu->vm, other) {
if (other != cur_vcpu) {
if ((other != cur_vcpu) && (other->state == VCPU_RUNNING)) {
vcpu_make_request(other, ACRN_REQUEST_SPLIT_LOCK);
}
}
@ -59,7 +59,7 @@ void vcpu_complete_lock_instr_emulation(struct acrn_vcpu *cur_vcpu)
if (cur_vcpu->vm->hw.created_vcpus > 1U) {
foreach_vcpu(i, cur_vcpu->vm, other) {
if (other != cur_vcpu) {
if ((other != cur_vcpu) && (other->state == VCPU_RUNNING)) {
signal_event(&other->events[VCPU_EVENT_SPLIT_LOCK]);
}
}

View File

@ -4,7 +4,7 @@
struct sched_event {
spinlock_t lock;
int8_t nqueued;
int32_t nqueued;
struct thread_object* waiting_thread;
};