|
@@ -124,15 +124,6 @@ int vcpu_load(struct kvm_vcpu *vcpu)
|
|
|
|
|
|
if (mutex_lock_killable(&vcpu->mutex))
|
|
|
return -EINTR;
|
|
|
- if (unlikely(vcpu->pid != current->pids[PIDTYPE_PID].pid)) {
|
|
|
- /* The thread running this VCPU changed. */
|
|
|
- struct pid *oldpid = vcpu->pid;
|
|
|
- struct pid *newpid = get_task_pid(current, PIDTYPE_PID);
|
|
|
- rcu_assign_pointer(vcpu->pid, newpid);
|
|
|
- if (oldpid)
|
|
|
- synchronize_rcu();
|
|
|
- put_pid(oldpid);
|
|
|
- }
|
|
|
cpu = get_cpu();
|
|
|
preempt_notifier_register(&vcpu->preempt_notifier);
|
|
|
kvm_arch_vcpu_load(vcpu, cpu);
|
|
@@ -2050,6 +2041,15 @@ static long kvm_vcpu_ioctl(struct file *filp,
|
|
|
r = -EINVAL;
|
|
|
if (arg)
|
|
|
goto out;
|
|
|
+ if (unlikely(vcpu->pid != current->pids[PIDTYPE_PID].pid)) {
|
|
|
+ /* The thread running this VCPU changed. */
|
|
|
+ struct pid *oldpid = vcpu->pid;
|
|
|
+ struct pid *newpid = get_task_pid(current, PIDTYPE_PID);
|
|
|
+ rcu_assign_pointer(vcpu->pid, newpid);
|
|
|
+ if (oldpid)
|
|
|
+ synchronize_rcu();
|
|
|
+ put_pid(oldpid);
|
|
|
+ }
|
|
|
r = kvm_arch_vcpu_ioctl_run(vcpu, vcpu->run);
|
|
|
trace_kvm_userspace_exit(vcpu->run->exit_reason, r);
|
|
|
break;
|