/* * Contents of the aipb remain registered for the life of the host * kernel, the information preserved in zpci_aipb and zpci_aif_sbv * in case we insert the KVM module again later. Clear the AIFT * information and free anything not registered with underlying * firmware.
*/
spin_lock_irqsave(&aift->gait_lock, flags);
gait_kzdev = aift->kzdev;
aift->gait = NULL;
aift->sbv = NULL;
aift->kzdev = NULL;
spin_unlock_irqrestore(&aift->gait_lock, flags);
kfree(gait_kzdev);
}
staticint zpci_setup_aipb(u8 nisc)
{ struct page *page; int size, rc;
zpci_aipb = kzalloc(sizeof(union zpci_sic_iib), GFP_KERNEL); if (!zpci_aipb) return -ENOMEM;
staticint zpci_reset_aipb(u8 nisc)
{ /* * AEN registration can only happen once per system boot. If * an aipb already exists then AEN was already registered and * we can reuse the aipb contents. This can only happen if * the KVM module was removed and re-inserted. However, we must * ensure that the same forwarding ISC is used as this is assigned * during KVM module load.
*/ if (zpci_aipb->aipb.afi != nisc) return -EINVAL;
/* Pin the guest AISB if one was specified */ if (fib->fmt0.sum == 1) {
idx = srcu_read_lock(&kvm->srcu);
hva = gfn_to_hva(kvm, gpa_to_gfn((gpa_t)fib->fmt0.aisb));
npages = pin_user_pages_fast(hva, 1, FOLL_WRITE | FOLL_LONGTERM,
pages);
srcu_read_unlock(&kvm->srcu, idx); if (npages < 1) {
rc = -EIO; goto unpin1;
}
aisb_page = pages[0];
pcount++;
}
/* Account for pinned pages, roll back on failure */ if (account_mem(pcount)) goto unpin2;
/* AISB must be allocated before we can fill in GAITE */
mutex_lock(&aift->aift_lock);
bit = airq_iv_alloc_bit(aift->sbv); if (bit == -1UL) goto unlock;
zdev->aisb = bit; /* store the summary bit number */
zdev->aibv = airq_iv_create(msi_vecs, AIRQ_IV_DATA |
AIRQ_IV_BITLOCK |
AIRQ_IV_GUESTVEC,
phys_to_virt(fib->fmt0.aibv));
/* Save some guest fib values in the host for later use */
zdev->kzdev->fib.fmt0.isc = fib->fmt0.isc;
zdev->kzdev->fib.fmt0.aibv = fib->fmt0.aibv;
mutex_unlock(&aift->aift_lock);
/* Issue the clp to setup the irq now */
rc = kvm_zpci_set_airq(zdev); return rc;
/* * If the clear fails due to an error, leave now unless we know this * device is about to go away (force) -- In that case clear the GAITE * regardless.
*/
rc = kvm_zpci_clear_airq(zdev); if (rc && !force) goto out;
/* * Register device with the specified KVM. If interpretation facilities are * available, enable them and let userspace indicate whether or not they will * be used (specify SHM bit to disable).
*/ staticint kvm_s390_pci_register_kvm(void *opaque, struct kvm *kvm)
{ struct zpci_dev *zdev = opaque; int rc;
rc = kvm_s390_pci_dev_open(zdev); if (rc) goto err;
/* * If interpretation facilities aren't available, add the device to * the kzdev list but don't enable for interpretation.
*/ if (!kvm_s390_pci_interp_allowed()) goto out;
/* * If this is the first request to use an interpreted device, make the * necessary vcpu changes
*/ if (!kvm->arch.use_zpci_interp)
kvm_s390_vcpu_pci_enable_interp(kvm);
if (zdev_enabled(zdev)) {
rc = zpci_disable_device(zdev); if (rc) goto err;
}
/* * Store information about the identity of the kvm guest allowed to * access this device via interpretation to be used by host CLP
*/
zdev->gisa = (u32)virt_to_phys(&kvm->arch.sie_page2->gisa);
rc = zpci_reenable_device(zdev); if (rc) goto clear_gisa;
void kvm_s390_pci_clear_list(struct kvm *kvm)
{ /* * This list should already be empty, either via vfio device closures * or kvm fd cleanup.
*/
spin_lock(&kvm->arch.kzdev_list_lock);
WARN_ON_ONCE(!list_empty(&kvm->arch.kzdev_list));
spin_unlock(&kvm->arch.kzdev_list_lock);
}
kzdev = zdev->kzdev; if (!kzdev) {
r = -ENODEV; goto out;
} if (kzdev->kvm != kvm) {
r = -EPERM; goto out;
}
switch (args->op) { case KVM_S390_ZPCIOP_REG_AEN: /* Fail on unknown flags */ if (args->u.reg_aen.flags & ~KVM_S390_ZPCIOP_REGAEN_HOST) {
r = -EINVAL; break;
}
r = kvm_s390_pci_zpci_reg_aen(zdev, args); break; case KVM_S390_ZPCIOP_DEREG_AEN:
r = kvm_s390_pci_aif_disable(zdev, false); break; default:
r = -EINVAL;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.