]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - virt/kvm/arm/vgic/vgic-init.c
KVM: arm/arm64: Register iodevs when setting redist base and creating VCPUs
[karo-tx-linux.git] / virt / kvm / arm / vgic / vgic-init.c
index 0ea64a1beff9ac7e122c7c89ba09d31392a72722..962bb577a1a0556bce5103961a595415a4260e09 100644 (file)
@@ -226,6 +226,27 @@ static int kvm_vgic_dist_init(struct kvm *kvm, unsigned int nr_spis)
        return 0;
 }
 
+/**
+ * kvm_vgic_vcpu_init() - Register VCPU-specific KVM iodevs
+ * @vcpu: pointer to the VCPU being created and initialized
+ */
+int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu)
+{
+       int ret = 0;
+       struct vgic_dist *dist = &vcpu->kvm->arch.vgic;
+
+       if (!irqchip_in_kernel(vcpu->kvm))
+               return 0;
+
+       /*
+        * If we are creating a VCPU with a GICv3 we must also register the
+        * KVM io device for the redistributor that belongs to this VCPU.
+        */
+       if (dist->vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3)
+               ret = vgic_register_redist_iodev(vcpu);
+       return ret;
+}
+
 static void kvm_vgic_vcpu_enable(struct kvm_vcpu *vcpu)
 {
        if (kvm_vgic_global_state.type == VGIC_V2)