2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
10 #include <asm/processor.h>
12 /* thread_info has a mm_segment_t in it, so put the definition up here */
17 #include "linux/thread_info.h"
20 #define VERIFY_WRITE 1
23 * The fs value determines whether argument validity checking should be
24 * performed or not. If get_fs() == USER_DS, checking is performed, with
25 * get_fs() == KERNEL_DS, checking is bypassed.
27 * For historical reasons, these macros are grossly misnamed.
30 #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
32 #define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF)
33 #define USER_DS MAKE_MM_SEG(TASK_SIZE)
35 #define get_ds() (KERNEL_DS)
36 #define get_fs() (current_thread_info()->addr_limit)
37 #define set_fs(x) (current_thread_info()->addr_limit = (x))
39 #define segment_eq(a, b) ((a).seg == (b).seg)
41 #include "um_uaccess.h"
43 #define __copy_from_user(to, from, n) copy_from_user(to, from, n)
45 #define __copy_to_user(to, from, n) copy_to_user(to, from, n)
47 #define __copy_to_user_inatomic __copy_to_user
48 #define __copy_from_user_inatomic __copy_from_user
50 #define __get_user(x, ptr) \
52 const __typeof__(*(ptr)) __user *__private_ptr = (ptr); \
53 __typeof__(x) __private_val; \
54 int __private_ret = -EFAULT; \
55 (x) = (__typeof__(*(__private_ptr)))0; \
56 if (__copy_from_user((__force void *)&__private_val, (__private_ptr),\
57 sizeof(*(__private_ptr))) == 0) { \
58 (x) = (__typeof__(*(__private_ptr))) __private_val; \
64 #define get_user(x, ptr) \
66 const __typeof__((*(ptr))) __user *private_ptr = (ptr); \
67 (access_ok(VERIFY_READ, private_ptr, sizeof(*private_ptr)) ? \
68 __get_user(x, private_ptr) : ((x) = (__typeof__(*ptr))0, -EFAULT)); \
71 #define __put_user(x, ptr) \
73 __typeof__(*(ptr)) __user *__private_ptr = ptr; \
74 __typeof__(*(__private_ptr)) __private_val; \
75 int __private_ret = -EFAULT; \
76 __private_val = (__typeof__(*(__private_ptr))) (x); \
77 if (__copy_to_user((__private_ptr), &__private_val, \
78 sizeof(*(__private_ptr))) == 0) { \
84 #define put_user(x, ptr) \
86 __typeof__(*(ptr)) __user *private_ptr = (ptr); \
87 (access_ok(VERIFY_WRITE, private_ptr, sizeof(*private_ptr)) ? \
88 __put_user(x, private_ptr) : -EFAULT); \
91 #define strlen_user(str) strnlen_user(str, ~0U >> 1)
93 struct exception_table_entry