]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
KVM: arm/arm64: timer: Check for properly initialized timer on init
authorChristoffer Dall <christoffer.dall@linaro.org>
Mon, 5 Dec 2016 09:32:11 +0000 (10:32 +0100)
committerMarc Zyngier <marc.zyngier@arm.com>
Fri, 9 Dec 2016 15:47:00 +0000 (15:47 +0000)
When the arch timer code fails to initialize (for example because the
memory mapped timer doesn't work, which is currently seen with the AEM
model), then KVM just continues happily with a final result that KVM
eventually does a NULL pointer dereference of the uninitialized cycle
counter.

Check directly for this in the init path and give the user a reasonable
error in this case.

Cc: Shih-Wei Li <shihwei@cs.columbia.edu>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
virt/kvm/arm/arch_timer.c

index 17b8fa52bf3ba8663a8241f0299e62b42d51056f..ae95fc0e32143083b1e5aa34286cb6e771f043dc 100644 (file)
@@ -425,6 +425,11 @@ int kvm_timer_hyp_init(void)
        info = arch_timer_get_kvm_info();
        timecounter = &info->timecounter;
 
+       if (!timecounter->cc) {
+               kvm_err("kvm_arch_timer: uninitialized timecounter\n");
+               return -ENODEV;
+       }
+
        if (info->virtual_irq <= 0) {
                kvm_err("kvm_arch_timer: invalid virtual timer IRQ: %d\n",
                        info->virtual_irq);