Skip to content

Commit

Permalink
KVM: arm/arm64: Fix emulated ptimer irq injection
Browse files Browse the repository at this point in the history
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: bee038a ("KVM: arm/arm64: Rework the timer code to use a timer_map")
Signed-off-by: Andrew Jones <[email protected]>
[Simplified the patch to res we only care about emulated timers here]
Signed-off-by: Marc Zyngier <[email protected]>
  • Loading branch information
Andrew Jones authored and Marc Zyngier committed Jun 19, 2019
1 parent 4729ec8 commit e4e5a86
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions virt/kvm/arm/arch_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,15 @@ static void kvm_timer_update_irq(struct kvm_vcpu *vcpu, bool new_level,
}
}

/* Only called for a fully emulated timer */
static void timer_emulate(struct arch_timer_context *ctx)
{
bool should_fire = kvm_timer_should_fire(ctx);

trace_kvm_timer_emulate(ctx, should_fire);

if (should_fire) {
kvm_timer_update_irq(ctx->vcpu, true, ctx);
if (should_fire != ctx->irq.level) {
kvm_timer_update_irq(ctx->vcpu, should_fire, ctx);
return;
}

Expand Down

0 comments on commit e4e5a86

Please sign in to comment.