@@ -1804,7 +1804,11 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu,
{
int r;
+ r = vcpu_load(vcpu);
+ if (r)
+ return r;
r = kvmppc_core_vcpu_translate(vcpu, tr);
+ vcpu_put(vcpu);
return r;
}
@@ -7654,6 +7654,11 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu,
unsigned long vaddr = tr->linear_address;
gpa_t gpa;
int idx;
+ int r;
+
+ r = vcpu_load(vcpu);
+ if (r)
+ return r;
idx = srcu_read_lock(&vcpu->kvm->srcu);
gpa = kvm_mmu_gva_to_gpa_system(vcpu, vaddr, NULL);
@@ -7663,6 +7668,7 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu,
tr->writeable = 1;
tr->usermode = 0;
+ vcpu_put(vcpu);
return 0;
}
@@ -2635,11 +2635,7 @@ static long kvm_vcpu_ioctl(struct file *filp,
r = -EFAULT;
if (copy_from_user(&tr, argp, sizeof(tr)))
goto out;
- r = vcpu_load(vcpu);
- if (r)
- goto out;
r = kvm_arch_vcpu_ioctl_translate(vcpu, &tr);
- vcpu_put(vcpu);
if (r)
goto out;
r = -EFAULT;
Move vcpu_load() and vcpu_put() into the architecture specific implementations of kvm_arch_vcpu_ioctl_translate(). Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org> --- arch/powerpc/kvm/booke.c | 4 ++++ arch/x86/kvm/x86.c | 6 ++++++ virt/kvm/kvm_main.c | 4 ---- 3 files changed, 10 insertions(+), 4 deletions(-)