/* * vgic_init: allocates and initializes dist and vcpu data structures * depending on two dimensioning parameters: * - the number of spis * - the number of vcpus * The function is generally called when nr_spis has been explicitly set * by the guest through the KVM DEVICE API. If not nr_spis is set to 256. * vgic_initialized() returns true when this function has succeeded. * Must be called with kvm->lock held! */ int vgic_init(struct kvm *kvm) { struct vgic_dist *dist = &kvm->arch.vgic; struct kvm_vcpu *vcpu; int ret = 0, i; if (vgic_initialized(kvm)) return 0; /* freeze the number of spis */ if (!dist->nr_spis) dist->nr_spis = VGIC_NR_IRQS_LEGACY - VGIC_NR_PRIVATE_IRQS; ret = kvm_vgic_dist_init(kvm, dist->nr_spis); if (ret) goto out; if (vgic_has_its(kvm)) dist->msis_require_devid = true; kvm_for_each_vcpu(i, vcpu, kvm) kvm_vgic_vcpu_init(vcpu); ret = kvm_vgic_setup_default_irq_routing(kvm); if (ret) goto out; dist->initialized = true; out: return ret; }
/** * kvm_set_msi: inject the MSI corresponding to the * MSI routing entry * * This is the entry point for irqfd MSI injection * and userspace MSI injection. */ int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e, struct kvm *kvm, int irq_source_id, int level, bool line_status) { struct kvm_msi msi; msi.address_lo = e->msi.address_lo; msi.address_hi = e->msi.address_hi; msi.data = e->msi.data; msi.flags = e->msi.flags; msi.devid = e->msi.devid; if (!vgic_has_its(kvm)) return -ENODEV; return vgic_its_inject_msi(kvm, &msi); }