1/*
2 *  arch/s390/lib/uaccess.S
3 *    __copy_{from|to}_user functions.
4 *
5 *  s390
6 *    Copyright (C) 2000,2002 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 *    Authors(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
8 *
9 *  These functions have standard call interface
10 */
11
12#include <asm/lowcore.h>
13
14        .text
15        .align 4
16        .globl __copy_from_user_asm
17__copy_from_user_asm:
18	lr	%r5,%r3
19	sacf	512
200:	mvcle	%r2,%r4,0
21	jo	0b
22	lr	%r2,%r5
231:	sacf	0
24	br	%r14
252:	lhi	%r1,-4096
26	lr	%r3,%r4
27	slr	%r3,%r1      # %r3 = %r4 + 4096
28	nr	%r3,%r1      # %r3 = (%r4 + 4096) & -4096
29	slr	%r3,%r4      # %r3 = #bytes to next user page boundary
30	clr	%r5,%r3      # copy crosses next page boundary ?
31	jnh	4f           # no, this page faulted
32	# The page after the current user page might have faulted.
33	# We can't find out which page because the program check handler
34	# might have called schedule, destroying all lowcore information.
35	# We retry with the shortened length.
363:	mvcle	%r2,%r4,0
37	jo	3b
384:	lr	%r1,%r5      # pad remaining bytes with 0
39	lr	%r3,%r5
40	slr	%r5,%r5
415:	mvcle	%r2,%r4,0
42	jo	5b
43	lr	%r2,%r1
44	j	1b
45        .section __ex_table,"a"
46	.long	0b,2b
47	.long	3b,4b
48        .previous
49
50        .align 4
51        .text
52        .globl __copy_to_user_asm
53__copy_to_user_asm:
54	lr	%r5,%r3
55	sacf	512
560:	mvcle	%r4,%r2,0
57	jo	0b
581:	sacf	0
59	lr	%r2,%r3
60	br	%r14
612:	lhi	%r1,-4096
62	lr	%r5,%r4
63	slr	%r5,%r1      # %r5 = %r4 + 4096
64	nr	%r5,%r1      # %r5 = (%r4 + 4096) & -4096
65	slr	%r5,%r4      # %r5 = #bytes to next user page boundary
66	clr	%r3,%r5      # copy crosses next page boundary ?
67	jnh	1b           # no, the current page fauled
68	# The page after the current user page might have faulted.
69	# We cant't find out which page because the program check handler
70	# might have callled schedule, destroying all lowcore information.
71	# We retry with the shortened length.
723:	mvcle	%r4,%r2,0
73	jo	3b
74	j	1b
75        .section __ex_table,"a"
76	.long	0b,2b
77	.long	3b,1b
78        .previous
79
80        .align 4
81        .text
82        .globl __clear_user_asm
83__clear_user_asm:
84	lr	%r4,%r2
85	lr	%r5,%r3
86	sr	%r2,%r2
87	sr	%r3,%r3
88	sacf	512
890:	mvcle	%r4,%r2,0
90	jo	0b
911:	sacf	0
92	br	%r14
932:	lr	%r2,%r5
94	lhi	%r1,-4096
95	slr	%r5,%r1      # %r5 = %r4 + 4096
96	nr	%r5,%r1      # %r5 = (%r4 + 4096) & -4096
97	slr	%r5,%r4      # %r5 = #bytes to next user page boundary
98	clr	%r2,%r5      # copy crosses next page boundary ?
99	jnh	1b           # no, the current page fauled
100	# The page after the current user page might have faulted.
101	# We cant't find out which page because the program check handler
102	# might have callled schedule, destroying all lowcore information.
103	# We retry with the shortened length.
104	slr	%r2,%r5
1053:	mvcle	%r4,%r2,0
106	jo	3b
107	j	1b
1084:	alr	%r2,%r5
109	j	1b
110        .section __ex_table,"a"
111	.long	0b,2b
112        .long	3b,4b
113        .previous
114
115