aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/lib/rwlock.S
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/lib/rwlock.S')
-rw-r--r--arch/x86/lib/rwlock.S44
1 files changed, 44 insertions, 0 deletions
diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
new file mode 100644
index 000000000000..fca17829caa8
--- /dev/null
+++ b/arch/x86/lib/rwlock.S
@@ -0,0 +1,44 @@
1/* Slow paths of read/write spinlocks. */
2
3#include <linux/linkage.h>
4#include <asm/alternative-asm.h>
5#include <asm/frame.h>
6#include <asm/rwlock.h>
7
8#ifdef CONFIG_X86_32
9# define __lock_ptr eax
10#else
11# define __lock_ptr rdi
12#endif
13
14ENTRY(__write_lock_failed)
15 CFI_STARTPROC
16 FRAME
170: LOCK_PREFIX
18 addl $RW_LOCK_BIAS, (%__lock_ptr)
191: rep; nop
20 cmpl $RW_LOCK_BIAS, (%__lock_ptr)
21 jne 1b
22 LOCK_PREFIX
23 subl $RW_LOCK_BIAS, (%__lock_ptr)
24 jnz 0b
25 ENDFRAME
26 ret
27 CFI_ENDPROC
28END(__write_lock_failed)
29
30ENTRY(__read_lock_failed)
31 CFI_STARTPROC
32 FRAME
330: LOCK_PREFIX
34 incl (%__lock_ptr)
351: rep; nop
36 cmpl $1, (%__lock_ptr)
37 js 1b
38 LOCK_PREFIX
39 decl (%__lock_ptr)
40 js 0b
41 ENDFRAME
42 ret
43 CFI_ENDPROC
44END(__read_lock_failed)