@@ -539,19 +539,20 @@ static u32 apic_get_tmcct(struct kvm_lapic *apic)
counter_passed = div64_u64(ktime_to_ns(passed),
(APIC_BUS_CYCLE_NS * apic->timer.divide_count));
+ if (counter_passed > 0x7f00000000000000) {
+ /* If we're in here we probably encountered a bug! */
+ printk(KERN_INFO "LAPIC: Too high counter_passed value: "
+ "0x%lx | 0x%lx (0x%lx) | 0x%lx (0x%lx)\n",
+ counter_passed, ktime_to_ns(passed), passed,
+ now.tv64, apic->timer.last_update.tv64);
+ }
+
if (counter_passed > tmcct) {
if (unlikely(!apic_lvtt_period(apic))) {
/* one-shot timers stick at 0 until reset */
tmcct = 0;
} else {
- /*
- * periodic timers reset to APIC_TMICT when they
- * hit 0. The while loop simulates this happening N
- * times. (counter_passed %= tmcct) would also work,
- * but might be slower or not work on 32-bit??
- */
- while (counter_passed > tmcct)
- counter_passed -= tmcct;
+ counter_passed %= (u64)tmcct;
tmcct -= counter_passed;
}
} else {