dect
/
linux-2.6
Archived
13
0
Fork 0
This repository has been archived on 2022-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
linux-2.6/arch/x86
Thomas Gleixner a7f4255f90 x86: Derandom delay_tsc for 64 bit
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>
Cc: stable@vger.kernel.org # >= 2.6.27
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-03-09 12:43:27 -08:00
..
boot
configs
crypto
ia32 aout: move setup_arg_pages() prior to reading/mapping the binary 2012-03-05 13:51:32 -08:00
include/asm perf/x86/kvm: Fix Host-Only/Guest-Only counting with SVM disabled 2012-03-02 12:16:39 +01:00
kernel perf/x86/kvm: Fix Host-Only/Guest-Only counting with SVM disabled 2012-03-02 12:16:39 +01:00
kvm perf/x86/kvm: Fix Host-Only/Guest-Only counting with SVM disabled 2012-03-02 12:16:39 +01:00
lguest
lib x86: Derandom delay_tsc for 64 bit 2012-03-09 12:43:27 -08:00
math-emu
mm x86: fix typo in recent find_vma_prev purge 2012-03-06 18:48:13 -08:00
net
oprofile
pci x86/PCI: do not tie MSI MS-7253 use_crs quirk to BIOS version 2012-03-01 10:56:37 -08:00
platform
power
syscalls
tools
um
vdso
video
xen
.gitignore
Kbuild
Kconfig
Kconfig.cpu
Kconfig.debug
Makefile
Makefile.um
Makefile_32.cpu