Skip to contentSkip to conversation

KVM: x86: No wrap around for lapic timer

PATCH New Sheng Yang 1 participant 1 message Jan 9, 2009

Subsystems (3)
lore
Share & tools
lore

Sheng Yang

author
#0 lore raw

PATCH 1/1 KVM: x86: No wrap around for lapic timer

Or would we meet 585 years later? :)

Seriously, this wrap around hide implicit error...

Reminder by Alexander Graf.

---
 arch/x86/kvm/lapic.c |   13 ++-----------
 1 files changed, 2 insertions(+), 11 deletions(-)
arch/x86/kvm/lapic.c +2 -11
index afac68c..87c1da5 100644
@@ -524,18 +524,9 @@ static u32 apic_get_tmcct(struct kvm_lapic *apic)
 	if (tmcct == 0)
 		return 0;
 
-	if (unlikely(ktime_to_ns(now) <=
-		ktime_to_ns(apic->timer.last_update))) {
-		/* Wrap around */
-		passed = ktime_add(( {
-				    (ktime_t) {
-				    .tv64 = KTIME_MAX -
-				    (apic->timer.last_update).tv64}; }
-				   ), now);
-		apic_debug("time elapsed\n");
-	} else
-		passed = ktime_sub(now, apic->timer.last_update);
+	BUG_ON(ktime_to_ns(now) <= ktime_to_ns(apic->timer.last_update));
 
+	passed = ktime_sub(now, apic->timer.last_update);
 	counter_passed = div64_u64(ktime_to_ns(passed),
 				   (APIC_BUS_CYCLE_NS * apic->timer.divide_count));
 
Signature · 1 line
1.5.4.5