android_kernel_xiaomi_sdm845/arch
Nicolas Pitre b49c0f24cf [ARM] 4659/1: remove possibilities for spurious false negative with __kuser_cmpxchg
The ARM __kuser_cmpxchg routine is meant to implement an atomic cmpxchg
in user space.  It however can produce spurious false negative if a
processor exception occurs in the middle of the operation.  Normally
this is not a problem since cmpxchg is typically called in a loop until
it succeeds to implement an atomic increment for example.

Some use cases which don't involve a loop require that the operation be
100% reliable though.  This patch changes the implementation so to
reattempt the operation after an exception has occurred in the critical
section rather than abort it.

Here's a simple program to test the fix (don't use CONFIG_NO_HZ in your
kernel as this depends on a sufficiently high interrupt rate):

	#include <stdio.h>

	typedef int (__kernel_cmpxchg_t)(int oldval, int newval, int *ptr);
	#define __kernel_cmpxchg (*(__kernel_cmpxchg_t *)0xffff0fc0)

	int main()
	{
		int i, x = 0;
		for (i = 0; i < 100000000; i++) {
			int v = x;
			if (__kernel_cmpxchg(v, v+1, &x))
				printf("failed at %d: %d vs %d\n", i, v, x);
		}
		printf("done with %d vs %d\n", i, x);
		return 0;
	}

Signed-off-by: Nicolas Pitre <nico@marvell.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2007-11-26 19:43:58 +00:00
..
alpha alpha: sg_virt() fallout 2007-10-23 12:31:05 +02:00
arm [ARM] 4659/1: remove possibilities for spurious false negative with __kuser_cmpxchg 2007-11-26 19:43:58 +00:00
avr32 [AVR32] Export intc_get_pending symbol 2007-11-15 13:47:20 +01:00
blackfin Blackfin arch: reclaim a few bytes from the end of our init section 2007-10-30 12:00:02 +08:00
cris CRISv10 fasttimer: Scrap INLINE and name timeval_cmp better 2007-11-14 18:45:47 -08:00
frv FRV: Remove the section annotation on free_initmem() 2007-11-09 15:02:25 -08:00
h8300 Kbuild/doc: fix links to Documentation files 2007-10-30 14:26:30 -07:00
ia64 Add IORESOUCE_BUSY flag for System RAM 2007-11-14 18:45:39 -08:00
m32r spelling fixes: arch/m32r/ 2007-10-20 01:14:39 +02:00
m68k m68k: sg fallout 2007-10-24 08:55:40 +02:00
m68knommu m68knommu: mark mem init functions as __init 2007-10-23 20:45:44 -07:00
mips [MIPS] N32 needs to use the compat version of sys_nfsservctl. 2007-11-15 23:21:52 +00:00
parisc parisc: fix sg_page() fallout 2007-10-23 09:49:31 +02:00
powerpc [POWERPC] Silence an annoying boot message 2007-11-13 16:23:47 +11:00
ppc [POWERPC] Avoid unpaired stwcx. on some processors 2007-11-13 16:22:43 +11:00
s390 sched: restore deterministic CPU accounting on powerpc 2007-11-09 22:39:38 +01:00
sh Merge branch 'page_colouring_despair' 2007-11-08 17:01:42 +09:00
sh64 sh64: Kill off duplicate includes. 2007-11-05 12:18:17 +09:00
sparc [SPARC]: Remove duplicate includes. 2007-11-06 21:23:11 -08:00
sparc64 [SPARC]: Remove duplicate includes. 2007-11-06 21:23:11 -08:00
um uml: fix build for !CONFIG_PRINTK 2007-11-14 18:45:43 -08:00
v850 spelling fixes: arch/v850/ 2007-10-20 01:24:05 +02:00
x86 x86: simplify "make ARCH=x86" and fix kconfig all.config 2007-11-17 17:21:54 +01:00
xtensa Kbuild/doc: fix links to Documentation files 2007-10-30 14:26:30 -07:00