2 * arch/s390/lib/uaccess.S
3 * __copy_{from|to}_user functions.
6 * Copyright (C) 2000,2002 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Authors(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
9 * These functions have standard call interface
12 #include <linux/errno.h>
13 #include <asm/lowcore.h>
14 #include <asm/offsets.h>
18 .globl __copy_from_user_asm
19 # %r2 = to, %r3 = n, %r4 = from
22 0: mvcp 0(%r3,%r2),0(%r4),%r0
29 2: mvcp 0(%r3,%r2),0(%r4),%r0
36 nr %r5,%r0 # %r5 = (%r4 + 4096) & -4096
37 slr %r5,%r4 # %r5 = #bytes to next user page boundary
38 clr %r3,%r5 # copy crosses next page boundary ?
39 jnh 6f # no, the current page faulted
40 # move with the reduced length which is < 256
41 5: mvcp 0(%r5,%r2),0(%r4),%r0
45 .section __ex_table,"a"
53 .globl __copy_to_user_asm
54 # %r2 = from, %r3 = n, %r4 = to
57 0: mvcs 0(%r3,%r4),0(%r2),%r0
64 2: mvcs 0(%r3,%r4),0(%r2),%r0
71 nr %r5,%r0 # %r5 = (%r4 + 4096) & -4096
72 slr %r5,%r4 # %r5 = #bytes to next user page boundary
73 clr %r3,%r5 # copy crosses next page boundary ?
74 jnh 6f # no, the current page faulted
75 # move with the reduced length which is < 256
76 5: mvcs 0(%r5,%r4),0(%r2),%r0
80 .section __ex_table,"a"
88 .globl __copy_in_user_asm
89 # %r2 = from, %r3 = n, %r4 = to
94 0: mvc 0(256,%r4),0(%r2)
103 3: mvc 0(1,%r4),0(%r2)
111 .section __ex_table,"a"
119 .globl __clear_user_asm
123 .long empty_zero_page
126 1: mvcs 0(%r3,%r2),0(%r5),%r0
132 3: mvcs 0(%r3,%r2),0(%r5),%r0
139 nr %r4,%r0 # %r4 = (%r2 + 4096) & -4096
140 slr %r4,%r2 # %r4 = #bytes to next user page boundary
141 clr %r3,%r4 # clear crosses next page boundary ?
142 jnh 7f # no, the current page faulted
143 # clear with the reduced length which is < 256
144 6: mvcs 0(%r4,%r2),0(%r5),%r0
148 .section __ex_table,"a"
156 .globl __strncpy_from_user_asm
157 # %r2 = count, %r3 = dst, %r4 = src
158 __strncpy_from_user_asm:
161 la %r4,0(%r4) # clear high order bit from %r4
162 la %r2,0(%r2,%r4) # %r2 points to first byte after string
168 jh 1f # \0 found in string ?
169 ahi %r1,1 # include \0 in copy
170 1: slr %r1,%r4 # %r1 = copy length (without \0)
171 slr %r2,%r4 # %r2 = return length (including \0)
172 2: mvcp 0(%r1,%r3),0(%r4),%r0
178 mvcp 0(%r1,%r3),0(%r4),%r0
184 .section __ex_table,"a"
190 .globl __strnlen_user_asm
191 # %r2 = count, %r3 = src
195 la %r3,0(%r3) # clear high order bit from %r4
196 la %r2,0(%r2,%r3) # %r2 points to first byte after string
201 jh 1f # \0 found in string ?
202 ahi %r2,1 # strnlen_user result includes the \0
208 .section __ex_table,"a"