Browse Source

x86_64: Add missing mask operation to vdso

vdso vgetns() didn't mask the time source offset calculation, which
could lead to time problems with 32bit HPET.  Add the masking.

Thanks to Chuck Ebbert for tracking this down.

Signed-off-by: Andi Kleen <ak@suse.de>
Cc: Chuck Ebbert <cebbert@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Andi Kleen 18 years ago
parent
commit
95b0867996
1 changed files with 3 additions and 2 deletions
  1. 3 2
      arch/x86_64/vdso/vclock_gettime.c

+ 3 - 2
arch/x86_64/vdso/vclock_gettime.c

@@ -34,10 +34,11 @@ static long vdso_fallback_gettime(long clock, struct timespec *ts)
 
 static inline long vgetns(void)
 {
+	long v;
 	cycles_t (*vread)(void);
 	vread = gtod->clock.vread;
-	return ((vread() - gtod->clock.cycle_last) * gtod->clock.mult) >>
-		gtod->clock.shift;
+	v = (vread() - gtod->clock.cycle_last) & gtod->clock.mask;
+	return (v * gtod->clock.mult) >> gtod->clock.shift;
 }
 
 static noinline int do_realtime(struct timespec *ts)