diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-15 12:00:19 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-15 12:00:19 -0500 |
commit | 17c330f98383629cfd359ee62b3adde1d2a3ff7c (patch) | |
tree | 876bed8fc7de7d404fae579035a948c46a7f05d4 /arch/sparc/include | |
parent | 48e902f0a3aea4b6b3a73e9d277b92024a493e6d (diff) | |
parent | 7466bd3caab6bd1d0095de957affbacd02ca58a7 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6:
sparc64: Fix clock event multiplier printf format.
sparc64: Use clock{source,events}_calc_mult_shift().
sparc64: Use free_bootmem_late() in mdesc_lmb_free().
sparc: Add alignment and emulation fault perf events.
sparc64: Add syscall tracepoint support.
sparc: Stop trying to be so fancy and use __builtin_{memcpy,memset}()
sparc: Use __builtin_object_size() to validate the buffer size for copy_from_user()
sparc64: Add some missing __kprobes annotations to kernel fault paths.
sparc64: Use kprobes_built_in() to avoid ifdefs in fault_64.c
sparc: Validate that kprobe address is 4-byte aligned.
sparc64: Don't specify IRQF_SHARED for LDC interrupts.
sparc64: Fix stack debugging IRQ stack regression.
sparc64: Fix overly strict range type matching for PCI devices.
Diffstat (limited to 'arch/sparc/include')
-rw-r--r-- | arch/sparc/include/asm/string_32.h | 78 | ||||
-rw-r--r-- | arch/sparc/include/asm/string_64.h | 25 | ||||
-rw-r--r-- | arch/sparc/include/asm/thread_info_64.h | 2 | ||||
-rw-r--r-- | arch/sparc/include/asm/uaccess_32.h | 15 | ||||
-rw-r--r-- | arch/sparc/include/asm/uaccess_64.h | 23 | ||||
-rw-r--r-- | arch/sparc/include/asm/unistd.h | 2 |
6 files changed, 41 insertions, 104 deletions
diff --git a/arch/sparc/include/asm/string_32.h b/arch/sparc/include/asm/string_32.h index 6c5fddb7e6b5..edf196ee4ef8 100644 --- a/arch/sparc/include/asm/string_32.h +++ b/arch/sparc/include/asm/string_32.h | |||
@@ -16,8 +16,6 @@ | |||
16 | #ifdef __KERNEL__ | 16 | #ifdef __KERNEL__ |
17 | 17 | ||
18 | extern void __memmove(void *,const void *,__kernel_size_t); | 18 | extern void __memmove(void *,const void *,__kernel_size_t); |
19 | extern __kernel_size_t __memcpy(void *,const void *,__kernel_size_t); | ||
20 | extern __kernel_size_t __memset(void *,int,__kernel_size_t); | ||
21 | 19 | ||
22 | #ifndef EXPORT_SYMTAB_STROPS | 20 | #ifndef EXPORT_SYMTAB_STROPS |
23 | 21 | ||
@@ -32,82 +30,10 @@ extern __kernel_size_t __memset(void *,int,__kernel_size_t); | |||
32 | }) | 30 | }) |
33 | 31 | ||
34 | #define __HAVE_ARCH_MEMCPY | 32 | #define __HAVE_ARCH_MEMCPY |
35 | 33 | #define memcpy(t, f, n) __builtin_memcpy(t, f, n) | |
36 | static inline void *__constant_memcpy(void *to, const void *from, __kernel_size_t n) | ||
37 | { | ||
38 | extern void __copy_1page(void *, const void *); | ||
39 | |||
40 | if(n <= 32) { | ||
41 | __builtin_memcpy(to, from, n); | ||
42 | } else if (((unsigned int) to & 7) != 0) { | ||
43 | /* Destination is not aligned on the double-word boundary */ | ||
44 | __memcpy(to, from, n); | ||
45 | } else { | ||
46 | switch(n) { | ||
47 | case PAGE_SIZE: | ||
48 | __copy_1page(to, from); | ||
49 | break; | ||
50 | default: | ||
51 | __memcpy(to, from, n); | ||
52 | break; | ||
53 | } | ||
54 | } | ||
55 | return to; | ||
56 | } | ||
57 | |||
58 | static inline void *__nonconstant_memcpy(void *to, const void *from, __kernel_size_t n) | ||
59 | { | ||
60 | __memcpy(to, from, n); | ||
61 | return to; | ||
62 | } | ||
63 | |||
64 | #undef memcpy | ||
65 | #define memcpy(t, f, n) \ | ||
66 | (__builtin_constant_p(n) ? \ | ||
67 | __constant_memcpy((t),(f),(n)) : \ | ||
68 | __nonconstant_memcpy((t),(f),(n))) | ||
69 | 34 | ||
70 | #define __HAVE_ARCH_MEMSET | 35 | #define __HAVE_ARCH_MEMSET |
71 | 36 | #define memset(s, c, count) __builtin_memset(s, c, count) | |
72 | static inline void *__constant_c_and_count_memset(void *s, char c, __kernel_size_t count) | ||
73 | { | ||
74 | extern void bzero_1page(void *); | ||
75 | extern __kernel_size_t __bzero(void *, __kernel_size_t); | ||
76 | |||
77 | if(!c) { | ||
78 | if(count == PAGE_SIZE) | ||
79 | bzero_1page(s); | ||
80 | else | ||
81 | __bzero(s, count); | ||
82 | } else { | ||
83 | __memset(s, c, count); | ||
84 | } | ||
85 | return s; | ||
86 | } | ||
87 | |||
88 | static inline void *__constant_c_memset(void *s, char c, __kernel_size_t count) | ||
89 | { | ||
90 | extern __kernel_size_t __bzero(void *, __kernel_size_t); | ||
91 | |||
92 | if(!c) | ||
93 | __bzero(s, count); | ||
94 | else | ||
95 | __memset(s, c, count); | ||
96 | return s; | ||
97 | } | ||
98 | |||
99 | static inline void *__nonconstant_memset(void *s, char c, __kernel_size_t count) | ||
100 | { | ||
101 | __memset(s, c, count); | ||
102 | return s; | ||
103 | } | ||
104 | |||
105 | #undef memset | ||
106 | #define memset(s, c, count) \ | ||
107 | (__builtin_constant_p(c) ? (__builtin_constant_p(count) ? \ | ||
108 | __constant_c_and_count_memset((s), (c), (count)) : \ | ||
109 | __constant_c_memset((s), (c), (count))) \ | ||
110 | : __nonconstant_memset((s), (c), (count))) | ||
111 | 37 | ||
112 | #define __HAVE_ARCH_MEMSCAN | 38 | #define __HAVE_ARCH_MEMSCAN |
113 | 39 | ||
diff --git a/arch/sparc/include/asm/string_64.h b/arch/sparc/include/asm/string_64.h index 43161f2d17eb..9623bc213158 100644 --- a/arch/sparc/include/asm/string_64.h +++ b/arch/sparc/include/asm/string_64.h | |||
@@ -15,8 +15,6 @@ | |||
15 | 15 | ||
16 | #include <asm/asi.h> | 16 | #include <asm/asi.h> |
17 | 17 | ||
18 | extern void *__memset(void *,int,__kernel_size_t); | ||
19 | |||
20 | #ifndef EXPORT_SYMTAB_STROPS | 18 | #ifndef EXPORT_SYMTAB_STROPS |
21 | 19 | ||
22 | /* First the mem*() things. */ | 20 | /* First the mem*() things. */ |
@@ -24,29 +22,10 @@ extern void *__memset(void *,int,__kernel_size_t); | |||
24 | extern void *memmove(void *, const void *, __kernel_size_t); | 22 | extern void *memmove(void *, const void *, __kernel_size_t); |
25 | 23 | ||
26 | #define __HAVE_ARCH_MEMCPY | 24 | #define __HAVE_ARCH_MEMCPY |
27 | extern void *memcpy(void *, const void *, __kernel_size_t); | 25 | #define memcpy(t, f, n) __builtin_memcpy(t, f, n) |
28 | 26 | ||
29 | #define __HAVE_ARCH_MEMSET | 27 | #define __HAVE_ARCH_MEMSET |
30 | extern void *__builtin_memset(void *,int,__kernel_size_t); | 28 | #define memset(s, c, count) __builtin_memset(s, c, count) |
31 | |||
32 | static inline void *__constant_memset(void *s, int c, __kernel_size_t count) | ||
33 | { | ||
34 | extern __kernel_size_t __bzero(void *, __kernel_size_t); | ||
35 | |||
36 | if (!c) { | ||
37 | __bzero(s, count); | ||
38 | return s; | ||
39 | } else | ||
40 | return __memset(s, c, count); | ||
41 | } | ||
42 | |||
43 | #undef memset | ||
44 | #define memset(s, c, count) \ | ||
45 | ((__builtin_constant_p(count) && (count) <= 32) ? \ | ||
46 | __builtin_memset((s), (c), (count)) : \ | ||
47 | (__builtin_constant_p(c) ? \ | ||
48 | __constant_memset((s), (c), (count)) : \ | ||
49 | __memset((s), (c), (count)))) | ||
50 | 29 | ||
51 | #define __HAVE_ARCH_MEMSCAN | 30 | #define __HAVE_ARCH_MEMSCAN |
52 | 31 | ||
diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h index 1b45a7bbe407..7257ebb8f394 100644 --- a/arch/sparc/include/asm/thread_info_64.h +++ b/arch/sparc/include/asm/thread_info_64.h | |||
@@ -227,6 +227,7 @@ register struct thread_info *current_thread_info_reg asm("g6"); | |||
227 | /* flag bit 8 is available */ | 227 | /* flag bit 8 is available */ |
228 | #define TIF_SECCOMP 9 /* secure computing */ | 228 | #define TIF_SECCOMP 9 /* secure computing */ |
229 | #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */ | 229 | #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */ |
230 | #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */ | ||
230 | /* flag bit 11 is available */ | 231 | /* flag bit 11 is available */ |
231 | /* NOTE: Thread flags >= 12 should be ones we have no interest | 232 | /* NOTE: Thread flags >= 12 should be ones we have no interest |
232 | * in using in assembly, else we can't use the mask as | 233 | * in using in assembly, else we can't use the mask as |
@@ -246,6 +247,7 @@ register struct thread_info *current_thread_info_reg asm("g6"); | |||
246 | #define _TIF_32BIT (1<<TIF_32BIT) | 247 | #define _TIF_32BIT (1<<TIF_32BIT) |
247 | #define _TIF_SECCOMP (1<<TIF_SECCOMP) | 248 | #define _TIF_SECCOMP (1<<TIF_SECCOMP) |
248 | #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) | 249 | #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) |
250 | #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT) | ||
249 | #define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING) | 251 | #define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING) |
250 | #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) | 252 | #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) |
251 | #define _TIF_FREEZE (1<<TIF_FREEZE) | 253 | #define _TIF_FREEZE (1<<TIF_FREEZE) |
diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h index 8303ac481034..489d2ba92bcb 100644 --- a/arch/sparc/include/asm/uaccess_32.h +++ b/arch/sparc/include/asm/uaccess_32.h | |||
@@ -260,8 +260,23 @@ static inline unsigned long __copy_to_user(void __user *to, const void *from, un | |||
260 | return __copy_user(to, (__force void __user *) from, n); | 260 | return __copy_user(to, (__force void __user *) from, n); |
261 | } | 261 | } |
262 | 262 | ||
263 | extern void copy_from_user_overflow(void) | ||
264 | #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS | ||
265 | __compiletime_error("copy_from_user() buffer size is not provably correct") | ||
266 | #else | ||
267 | __compiletime_warning("copy_from_user() buffer size is not provably correct") | ||
268 | #endif | ||
269 | ; | ||
270 | |||
263 | static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n) | 271 | static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n) |
264 | { | 272 | { |
273 | int sz = __compiletime_object_size(to); | ||
274 | |||
275 | if (unlikely(sz != -1 && sz < n)) { | ||
276 | copy_from_user_overflow(); | ||
277 | return -EFAULT; | ||
278 | } | ||
279 | |||
265 | if (n && __access_ok((unsigned long) from, n)) | 280 | if (n && __access_ok((unsigned long) from, n)) |
266 | return __copy_user((__force void __user *) to, from, n); | 281 | return __copy_user((__force void __user *) to, from, n); |
267 | else | 282 | else |
diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h index 9ea271e19c70..dbc141660994 100644 --- a/arch/sparc/include/asm/uaccess_64.h +++ b/arch/sparc/include/asm/uaccess_64.h | |||
@@ -6,6 +6,7 @@ | |||
6 | */ | 6 | */ |
7 | 7 | ||
8 | #ifdef __KERNEL__ | 8 | #ifdef __KERNEL__ |
9 | #include <linux/errno.h> | ||
9 | #include <linux/compiler.h> | 10 | #include <linux/compiler.h> |
10 | #include <linux/string.h> | 11 | #include <linux/string.h> |
11 | #include <linux/thread_info.h> | 12 | #include <linux/thread_info.h> |
@@ -204,6 +205,14 @@ __asm__ __volatile__( \ | |||
204 | 205 | ||
205 | extern int __get_user_bad(void); | 206 | extern int __get_user_bad(void); |
206 | 207 | ||
208 | extern void copy_from_user_overflow(void) | ||
209 | #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS | ||
210 | __compiletime_error("copy_from_user() buffer size is not provably correct") | ||
211 | #else | ||
212 | __compiletime_warning("copy_from_user() buffer size is not provably correct") | ||
213 | #endif | ||
214 | ; | ||
215 | |||
207 | extern unsigned long __must_check ___copy_from_user(void *to, | 216 | extern unsigned long __must_check ___copy_from_user(void *to, |
208 | const void __user *from, | 217 | const void __user *from, |
209 | unsigned long size); | 218 | unsigned long size); |
@@ -212,10 +221,16 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from, | |||
212 | static inline unsigned long __must_check | 221 | static inline unsigned long __must_check |
213 | copy_from_user(void *to, const void __user *from, unsigned long size) | 222 | copy_from_user(void *to, const void __user *from, unsigned long size) |
214 | { | 223 | { |
215 | unsigned long ret = ___copy_from_user(to, from, size); | 224 | unsigned long ret = (unsigned long) -EFAULT; |
216 | 225 | int sz = __compiletime_object_size(to); | |
217 | if (unlikely(ret)) | 226 | |
218 | ret = copy_from_user_fixup(to, from, size); | 227 | if (likely(sz == -1 || sz >= size)) { |
228 | ret = ___copy_from_user(to, from, size); | ||
229 | if (unlikely(ret)) | ||
230 | ret = copy_from_user_fixup(to, from, size); | ||
231 | } else { | ||
232 | copy_from_user_overflow(); | ||
233 | } | ||
219 | return ret; | 234 | return ret; |
220 | } | 235 | } |
221 | #define __copy_from_user copy_from_user | 236 | #define __copy_from_user copy_from_user |
diff --git a/arch/sparc/include/asm/unistd.h b/arch/sparc/include/asm/unistd.h index d8d25bd97121..cb4b9bfd0d87 100644 --- a/arch/sparc/include/asm/unistd.h +++ b/arch/sparc/include/asm/unistd.h | |||
@@ -398,7 +398,7 @@ | |||
398 | #define __NR_perf_event_open 327 | 398 | #define __NR_perf_event_open 327 |
399 | #define __NR_recvmmsg 328 | 399 | #define __NR_recvmmsg 328 |
400 | 400 | ||
401 | #define NR_SYSCALLS 329 | 401 | #define NR_syscalls 329 |
402 | 402 | ||
403 | #ifdef __32bit_syscall_numbers__ | 403 | #ifdef __32bit_syscall_numbers__ |
404 | /* Sparc 32-bit only has the "setresuid32", "getresuid32" variants, | 404 | /* Sparc 32-bit only has the "setresuid32", "getresuid32" variants, |