KVM: PPC: Move vcpu_load/vcpu_put down to each ioctl case in kvm_arch_vcpu_ioctl
Although we already have kvm_arch_vcpu_async_ioctl() which doesn't require ioctl to load vcpu, the sync ioctl code need to be cleaned up when CONFIG_HAVE_KVM_VCPU_ASYNC_IOCTL is not configured. This patch moves vcpu_load/vcpu_put down to each ioctl switch case so that each ioctl can decide to do vcpu_load/vcpu_put or not independently. Signed-off-by: Simon Guo <wei.guo.simon@gmail.com> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
This commit is contained in:
Родитель
d234d68eb7
Коммит
b3cebfe8c1
|
@ -1980,16 +1980,16 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
|
||||||
void __user *argp = (void __user *)arg;
|
void __user *argp = (void __user *)arg;
|
||||||
long r;
|
long r;
|
||||||
|
|
||||||
vcpu_load(vcpu);
|
|
||||||
|
|
||||||
switch (ioctl) {
|
switch (ioctl) {
|
||||||
case KVM_ENABLE_CAP:
|
case KVM_ENABLE_CAP:
|
||||||
{
|
{
|
||||||
struct kvm_enable_cap cap;
|
struct kvm_enable_cap cap;
|
||||||
r = -EFAULT;
|
r = -EFAULT;
|
||||||
|
vcpu_load(vcpu);
|
||||||
if (copy_from_user(&cap, argp, sizeof(cap)))
|
if (copy_from_user(&cap, argp, sizeof(cap)))
|
||||||
goto out;
|
goto out;
|
||||||
r = kvm_vcpu_ioctl_enable_cap(vcpu, &cap);
|
r = kvm_vcpu_ioctl_enable_cap(vcpu, &cap);
|
||||||
|
vcpu_put(vcpu);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1998,12 +1998,14 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
|
||||||
{
|
{
|
||||||
struct kvm_one_reg reg;
|
struct kvm_one_reg reg;
|
||||||
r = -EFAULT;
|
r = -EFAULT;
|
||||||
|
vcpu_load(vcpu);
|
||||||
if (copy_from_user(®, argp, sizeof(reg)))
|
if (copy_from_user(®, argp, sizeof(reg)))
|
||||||
goto out;
|
goto out;
|
||||||
if (ioctl == KVM_SET_ONE_REG)
|
if (ioctl == KVM_SET_ONE_REG)
|
||||||
r = kvm_vcpu_ioctl_set_one_reg(vcpu, ®);
|
r = kvm_vcpu_ioctl_set_one_reg(vcpu, ®);
|
||||||
else
|
else
|
||||||
r = kvm_vcpu_ioctl_get_one_reg(vcpu, ®);
|
r = kvm_vcpu_ioctl_get_one_reg(vcpu, ®);
|
||||||
|
vcpu_put(vcpu);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2011,9 +2013,11 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
|
||||||
case KVM_DIRTY_TLB: {
|
case KVM_DIRTY_TLB: {
|
||||||
struct kvm_dirty_tlb dirty;
|
struct kvm_dirty_tlb dirty;
|
||||||
r = -EFAULT;
|
r = -EFAULT;
|
||||||
|
vcpu_load(vcpu);
|
||||||
if (copy_from_user(&dirty, argp, sizeof(dirty)))
|
if (copy_from_user(&dirty, argp, sizeof(dirty)))
|
||||||
goto out;
|
goto out;
|
||||||
r = kvm_vcpu_ioctl_dirty_tlb(vcpu, &dirty);
|
r = kvm_vcpu_ioctl_dirty_tlb(vcpu, &dirty);
|
||||||
|
vcpu_put(vcpu);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -2022,7 +2026,6 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
vcpu_put(vcpu);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче