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

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

index d27a1dd..4297f50 100644 (file)
@@ -2833,9 +2833,16 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
 int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
                                    struct kvm_mp_state *mp_state)
 {
+       int ret;
+
+       vcpu_load(vcpu);
+
        /* CHECK_STOP and LOAD are not supported yet */
-       return is_vcpu_stopped(vcpu) ? KVM_MP_STATE_STOPPED :
-                                      KVM_MP_STATE_OPERATING;
+       ret = is_vcpu_stopped(vcpu) ? KVM_MP_STATE_STOPPED :
+                                     KVM_MP_STATE_OPERATING;
+
+       vcpu_put(vcpu);
+       return ret;
 }
 
 int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
index f01a7d7..8079193 100644 (file)
@@ -7465,6 +7465,8 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
 int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
                                    struct kvm_mp_state *mp_state)
 {
+       vcpu_load(vcpu);
+
        kvm_apic_accept_events(vcpu);
        if (vcpu->arch.mp_state == KVM_MP_STATE_HALTED &&
                                        vcpu->arch.pv.pv_unhalted)
@@ -7472,6 +7474,7 @@ int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
        else
                mp_state->mp_state = vcpu->arch.mp_state;
 
+       vcpu_put(vcpu);
        return 0;
 }
 
index a1b2e8a..65d5010 100644 (file)
@@ -381,11 +381,14 @@ static void vcpu_power_off(struct kvm_vcpu *vcpu)
 int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
                                    struct kvm_mp_state *mp_state)
 {
+       vcpu_load(vcpu);
+
        if (vcpu->arch.power_off)
                mp_state->mp_state = KVM_MP_STATE_STOPPED;
        else
                mp_state->mp_state = KVM_MP_STATE_RUNNABLE;
 
+       vcpu_put(vcpu);
        return 0;
 }
 
index e04a216..8e2f582 100644 (file)
@@ -2634,9 +2634,7 @@ out_free1:
        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;