diff mbox

[1/1] KVM: x86: No wrap around for lapic timer

Message ID 1231484471-18777-1-git-send-email-sheng@linux.intel.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Sheng Yang Jan. 9, 2009, 7:01 a.m. UTC
Or would we meet 585 years later? :)

Seriously, this wrap around hide implicit error...

Reminder by Alexander Graf.

Signed-off-by: Sheng Yang <sheng@linux.intel.com>
---
 arch/x86/kvm/lapic.c |   13 ++-----------
 1 files changed, 2 insertions(+), 11 deletions(-)
diff mbox

Patch

diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index afac68c..87c1da5 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -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));