@@ -461,13 +461,7 @@ static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu)
return ret;
}
- /*
- * Enable the arch timers only if we have an in-kernel VGIC
- * and it has been properly initialized, since we cannot handle
- * interrupts from the virtual timer with a userspace gic.
- */
- if (irqchip_in_kernel(kvm) && vgic_initialized(kvm))
- kvm_timer_enable(kvm);
+ kvm_timer_enable(kvm);
return 0;
}
@@ -547,6 +541,16 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
run->exit_reason = KVM_EXIT_INTR;
}
+ if (vcpu->irq) {
+ ret = 0;
+ run->exit_reason = KVM_EXIT_IRQ;
+ run->irq.irq = vcpu->irq->irq;
+ run->irq.level = vcpu->irq->level;
+
+ vcpu->irq = NULL;
+ continue;
+ }
+
if (ret <= 0 || need_new_vmid_gen(vcpu->kvm)) {
local_irq_enable();
kvm_timer_sync_hwstate(vcpu);
@@ -267,6 +267,13 @@ struct kvm_vcpu {
} spin_loop;
#endif
bool preempted;
+
+ /*
+ * IRQ pending to the userspace on this CPU.
+ * Currently we support only one slot, used only by ARM architecture.
+ */
+ const struct kvm_irq_level *irq;
+
struct kvm_vcpu_arch arch;
};
@@ -65,6 +65,12 @@ static void kvm_timer_inject_irq(struct kvm_vcpu *vcpu)
struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu;
timer->cntv_ctl |= ARCH_TIMER_CTRL_IT_MASK;
+
+ if (!irqchip_in_kernel(vcpu->kvm)) {
+ vcpu->irq = timer->irq;
+ return;
+ }
+
ret = kvm_vgic_inject_irq(vcpu->kvm, vcpu->vcpu_id,
timer->irq->irq,
timer->irq->level);
Signed-off-by: Pavel Fedin <p.fedin@samsung.com> --- arch/arm/kvm/arm.c | 18 +++++++++++------- include/linux/kvm_host.h | 7 +++++++ virt/kvm/arm/arch_timer.c | 6 ++++++ 3 files changed, 24 insertions(+), 7 deletions(-)