KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_run
[platform/kernel/linux-starfive.git] / arch / s390 / kvm / kvm-s390.c
index 9614aea..7972598 100644 (file)
@@ -1,11 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
- * hosting zSeries kernel virtual machines
+ * hosting IBM Z kernel virtual machines (s390x)
  *
- * Copyright IBM Corp. 2008, 2009
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License (version 2 only)
- * as published by the Free Software Foundation.
+ * Copyright IBM Corp. 2008, 2017
  *
  *    Author(s): Carsten Otte <cotte@de.ibm.com>
  *               Christian Borntraeger <borntraeger@de.ibm.com>
@@ -3376,9 +3373,12 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
        if (kvm_run->immediate_exit)
                return -EINTR;
 
+       vcpu_load(vcpu);
+
        if (guestdbg_exit_pending(vcpu)) {
                kvm_s390_prepare_debug_exit(vcpu);
-               return 0;
+               rc = 0;
+               goto out;
        }
 
        kvm_sigset_activate(vcpu);
@@ -3388,7 +3388,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
        } else if (is_vcpu_stopped(vcpu)) {
                pr_err_ratelimited("can't run stopped vcpu %d\n",
                                   vcpu->vcpu_id);
-               return -EINVAL;
+               rc = -EINVAL;
+               goto out;
        }
 
        sync_regs(vcpu, kvm_run);
@@ -3418,6 +3419,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
        kvm_sigset_deactivate(vcpu);
 
        vcpu->stat.exit_userspace++;
+out:
+       vcpu_put(vcpu);
        return rc;
 }
 
@@ -3808,6 +3811,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
                        r = -EINVAL;
                        break;
                }
+               /* do not use irq_state.flags, it will break old QEMUs */
                r = kvm_s390_set_irq_state(vcpu,
                                           (void __user *) irq_state.buf,
                                           irq_state.len);
@@ -3823,6 +3827,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
                        r = -EINVAL;
                        break;
                }
+               /* do not use irq_state.flags, it will break old QEMUs */
                r = kvm_s390_get_irq_state(vcpu,
                                           (__u8 __user *)  irq_state.buf,
                                           irq_state.len);