From: Glauber Costa <glommer@redhat.com> Date: Fri, 18 Sep 2009 17:27:23 -0400 Subject: [x86_64] kvm: bound last_kvm to prevent backwards time Message-id: 1253309243-13769-3-git-send-email-glommer@redhat.com O-Subject: [PATCH 2/2] RHEL5 BZ524076 try this on on top of the others Bugzilla: 524076 RH-Acked-by: Rik van Riel <riel@redhat.com> Since we don't have the whole clocksource infrastructure in place, we need to make sure that clock don't go backwards. We do this by checking the value of last_kvm, and using it as a lower bound. RH-Upstream-status: Specific to RHEL5 port. Signed-off-by: Glauber Costa <glommer@redhat.com> diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c index 90bc1e7..73abf98 100644 --- a/arch/x86_64/kernel/time.c +++ b/arch/x86_64/kernel/time.c @@ -126,7 +126,11 @@ static inline long do_gettimeoffset_tsc(void) static inline long do_gettimeoffset_kvm(void) { - return (kvm_clock_read() - vxtime.last_kvm); + unsigned long t; + t = kvm_clock_read(); + if (t < vxtime.last_kvm) + t = vxtime.last_kvm; + return t -vxtime.last_kvm; } static inline long do_gettimeoffset_hpet(void)