Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
[linux-2.6-microblaze.git] / arch / s390 / kvm / kvm-s390.c
index 1053c14..752a0ff 100644 (file)
@@ -2555,12 +2555,26 @@ static void kvm_s390_set_crycb_format(struct kvm *kvm)
                kvm->arch.crypto.crycbd |= CRYCB_FORMAT1;
 }
 
+/*
+ * kvm_arch_crypto_set_masks
+ *
+ * @kvm: pointer to the target guest's KVM struct containing the crypto masks
+ *      to be set.
+ * @apm: the mask identifying the accessible AP adapters
+ * @aqm: the mask identifying the accessible AP domains
+ * @adm: the mask identifying the accessible AP control domains
+ *
+ * Set the masks that identify the adapters, domains and control domains to
+ * which the KVM guest is granted access.
+ *
+ * Note: The kvm->lock mutex must be locked by the caller before invoking this
+ *      function.
+ */
 void kvm_arch_crypto_set_masks(struct kvm *kvm, unsigned long *apm,
                               unsigned long *aqm, unsigned long *adm)
 {
        struct kvm_s390_crypto_cb *crycb = kvm->arch.crypto.crycb;
 
-       mutex_lock(&kvm->lock);
        kvm_s390_vcpu_block_all(kvm);
 
        switch (kvm->arch.crypto.crycbd & CRYCB_FORMAT_MASK) {
@@ -2591,13 +2605,23 @@ void kvm_arch_crypto_set_masks(struct kvm *kvm, unsigned long *apm,
        /* recreate the shadow crycb for each vcpu */
        kvm_s390_sync_request_broadcast(kvm, KVM_REQ_VSIE_RESTART);
        kvm_s390_vcpu_unblock_all(kvm);
-       mutex_unlock(&kvm->lock);
 }
 EXPORT_SYMBOL_GPL(kvm_arch_crypto_set_masks);
 
+/*
+ * kvm_arch_crypto_clear_masks
+ *
+ * @kvm: pointer to the target guest's KVM struct containing the crypto masks
+ *      to be cleared.
+ *
+ * Clear the masks that identify the adapters, domains and control domains to
+ * which the KVM guest is granted access.
+ *
+ * Note: The kvm->lock mutex must be locked by the caller before invoking this
+ *      function.
+ */
 void kvm_arch_crypto_clear_masks(struct kvm *kvm)
 {
-       mutex_lock(&kvm->lock);
        kvm_s390_vcpu_block_all(kvm);
 
        memset(&kvm->arch.crypto.crycb->apcb0, 0,
@@ -2609,7 +2633,6 @@ void kvm_arch_crypto_clear_masks(struct kvm *kvm)
        /* recreate the shadow crycb for each vcpu */
        kvm_s390_sync_request_broadcast(kvm, KVM_REQ_VSIE_RESTART);
        kvm_s390_vcpu_unblock_all(kvm);
-       mutex_unlock(&kvm->lock);
 }
 EXPORT_SYMBOL_GPL(kvm_arch_crypto_clear_masks);
 
@@ -2626,6 +2649,7 @@ static void kvm_s390_crypto_init(struct kvm *kvm)
 {
        kvm->arch.crypto.crycb = &kvm->arch.sie_page2->crycb;
        kvm_s390_set_crycb_format(kvm);
+       init_rwsem(&kvm->arch.crypto.pqap_hook_rwsem);
 
        if (!test_kvm_facility(kvm, 76))
                return;