Merge tag 'bitmap-for-5.19-rc1' of https://github.com/norov/linux
[linux-2.6-microblaze.git] / arch / s390 / kvm / kvm-s390.c
index a353bb4..8fcb561 100644 (file)
@@ -2380,7 +2380,16 @@ static int kvm_s390_vm_mem_op(struct kvm *kvm, struct kvm_s390_mem_op *mop)
                return -EINVAL;
        if (mop->size > MEM_OP_MAX_SIZE)
                return -E2BIG;
-       if (kvm_s390_pv_is_protected(kvm))
+       /*
+        * This is technically a heuristic only, if the kvm->lock is not
+        * taken, it is not guaranteed that the vm is/remains non-protected.
+        * This is ok from a kernel perspective, wrongdoing is detected
+        * on the access, -EFAULT is returned and the vm may crash the
+        * next time it accesses the memory in question.
+        * There is no sane usecase to do switching and a memop on two
+        * different CPUs at the same time.
+        */
+       if (kvm_s390_pv_get_handle(kvm))
                return -EINVAL;
        if (mop->flags & KVM_S390_MEMOP_F_SKEY_PROTECTION) {
                if (access_key_invalid(mop->key))
@@ -4233,14 +4242,14 @@ static int __vcpu_run(struct kvm_vcpu *vcpu)
         * We try to hold kvm->srcu during most of vcpu_run (except when run-
         * ning the guest), so that memslots (and other stuff) are protected
         */
-       vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
+       kvm_vcpu_srcu_read_lock(vcpu);
 
        do {
                rc = vcpu_pre_run(vcpu);
                if (rc)
                        break;
 
-               srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
+               kvm_vcpu_srcu_read_unlock(vcpu);
                /*
                 * As PF_VCPU will be used in fault handler, between
                 * guest_enter and guest_exit should be no uaccess.
@@ -4277,12 +4286,12 @@ static int __vcpu_run(struct kvm_vcpu *vcpu)
                __enable_cpu_timer_accounting(vcpu);
                guest_exit_irqoff();
                local_irq_enable();
-               vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
+               kvm_vcpu_srcu_read_lock(vcpu);
 
                rc = vcpu_post_run(vcpu, exit_reason);
        } while (!signal_pending(current) && !guestdbg_exit_pending(vcpu) && !rc);
 
-       srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
+       kvm_vcpu_srcu_read_unlock(vcpu);
        return rc;
 }