linux-uconsole/arch
Thomas Gleixner 5bcb3f882a x86: Derandom delay_tsc for 64 bit
commit a7f4255f90 upstream.

Commit f0fbf0abc0 ("x86: integrate delay functions") converted
delay_tsc() into a random delay generator for 64 bit.  The reason is
that it merged the mostly identical versions of delay_32.c and
delay_64.c.  Though the subtle difference of the result was:

 static void delay_tsc(unsigned long loops)
 {
-	unsigned bclock, now;
+	unsigned long bclock, now;

Now the function uses rdtscl() which returns the lower 32bit of the
TSC. On 32bit that's not problematic as unsigned long is 32bit. On 64
bit this fails when the lower 32bit are close to wrap around when
bclock is read, because the following check

       if ((now - bclock) >= loops)
       	  	break;

evaluated to true on 64bit for e.g. bclock = 0xffffffff and now = 0
because the unsigned long (now - bclock) of these values results in
0xffffffff00000001 which is definitely larger than the loops
value. That explains Tvortkos observation:

"Because I am seeing udelay(500) (_occasionally_) being short, and
 that by delaying for some duration between 0us (yep) and 491us."

Make those variables explicitely u32 again, so this works for both 32
and 64 bit.

Reported-by: Tvrtko Ursulin <tvrtko.ursulin@onelan.co.uk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-03-19 08:57:43 -07:00
..
alpha alpha: fix 32/64-bit bug in futex support 2012-03-12 10:32:55 -07:00
arm ARM: 7345/1: errata: update workaround for A9 erratum #743622 2012-03-12 10:32:59 -07:00
avr32 avr32: select generic atomic64_t support 2012-03-12 10:32:57 -07:00
blackfin rtc: fix build warnings in defconfigs 2011-06-15 20:04:02 -07:00
cris cris: add missing declaration of kgdb_init() and breakpoint() 2011-08-15 18:31:32 -07:00
frv Merge branch 'setns' 2011-05-28 10:51:01 -07:00
h8300 Merge branch 'setns' 2011-05-28 10:51:01 -07:00
ia64 ACPI, ia64: Use SRAT table rev to use 8bit or 16/32bit PXM fields (ia64) 2012-01-25 17:24:58 -08:00
m32r Fix node_start/end_pfn() definition for mm/page_cgroup.c 2011-06-27 14:13:09 -07:00
m68k m68k: use kernel processor defines for conditional optimizations 2011-06-14 11:42:29 +10:00
microblaze Merge branch 'setns' 2011-05-28 10:51:01 -07:00
mips MIPS: PM: Use struct syscore_ops instead of sysdevs for PM (v2) 2011-10-16 14:14:55 -07:00
mn10300 MN10300: asm/uaccess.h needs to #include linux/kernel.h for might_sleep() 2011-06-21 18:31:44 -07:00
parisc fix return type of __atomic64_add_return 2011-08-15 18:31:32 -07:00
powerpc powerpc/perf: power_pmu_start restores incorrect values, breaking frequency events 2012-02-29 16:33:39 -08:00
s390 S390: KEYS: Enable the compat keyctl wrapper on s390x 2012-03-12 10:32:40 -07:00
score score: fix off-by-one index into syscall table 2012-01-25 17:25:04 -08:00
sh oprofile, arm/sh: Fix oprofile_arch_exit() linkage issue 2012-01-06 14:13:57 -08:00
sparc sparc: Fix handling of orig_i0 wrt. debugging when restarting syscalls. 2012-01-06 14:14:05 -08:00
tile Fix node_start/end_pfn() definition for mm/page_cgroup.c 2011-06-27 14:13:09 -07:00
um um: fix ubd cow size 2011-11-11 09:36:19 -08:00
unicore32 unicore32: using generic-y format for one line asm-generic files 2011-06-09 16:29:52 +08:00
x86 x86: Derandom delay_tsc for 64 bit 2012-03-19 08:57:43 -07:00
xtensa xtensa: prevent arbitrary read in ptrace 2011-08-04 21:58:39 -07:00
.gitignore
Kconfig mm, powerpc: move the RCU page-table freeing into generic code 2011-05-25 08:39:16 -07:00