diff options
author | David Miller <davem@davemloft.net> | 2012-05-26 14:14:27 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-26 14:33:54 -0400 |
commit | 2c66f623631709aa5f2e4c14c7e089682e7394a3 (patch) | |
tree | 75e9c0fc8b832b0f9f2fe3ff41e3ae2c26036292 | |
parent | 5723aa993d83803157c22327e90cd59e3dcbe879 (diff) |
sparc: use the new generic strnlen_user() function
This throws away the sparc-specific functions in favor of the generic
optimized version.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | arch/sparc/Kconfig | 1 | ||||
-rw-r--r-- | arch/sparc/include/asm/uaccess_32.h | 22 | ||||
-rw-r--r-- | arch/sparc/include/asm/uaccess_64.h | 8 | ||||
-rw-r--r-- | arch/sparc/lib/Makefile | 1 | ||||
-rw-r--r-- | arch/sparc/lib/ksyms.c | 2 | ||||
-rw-r--r-- | arch/sparc/lib/strlen_user_32.S | 109 | ||||
-rw-r--r-- | arch/sparc/lib/strlen_user_64.S | 97 |
7 files changed, 9 insertions, 231 deletions
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 15e9e05740da..83bd051754e1 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig | |||
@@ -35,6 +35,7 @@ config SPARC | |||
35 | select GENERIC_CMOS_UPDATE | 35 | select GENERIC_CMOS_UPDATE |
36 | select GENERIC_CLOCKEVENTS | 36 | select GENERIC_CLOCKEVENTS |
37 | select GENERIC_STRNCPY_FROM_USER | 37 | select GENERIC_STRNCPY_FROM_USER |
38 | select GENERIC_STRNLEN_USER | ||
38 | 39 | ||
39 | config SPARC32 | 40 | config SPARC32 |
40 | def_bool !64BIT | 41 | def_bool !64BIT |
diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h index 59586b57ef1a..53a28dd59f59 100644 --- a/arch/sparc/include/asm/uaccess_32.h +++ b/arch/sparc/include/asm/uaccess_32.h | |||
@@ -16,6 +16,8 @@ | |||
16 | 16 | ||
17 | #ifndef __ASSEMBLY__ | 17 | #ifndef __ASSEMBLY__ |
18 | 18 | ||
19 | #include <asm/processor.h> | ||
20 | |||
19 | #define ARCH_HAS_SORT_EXTABLE | 21 | #define ARCH_HAS_SORT_EXTABLE |
20 | #define ARCH_HAS_SEARCH_EXTABLE | 22 | #define ARCH_HAS_SEARCH_EXTABLE |
21 | 23 | ||
@@ -304,24 +306,8 @@ static inline unsigned long clear_user(void __user *addr, unsigned long n) | |||
304 | return n; | 306 | return n; |
305 | } | 307 | } |
306 | 308 | ||
307 | extern long __strlen_user(const char __user *); | 309 | extern __must_check long strlen_user(const char __user *str); |
308 | extern long __strnlen_user(const char __user *, long len); | 310 | extern __must_check long strnlen_user(const char __user *str, long n); |
309 | |||
310 | static inline long strlen_user(const char __user *str) | ||
311 | { | ||
312 | if (!access_ok(VERIFY_READ, str, 0)) | ||
313 | return 0; | ||
314 | else | ||
315 | return __strlen_user(str); | ||
316 | } | ||
317 | |||
318 | static inline long strnlen_user(const char __user *str, long len) | ||
319 | { | ||
320 | if (!access_ok(VERIFY_READ, str, 0)) | ||
321 | return 0; | ||
322 | else | ||
323 | return __strnlen_user(str, len); | ||
324 | } | ||
325 | 311 | ||
326 | #endif /* __ASSEMBLY__ */ | 312 | #endif /* __ASSEMBLY__ */ |
327 | 313 | ||
diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h index dcdfb89cbf3f..7c831d848b4e 100644 --- a/arch/sparc/include/asm/uaccess_64.h +++ b/arch/sparc/include/asm/uaccess_64.h | |||
@@ -17,6 +17,8 @@ | |||
17 | 17 | ||
18 | #ifndef __ASSEMBLY__ | 18 | #ifndef __ASSEMBLY__ |
19 | 19 | ||
20 | #include <asm/processor.h> | ||
21 | |||
20 | /* | 22 | /* |
21 | * Sparc64 is segmented, though more like the M68K than the I386. | 23 | * Sparc64 is segmented, though more like the M68K than the I386. |
22 | * We use the secondary ASI to address user memory, which references a | 24 | * We use the secondary ASI to address user memory, which references a |
@@ -257,11 +259,9 @@ extern unsigned long __must_check __clear_user(void __user *, unsigned long); | |||
257 | 259 | ||
258 | #define clear_user __clear_user | 260 | #define clear_user __clear_user |
259 | 261 | ||
260 | extern long __strlen_user(const char __user *); | 262 | extern __must_check long strlen_user(const char __user *str); |
261 | extern long __strnlen_user(const char __user *, long len); | 263 | extern __must_check long strnlen_user(const char __user *str, long n); |
262 | 264 | ||
263 | #define strlen_user __strlen_user | ||
264 | #define strnlen_user __strnlen_user | ||
265 | #define __copy_to_user_inatomic ___copy_to_user | 265 | #define __copy_to_user_inatomic ___copy_to_user |
266 | #define __copy_from_user_inatomic ___copy_from_user | 266 | #define __copy_from_user_inatomic ___copy_from_user |
267 | 267 | ||
diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile index 943d98dc4cdb..dff4096f3dec 100644 --- a/arch/sparc/lib/Makefile +++ b/arch/sparc/lib/Makefile | |||
@@ -10,7 +10,6 @@ lib-y += strlen.o | |||
10 | lib-y += checksum_$(BITS).o | 10 | lib-y += checksum_$(BITS).o |
11 | lib-$(CONFIG_SPARC32) += blockops.o | 11 | lib-$(CONFIG_SPARC32) += blockops.o |
12 | lib-y += memscan_$(BITS).o memcmp.o strncmp_$(BITS).o | 12 | lib-y += memscan_$(BITS).o memcmp.o strncmp_$(BITS).o |
13 | lib-y += strlen_user_$(BITS).o | ||
14 | lib-$(CONFIG_SPARC32) += divdi3.o udivdi3.o | 13 | lib-$(CONFIG_SPARC32) += divdi3.o udivdi3.o |
15 | lib-$(CONFIG_SPARC32) += copy_user.o locks.o | 14 | lib-$(CONFIG_SPARC32) += copy_user.o locks.o |
16 | lib-$(CONFIG_SPARC64) += atomic_64.o | 15 | lib-$(CONFIG_SPARC64) += atomic_64.o |
diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c index 6b278abdb63d..3b31218cafc6 100644 --- a/arch/sparc/lib/ksyms.c +++ b/arch/sparc/lib/ksyms.c | |||
@@ -15,8 +15,6 @@ | |||
15 | 15 | ||
16 | /* string functions */ | 16 | /* string functions */ |
17 | EXPORT_SYMBOL(strlen); | 17 | EXPORT_SYMBOL(strlen); |
18 | EXPORT_SYMBOL(__strlen_user); | ||
19 | EXPORT_SYMBOL(__strnlen_user); | ||
20 | EXPORT_SYMBOL(strncmp); | 18 | EXPORT_SYMBOL(strncmp); |
21 | 19 | ||
22 | /* mem* functions */ | 20 | /* mem* functions */ |
diff --git a/arch/sparc/lib/strlen_user_32.S b/arch/sparc/lib/strlen_user_32.S deleted file mode 100644 index 8c8a371df3c9..000000000000 --- a/arch/sparc/lib/strlen_user_32.S +++ /dev/null | |||
@@ -1,109 +0,0 @@ | |||
1 | /* strlen_user.S: Sparc optimized strlen_user code | ||
2 | * | ||
3 | * Return length of string in userspace including terminating 0 | ||
4 | * or 0 for error | ||
5 | * | ||
6 | * Copyright (C) 1991,1996 Free Software Foundation | ||
7 | * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) | ||
8 | * Copyright (C) 1996 Jakub Jelinek (jj@sunsite.mff.cuni.cz) | ||
9 | */ | ||
10 | |||
11 | #define LO_MAGIC 0x01010101 | ||
12 | #define HI_MAGIC 0x80808080 | ||
13 | |||
14 | 10: | ||
15 | ldub [%o0], %o5 | ||
16 | cmp %o5, 0 | ||
17 | be 1f | ||
18 | add %o0, 1, %o0 | ||
19 | andcc %o0, 3, %g0 | ||
20 | be 4f | ||
21 | or %o4, %lo(HI_MAGIC), %o3 | ||
22 | 11: | ||
23 | ldub [%o0], %o5 | ||
24 | cmp %o5, 0 | ||
25 | be 2f | ||
26 | add %o0, 1, %o0 | ||
27 | andcc %o0, 3, %g0 | ||
28 | be 5f | ||
29 | sethi %hi(LO_MAGIC), %o4 | ||
30 | 12: | ||
31 | ldub [%o0], %o5 | ||
32 | cmp %o5, 0 | ||
33 | be 3f | ||
34 | add %o0, 1, %o0 | ||
35 | b 13f | ||
36 | or %o4, %lo(LO_MAGIC), %o2 | ||
37 | 1: | ||
38 | retl | ||
39 | mov 1, %o0 | ||
40 | 2: | ||
41 | retl | ||
42 | mov 2, %o0 | ||
43 | 3: | ||
44 | retl | ||
45 | mov 3, %o0 | ||
46 | |||
47 | .align 4 | ||
48 | .global __strlen_user, __strnlen_user | ||
49 | __strlen_user: | ||
50 | sethi %hi(32768), %o1 | ||
51 | __strnlen_user: | ||
52 | mov %o1, %g1 | ||
53 | mov %o0, %o1 | ||
54 | andcc %o0, 3, %g0 | ||
55 | bne 10b | ||
56 | sethi %hi(HI_MAGIC), %o4 | ||
57 | or %o4, %lo(HI_MAGIC), %o3 | ||
58 | 4: | ||
59 | sethi %hi(LO_MAGIC), %o4 | ||
60 | 5: | ||
61 | or %o4, %lo(LO_MAGIC), %o2 | ||
62 | 13: | ||
63 | ld [%o0], %o5 | ||
64 | 2: | ||
65 | sub %o5, %o2, %o4 | ||
66 | andcc %o4, %o3, %g0 | ||
67 | bne 82f | ||
68 | add %o0, 4, %o0 | ||
69 | sub %o0, %o1, %g2 | ||
70 | 81: cmp %g2, %g1 | ||
71 | blu 13b | ||
72 | mov %o0, %o4 | ||
73 | ba,a 1f | ||
74 | |||
75 | /* Check every byte. */ | ||
76 | 82: srl %o5, 24, %g5 | ||
77 | andcc %g5, 0xff, %g0 | ||
78 | be 1f | ||
79 | add %o0, -3, %o4 | ||
80 | srl %o5, 16, %g5 | ||
81 | andcc %g5, 0xff, %g0 | ||
82 | be 1f | ||
83 | add %o4, 1, %o4 | ||
84 | srl %o5, 8, %g5 | ||
85 | andcc %g5, 0xff, %g0 | ||
86 | be 1f | ||
87 | add %o4, 1, %o4 | ||
88 | andcc %o5, 0xff, %g0 | ||
89 | bne 81b | ||
90 | sub %o0, %o1, %g2 | ||
91 | |||
92 | add %o4, 1, %o4 | ||
93 | 1: | ||
94 | retl | ||
95 | sub %o4, %o1, %o0 | ||
96 | |||
97 | .section .fixup,#alloc,#execinstr | ||
98 | .align 4 | ||
99 | 9: | ||
100 | retl | ||
101 | clr %o0 | ||
102 | |||
103 | .section __ex_table,#alloc | ||
104 | .align 4 | ||
105 | |||
106 | .word 10b, 9b | ||
107 | .word 11b, 9b | ||
108 | .word 12b, 9b | ||
109 | .word 13b, 9b | ||
diff --git a/arch/sparc/lib/strlen_user_64.S b/arch/sparc/lib/strlen_user_64.S deleted file mode 100644 index c3df71fa4928..000000000000 --- a/arch/sparc/lib/strlen_user_64.S +++ /dev/null | |||
@@ -1,97 +0,0 @@ | |||
1 | /* strlen_user.S: Sparc64 optimized strlen_user code | ||
2 | * | ||
3 | * Return length of string in userspace including terminating 0 | ||
4 | * or 0 for error | ||
5 | * | ||
6 | * Copyright (C) 1991,1996 Free Software Foundation | ||
7 | * Copyright (C) 1996,1999 David S. Miller (davem@redhat.com) | ||
8 | * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz) | ||
9 | */ | ||
10 | |||
11 | #include <linux/linkage.h> | ||
12 | #include <asm/asi.h> | ||
13 | |||
14 | #define LO_MAGIC 0x01010101 | ||
15 | #define HI_MAGIC 0x80808080 | ||
16 | |||
17 | .align 4 | ||
18 | ENTRY(__strlen_user) | ||
19 | sethi %hi(32768), %o1 | ||
20 | ENTRY(__strnlen_user) | ||
21 | mov %o1, %g1 | ||
22 | mov %o0, %o1 | ||
23 | andcc %o0, 3, %g0 | ||
24 | be,pt %icc, 9f | ||
25 | sethi %hi(HI_MAGIC), %o4 | ||
26 | 10: lduba [%o0] %asi, %o5 | ||
27 | brz,pn %o5, 21f | ||
28 | add %o0, 1, %o0 | ||
29 | andcc %o0, 3, %g0 | ||
30 | be,pn %icc, 4f | ||
31 | or %o4, %lo(HI_MAGIC), %o3 | ||
32 | 11: lduba [%o0] %asi, %o5 | ||
33 | brz,pn %o5, 22f | ||
34 | add %o0, 1, %o0 | ||
35 | andcc %o0, 3, %g0 | ||
36 | be,pt %icc, 13f | ||
37 | srl %o3, 7, %o2 | ||
38 | 12: lduba [%o0] %asi, %o5 | ||
39 | brz,pn %o5, 23f | ||
40 | add %o0, 1, %o0 | ||
41 | ba,pt %icc, 2f | ||
42 | 15: lda [%o0] %asi, %o5 | ||
43 | 9: or %o4, %lo(HI_MAGIC), %o3 | ||
44 | 4: srl %o3, 7, %o2 | ||
45 | 13: lda [%o0] %asi, %o5 | ||
46 | 2: sub %o5, %o2, %o4 | ||
47 | andcc %o4, %o3, %g0 | ||
48 | bne,pn %icc, 82f | ||
49 | add %o0, 4, %o0 | ||
50 | sub %o0, %o1, %g2 | ||
51 | 81: cmp %g2, %g1 | ||
52 | blu,pt %icc, 13b | ||
53 | mov %o0, %o4 | ||
54 | ba,a,pt %xcc, 1f | ||
55 | |||
56 | /* Check every byte. */ | ||
57 | 82: srl %o5, 24, %g7 | ||
58 | andcc %g7, 0xff, %g0 | ||
59 | be,pn %icc, 1f | ||
60 | add %o0, -3, %o4 | ||
61 | srl %o5, 16, %g7 | ||
62 | andcc %g7, 0xff, %g0 | ||
63 | be,pn %icc, 1f | ||
64 | add %o4, 1, %o4 | ||
65 | srl %o5, 8, %g7 | ||
66 | andcc %g7, 0xff, %g0 | ||
67 | be,pn %icc, 1f | ||
68 | add %o4, 1, %o4 | ||
69 | andcc %o5, 0xff, %g0 | ||
70 | bne,pt %icc, 81b | ||
71 | sub %o0, %o1, %g2 | ||
72 | add %o4, 1, %o4 | ||
73 | 1: retl | ||
74 | sub %o4, %o1, %o0 | ||
75 | 21: retl | ||
76 | mov 1, %o0 | ||
77 | 22: retl | ||
78 | mov 2, %o0 | ||
79 | 23: retl | ||
80 | mov 3, %o0 | ||
81 | ENDPROC(__strlen_user) | ||
82 | ENDPROC(__strnlen_user) | ||
83 | |||
84 | .section .fixup,#alloc,#execinstr | ||
85 | .align 4 | ||
86 | 30: | ||
87 | retl | ||
88 | clr %o0 | ||
89 | |||
90 | .section __ex_table,"a" | ||
91 | .align 4 | ||
92 | |||
93 | .word 10b, 30b | ||
94 | .word 11b, 30b | ||
95 | .word 12b, 30b | ||
96 | .word 15b, 30b | ||
97 | .word 13b, 30b | ||