arm/arm64: KVM: move kvm_register_device_ops() into vGIC probing
authorAndre Przywara <andre.przywara@arm.com>
Sun, 26 Oct 2014 23:17:00 +0000 (23:17 +0000)
committerChristoffer Dall <christoffer.dall@linaro.org>
Tue, 20 Jan 2015 17:25:27 +0000 (18:25 +0100)
Currently we unconditionally register the GICv2 emulation device
during the host's KVM initialization. Since with GICv3 support we
may end up with only v2 or only v3 or both supported, we move the
registration into the GIC probing function, where we will later know
which combination is valid.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Acked-by: Christoffer Dall <christoffer.dall@linaro.org>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
include/linux/kvm_host.h
virt/kvm/arm/vgic-v2.c
virt/kvm/arm/vgic-v3.c
virt/kvm/arm/vgic.c

index 3b934cc94cc83ed1b5348841fbb14e54be1f3bed..25d7ce31a5d4fe4c37450cb219e30d3250a68f28 100644 (file)
@@ -1051,6 +1051,7 @@ void kvm_unregister_device_ops(u32 type);
 
 extern struct kvm_device_ops kvm_mpic_ops;
 extern struct kvm_device_ops kvm_xics_ops;
+extern struct kvm_device_ops kvm_arm_vgic_v2_ops;
 
 #ifdef CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT
 
index 2935405ad22f6ce7f1aaa1239653c3c37224a065..e1cd3cb95903d9c237a1cec353efd41cf45c5d80 100644 (file)
@@ -229,6 +229,8 @@ int vgic_v2_probe(struct device_node *vgic_node,
                goto out_unmap;
        }
 
+       kvm_register_device_ops(&kvm_arm_vgic_v2_ops, KVM_DEV_TYPE_ARM_VGIC_V2);
+
        vgic->vcpu_base = vcpu_res.start;
 
        kvm_info("%s@%llx IRQ%d\n", vgic_node->name,
index 1c2c8eef05993cac943cb90db058dda87d37434e..d14c75f4a33bb1f8a03e10fe24b6dbf168c1053d 100644 (file)
@@ -230,6 +230,7 @@ int vgic_v3_probe(struct device_node *vgic_node,
                ret = -ENXIO;
                goto out;
        }
+       kvm_register_device_ops(&kvm_arm_vgic_v2_ops, KVM_DEV_TYPE_ARM_VGIC_V2);
 
        vgic->vcpu_base = vcpu_res.start;
        vgic->vctrl_base = NULL;
index 9b63141a599d9cf7361ed34ae171049c0f84ef22..69f6e7aa573edabf740c934ead3a66e1794f72af 100644 (file)
@@ -2564,7 +2564,7 @@ static int vgic_create(struct kvm_device *dev, u32 type)
        return kvm_vgic_create(dev->kvm, type);
 }
 
-static struct kvm_device_ops kvm_arm_vgic_v2_ops = {
+struct kvm_device_ops kvm_arm_vgic_v2_ops = {
        .name = "kvm-arm-vgic",
        .create = vgic_create,
        .destroy = vgic_destroy,
@@ -2643,8 +2643,7 @@ int kvm_vgic_hyp_init(void)
 
        on_each_cpu(vgic_init_maintenance_interrupt, NULL, 1);
 
-       return kvm_register_device_ops(&kvm_arm_vgic_v2_ops,
-                                      KVM_DEV_TYPE_ARM_VGIC_V2);
+       return 0;
 
 out_free_irq:
        free_percpu_irq(vgic->maint_irq, kvm_get_running_vcpus());