kvmarm.lists.cs.columbia.edu archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: arm/arm64: fix emulated ptimer irq injection
@ 2019-05-27 11:46 Andrew Jones
  2019-05-28 11:01 ` Christoffer Dall
  0 siblings, 1 reply; 13+ messages in thread
From: Andrew Jones @ 2019-05-27 11:46 UTC (permalink / raw)
  To: kvmarm; +Cc: marc.zyngier

The emulated ptimer needs to track the level changes, otherwise the
the interrupt will never get deasserted, resulting in the guest getting
stuck in an interrupt storm if it enables ptimer interrupts. This was
found with kvm-unit-tests; the ptimer tests hung as soon as interrupts
were enabled. Typical Linux guests don't have a problem as they prefer
using the virtual timer.

Fixes: bee038a674875 ("KVM: arm/arm64: Rework the timer code to use a timer_map")
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 virt/kvm/arm/arch_timer.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c
index 7fc272ecae16..9f5d8cc8b5e5 100644
--- a/virt/kvm/arm/arch_timer.c
+++ b/virt/kvm/arm/arch_timer.c
@@ -324,10 +324,15 @@ static void kvm_timer_update_irq(struct kvm_vcpu *vcpu, bool new_level,
 static void timer_emulate(struct arch_timer_context *ctx)
 {
 	bool should_fire = kvm_timer_should_fire(ctx);
+	struct timer_map map;
+
+	get_timer_map(ctx->vcpu, &map);
 
 	trace_kvm_timer_emulate(ctx, should_fire);
 
-	if (should_fire) {
+	if (ctx == map.emul_ptimer && should_fire != ctx->irq.level) {
+		kvm_timer_update_irq(ctx->vcpu, !ctx->irq.level, ctx);
+	} else if (should_fire) {
 		kvm_timer_update_irq(ctx->vcpu, true, ctx);
 		return;
 	}
-- 
2.18.1

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-06-13 15:45 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-27 11:46 [PATCH] KVM: arm/arm64: fix emulated ptimer irq injection Andrew Jones
2019-05-28 11:01 ` Christoffer Dall
2019-05-28 12:25   ` Marc Zyngier
2019-05-28 13:12     ` Christoffer Dall
2019-05-28 13:40       ` Andrew Jones
2019-05-28 16:08         ` Marc Zyngier
2019-05-29  5:19           ` Andrew Jones
2019-05-29  9:08           ` Christoffer Dall
2019-05-29  9:13             ` Marc Zyngier
2019-05-29 10:03               ` Christoffer Dall
2019-06-03 12:14                 ` Andrew Jones
2019-06-13 10:01                   ` Marc Zyngier
2019-06-13 15:45                     ` Christoffer Dall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).