@@ -2559,12 +2559,26 @@ static void kvm_s390_set_crycb_format(struct kvm *kvm)
25592559 kvm -> arch .crypto .crycbd |= CRYCB_FORMAT1 ;
25602560}
25612561
2562+ /*
2563+ * kvm_arch_crypto_set_masks
2564+ *
2565+ * @kvm: pointer to the target guest's KVM struct containing the crypto masks
2566+ * to be set.
2567+ * @apm: the mask identifying the accessible AP adapters
2568+ * @aqm: the mask identifying the accessible AP domains
2569+ * @adm: the mask identifying the accessible AP control domains
2570+ *
2571+ * Set the masks that identify the adapters, domains and control domains to
2572+ * which the KVM guest is granted access.
2573+ *
2574+ * Note: The kvm->lock mutex must be locked by the caller before invoking this
2575+ * function.
2576+ */
25622577void kvm_arch_crypto_set_masks (struct kvm * kvm , unsigned long * apm ,
25632578 unsigned long * aqm , unsigned long * adm )
25642579{
25652580 struct kvm_s390_crypto_cb * crycb = kvm -> arch .crypto .crycb ;
25662581
2567- mutex_lock (& kvm -> lock );
25682582 kvm_s390_vcpu_block_all (kvm );
25692583
25702584 switch (kvm -> arch .crypto .crycbd & CRYCB_FORMAT_MASK ) {
@@ -2595,13 +2609,23 @@ void kvm_arch_crypto_set_masks(struct kvm *kvm, unsigned long *apm,
25952609 /* recreate the shadow crycb for each vcpu */
25962610 kvm_s390_sync_request_broadcast (kvm , KVM_REQ_VSIE_RESTART );
25972611 kvm_s390_vcpu_unblock_all (kvm );
2598- mutex_unlock (& kvm -> lock );
25992612}
26002613EXPORT_SYMBOL_GPL (kvm_arch_crypto_set_masks );
26012614
2615+ /*
2616+ * kvm_arch_crypto_clear_masks
2617+ *
2618+ * @kvm: pointer to the target guest's KVM struct containing the crypto masks
2619+ * to be cleared.
2620+ *
2621+ * Clear the masks that identify the adapters, domains and control domains to
2622+ * which the KVM guest is granted access.
2623+ *
2624+ * Note: The kvm->lock mutex must be locked by the caller before invoking this
2625+ * function.
2626+ */
26022627void kvm_arch_crypto_clear_masks (struct kvm * kvm )
26032628{
2604- mutex_lock (& kvm -> lock );
26052629 kvm_s390_vcpu_block_all (kvm );
26062630
26072631 memset (& kvm -> arch .crypto .crycb -> apcb0 , 0 ,
@@ -2613,7 +2637,6 @@ void kvm_arch_crypto_clear_masks(struct kvm *kvm)
26132637 /* recreate the shadow crycb for each vcpu */
26142638 kvm_s390_sync_request_broadcast (kvm , KVM_REQ_VSIE_RESTART );
26152639 kvm_s390_vcpu_unblock_all (kvm );
2616- mutex_unlock (& kvm -> lock );
26172640}
26182641EXPORT_SYMBOL_GPL (kvm_arch_crypto_clear_masks );
26192642
@@ -2630,6 +2653,7 @@ static void kvm_s390_crypto_init(struct kvm *kvm)
26302653{
26312654 kvm -> arch .crypto .crycb = & kvm -> arch .sie_page2 -> crycb ;
26322655 kvm_s390_set_crycb_format (kvm );
2656+ init_rwsem (& kvm -> arch .crypto .pqap_hook_rwsem );
26332657
26342658 if (!test_kvm_facility (kvm , 76 ))
26352659 return ;
0 commit comments