Skip to contentSkip to conversation

KVM: arm/arm64: Fixes for scheudling htimer of emulated timers

PATCH In review Tomasz Nowicki 2 participants 5 messages Feb 17, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover KVM: arm/arm64: Fixes for scheudling htimer of emulated timers

This small series contains two fixes which were found while testing Marc's ARM NV patch set, where we are going to have at most 4 timers and the two are purely emulated.

First patch cancels hrtimer when the timer should fire and there is no change in irq line level which suppresses timer interrupt storm when guest enables interrupts.

Second patch makes sure that hrtimer is scheduled when timer irq line goes down and there is still some time to expire.

Tomasz Nowicki (2):
KVM: arm/arm64: Fix spurious htimer setup for emulated timer
KVM: arm/arm64: Fix htimer setup for emulated timer when irq goes down

 virt/kvm/arm/arch_timer.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
Signature · 6 lines
2.17.1

_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
#1 lore raw

PATCH 1/2 KVM: arm/arm64: Fix spurious htimer setup for emulated timer

The emulated timer needs no further software timer if the timer should fire now and there is no change in irq line level: (should_fire == 1 && should_fire == ctx->irq.level). In that case htimer should be simply canceled.

Fixes bee038a674875 ("KVM: arm/arm64: Rework the timer code to use a timer_map")
---
 virt/kvm/arm/arch_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
virt/kvm/arm/arch_timer.c +1 -1
index 0d9438e9de2a..f1814f733ef8 100644
@@ -326,7 +326,7 @@ static void timer_emulate(struct arch_timer_context *ctx)
 	 * scheduled for the future.  If the timer cannot fire at all,
 	 * then we also don't need a soft timer.
 	 */
-	if (!kvm_timer_irq_can_fire(ctx)) {
+	if (should_fire || !kvm_timer_irq_can_fire(ctx)) {
 		soft_timer_cancel(&ctx->hrtimer);
 		return;
 	}
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/2 KVM: arm/arm64: Fix htimer setup for emulated timer when irq goes down

In reply to Tomasz Nowicki

We still need to schedule software timer if the line goes down (should_fire == 0 && should_fire != ctx->irq.level) and there is still some time to expire again.

Fixes bee038a674875 ("KVM: arm/arm64: Rework the timer code to use a timer_map")
---
 virt/kvm/arm/arch_timer.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
virt/kvm/arm/arch_timer.c +1 -3
index f1814f733ef8..de14520c6cc2 100644
@@ -316,10 +316,8 @@ static void timer_emulate(struct arch_timer_context *ctx)
 
 	trace_kvm_timer_emulate(ctx, should_fire);
 
-	if (should_fire != ctx->irq.level) {
+	if (should_fire != ctx->irq.level)
 		kvm_timer_update_irq(ctx->vcpu, should_fire, ctx);
-		return;
-	}
 
 	/*
 	 * If the timer can fire now, we don't need to have a soft timer
Signature · 6 lines
2.17.1

_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
maintainer
#3 lore raw
In reply to Tomasz Nowicki
Quoted 3 lines · Tomasz Nowicki

This small series contains two fixes which were found while testing Marc's ARM NV patch set, where we are going to have at most 4 timers and the two are purely emulated.

What are these patches fixing? the NV series? or mainline?

Thanks,

        M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#4 lore raw
Quoted 8 lines · Marc Zyngier

----------------------------------------------------------------------

Quoted 3 lines · Tomasz Nowicki

This small series contains two fixes which were found while testing Marc's ARM NV patch set, where we are going to have at most 4 timers and the two are purely emulated.

What are these patches fixing? the NV series? or mainline?

Both, but found when testing NV.

Tomasz
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm