All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Fedin <p.fedin@samsung.com>
To: kvm@vger.kernel.org
Cc: Marc Zyngier <marc.zyngier@arm.com>
Subject: [RFC 2/2] Send KVM_EXIT_IRQ from timer if irqchip is not used
Date: Fri, 24 Jul 2015 18:23:35 +0300	[thread overview]
Message-ID: <487f6cfeeb9fe6aa26ebcdd3a15885f305b3e21a.1437750590.git.p.fedin@samsung.com> (raw)
In-Reply-To: <cover.1437750590.git.p.fedin@samsung.com>
In-Reply-To: <cover.1437750590.git.p.fedin@samsung.com>

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(-)

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


      parent reply	other threads:[~2015-07-24 15:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-24 15:23 [RFC 0/2] Propagate virtual timer interrupts to userspace Pavel Fedin
2015-07-24 15:23 ` [RFC 1/2] Introduce KVM_EXIT_IRQ Pavel Fedin
2015-07-24 15:23 ` Pavel Fedin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=487f6cfeeb9fe6aa26ebcdd3a15885f305b3e21a.1437750590.git.p.fedin@samsung.com \
    --to=p.fedin@samsung.com \
    --cc=kvm@vger.kernel.org \
    --cc=marc.zyngier@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.