2 * arch/s390x/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 ngr %r5,%r0 # %r5 = (%r4 + 4096) & -4096
37 slgr %r5,%r4 # %r5 = #bytes to next user page boundary
38 clgr %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 ngr %r5,%r0 # %r5 = (%r4 + 4096) & -4096
72 slgr %r5,%r4 # %r5 = #bytes to next user page boundary
73 clgr %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 larl %r5,empty_zero_page
124 1: mvcs 0(%r3,%r2),0(%r5),%r0
130 3: mvcs 0(%r3,%r2),0(%r5),%r0
137 ngr %r4,%r0 # %r4 = (%r2 + 4096) & -4096
138 slgr %r4,%r2 # %r4 = #bytes to next user page boundary
139 clgr %r3,%r4 # clear crosses next page boundary ?
140 jnh 7f # no, the current page faulted
141 # clear with the reduced length which is < 256
142 6: mvcs 0(%r4,%r2),0(%r5),%r0
146 .section __ex_table,"a"
154 .globl __strncpy_from_user_asm
155 # %r2 = count, %r3 = dst, %r4 = src
156 __strncpy_from_user_asm:
159 la %r2,0(%r2,%r4) # %r2 points to first byte after string
165 jh 1f # \0 found in string ?
166 aghi %r1,1 # include \0 in copy
167 1: slgr %r1,%r4 # %r1 = copy length (without \0)
168 slgr %r2,%r4 # %r2 = return length (including \0)
169 2: mvcp 0(%r1,%r3),0(%r4),%r0
175 mvcp 0(%r1,%r3),0(%r4),%r0
181 .section __ex_table,"a"
187 .globl __strnlen_user_asm
188 # %r2 = count, %r3 = src
192 la %r2,0(%r2,%r3) # %r2 points to first byte after string
197 jh 1f # \0 found in string ?
198 aghi %r2,1 # strnlen_user result includes the \0
204 .section __ex_table,"a"