Archived
14
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 x86/boot-image: Don't leak phdrs in arch/x86/boot/compressed/misc.c::Parse_elf() 2012-01-26 11:30:29 +01:00
configs
crypto crypto: serpent-sse2 - remove unneeded LRW/XTS #ifdefs 2011-12-20 15:20:08 +08:00
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 lguest: Make sure interrupt is allocated ok by lguest_setup_irq 2012-01-12 15:44:47 +10:30
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 net: bpf_jit: fix divide by 0 generation 2012-01-18 16:04:26 -05:00
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 x86/uv: Fix uninitialized spinlocks 2012-01-26 10:58:34 +01:00
power
syscalls
tools x86/tools: Add decoded instruction dump mode 2011-12-05 14:53:23 +01:00
um uml: fix compile for x86-64 2012-01-18 19:26:11 -08:00
vdso
video
xen xen/pat: Disable PAT support for now. 2012-02-20 10:41:35 -05:00
.gitignore x86/kprobes: Add arch/x86/tools/insn_sanity to .gitignore 2012-01-16 08:21:59 +01:00
Kbuild
Kconfig x86/numachip: Drop unnecessary conflict with EDAC 2012-01-26 11:03:03 +01:00
Kconfig.cpu mm,x86,um: move CMPXCHG_DOUBLE config option 2012-01-12 20:13:03 -08:00
Kconfig.debug Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-01-11 19:13:40 -08:00
Makefile
Makefile.um
Makefile_32.cpu