diff options
author | Paul Mundt <lethal@linux-sh.org> | 2007-05-13 23:52:56 -0400 |
---|---|---|
committer | Paul Mundt <lethal@hera.kernel.org> | 2007-06-07 22:43:36 -0400 |
commit | e08f457c7c0cc7720f28349f8780ea752c063441 (patch) | |
tree | 7b82666f2002d57dc57d022daf90c778265159e9 /include | |
parent | 7a302a9674593259866de4a9d5ae8edc03dc1934 (diff) |
sh: __user annotations for __get/__put_user().
This adds in some more __user annotations. These weren't being
handled properly in some of the __get_user and __put_user paths,
so tidy those up.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-sh/page.h | 1 | ||||
-rw-r--r-- | include/asm-sh/sections.h | 2 | ||||
-rw-r--r-- | include/asm-sh/system.h | 14 | ||||
-rw-r--r-- | include/asm-sh/uaccess.h | 40 |
4 files changed, 37 insertions, 20 deletions
diff --git a/include/asm-sh/page.h b/include/asm-sh/page.h index 7464de4ba07d..011dfbe14a6b 100644 --- a/include/asm-sh/page.h +++ b/include/asm-sh/page.h | |||
@@ -60,6 +60,7 @@ extern void (*copy_page)(void *to, void *from); | |||
60 | 60 | ||
61 | extern unsigned long shm_align_mask; | 61 | extern unsigned long shm_align_mask; |
62 | extern unsigned long max_low_pfn, min_low_pfn; | 62 | extern unsigned long max_low_pfn, min_low_pfn; |
63 | extern unsigned long memory_start, memory_end; | ||
63 | 64 | ||
64 | #ifdef CONFIG_MMU | 65 | #ifdef CONFIG_MMU |
65 | extern void clear_page_slow(void *to); | 66 | extern void clear_page_slow(void *to); |
diff --git a/include/asm-sh/sections.h b/include/asm-sh/sections.h index 57abd708b236..44c06c09e208 100644 --- a/include/asm-sh/sections.h +++ b/include/asm-sh/sections.h | |||
@@ -3,7 +3,5 @@ | |||
3 | 3 | ||
4 | #include <asm-generic/sections.h> | 4 | #include <asm-generic/sections.h> |
5 | 5 | ||
6 | extern char _end[]; | ||
7 | |||
8 | #endif /* __ASM_SH_SECTIONS_H */ | 6 | #endif /* __ASM_SH_SECTIONS_H */ |
9 | 7 | ||
diff --git a/include/asm-sh/system.h b/include/asm-sh/system.h index 82f3e229e621..fb22fc3f87ad 100644 --- a/include/asm-sh/system.h +++ b/include/asm-sh/system.h | |||
@@ -8,9 +8,13 @@ | |||
8 | 8 | ||
9 | #include <linux/irqflags.h> | 9 | #include <linux/irqflags.h> |
10 | #include <linux/compiler.h> | 10 | #include <linux/compiler.h> |
11 | #include <linux/linkage.h> | ||
11 | #include <asm/types.h> | 12 | #include <asm/types.h> |
12 | #include <asm/ptrace.h> | 13 | #include <asm/ptrace.h> |
13 | 14 | ||
15 | struct task_struct *__switch_to(struct task_struct *prev, | ||
16 | struct task_struct *next); | ||
17 | |||
14 | /* | 18 | /* |
15 | * switch_to() should switch tasks to task nr n, first | 19 | * switch_to() should switch tasks to task nr n, first |
16 | */ | 20 | */ |
@@ -271,6 +275,16 @@ extern unsigned int instruction_size(unsigned int insn); | |||
271 | void disable_hlt(void); | 275 | void disable_hlt(void); |
272 | void enable_hlt(void); | 276 | void enable_hlt(void); |
273 | 277 | ||
278 | void default_idle(void); | ||
279 | |||
280 | asmlinkage void break_point_trap(void); | ||
281 | asmlinkage void debug_trap_handler(unsigned long r4, unsigned long r5, | ||
282 | unsigned long r6, unsigned long r7, | ||
283 | struct pt_regs __regs); | ||
284 | asmlinkage void bug_trap_handler(unsigned long r4, unsigned long r5, | ||
285 | unsigned long r6, unsigned long r7, | ||
286 | struct pt_regs __regs); | ||
287 | |||
274 | #define arch_align_stack(x) (x) | 288 | #define arch_align_stack(x) (x) |
275 | 289 | ||
276 | #endif | 290 | #endif |
diff --git a/include/asm-sh/uaccess.h b/include/asm-sh/uaccess.h index 5c49ed6715f2..f18a1a5c95c0 100644 --- a/include/asm-sh/uaccess.h +++ b/include/asm-sh/uaccess.h | |||
@@ -61,8 +61,6 @@ static inline void set_fs(mm_segment_t s) | |||
61 | */ | 61 | */ |
62 | static inline int __access_ok(unsigned long addr, unsigned long size) | 62 | static inline int __access_ok(unsigned long addr, unsigned long size) |
63 | { | 63 | { |
64 | extern unsigned long memory_start, memory_end; | ||
65 | |||
66 | return ((addr >= memory_start) && ((addr + size) < memory_end)); | 64 | return ((addr >= memory_start) && ((addr + size) < memory_end)); |
67 | } | 65 | } |
68 | #else /* CONFIG_MMU */ | 66 | #else /* CONFIG_MMU */ |
@@ -76,7 +74,7 @@ static inline int __access_ok(unsigned long addr, unsigned long size) | |||
76 | * __access_ok: Check if address with size is OK or not. | 74 | * __access_ok: Check if address with size is OK or not. |
77 | * | 75 | * |
78 | * We do three checks: | 76 | * We do three checks: |
79 | * (1) is it user space? | 77 | * (1) is it user space? |
80 | * (2) addr + size --> carry? | 78 | * (2) addr + size --> carry? |
81 | * (3) addr + size >= 0x80000000 (PAGE_OFFSET) | 79 | * (3) addr + size >= 0x80000000 (PAGE_OFFSET) |
82 | * | 80 | * |
@@ -142,11 +140,12 @@ static inline int access_ok(int type, const void __user *p, unsigned long size) | |||
142 | __get_user_nocheck((x),(ptr),sizeof(*(ptr))) | 140 | __get_user_nocheck((x),(ptr),sizeof(*(ptr))) |
143 | 141 | ||
144 | struct __large_struct { unsigned long buf[100]; }; | 142 | struct __large_struct { unsigned long buf[100]; }; |
145 | #define __m(x) (*(struct __large_struct *)(x)) | 143 | #define __m(x) (*(struct __large_struct __user *)(x)) |
146 | 144 | ||
147 | #define __get_user_size(x,ptr,size,retval) \ | 145 | #define __get_user_size(x,ptr,size,retval) \ |
148 | do { \ | 146 | do { \ |
149 | retval = 0; \ | 147 | retval = 0; \ |
148 | __chk_user_ptr(ptr); \ | ||
150 | switch (size) { \ | 149 | switch (size) { \ |
151 | case 1: \ | 150 | case 1: \ |
152 | __get_user_asm(x, ptr, retval, "b"); \ | 151 | __get_user_asm(x, ptr, retval, "b"); \ |
@@ -175,6 +174,7 @@ do { \ | |||
175 | #define __get_user_check(x,ptr,size) \ | 174 | #define __get_user_check(x,ptr,size) \ |
176 | ({ \ | 175 | ({ \ |
177 | long __gu_err, __gu_val; \ | 176 | long __gu_err, __gu_val; \ |
177 | __chk_user_ptr(ptr); \ | ||
178 | switch (size) { \ | 178 | switch (size) { \ |
179 | case 1: \ | 179 | case 1: \ |
180 | __get_user_1(__gu_val, (ptr), __gu_err); \ | 180 | __get_user_1(__gu_val, (ptr), __gu_err); \ |
@@ -300,6 +300,7 @@ extern void __get_user_unknown(void); | |||
300 | #define __put_user_size(x,ptr,size,retval) \ | 300 | #define __put_user_size(x,ptr,size,retval) \ |
301 | do { \ | 301 | do { \ |
302 | retval = 0; \ | 302 | retval = 0; \ |
303 | __chk_user_ptr(ptr); \ | ||
303 | switch (size) { \ | 304 | switch (size) { \ |
304 | case 1: \ | 305 | case 1: \ |
305 | __put_user_asm(x, ptr, retval, "b"); \ | 306 | __put_user_asm(x, ptr, retval, "b"); \ |
@@ -328,7 +329,7 @@ do { \ | |||
328 | #define __put_user_check(x,ptr,size) \ | 329 | #define __put_user_check(x,ptr,size) \ |
329 | ({ \ | 330 | ({ \ |
330 | long __pu_err = -EFAULT; \ | 331 | long __pu_err = -EFAULT; \ |
331 | __typeof__(*(ptr)) *__pu_addr = (ptr); \ | 332 | __typeof__(*(ptr)) __user *__pu_addr = (ptr); \ |
332 | \ | 333 | \ |
333 | if (__access_ok((unsigned long)__pu_addr,size)) \ | 334 | if (__access_ok((unsigned long)__pu_addr,size)) \ |
334 | __put_user_size((x),__pu_addr,(size),__pu_err); \ | 335 | __put_user_size((x),__pu_addr,(size),__pu_err); \ |
@@ -406,10 +407,10 @@ __asm__ __volatile__( \ | |||
406 | #endif | 407 | #endif |
407 | 408 | ||
408 | extern void __put_user_unknown(void); | 409 | extern void __put_user_unknown(void); |
409 | 410 | ||
410 | /* Generic arbitrary sized copy. */ | 411 | /* Generic arbitrary sized copy. */ |
411 | /* Return the number of bytes NOT copied */ | 412 | /* Return the number of bytes NOT copied */ |
412 | extern __kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n); | 413 | __kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n); |
413 | 414 | ||
414 | #define copy_to_user(to,from,n) ({ \ | 415 | #define copy_to_user(to,from,n) ({ \ |
415 | void *__copy_to = (void *) (to); \ | 416 | void *__copy_to = (void *) (to); \ |
@@ -420,14 +421,6 @@ __copy_res = __copy_user(__copy_to, (void *) (from), __copy_size); \ | |||
420 | } else __copy_res = __copy_size; \ | 421 | } else __copy_res = __copy_size; \ |
421 | __copy_res; }) | 422 | __copy_res; }) |
422 | 423 | ||
423 | #define __copy_to_user(to,from,n) \ | ||
424 | __copy_user((void *)(to), \ | ||
425 | (void *)(from), n) | ||
426 | |||
427 | #define __copy_to_user_inatomic __copy_to_user | ||
428 | #define __copy_from_user_inatomic __copy_from_user | ||
429 | |||
430 | |||
431 | #define copy_from_user(to,from,n) ({ \ | 424 | #define copy_from_user(to,from,n) ({ \ |
432 | void *__copy_to = (void *) (to); \ | 425 | void *__copy_to = (void *) (to); \ |
433 | void *__copy_from = (void *) (from); \ | 426 | void *__copy_from = (void *) (from); \ |
@@ -438,9 +431,20 @@ __copy_res = __copy_user(__copy_to, __copy_from, __copy_size); \ | |||
438 | } else __copy_res = __copy_size; \ | 431 | } else __copy_res = __copy_size; \ |
439 | __copy_res; }) | 432 | __copy_res; }) |
440 | 433 | ||
441 | #define __copy_from_user(to,from,n) \ | 434 | static __always_inline unsigned long |
442 | __copy_user((void *)(to), \ | 435 | __copy_from_user(void *to, const void __user *from, unsigned long n) |
443 | (void *)(from), n) | 436 | { |
437 | return __copy_user(to, (__force void *)from, n); | ||
438 | } | ||
439 | |||
440 | static __always_inline unsigned long __must_check | ||
441 | __copy_to_user(void __user *to, const void *from, unsigned long n) | ||
442 | { | ||
443 | return __copy_user((__force void *)to, from, n); | ||
444 | } | ||
445 | |||
446 | #define __copy_to_user_inatomic __copy_to_user | ||
447 | #define __copy_from_user_inatomic __copy_from_user | ||
444 | 448 | ||
445 | /* | 449 | /* |
446 | * Clear the area and return remaining number of bytes | 450 | * Clear the area and return remaining number of bytes |