On Fri, 13 Oct 2017 13:39:01 -0400 Tony Krowiak <akrowiak@xxxxxxxxxxxxxxxxxx> wrote: > Provides an interface to assign AP adapters, usage domains > and control domains to a KVM guest. > > A KVM guest is started by executing the Start Interpretive Execution (SIE) > instruction. The SIE state description is a control block that contains the > state information for a KVM guest and is supplied as input to the SIE > instruction. The SIE state description contains a field that references > a Crypto Control Block (CRYCB). The CRYCB contains three bitmask fields > identifying the adapters, usage domains and control domains assigned to the > KVM guest: > > * The AP Adapter Matrix (APM) field identifies the AP adapters assigned to > the KVM guest > > * The AP Queue Matrix (AQM) field identifies the usage domains assigned to > the KVM guest > > * The AP Domain matrix (ADM) field identifies the control domains > assigned to the KVM guest. > > Each adapter, usage domain and control domain are identified by a number > from 0 to 255. The bits in each mask, from left to right, correspond to > the numbers 0-255. When a bit is set, the corresponding adapter, > usage domain or control domain will be assigned to the KVM guest. > > This patch will set the bits in the APM, AQM and ADM fields of the > CRYCB referenced by the KVM guest's SIE state description. The process > used is: > > 1. Perform a logical AND of the AP matrix masks configured for the > mediated AP matrix device via its sysfs attributes files with > the matrix masks assigned to the LPAR in which the host linux > system is running to create the effective masks, EAPM, EAQM and > EADM. > > 2. Set the APM, AQM and ADM in the CRYCB from the EAPM, EAQM and > EADM calculated in step 1. > > Signed-off-by: Tony Krowiak <akrowiak@xxxxxxxxxxxxxxxxxx> > --- > arch/s390/include/asm/ap-config.h | 7 ++ > arch/s390/kvm/ap-config.c | 144 +++++++++++++++++++++++++++++++++++++ > 2 files changed, 151 insertions(+), 0 deletions(-) > > +static int ap_config_get_emasks(struct ap_config_masks *masks) > +{ > + int ret; > + struct ap_config_info config; > + > + ret = ap_query_configuration(&config); > + if (ret) { > + if (ret == -EOPNOTSUPP) { > + pr_err("%s: Query AP configuration not supported", > + __func__); > + > + return ret; I'm wondering whether we should check this at init time for vfio-ap? If PQAP(QCI) is not supported, it probably does not make any sense to pretend that we could do device assignment... > + } > + > + pr_err("%s: Query AP configuration failed with rc=%d", > + __func__, ret); > + > + return ret; > + } > + > + ret = ap_config_set_emask(AP_MATRIX_MASK_TYPE_ADAPTER, > + (unsigned long *)masks->apm, > + (unsigned long *)config.apm); > + if (ret) > + return ret; > + > + ret = ap_config_set_emask(AP_MATRIX_MASK_TYPE_DOMAIN, > + (unsigned long *)masks->aqm, > + (unsigned long *)config.aqm); > + if (ret) > + return ret; > + > + ret = ap_config_set_emask(AP_MATRIX_MASK_TYPE_CONTROL, > + (unsigned long *)masks->adm, > + (unsigned long *)config.adm); > + if (ret) > + return ret; > + > + return 0; > +} > + > +int ap_config_matrix(struct kvm *kvm, struct ap_config_masks *masks) > +{ > + int ret; > + > + ret = ap_config_get_emasks(masks); > + if (ret) > + return ret; > + > + ap_config_set_crycb_masks(kvm, masks); > + > + return 0; > +} > +EXPORT_SYMBOL(ap_config_matrix); -- To unsubscribe from this list: send the line "unsubscribe linux-s390" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html