aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlauber Costa <gcosta@redhat.com>2008-06-25 10:05:11 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-09 03:14:18 -0400
commit865e5b76505cdade261773bde32f785b3ce579f1 (patch)
tree3ac122f2b95162b286b1a136ec4460f422b0d8b9
parentca23386216b9d4fc3bb211101205077d2b2916ae (diff)
x86: merge getuser.
Merge versions of getuser from uaccess_32.h and uaccess_64.h into uaccess.h. There is a part which is 64-bit only (for now), and for that, we use a __get_user_8 macro. Signed-off-by: Glauber Costa <gcosta@redhat.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--include/asm-x86/uaccess.h55
-rw-r--r--include/asm-x86/uaccess_32.h43
-rw-r--r--include/asm-x86/uaccess_64.h29
3 files changed, 55 insertions, 72 deletions
diff --git a/include/asm-x86/uaccess.h b/include/asm-x86/uaccess.h
index 2fc30c2a8a98..8cb580c0b411 100644
--- a/include/asm-x86/uaccess.h
+++ b/include/asm-x86/uaccess.h
@@ -120,6 +120,61 @@ extern int __get_user_bad(void);
120 : "=a" (ret),"=d" (x) \ 120 : "=a" (ret),"=d" (x) \
121 : "0" (ptr)) \ 121 : "0" (ptr)) \
122 122
123/* Careful: we have to cast the result to the type of the pointer
124 * for sign reasons */
125
126/**
127 * get_user: - Get a simple variable from user space.
128 * @x: Variable to store result.
129 * @ptr: Source address, in user space.
130 *
131 * Context: User context only. This function may sleep.
132 *
133 * This macro copies a single simple variable from user space to kernel
134 * space. It supports simple types like char and int, but not larger
135 * data types like structures or arrays.
136 *
137 * @ptr must have pointer-to-simple-variable type, and the result of
138 * dereferencing @ptr must be assignable to @x without a cast.
139 *
140 * Returns zero on success, or -EFAULT on error.
141 * On error, the variable @x is set to zero.
142 */
143#ifdef CONFIG_X86_32
144#define __get_user_8(__ret_gu, __val_gu, ptr) \
145 __get_user_x(X, __ret_gu, __val_gu, ptr)
146#else
147#define __get_user_8(__ret_gu, __val_gu, ptr) \
148 __get_user_x(8, __ret_gu, __val_gu, ptr)
149#endif
150
151#define get_user(x, ptr) \
152({ \
153 int __ret_gu; \
154 unsigned long __val_gu; \
155 __chk_user_ptr(ptr); \
156 switch (sizeof(*(ptr))) { \
157 case 1: \
158 __get_user_x(1, __ret_gu, __val_gu, ptr); \
159 break; \
160 case 2: \
161 __get_user_x(2, __ret_gu, __val_gu, ptr); \
162 break; \
163 case 4: \
164 __get_user_x(4, __ret_gu, __val_gu, ptr); \
165 break; \
166 case 8: \
167 __get_user_8(__ret_gu, __val_gu, ptr); \
168 break; \
169 default: \
170 __get_user_x(X, __ret_gu, __val_gu, ptr); \
171 break; \
172 } \
173 (x) = (__typeof__(*(ptr)))__val_gu; \
174 __ret_gu; \
175})
176
177
123#ifdef CONFIG_X86_32 178#ifdef CONFIG_X86_32
124# include "uaccess_32.h" 179# include "uaccess_32.h"
125#else 180#else
diff --git a/include/asm-x86/uaccess_32.h b/include/asm-x86/uaccess_32.h
index 92ad19e70989..3cc323694438 100644
--- a/include/asm-x86/uaccess_32.h
+++ b/include/asm-x86/uaccess_32.h
@@ -24,49 +24,6 @@ extern struct movsl_mask {
24 ((unsigned long __force)(addr) < \ 24 ((unsigned long __force)(addr) < \
25 (current_thread_info()->addr_limit.seg)) 25 (current_thread_info()->addr_limit.seg))
26 26
27/* Careful: we have to cast the result to the type of the pointer
28 * for sign reasons */
29
30/**
31 * get_user: - Get a simple variable from user space.
32 * @x: Variable to store result.
33 * @ptr: Source address, in user space.
34 *
35 * Context: User context only. This function may sleep.
36 *
37 * This macro copies a single simple variable from user space to kernel
38 * space. It supports simple types like char and int, but not larger
39 * data types like structures or arrays.
40 *
41 * @ptr must have pointer-to-simple-variable type, and the result of
42 * dereferencing @ptr must be assignable to @x without a cast.
43 *
44 * Returns zero on success, or -EFAULT on error.
45 * On error, the variable @x is set to zero.
46 */
47#define get_user(x, ptr) \
48({ \
49 int __ret_gu; \
50 unsigned long __val_gu; \
51 __chk_user_ptr(ptr); \
52 switch (sizeof(*(ptr))) { \
53 case 1: \
54 __get_user_x(1, __ret_gu, __val_gu, ptr); \
55 break; \
56 case 2: \
57 __get_user_x(2, __ret_gu, __val_gu, ptr); \
58 break; \
59 case 4: \
60 __get_user_x(4, __ret_gu, __val_gu, ptr); \
61 break; \
62 default: \
63 __get_user_x(X, __ret_gu, __val_gu, ptr); \
64 break; \
65 } \
66 (x) = (__typeof__(*(ptr)))__val_gu; \
67 __ret_gu; \
68})
69
70extern void __put_user_bad(void); 27extern void __put_user_bad(void);
71 28
72/* 29/*
diff --git a/include/asm-x86/uaccess_64.h b/include/asm-x86/uaccess_64.h
index 243dbb467f3a..4a44b906e4c3 100644
--- a/include/asm-x86/uaccess_64.h
+++ b/include/asm-x86/uaccess_64.h
@@ -14,35 +14,6 @@
14 14
15#define ARCH_HAS_SEARCH_EXTABLE 15#define ARCH_HAS_SEARCH_EXTABLE
16 16
17/* Careful: we have to cast the result to the type of the pointer
18 * for sign reasons */
19
20#define get_user(x, ptr) \
21({ \
22 unsigned long __val_gu; \
23 int __ret_gu; \
24 __chk_user_ptr(ptr); \
25 switch (sizeof(*(ptr))) { \
26 case 1: \
27 __get_user_x(1, __ret_gu, __val_gu, ptr); \
28 break; \
29 case 2: \
30 __get_user_x(2, __ret_gu, __val_gu, ptr); \
31 break; \
32 case 4: \
33 __get_user_x(4, __ret_gu, __val_gu, ptr); \
34 break; \
35 case 8: \
36 __get_user_x(8, __ret_gu, __val_gu, ptr); \
37 break; \
38 default: \
39 __get_user_bad(); \
40 break; \
41 } \
42 (x) = (__force typeof(*(ptr)))__val_gu; \
43 __ret_gu; \
44})
45
46extern void __put_user_1(void); 17extern void __put_user_1(void);
47extern void __put_user_2(void); 18extern void __put_user_2(void);
48extern void __put_user_4(void); 19extern void __put_user_4(void);