KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_regs
authorChristoffer Dall <christoffer.dall@linaro.org>
Mon, 4 Dec 2017 20:35:26 +0000 (21:35 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 14 Dec 2017 08:26:51 +0000 (09:26 +0100)
Move vcpu_load() and vcpu_put() into the architecture specific
implementations of kvm_arch_vcpu_ioctl_get_regs().

Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/mips/kvm/mips.c
arch/powerpc/kvm/book3s.c
arch/powerpc/kvm/booke.c
arch/s390/kvm/kvm-s390.c
arch/x86/kvm/x86.c
virt/kvm/kvm_main.c

index ba5ecf22bb96fccc4953ad62d9e0f237aadce8e1..6023b5f808c0a336dcc642badf767c2cd65139c5 100644 (file)
@@ -1162,6 +1162,8 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
 {
        int i;
 
+       vcpu_load(vcpu);
+
        for (i = 0; i < ARRAY_SIZE(vcpu->arch.gprs); i++)
                regs->gpr[i] = vcpu->arch.gprs[i];
 
@@ -1169,6 +1171,7 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
        regs->lo = vcpu->arch.lo;
        regs->pc = vcpu->arch.pc;
 
+       vcpu_put(vcpu);
        return 0;
 }
 
index 72d977e309523f9c1720f32da241b29ad6e24755..d85bfd733ccd42f4a395ed3a7f3a16691a8321a3 100644 (file)
@@ -497,6 +497,8 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
 {
        int i;
 
+       vcpu_load(vcpu);
+
        regs->pc = kvmppc_get_pc(vcpu);
        regs->cr = kvmppc_get_cr(vcpu);
        regs->ctr = kvmppc_get_ctr(vcpu);
@@ -518,6 +520,7 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
        for (i = 0; i < ARRAY_SIZE(regs->gpr); i++)
                regs->gpr[i] = kvmppc_get_gpr(vcpu, i);
 
+       vcpu_put(vcpu);
        return 0;
 }
 
index 83b485810aea2fbfccc01718d1823f30b18e9398..e0e4f04c55354d54ffd629023d5605f32b03df8c 100644 (file)
@@ -1431,6 +1431,8 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
 {
        int i;
 
+       vcpu_load(vcpu);
+
        regs->pc = vcpu->arch.pc;
        regs->cr = kvmppc_get_cr(vcpu);
        regs->ctr = vcpu->arch.ctr;
@@ -1452,6 +1454,7 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
        for (i = 0; i < ARRAY_SIZE(regs->gpr); i++)
                regs->gpr[i] = kvmppc_get_gpr(vcpu, i);
 
+       vcpu_put(vcpu);
        return 0;
 }
 
index 7972598e60d03ed63d35a72f2e425b5d25a14d19..44317813f498244bf8e2478063ea437bbbbc15a9 100644 (file)
@@ -2715,7 +2715,9 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
 
 int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
 {
+       vcpu_load(vcpu);
        memcpy(&regs->gprs, &vcpu->run->s.regs.gprs, sizeof(regs->gprs));
+       vcpu_put(vcpu);
        return 0;
 }
 
index af9da75011bce1c6d5d3a6baabd9e7da4e83c620..3364c6d4f743111c8cffad1ae2cdb2fc589a7342 100644 (file)
@@ -7334,6 +7334,8 @@ out:
 
 int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
 {
+       vcpu_load(vcpu);
+
        if (vcpu->arch.emulate_regs_need_sync_to_vcpu) {
                /*
                 * We are here if userspace calls get_regs() in the middle of
@@ -7367,6 +7369,7 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
        regs->rip = kvm_rip_read(vcpu);
        regs->rflags = kvm_get_rflags(vcpu);
 
+       vcpu_put(vcpu);
        return 0;
 }
 
index 0b149827570cc37ee97e1564554fd80d935b34b3..6dab2e6f83217bd8f4f9785ef396701348e8ed4a 100644 (file)
@@ -2583,9 +2583,7 @@ static long kvm_vcpu_ioctl(struct file *filp,
                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;