if (mutex_lock_killable(&vcpu->mutex))
return -EINTR;
- vcpu_load(vcpu);
switch (ioctl) {
case KVM_RUN: {
struct pid *oldpid;
r = -EINVAL;
if (arg)
goto out;
+ vcpu_load(vcpu);
oldpid = rcu_access_pointer(vcpu->pid);
if (unlikely(oldpid != current->pids[PIDTYPE_PID].pid)) {
/* The thread running this VCPU changed. */
put_pid(oldpid);
}
r = kvm_arch_vcpu_ioctl_run(vcpu, vcpu->run);
+ vcpu_put(vcpu);
trace_kvm_userspace_exit(vcpu->run->exit_reason, r);
break;
}
kvm_regs = kzalloc(sizeof(struct kvm_regs), GFP_KERNEL);
if (!kvm_regs)
goto out;
+ vcpu_load(vcpu);
r = kvm_arch_vcpu_ioctl_get_regs(vcpu, kvm_regs);
+ vcpu_put(vcpu);
if (r)
goto out_free1;
r = -EFAULT;
r = PTR_ERR(kvm_regs);
goto out;
}
+ vcpu_load(vcpu);
r = kvm_arch_vcpu_ioctl_set_regs(vcpu, kvm_regs);
+ vcpu_put(vcpu);
kfree(kvm_regs);
break;
}
r = -ENOMEM;
if (!kvm_sregs)
goto out;
+ vcpu_load(vcpu);
r = kvm_arch_vcpu_ioctl_get_sregs(vcpu, kvm_sregs);
+ vcpu_put(vcpu);
if (r)
goto out;
r = -EFAULT;
kvm_sregs = NULL;
goto out;
}
+ vcpu_load(vcpu);
r = kvm_arch_vcpu_ioctl_set_sregs(vcpu, kvm_sregs);
+ vcpu_put(vcpu);
break;
}
case KVM_GET_MP_STATE: {
struct kvm_mp_state mp_state;
+ vcpu_load(vcpu);
r = kvm_arch_vcpu_ioctl_get_mpstate(vcpu, &mp_state);
+ vcpu_put(vcpu);
if (r)
goto out;
r = -EFAULT;
r = -EFAULT;
if (copy_from_user(&mp_state, argp, sizeof(mp_state)))
goto out;
+ vcpu_load(vcpu);
r = kvm_arch_vcpu_ioctl_set_mpstate(vcpu, &mp_state);
+ vcpu_put(vcpu);
break;
}
case KVM_TRANSLATE: {
r = -EFAULT;
if (copy_from_user(&tr, argp, sizeof(tr)))
goto out;
+ vcpu_load(vcpu);
r = kvm_arch_vcpu_ioctl_translate(vcpu, &tr);
+ vcpu_put(vcpu);
if (r)
goto out;
r = -EFAULT;
r = -EFAULT;
if (copy_from_user(&dbg, argp, sizeof(dbg)))
goto out;
+ vcpu_load(vcpu);
r = kvm_arch_vcpu_ioctl_set_guest_debug(vcpu, &dbg);
+ vcpu_put(vcpu);
break;
}
case KVM_SET_SIGNAL_MASK: {
r = -ENOMEM;
if (!fpu)
goto out;
+ vcpu_load(vcpu);
r = kvm_arch_vcpu_ioctl_get_fpu(vcpu, fpu);
+ vcpu_put(vcpu);
if (r)
goto out;
r = -EFAULT;
fpu = NULL;
goto out;
}
+ vcpu_load(vcpu);
r = kvm_arch_vcpu_ioctl_set_fpu(vcpu, fpu);
+ vcpu_put(vcpu);
break;
}
default:
+ vcpu_load(vcpu);
r = kvm_arch_vcpu_ioctl(filp, ioctl, arg);
+ vcpu_put(vcpu);
}
out:
- vcpu_put(vcpu);
mutex_unlock(&vcpu->mutex);
kfree(fpu);
kfree(kvm_sregs);