add lock for vcpu state access
keep the global variables access exclusive in vcpu pause & resume.
Signed-]off-by: Minggui Cao
Acked-by: Eddie Dong
@@ -280,10 +280,10 @@ void pause_vcpu(struct vcpu *vcpu, enum vcpu_state new_state)
pr_dbg("vcpu%d paused, new state: %d",
vcpu->vcpu_id, new_state);
+ get_schedule_lock(vcpu->pcpu_id);
vcpu->prev_state = vcpu->state;
vcpu->state = new_state;
- get_schedule_lock(vcpu->pcpu_id);
if (atomic_load(&vcpu->running) == 1) {
remove_vcpu_from_runqueue(vcpu);
make_reschedule_request(vcpu);
@@ -303,9 +303,9 @@ void resume_vcpu(struct vcpu *vcpu)
{
pr_dbg("vcpu%d resumed", vcpu->vcpu_id);
+ get_schedule_lock(vcpu->pcpu_id);
vcpu->state = vcpu->prev_state;
- get_schedule_lock(vcpu->pcpu_id);
if (vcpu->state == VCPU_RUNNING) {
add_vcpu_to_runqueue(vcpu);
make_reschedule_request(vcpu);
