Signed-off-by: Pavel Fedin <[email protected]>
---
 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(-)

diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index 7e389fd..67545bd 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -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);
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index ad45054..3907e79 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -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;
 };
 
diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c
index 98c95f2..e1b0aa9 100644
--- a/virt/kvm/arm/arch_timer.c
+++ b/virt/kvm/arm/arch_timer.c
@@ -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);
-- 
2.4.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to