]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/x86/lib/putuser_64.S
6d7513bf885ef2d9a4cc1d4afe12bfd7044149c9
[linux-2.6-omap-h63xx.git] / arch / x86 / lib / putuser_64.S
1 /*
2  * __put_user functions.
3  *
4  * (C) Copyright 1998 Linus Torvalds
5  * (C) Copyright 2005 Andi Kleen
6  *
7  * These functions have a non-standard call interface
8  * to make them more efficient, especially as they
9  * return an error value in addition to the "real"
10  * return value.
11  */
12
13 /*
14  * __put_user_X
15  *
16  * Inputs:      %rcx contains the address
17  *              %rdx contains new value
18  *
19  * Outputs:     %rax is error code (0 or -EFAULT)
20  *
21  * %rbx is destroyed.
22  *
23  * These functions should not modify any other registers,
24  * as they get called from within inline assembly.
25  */
26
27 #include <linux/linkage.h>
28 #include <asm/dwarf2.h>
29 #include <asm/page.h>
30 #include <asm/errno.h>
31 #include <asm/asm-offsets.h>
32 #include <asm/thread_info.h>
33
34 #define ENTER   CFI_STARTPROC ; \
35                 GET_THREAD_INFO(%rbx)
36 #define EXIT    ret ; \
37                 CFI_ENDPROC
38
39         .text
40 ENTRY(__put_user_1)
41         ENTER
42         cmpq TI_addr_limit(%rbx),%rcx
43         jae bad_put_user
44 1:      movb %al,(%rcx)
45         xorl %eax,%eax
46         EXIT
47 ENDPROC(__put_user_1)
48
49 ENTRY(__put_user_2)
50         ENTER
51         mov TI_addr_limit(%rbx),%rbx
52         sub  $1, %rbx
53         cmpq %rbx ,%rcx
54         jae  bad_put_user
55 2:      movw %ax,(%rcx)
56         xorl %eax,%eax
57         EXIT
58 ENDPROC(__put_user_2)
59
60 ENTRY(__put_user_4)
61         ENTER
62         mov TI_addr_limit(%rbx),%rbx
63         sub  $3, %rbx
64         cmp  %rbx, %rcx
65         jae bad_put_user
66 3:      movl %eax,(%rcx)
67         xorl %eax,%eax
68         EXIT
69 ENDPROC(__put_user_4)
70
71 ENTRY(__put_user_8)
72         ENTER
73         mov TI_addr_limit(%rbx),%rbx
74         sub  $7, %rbx
75         cmp  %rbx, %rcx
76         jae bad_put_user
77 4:      movq %rax,(%rcx)
78         xorl %eax,%eax
79         EXIT
80 ENDPROC(__put_user_8)
81
82 bad_put_user:
83         CFI_STARTPROC
84         movq $(-EFAULT),%rax
85         EXIT
86 END(bad_put_user)
87
88 .section __ex_table,"a"
89         .quad 1b,bad_put_user
90         .quad 2b,bad_put_user
91         .quad 3b,bad_put_user
92         .quad 4b,bad_put_user
93 .previous