@@ -441,6 +441,16 @@ static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu)
return ret;
}
+#ifdef CONFIG_KVM_ARM_TIMER
+ /*
+ * If the Architected Timers are supported, userspace must have
+ * created an in-kernel irqchip, since otherwise we will receive
+ * virtual timer interrupt and have nowhere to route them to.
+ */
+ if (!irqchip_in_kernel(kvm))
+ return -ENODEV;
+#endif
+
return 0;
}
@@ -61,12 +61,14 @@ static void timer_disarm(struct arch_timer_cpu *timer)
static void kvm_timer_inject_irq(struct kvm_vcpu *vcpu)
{
+ int ret;
struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu;
timer->cntv_ctl |= ARCH_TIMER_CTRL_IT_MASK;
- kvm_vgic_inject_irq(vcpu->kvm, vcpu->vcpu_id,
- timer->irq->irq,
- timer->irq->level);
+ ret = kvm_vgic_inject_irq(vcpu->kvm, vcpu->vcpu_id,
+ timer->irq->irq,
+ timer->irq->level);
+ BUG_ON(ret);
}
static irqreturn_t kvm_arch_timer_handler(int irq, void *dev_id)