aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86/uaccess_32.h
diff options
context:
space:
mode:
authorGlauber Costa <gcosta@redhat.com>2008-06-25 12:17:43 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-09 03:14:26 -0400
commite30a44fdbf11c7ca3a0096d71790f176a4a09e03 (patch)
tree21d173ba08e47cb539c965dfb5119ff9f3b28d04 /include/asm-x86/uaccess_32.h
parentec840956d269e2beefe3a1c0fd7c1c70a199087f (diff)
x86: merge put_user.
Move both versions, which are highly similar, to uaccess.h. Note that, for x86_64, X86_WP_WORKS_OK is always defined. 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>
Diffstat (limited to 'include/asm-x86/uaccess_32.h')
-rw-r--r--include/asm-x86/uaccess_32.h79
1 files changed, 0 insertions, 79 deletions
diff --git a/include/asm-x86/uaccess_32.h b/include/asm-x86/uaccess_32.h
index 2c9067324d2c..e5c0437f509b 100644
--- a/include/asm-x86/uaccess_32.h
+++ b/include/asm-x86/uaccess_32.h
@@ -20,85 +20,6 @@ extern struct movsl_mask {
20} ____cacheline_aligned_in_smp movsl_mask; 20} ____cacheline_aligned_in_smp movsl_mask;
21#endif 21#endif
22 22
23extern void __put_user_bad(void);
24
25/*
26 * Strange magic calling convention: pointer in %ecx,
27 * value in %eax(:%edx), return value in %eax, no clobbers.
28 */
29extern void __put_user_1(void);
30extern void __put_user_2(void);
31extern void __put_user_4(void);
32extern void __put_user_8(void);
33
34#define __put_user_x(size, x, ptr, __ret_pu) \
35 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
36 :"0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
37
38#define __put_user_8(x, ptr, __ret_pu) \
39 asm volatile("call __put_user_8" : "=a" (__ret_pu) \
40 : "A" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
41
42
43/**
44 * put_user: - Write a simple value into user space.
45 * @x: Value to copy to user space.
46 * @ptr: Destination address, in user space.
47 *
48 * Context: User context only. This function may sleep.
49 *
50 * This macro copies a single simple value from kernel space to user
51 * space. It supports simple types like char and int, but not larger
52 * data types like structures or arrays.
53 *
54 * @ptr must have pointer-to-simple-variable type, and @x must be assignable
55 * to the result of dereferencing @ptr.
56 *
57 * Returns zero on success, or -EFAULT on error.
58 */
59#ifdef CONFIG_X86_WP_WORKS_OK
60
61#define put_user(x, ptr) \
62({ \
63 int __ret_pu; \
64 __typeof__(*(ptr)) __pu_val; \
65 __chk_user_ptr(ptr); \
66 __pu_val = x; \
67 switch (sizeof(*(ptr))) { \
68 case 1: \
69 __put_user_x(1, __pu_val, ptr, __ret_pu); \
70 break; \
71 case 2: \
72 __put_user_x(2, __pu_val, ptr, __ret_pu); \
73 break; \
74 case 4: \
75 __put_user_x(4, __pu_val, ptr, __ret_pu); \
76 break; \
77 case 8: \
78 __put_user_8(__pu_val, ptr, __ret_pu); \
79 break; \
80 default: \
81 __put_user_x(X, __pu_val, ptr, __ret_pu); \
82 break; \
83 } \
84 __ret_pu; \
85})
86
87#else
88#define put_user(x, ptr) \
89({ \
90 int __ret_pu; \
91 __typeof__(*(ptr))__pus_tmp = x; \
92 __ret_pu = 0; \
93 if (unlikely(__copy_to_user_ll(ptr, &__pus_tmp, \
94 sizeof(*(ptr))) != 0)) \
95 __ret_pu = -EFAULT; \
96 __ret_pu; \
97})
98
99
100#endif
101
102/** 23/**
103 * __get_user: - Get a simple variable from user space, with less checking. 24 * __get_user: - Get a simple variable from user space, with less checking.
104 * @x: Variable to store result. 25 * @x: Variable to store result.