ia64/xen-unstable

view xen/arch/x86/usercopy.c @ 19835:edfdeb150f27

Fix buildsystem to detect udev > version 124

udev removed the udevinfo symlink from versions higher than 123 and
xen's build-system could not detect if udev is in place and has the
required version.

Signed-off-by: Marc-A. Dahlhaus <mad@wol.de>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 25 13:02:37 2009 +0100 (2009-06-25)
parents 2052364cb456
children
line source
1 /*
2 * User address space access functions.
3 *
4 * Copyright 1997 Andi Kleen <ak@muc.de>
5 * Copyright 1997 Linus Torvalds
6 * Copyright 2002 Andi Kleen <ak@suse.de>
7 */
9 #include <xen/config.h>
10 #include <xen/lib.h>
11 #include <asm/uaccess.h>
13 unsigned long __copy_to_user_ll(void __user *to, const void *from, unsigned n)
14 {
15 unsigned long __d0, __d1, __d2, __n = n;
17 asm volatile (
18 " cmp $"STR(2*BYTES_PER_LONG-1)",%0\n"
19 " jbe 1f\n"
20 " mov %1,%0\n"
21 " neg %0\n"
22 " and $"STR(BYTES_PER_LONG-1)",%0\n"
23 " sub %0,%3\n"
24 "4: rep movsb\n" /* make 'to' address aligned */
25 " mov %3,%0\n"
26 " shr $"STR(LONG_BYTEORDER)",%0\n"
27 " and $"STR(BYTES_PER_LONG-1)",%3\n"
28 " .align 2,0x90\n"
29 "0: rep movs"__OS"\n" /* as many words as possible... */
30 " mov %3,%0\n"
31 "1: rep movsb\n" /* ...remainder copied as bytes */
32 "2:\n"
33 ".section .fixup,\"ax\"\n"
34 "5: add %3,%0\n"
35 " jmp 2b\n"
36 "3: lea 0(%3,%0,"STR(BYTES_PER_LONG)"),%0\n"
37 " jmp 2b\n"
38 ".previous\n"
39 ".section __ex_table,\"a\"\n"
40 " "__FIXUP_ALIGN"\n"
41 " "__FIXUP_WORD" 4b,5b\n"
42 " "__FIXUP_WORD" 0b,3b\n"
43 " "__FIXUP_WORD" 1b,2b\n"
44 ".previous"
45 : "=&c" (__n), "=&D" (__d0), "=&S" (__d1), "=&r" (__d2)
46 : "0" (__n), "1" (to), "2" (from), "3" (__n)
47 : "memory" );
49 return __n;
50 }
52 unsigned long
53 __copy_from_user_ll(void *to, const void __user *from, unsigned n)
54 {
55 unsigned long __d0, __d1, __d2, __n = n;
57 asm volatile (
58 " cmp $"STR(2*BYTES_PER_LONG-1)",%0\n"
59 " jbe 1f\n"
60 " mov %1,%0\n"
61 " neg %0\n"
62 " and $"STR(BYTES_PER_LONG-1)",%0\n"
63 " sub %0,%3\n"
64 "4: rep; movsb\n" /* make 'to' address aligned */
65 " mov %3,%0\n"
66 " shr $"STR(LONG_BYTEORDER)",%0\n"
67 " and $"STR(BYTES_PER_LONG-1)",%3\n"
68 " .align 2,0x90\n"
69 "0: rep; movs"__OS"\n" /* as many words as possible... */
70 " mov %3,%0\n"
71 "1: rep; movsb\n" /* ...remainder copied as bytes */
72 "2:\n"
73 ".section .fixup,\"ax\"\n"
74 "5: add %3,%0\n"
75 " jmp 6f\n"
76 "3: lea 0(%3,%0,"STR(BYTES_PER_LONG)"),%0\n"
77 "6: push %0\n"
78 " push %%"__OP"ax\n"
79 " xor %%eax,%%eax\n"
80 " rep; stosb\n"
81 " pop %%"__OP"ax\n"
82 " pop %0\n"
83 " jmp 2b\n"
84 ".previous\n"
85 ".section __ex_table,\"a\"\n"
86 " "__FIXUP_ALIGN"\n"
87 " "__FIXUP_WORD" 4b,5b\n"
88 " "__FIXUP_WORD" 0b,3b\n"
89 " "__FIXUP_WORD" 1b,6b\n"
90 ".previous"
91 : "=&c" (__n), "=&D" (__d0), "=&S" (__d1), "=&r" (__d2)
92 : "0" (__n), "1" (to), "2" (from), "3" (__n)
93 : "memory" );
95 return __n;
96 }
98 /**
99 * copy_to_user: - Copy a block of data into user space.
100 * @to: Destination address, in user space.
101 * @from: Source address, in kernel space.
102 * @n: Number of bytes to copy.
103 *
104 * Context: User context only. This function may sleep.
105 *
106 * Copy data from kernel space to user space.
107 *
108 * Returns number of bytes that could not be copied.
109 * On success, this will be zero.
110 */
111 unsigned long
112 copy_to_user(void __user *to, const void *from, unsigned n)
113 {
114 if ( access_ok(to, n) )
115 n = __copy_to_user(to, from, n);
116 return n;
117 }
119 /**
120 * copy_from_user: - Copy a block of data from user space.
121 * @to: Destination address, in kernel space.
122 * @from: Source address, in user space.
123 * @n: Number of bytes to copy.
124 *
125 * Context: User context only. This function may sleep.
126 *
127 * Copy data from user space to kernel space.
128 *
129 * Returns number of bytes that could not be copied.
130 * On success, this will be zero.
131 *
132 * If some data could not be copied, this function will pad the copied
133 * data to the requested size using zero bytes.
134 */
135 unsigned long
136 copy_from_user(void *to, const void __user *from, unsigned n)
137 {
138 if ( access_ok(from, n) )
139 n = __copy_from_user(to, from, n);
140 else
141 memset(to, 0, n);
142 return n;
143 }
145 /*
146 * Local variables:
147 * mode: C
148 * c-set-style: "BSD"
149 * c-basic-offset: 4
150 * tab-width: 4
151 * indent-tabs-mode: nil
152 * End:
153 */