x86: change testing logic in putuser_64.S.
[linux-2.6/mini2440.git] / arch / x86 / lib / putuser_64.S
bloba96bd8a5298ef684dc4d1c8e1eeec4635576ade5
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  */
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  */
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>
34         .text
35 ENTRY(__put_user_1)
36         CFI_STARTPROC
37         GET_THREAD_INFO(%rbx)
38         cmpq TI_addr_limit(%rbx),%rcx
39         jae bad_put_user
40 1:      movb %al,(%rcx)
41         xorl %eax,%eax
42         ret
43         CFI_ENDPROC
44 ENDPROC(__put_user_1)
46 ENTRY(__put_user_2)
47         CFI_STARTPROC
48         GET_THREAD_INFO(%rbx)
49         mov TI_addr_limit(%rbx),%rbx
50         sub  $1, %rbx
51         cmpq %rbx ,%rcx
52         jae  bad_put_user
53 2:      movw %ax,(%rcx)
54         xorl %eax,%eax
55         ret
56         CFI_ENDPROC
57 ENDPROC(__put_user_2)
59 ENTRY(__put_user_4)
60         CFI_STARTPROC
61         GET_THREAD_INFO(%rbx)
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         ret
69         CFI_ENDPROC
70 ENDPROC(__put_user_4)
72 ENTRY(__put_user_8)
73         CFI_STARTPROC
74         GET_THREAD_INFO(%rbx)
75         mov TI_addr_limit(%rbx),%rbx
76         sub  $7, %rbx
77         cmp  %rbx, %rcx
78         jae bad_put_user
79 4:      movq %rax,(%rcx)
80         xorl %eax,%eax
81         ret
82         CFI_ENDPROC
83 ENDPROC(__put_user_8)
85 bad_put_user:
86         CFI_STARTPROC
87         movq $(-EFAULT),%rax
88         ret
89         CFI_ENDPROC
90 END(bad_put_user)
92 .section __ex_table,"a"
93         .quad 1b,bad_put_user
94         .quad 2b,bad_put_user
95         .quad 3b,bad_put_user
96         .quad 4b,bad_put_user
97 .previous