Merge tag 'iommu-updates-v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-microblaze.git] / arch / s390 / kvm / priv.c
index 9928f78..53da4ce 100644 (file)
@@ -610,6 +610,7 @@ static int handle_io_inst(struct kvm_vcpu *vcpu)
 static int handle_pqap(struct kvm_vcpu *vcpu)
 {
        struct ap_queue_status status = {};
+       crypto_hook pqap_hook;
        unsigned long reg0;
        int ret;
        uint8_t fc;
@@ -654,18 +655,20 @@ static int handle_pqap(struct kvm_vcpu *vcpu)
                return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
 
        /*
-        * Verify that the hook callback is registered, lock the owner
-        * and call the hook.
+        * If the hook callback is registered, there will be a pointer to the
+        * hook function pointer in the kvm_s390_crypto structure. Lock the
+        * owner, retrieve the hook function pointer and call the hook.
         */
+       down_read(&vcpu->kvm->arch.crypto.pqap_hook_rwsem);
        if (vcpu->kvm->arch.crypto.pqap_hook) {
-               if (!try_module_get(vcpu->kvm->arch.crypto.pqap_hook->owner))
-                       return -EOPNOTSUPP;
-               ret = vcpu->kvm->arch.crypto.pqap_hook->hook(vcpu);
-               module_put(vcpu->kvm->arch.crypto.pqap_hook->owner);
+               pqap_hook = *vcpu->kvm->arch.crypto.pqap_hook;
+               ret = pqap_hook(vcpu);
                if (!ret && vcpu->run->s.regs.gprs[1] & 0x00ff0000)
                        kvm_s390_set_psw_cc(vcpu, 3);
+               up_read(&vcpu->kvm->arch.crypto.pqap_hook_rwsem);
                return ret;
        }
+       up_read(&vcpu->kvm->arch.crypto.pqap_hook_rwsem);
        /*
         * A vfio_driver must register a hook.
         * No hook means no driver to enable the SIE CRYCB and no queues.