From: Tony Krowiak <akrowiak@xxxxxxxxxxxxx>[..]
Configures the AP adapters, usage domains and control domains for the
KVM guest from the matrix configured via the mediated matrix device's
sysfs attribute files.
+
+static void kvm_ap_set_crycb_masks(struct ap_matrix_mdev *matrix_mdev)
+{
+ int nbytes;
+ unsigned long *apm, *aqm, *adm;
+
+ kvm_ap_clear_crycb_masks(matrix_mdev);
+
+ apm = kvm_ap_get_crycb_apm(matrix_mdev);
+ aqm = kvm_ap_get_crycb_aqm(matrix_mdev);
+ adm = kvm_ap_get_crycb_adm(matrix_mdev);
+
+ nbytes = KVM_AP_MASK_BYTES(matrix_mdev->matrix.apm_max + 1);
+ memcpy(apm, matrix_mdev->matrix.apm, nbytes);
+
+ nbytes = KVM_AP_MASK_BYTES(matrix_mdev->matrix.aqm_max + 1);
+ memcpy(aqm, matrix_mdev->matrix.aqm, nbytes);
+
+ /*
+ * Merge the AQM and ADM since the ADM is a superset of the
+ * AQM by agreed-upon convention.
+ */
+ bitmap_or(adm, matrix_mdev->matrix.adm, matrix_mdev->matrix.aqm,
+ matrix_mdev->matrix.adm_max + 1);
+}