Browse Source

ARM: Use a definition for the userspace cmpxchg emulation syscall

Use a definition for the cmpxchg SWI instead of hard-coding the number.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Acked-by: Nicolas Pitre <nico@fluxnic.net>
Russell King 15 years ago
parent
commit
cc20d42986
3 changed files with 14 additions and 4 deletions
  1. 9 0
      arch/arm/include/asm/unistd.h
  2. 4 3
      arch/arm/kernel/entry-armv.S
  3. 1 1
      arch/arm/kernel/traps.c

+ 9 - 0
arch/arm/include/asm/unistd.h

@@ -402,6 +402,15 @@
 #define __ARM_NR_usr32			(__ARM_NR_BASE+4)
 #define __ARM_NR_usr32			(__ARM_NR_BASE+4)
 #define __ARM_NR_set_tls		(__ARM_NR_BASE+5)
 #define __ARM_NR_set_tls		(__ARM_NR_BASE+5)
 
 
+/*
+ * *NOTE*: This is a ghost syscall private to the kernel.  Only the
+ * __kuser_cmpxchg code in entry-armv.S should be aware of its
+ * existence.  Don't ever use this from user code.
+ */
+#ifdef __KERNEL__
+#define __ARM_NR_cmpxchg		(__ARM_NR_BASE+0x00fff0)
+#endif
+
 /*
 /*
  * The following syscalls are obsolete and no longer available for EABI.
  * The following syscalls are obsolete and no longer available for EABI.
  */
  */

+ 4 - 3
arch/arm/kernel/entry-armv.S

@@ -21,6 +21,7 @@
 #include <mach/entry-macro.S>
 #include <mach/entry-macro.S>
 #include <asm/thread_notify.h>
 #include <asm/thread_notify.h>
 #include <asm/unwind.h>
 #include <asm/unwind.h>
+#include <asm/unistd.h>
 
 
 #include "entry-header.S"
 #include "entry-header.S"
 
 
@@ -908,10 +909,10 @@ __kuser_cmpxchg:				@ 0xffff0fc0
 	 * A special ghost syscall is used for that (see traps.c).
 	 * A special ghost syscall is used for that (see traps.c).
 	 */
 	 */
 	stmfd	sp!, {r7, lr}
 	stmfd	sp!, {r7, lr}
-	mov	r7, #0xff00		@ 0xfff0 into r7 for EABI
-	orr	r7, r7, #0xf0
-	swi	#0x9ffff0
+	ldr	r7, =1f			@ it's 20 bits
+	swi	__ARM_NR_cmpxchg
 	ldmfd	sp!, {r7, pc}
 	ldmfd	sp!, {r7, pc}
+1:	.word	__ARM_NR_cmpxchg
 
 
 #elif __LINUX_ARM_ARCH__ < 6
 #elif __LINUX_ARM_ARCH__ < 6
 
 

+ 1 - 1
arch/arm/kernel/traps.c

@@ -528,7 +528,7 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
 	 * __kuser_cmpxchg code in entry-armv.S should be aware of its
 	 * __kuser_cmpxchg code in entry-armv.S should be aware of its
 	 * existence.  Don't ever use this from user code.
 	 * existence.  Don't ever use this from user code.
 	 */
 	 */
-	case 0xfff0:
+	case NR(cmpxchg):
 	for (;;) {
 	for (;;) {
 		extern void do_DataAbort(unsigned long addr, unsigned int fsr,
 		extern void do_DataAbort(unsigned long addr, unsigned int fsr,
 					 struct pt_regs *regs);
 					 struct pt_regs *regs);