ia64/xen-unstable

changeset 5335:4736c86802ad

bitkeeper revision 1.1682 (42a42b05Cvw3LyFcUHH4i1_9HWbLBA)

Merge x86/32 and x86/64 usercopy routines.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Mon Jun 06 10:52:53 2005 +0000 (2005-06-06)
parents fa735bb2f79a
children 7385718ad7c0
files .rootkeys xen/arch/x86/usercopy.c xen/arch/x86/x86_32/usercopy.c xen/arch/x86/x86_64/usercopy.c xen/include/asm-x86/types.h xen/include/asm-x86/uaccess.h xen/include/asm-x86/x86_32/uaccess.h xen/include/asm-x86/x86_64/uaccess.h
line diff
     1.1 --- a/.rootkeys	Mon Jun 06 09:28:15 2005 +0000
     1.2 +++ b/.rootkeys	Mon Jun 06 10:52:53 2005 +0000
     1.3 @@ -1210,6 +1210,7 @@ 4266673dBje6CS6CwQ3lEdvWbf5Dcw xen/arch/
     1.4  3ddb79bc-Udq7ol-NX4q9XsYnN7A2Q xen/arch/x86/time.c
     1.5  3ddb79bccYVzXZJyVaxuv5T42Z1Fsw xen/arch/x86/trampoline.S
     1.6  3ddb79bcOftONV9h4QCxXOfiT0h91w xen/arch/x86/traps.c
     1.7 +40e96d3ahBTZqbTViInnq0lM03vs7A xen/arch/x86/usercopy.c
     1.8  41c0c411tD3C7TpfDMiFTf7BaNd_Dg xen/arch/x86/vmx.c
     1.9  420951dcf1rSGnCH0AEYN2KjWGLG6A xen/arch/x86/vmx_intercept.c
    1.10  41c0c411ODt8uEmV-yUxpQLpqimE5Q xen/arch/x86/vmx_io.c
    1.11 @@ -1221,13 +1222,11 @@ 3ddb79bcecupHj56ZbTa3B0FxDowMg xen/arch/
    1.12  3ddb79bcHwuCQDjBICDTSis52hWguw xen/arch/x86/x86_32/mm.c
    1.13  40f92331jfOlE7MfKwpdkEb1CEf23g xen/arch/x86/x86_32/seg_fixup.c
    1.14  42000d3ckiFc1qxa4AWqsd0t3lxuyw xen/arch/x86/x86_32/traps.c
    1.15 -3ddb79bc4nTpGQOe6_-MbyZzkhlhFQ xen/arch/x86/x86_32/usercopy.c
    1.16  3ddb79bcOMCu9-5mKpjIh5d0qqBDPg xen/arch/x86/x86_32/xen.lds
    1.17  41bf1717Ty3hwN3E9swdu8QfnvGqww xen/arch/x86/x86_64/asm-offsets.c
    1.18  40e96d3aLDI-nViMuYneD7VKYlZrVg xen/arch/x86/x86_64/entry.S
    1.19  41bf1717XhPz_dNT5OKSjgmbFuWBuA xen/arch/x86/x86_64/mm.c
    1.20  42000d3cMb8o1WuFBXC07c8i3lPZBw xen/arch/x86/x86_64/traps.c
    1.21 -40e96d3ahBTZqbTViInnq0lM03vs7A xen/arch/x86/x86_64/usercopy.c
    1.22  40e96d3akN3Hu_J5Bk-WXD8OGscrYQ xen/arch/x86/x86_64/xen.lds
    1.23  422f27c8J9DQfCpegccMid59XhSmGA xen/arch/x86/x86_emulate.c
    1.24  3ddb79bdff-gj-jFGKjOejeHLqL8Lg xen/common/Makefile
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/xen/arch/x86/usercopy.c	Mon Jun 06 10:52:53 2005 +0000
     2.3 @@ -0,0 +1,139 @@
     2.4 +/* 
     2.5 + * User address space access functions.
     2.6 + *
     2.7 + * Copyright 1997 Andi Kleen <ak@muc.de>
     2.8 + * Copyright 1997 Linus Torvalds
     2.9 + * Copyright 2002 Andi Kleen <ak@suse.de>
    2.10 + */
    2.11 +
    2.12 +#include <xen/config.h>
    2.13 +#include <xen/lib.h>
    2.14 +#include <asm/uaccess.h>
    2.15 +
    2.16 +unsigned long __copy_to_user_ll(void __user *to, const void *from, unsigned n)
    2.17 +{
    2.18 +	unsigned long __d0, __d1, __d2, __n = n;
    2.19 +	__asm__ __volatile__(
    2.20 +		"	cmp  $"STR(2*BYTES_PER_LONG-1)",%0\n"
    2.21 +		"	jbe  1f\n"
    2.22 +		"	mov  %1,%0\n"
    2.23 +		"	neg  %0\n"
    2.24 +		"	and  $"STR(BYTES_PER_LONG-1)",%0\n"
    2.25 +		"	sub  %0,%3\n"
    2.26 +		"4:	rep; movsb\n" /* make 'to' address aligned */
    2.27 +		"	mov  %3,%0\n"
    2.28 +		"	shr  $"STR(LONG_BYTEORDER)",%0\n"
    2.29 +		"	and  $"STR(BYTES_PER_LONG-1)",%3\n"
    2.30 +		"	.align 2,0x90\n"
    2.31 +		"0:	rep; movs"__OS"\n" /* as many words as possible... */
    2.32 +		"	mov  %3,%0\n"
    2.33 +		"1:	rep; movsb\n" /* ...remainder copied as bytes */
    2.34 +		"2:\n"
    2.35 +		".section .fixup,\"ax\"\n"
    2.36 +		"5:	add %3,%0\n"
    2.37 +		"	jmp 2b\n"
    2.38 +		"3:	lea 0(%3,%0,"STR(BYTES_PER_LONG)"),%0\n"
    2.39 +		"	jmp 2b\n"
    2.40 +		".previous\n"
    2.41 +		".section __ex_table,\"a\"\n"
    2.42 +		"	"__FIXUP_ALIGN"\n"
    2.43 +		"	"__FIXUP_WORD" 4b,5b\n"
    2.44 +		"	"__FIXUP_WORD" 0b,3b\n"
    2.45 +		"	"__FIXUP_WORD" 1b,2b\n"
    2.46 +		".previous"
    2.47 +		: "=&c"(__n), "=&D" (__d0), "=&S" (__d1), "=r"(__d2)
    2.48 +		: "3"(__n), "0"(__n), "1"(to), "2"(from)
    2.49 +		: "memory");
    2.50 +	return (unsigned)__n;
    2.51 +}
    2.52 +
    2.53 +unsigned long
    2.54 +__copy_from_user_ll(void *to, const void __user *from, unsigned n)
    2.55 +{
    2.56 +	unsigned long __d0, __d1, __d2, __n = n;
    2.57 +	__asm__ __volatile__(
    2.58 +		"	cmp  $"STR(2*BYTES_PER_LONG-1)",%0\n"
    2.59 +		"	jbe  1f\n"
    2.60 +		"	mov  %1,%0\n"
    2.61 +		"	neg  %0\n"
    2.62 +		"	and  $"STR(BYTES_PER_LONG-1)",%0\n"
    2.63 +		"	sub  %0,%3\n"
    2.64 +		"4:	rep; movsb\n" /* make 'to' address aligned */
    2.65 +		"	mov  %3,%0\n"
    2.66 +		"	shr  $"STR(LONG_BYTEORDER)",%0\n"
    2.67 +		"	and  $"STR(BYTES_PER_LONG-1)",%3\n"
    2.68 +		"	.align 2,0x90\n"
    2.69 +		"0:	rep; movs"__OS"\n" /* as many words as possible... */
    2.70 +		"	mov  %3,%0\n"
    2.71 +		"1:	rep; movsb\n" /* ...remainder copied as bytes */
    2.72 +		"2:\n"
    2.73 +		".section .fixup,\"ax\"\n"
    2.74 +		"5:	add %3,%0\n"
    2.75 +		"	jmp 6f\n"
    2.76 +		"3:	lea 0(%3,%0,"STR(BYTES_PER_LONG)"),%0\n"
    2.77 +		"6:	push %0\n"
    2.78 +		"	push %%"__OP"ax\n"
    2.79 +		"	xor  %%eax,%%eax\n"
    2.80 +		"	rep; stosb\n"
    2.81 +		"	pop  %%"__OP"ax\n"
    2.82 +		"	pop  %0\n"
    2.83 +		"	jmp 2b\n"
    2.84 +		".previous\n"
    2.85 +		".section __ex_table,\"a\"\n"
    2.86 +		"	"__FIXUP_ALIGN"\n"
    2.87 +		"	"__FIXUP_WORD" 4b,5b\n"
    2.88 +		"	"__FIXUP_WORD" 0b,3b\n"
    2.89 +		"	"__FIXUP_WORD" 1b,6b\n"
    2.90 +		".previous"
    2.91 +		: "=&c"(__n), "=&D" (__d0), "=&S" (__d1), "=r"(__d2)
    2.92 +		: "3"(__n), "0"(__n), "1"(to), "2"(from)
    2.93 +		: "memory");
    2.94 +	return (unsigned)__n;
    2.95 +}
    2.96 +
    2.97 +/**
    2.98 + * copy_to_user: - Copy a block of data into user space.
    2.99 + * @to:   Destination address, in user space.
   2.100 + * @from: Source address, in kernel space.
   2.101 + * @n:    Number of bytes to copy.
   2.102 + *
   2.103 + * Context: User context only.  This function may sleep.
   2.104 + *
   2.105 + * Copy data from kernel space to user space.
   2.106 + *
   2.107 + * Returns number of bytes that could not be copied.
   2.108 + * On success, this will be zero.
   2.109 + */
   2.110 +unsigned long
   2.111 +copy_to_user(void __user *to, const void *from, unsigned n)
   2.112 +{
   2.113 +	if (access_ok(to, n))
   2.114 +		n = __copy_to_user(to, from, n);
   2.115 +	return n;
   2.116 +}
   2.117 +
   2.118 +/**
   2.119 + * copy_from_user: - Copy a block of data from user space.
   2.120 + * @to:   Destination address, in kernel space.
   2.121 + * @from: Source address, in user space.
   2.122 + * @n:    Number of bytes to copy.
   2.123 + *
   2.124 + * Context: User context only.  This function may sleep.
   2.125 + *
   2.126 + * Copy data from user space to kernel space.
   2.127 + *
   2.128 + * Returns number of bytes that could not be copied.
   2.129 + * On success, this will be zero.
   2.130 + *
   2.131 + * If some data could not be copied, this function will pad the copied
   2.132 + * data to the requested size using zero bytes.
   2.133 + */
   2.134 +unsigned long
   2.135 +copy_from_user(void *to, const void __user *from, unsigned n)
   2.136 +{
   2.137 +	if (access_ok(from, n))
   2.138 +		n = __copy_from_user(to, from, n);
   2.139 +	else
   2.140 +		memset(to, 0, n);
   2.141 +	return n;
   2.142 +}
     3.1 --- a/xen/arch/x86/x86_32/usercopy.c	Mon Jun 06 09:28:15 2005 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,443 +0,0 @@
     3.4 -/* 
     3.5 - * User address space access functions.
     3.6 - * The non inlined parts of asm-i386/uaccess.h are here.
     3.7 - *
     3.8 - * Copyright 1997 Andi Kleen <ak@muc.de>
     3.9 - * Copyright 1997 Linus Torvalds
    3.10 - */
    3.11 -
    3.12 -#include <xen/config.h>
    3.13 -#include <xen/lib.h>
    3.14 -#include <asm/uaccess.h>
    3.15 -
    3.16 -static inline int __movsl_is_ok(unsigned long a1, unsigned long a2, unsigned long n)
    3.17 -{
    3.18 -#ifdef CONFIG_X86_INTEL_USERCOPY
    3.19 -	if (n >= 64 && ((a1 ^ a2) & movsl_mask.mask))
    3.20 -		return 0;
    3.21 -#endif
    3.22 -	return 1;
    3.23 -}
    3.24 -#define movsl_is_ok(a1,a2,n) \
    3.25 -	__movsl_is_ok((unsigned long)(a1),(unsigned long)(a2),(n))
    3.26 -
    3.27 -
    3.28 -/*
    3.29 - * Zero Userspace
    3.30 - */
    3.31 -
    3.32 -#define __do_clear_user(addr,size)					\
    3.33 -do {									\
    3.34 -	int __d0;							\
    3.35 -  	__asm__ __volatile__(						\
    3.36 -		"0:	rep; stosl\n"					\
    3.37 -		"	movl %2,%0\n"					\
    3.38 -		"1:	rep; stosb\n"					\
    3.39 -		"2:\n"							\
    3.40 -		".section .fixup,\"ax\"\n"				\
    3.41 -		"3:	lea 0(%2,%0,4),%0\n"				\
    3.42 -		"	jmp 2b\n"					\
    3.43 -		".previous\n"						\
    3.44 -		".section __ex_table,\"a\"\n"				\
    3.45 -		"	.align 4\n"					\
    3.46 -		"	.long 0b,3b\n"					\
    3.47 -		"	.long 1b,2b\n"					\
    3.48 -		".previous"						\
    3.49 -		: "=&c"(size), "=&D" (__d0)				\
    3.50 -		: "r"(size & 3), "0"(size / 4), "1"(addr), "a"(0));	\
    3.51 -} while (0)
    3.52 -
    3.53 -/**
    3.54 - * clear_user: - Zero a block of memory in user space.
    3.55 - * @to:   Destination address, in user space.
    3.56 - * @n:    Number of bytes to zero.
    3.57 - *
    3.58 - * Zero a block of memory in user space.
    3.59 - *
    3.60 - * Returns number of bytes that could not be cleared.
    3.61 - * On success, this will be zero.
    3.62 - */
    3.63 -unsigned long
    3.64 -clear_user(void __user *to, unsigned long n)
    3.65 -{
    3.66 -	if (access_ok(to, n))
    3.67 -		__do_clear_user(to, n);
    3.68 -	return n;
    3.69 -}
    3.70 -
    3.71 -/**
    3.72 - * __clear_user: - Zero a block of memory in user space, with less checking.
    3.73 - * @to:   Destination address, in user space.
    3.74 - * @n:    Number of bytes to zero.
    3.75 - *
    3.76 - * Zero a block of memory in user space.  Caller must check
    3.77 - * the specified block with access_ok() before calling this function.
    3.78 - *
    3.79 - * Returns number of bytes that could not be cleared.
    3.80 - * On success, this will be zero.
    3.81 - */
    3.82 -unsigned long
    3.83 -__clear_user(void __user *to, unsigned long n)
    3.84 -{
    3.85 -	__do_clear_user(to, n);
    3.86 -	return n;
    3.87 -}
    3.88 -
    3.89 -#ifdef CONFIG_X86_INTEL_USERCOPY
    3.90 -static unsigned long
    3.91 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
    3.92 -{
    3.93 -	int d0, d1;
    3.94 -	__asm__ __volatile__(
    3.95 -		       "       .align 2,0x90\n"
    3.96 -		       "1:     movl 32(%4), %%eax\n"
    3.97 -		       "       cmpl $67, %0\n"
    3.98 -		       "       jbe 3f\n"
    3.99 -		       "2:     movl 64(%4), %%eax\n"
   3.100 -		       "       .align 2,0x90\n"
   3.101 -		       "3:     movl 0(%4), %%eax\n"
   3.102 -		       "4:     movl 4(%4), %%edx\n"
   3.103 -		       "5:     movl %%eax, 0(%3)\n"
   3.104 -		       "6:     movl %%edx, 4(%3)\n"
   3.105 -		       "7:     movl 8(%4), %%eax\n"
   3.106 -		       "8:     movl 12(%4),%%edx\n"
   3.107 -		       "9:     movl %%eax, 8(%3)\n"
   3.108 -		       "10:    movl %%edx, 12(%3)\n"
   3.109 -		       "11:    movl 16(%4), %%eax\n"
   3.110 -		       "12:    movl 20(%4), %%edx\n"
   3.111 -		       "13:    movl %%eax, 16(%3)\n"
   3.112 -		       "14:    movl %%edx, 20(%3)\n"
   3.113 -		       "15:    movl 24(%4), %%eax\n"
   3.114 -		       "16:    movl 28(%4), %%edx\n"
   3.115 -		       "17:    movl %%eax, 24(%3)\n"
   3.116 -		       "18:    movl %%edx, 28(%3)\n"
   3.117 -		       "19:    movl 32(%4), %%eax\n"
   3.118 -		       "20:    movl 36(%4), %%edx\n"
   3.119 -		       "21:    movl %%eax, 32(%3)\n"
   3.120 -		       "22:    movl %%edx, 36(%3)\n"
   3.121 -		       "23:    movl 40(%4), %%eax\n"
   3.122 -		       "24:    movl 44(%4), %%edx\n"
   3.123 -		       "25:    movl %%eax, 40(%3)\n"
   3.124 -		       "26:    movl %%edx, 44(%3)\n"
   3.125 -		       "27:    movl 48(%4), %%eax\n"
   3.126 -		       "28:    movl 52(%4), %%edx\n"
   3.127 -		       "29:    movl %%eax, 48(%3)\n"
   3.128 -		       "30:    movl %%edx, 52(%3)\n"
   3.129 -		       "31:    movl 56(%4), %%eax\n"
   3.130 -		       "32:    movl 60(%4), %%edx\n"
   3.131 -		       "33:    movl %%eax, 56(%3)\n"
   3.132 -		       "34:    movl %%edx, 60(%3)\n"
   3.133 -		       "       addl $-64, %0\n"
   3.134 -		       "       addl $64, %4\n"
   3.135 -		       "       addl $64, %3\n"
   3.136 -		       "       cmpl $63, %0\n"
   3.137 -		       "       ja  1b\n"
   3.138 -		       "35:    movl  %0, %%eax\n"
   3.139 -		       "       shrl  $2, %0\n"
   3.140 -		       "       andl  $3, %%eax\n"
   3.141 -		       "       cld\n"
   3.142 -		       "99:    rep; movsl\n"
   3.143 -		       "36:    movl %%eax, %0\n"
   3.144 -		       "37:    rep; movsb\n"
   3.145 -		       "100:\n"
   3.146 -		       ".section .fixup,\"ax\"\n"
   3.147 -		       "101:   lea 0(%%eax,%0,4),%0\n"
   3.148 -		       "       jmp 100b\n"
   3.149 -		       ".previous\n"
   3.150 -		       ".section __ex_table,\"a\"\n"
   3.151 -		       "       .align 4\n"
   3.152 -		       "       .long 1b,100b\n"
   3.153 -		       "       .long 2b,100b\n"
   3.154 -		       "       .long 3b,100b\n"
   3.155 -		       "       .long 4b,100b\n"
   3.156 -		       "       .long 5b,100b\n"
   3.157 -		       "       .long 6b,100b\n"
   3.158 -		       "       .long 7b,100b\n"
   3.159 -		       "       .long 8b,100b\n"
   3.160 -		       "       .long 9b,100b\n"
   3.161 -		       "       .long 10b,100b\n"
   3.162 -		       "       .long 11b,100b\n"
   3.163 -		       "       .long 12b,100b\n"
   3.164 -		       "       .long 13b,100b\n"
   3.165 -		       "       .long 14b,100b\n"
   3.166 -		       "       .long 15b,100b\n"
   3.167 -		       "       .long 16b,100b\n"
   3.168 -		       "       .long 17b,100b\n"
   3.169 -		       "       .long 18b,100b\n"
   3.170 -		       "       .long 19b,100b\n"
   3.171 -		       "       .long 20b,100b\n"
   3.172 -		       "       .long 21b,100b\n"
   3.173 -		       "       .long 22b,100b\n"
   3.174 -		       "       .long 23b,100b\n"
   3.175 -		       "       .long 24b,100b\n"
   3.176 -		       "       .long 25b,100b\n"
   3.177 -		       "       .long 26b,100b\n"
   3.178 -		       "       .long 27b,100b\n"
   3.179 -		       "       .long 28b,100b\n"
   3.180 -		       "       .long 29b,100b\n"
   3.181 -		       "       .long 30b,100b\n"
   3.182 -		       "       .long 31b,100b\n"
   3.183 -		       "       .long 32b,100b\n"
   3.184 -		       "       .long 33b,100b\n"
   3.185 -		       "       .long 34b,100b\n"
   3.186 -		       "       .long 35b,100b\n"
   3.187 -		       "       .long 36b,100b\n"
   3.188 -		       "       .long 37b,100b\n"
   3.189 -		       "       .long 99b,101b\n"
   3.190 -		       ".previous"
   3.191 -		       : "=&c"(size), "=&D" (d0), "=&S" (d1)
   3.192 -		       :  "1"(to), "2"(from), "0"(size)
   3.193 -		       : "eax", "edx", "memory");
   3.194 -	return size;
   3.195 -}
   3.196 -
   3.197 -static unsigned long
   3.198 -__copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
   3.199 -{
   3.200 -	int d0, d1;
   3.201 -	__asm__ __volatile__(
   3.202 -		       "        .align 2,0x90\n"
   3.203 -		       "0:      movl 32(%4), %%eax\n"
   3.204 -		       "        cmpl $67, %0\n"      
   3.205 -		       "        jbe 2f\n"            
   3.206 -		       "1:      movl 64(%4), %%eax\n"
   3.207 -		       "        .align 2,0x90\n"     
   3.208 -		       "2:      movl 0(%4), %%eax\n" 
   3.209 -		       "21:     movl 4(%4), %%edx\n" 
   3.210 -		       "        movl %%eax, 0(%3)\n" 
   3.211 -		       "        movl %%edx, 4(%3)\n" 
   3.212 -		       "3:      movl 8(%4), %%eax\n" 
   3.213 -		       "31:     movl 12(%4),%%edx\n" 
   3.214 -		       "        movl %%eax, 8(%3)\n" 
   3.215 -		       "        movl %%edx, 12(%3)\n"
   3.216 -		       "4:      movl 16(%4), %%eax\n"
   3.217 -		       "41:     movl 20(%4), %%edx\n"
   3.218 -		       "        movl %%eax, 16(%3)\n"
   3.219 -		       "        movl %%edx, 20(%3)\n"
   3.220 -		       "10:     movl 24(%4), %%eax\n"
   3.221 -		       "51:     movl 28(%4), %%edx\n"
   3.222 -		       "        movl %%eax, 24(%3)\n"
   3.223 -		       "        movl %%edx, 28(%3)\n"
   3.224 -		       "11:     movl 32(%4), %%eax\n"
   3.225 -		       "61:     movl 36(%4), %%edx\n"
   3.226 -		       "        movl %%eax, 32(%3)\n"
   3.227 -		       "        movl %%edx, 36(%3)\n"
   3.228 -		       "12:     movl 40(%4), %%eax\n"
   3.229 -		       "71:     movl 44(%4), %%edx\n"
   3.230 -		       "        movl %%eax, 40(%3)\n"
   3.231 -		       "        movl %%edx, 44(%3)\n"
   3.232 -		       "13:     movl 48(%4), %%eax\n"
   3.233 -		       "81:     movl 52(%4), %%edx\n"
   3.234 -		       "        movl %%eax, 48(%3)\n"
   3.235 -		       "        movl %%edx, 52(%3)\n"
   3.236 -		       "14:     movl 56(%4), %%eax\n"
   3.237 -		       "91:     movl 60(%4), %%edx\n"
   3.238 -		       "        movl %%eax, 56(%3)\n"
   3.239 -		       "        movl %%edx, 60(%3)\n"
   3.240 -		       "        addl $-64, %0\n"     
   3.241 -		       "        addl $64, %4\n"      
   3.242 -		       "        addl $64, %3\n"      
   3.243 -		       "        cmpl $63, %0\n"      
   3.244 -		       "        ja  0b\n"            
   3.245 -		       "5:      movl  %0, %%eax\n"   
   3.246 -		       "        shrl  $2, %0\n"      
   3.247 -		       "        andl $3, %%eax\n"    
   3.248 -		       "        cld\n"               
   3.249 -		       "6:      rep; movsl\n"   
   3.250 -		       "        movl %%eax,%0\n"
   3.251 -		       "7:      rep; movsb\n"	
   3.252 -		       "8:\n"			
   3.253 -		       ".section .fixup,\"ax\"\n"
   3.254 -		       "9:      lea 0(%%eax,%0,4),%0\n"	
   3.255 -		       "16:     pushl %0\n"	
   3.256 -		       "        pushl %%eax\n"	
   3.257 -		       "        xorl %%eax,%%eax\n"
   3.258 -		       "        rep; stosb\n"	
   3.259 -		       "        popl %%eax\n"	
   3.260 -		       "        popl %0\n"	
   3.261 -		       "        jmp 8b\n"	
   3.262 -		       ".previous\n"		
   3.263 -		       ".section __ex_table,\"a\"\n"
   3.264 -		       "	.align 4\n"	   
   3.265 -		       "	.long 0b,16b\n"	 
   3.266 -		       "	.long 1b,16b\n"
   3.267 -		       "	.long 2b,16b\n"
   3.268 -		       "	.long 21b,16b\n"
   3.269 -		       "	.long 3b,16b\n"	
   3.270 -		       "	.long 31b,16b\n"
   3.271 -		       "	.long 4b,16b\n"	
   3.272 -		       "	.long 41b,16b\n"
   3.273 -		       "	.long 10b,16b\n"
   3.274 -		       "	.long 51b,16b\n"
   3.275 -		       "	.long 11b,16b\n"
   3.276 -		       "	.long 61b,16b\n"
   3.277 -		       "	.long 12b,16b\n"
   3.278 -		       "	.long 71b,16b\n"
   3.279 -		       "	.long 13b,16b\n"
   3.280 -		       "	.long 81b,16b\n"
   3.281 -		       "	.long 14b,16b\n"
   3.282 -		       "	.long 91b,16b\n"
   3.283 -		       "	.long 6b,9b\n"	
   3.284 -		       "        .long 7b,16b\n" 
   3.285 -		       ".previous"		
   3.286 -		       : "=&c"(size), "=&D" (d0), "=&S" (d1)
   3.287 -		       :  "1"(to), "2"(from), "0"(size)
   3.288 -		       : "eax", "edx", "memory");
   3.289 -	return size;
   3.290 -}
   3.291 -#else
   3.292 -/*
   3.293 - * Leave these declared but undefined.  They should not be any references to
   3.294 - * them
   3.295 - */
   3.296 -unsigned long
   3.297 -__copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size);
   3.298 -unsigned long
   3.299 -__copy_user_intel(void __user *to, const void *from, unsigned long size);
   3.300 -#endif /* CONFIG_X86_INTEL_USERCOPY */
   3.301 -
   3.302 -/* Generic arbitrary sized copy.  */
   3.303 -#define __copy_user(to,from,size)					\
   3.304 -do {									\
   3.305 -	int __d0, __d1, __d2;						\
   3.306 -	__asm__ __volatile__(						\
   3.307 -		"	cmp  $7,%0\n"					\
   3.308 -		"	jbe  1f\n"					\
   3.309 -		"	movl %1,%0\n"					\
   3.310 -		"	negl %0\n"					\
   3.311 -		"	andl $7,%0\n"					\
   3.312 -		"	subl %0,%3\n"					\
   3.313 -		"4:	rep; movsb\n"					\
   3.314 -		"	movl %3,%0\n"					\
   3.315 -		"	shrl $2,%0\n"					\
   3.316 -		"	andl $3,%3\n"					\
   3.317 -		"	.align 2,0x90\n"				\
   3.318 -		"0:	rep; movsl\n"					\
   3.319 -		"	movl %3,%0\n"					\
   3.320 -		"1:	rep; movsb\n"					\
   3.321 -		"2:\n"							\
   3.322 -		".section .fixup,\"ax\"\n"				\
   3.323 -		"5:	addl %3,%0\n"					\
   3.324 -		"	jmp 2b\n"					\
   3.325 -		"3:	lea 0(%3,%0,4),%0\n"				\
   3.326 -		"	jmp 2b\n"					\
   3.327 -		".previous\n"						\
   3.328 -		".section __ex_table,\"a\"\n"				\
   3.329 -		"	.align 4\n"					\
   3.330 -		"	.long 4b,5b\n"					\
   3.331 -		"	.long 0b,3b\n"					\
   3.332 -		"	.long 1b,2b\n"					\
   3.333 -		".previous"						\
   3.334 -		: "=&c"(size), "=&D" (__d0), "=&S" (__d1), "=r"(__d2)	\
   3.335 -		: "3"(size), "0"(size), "1"(to), "2"(from)		\
   3.336 -		: "memory");						\
   3.337 -} while (0)
   3.338 -
   3.339 -#define __copy_user_zeroing(to,from,size)				\
   3.340 -do {									\
   3.341 -	int __d0, __d1, __d2;						\
   3.342 -	__asm__ __volatile__(						\
   3.343 -		"	cmp  $7,%0\n"					\
   3.344 -		"	jbe  1f\n"					\
   3.345 -		"	movl %1,%0\n"					\
   3.346 -		"	negl %0\n"					\
   3.347 -		"	andl $7,%0\n"					\
   3.348 -		"	subl %0,%3\n"					\
   3.349 -		"4:	rep; movsb\n"					\
   3.350 -		"	movl %3,%0\n"					\
   3.351 -		"	shrl $2,%0\n"					\
   3.352 -		"	andl $3,%3\n"					\
   3.353 -		"	.align 2,0x90\n"				\
   3.354 -		"0:	rep; movsl\n"					\
   3.355 -		"	movl %3,%0\n"					\
   3.356 -		"1:	rep; movsb\n"					\
   3.357 -		"2:\n"							\
   3.358 -		".section .fixup,\"ax\"\n"				\
   3.359 -		"5:	addl %3,%0\n"					\
   3.360 -		"	jmp 6f\n"					\
   3.361 -		"3:	lea 0(%3,%0,4),%0\n"				\
   3.362 -		"6:	pushl %0\n"					\
   3.363 -		"	pushl %%eax\n"					\
   3.364 -		"	xorl %%eax,%%eax\n"				\
   3.365 -		"	rep; stosb\n"					\
   3.366 -		"	popl %%eax\n"					\
   3.367 -		"	popl %0\n"					\
   3.368 -		"	jmp 2b\n"					\
   3.369 -		".previous\n"						\
   3.370 -		".section __ex_table,\"a\"\n"				\
   3.371 -		"	.align 4\n"					\
   3.372 -		"	.long 4b,5b\n"					\
   3.373 -		"	.long 0b,3b\n"					\
   3.374 -		"	.long 1b,6b\n"					\
   3.375 -		".previous"						\
   3.376 -		: "=&c"(size), "=&D" (__d0), "=&S" (__d1), "=r"(__d2)	\
   3.377 -		: "3"(size), "0"(size), "1"(to), "2"(from)		\
   3.378 -		: "memory");						\
   3.379 -} while (0)
   3.380 -
   3.381 -
   3.382 -unsigned long __copy_to_user_ll(void __user *to, const void *from, unsigned long n)
   3.383 -{
   3.384 -	if (movsl_is_ok(to, from, n))
   3.385 -		__copy_user(to, from, n);
   3.386 -	else
   3.387 -		n = __copy_user_intel(to, from, n);
   3.388 -	return n;
   3.389 -}
   3.390 -
   3.391 -unsigned long
   3.392 -__copy_from_user_ll(void *to, const void __user *from, unsigned long n)
   3.393 -{
   3.394 -	if (movsl_is_ok(to, from, n))
   3.395 -		__copy_user_zeroing(to, from, n);
   3.396 -	else
   3.397 -		n = __copy_user_zeroing_intel(to, from, n);
   3.398 -	return n;
   3.399 -}
   3.400 -
   3.401 -/**
   3.402 - * copy_to_user: - Copy a block of data into user space.
   3.403 - * @to:   Destination address, in user space.
   3.404 - * @from: Source address, in kernel space.
   3.405 - * @n:    Number of bytes to copy.
   3.406 - *
   3.407 - * Context: User context only.  This function may sleep.
   3.408 - *
   3.409 - * Copy data from kernel space to user space.
   3.410 - *
   3.411 - * Returns number of bytes that could not be copied.
   3.412 - * On success, this will be zero.
   3.413 - */
   3.414 -unsigned long
   3.415 -copy_to_user(void __user *to, const void *from, unsigned long n)
   3.416 -{
   3.417 -	if (access_ok(to, n))
   3.418 -		n = __copy_to_user(to, from, n);
   3.419 -	return n;
   3.420 -}
   3.421 -
   3.422 -/**
   3.423 - * copy_from_user: - Copy a block of data from user space.
   3.424 - * @to:   Destination address, in kernel space.
   3.425 - * @from: Source address, in user space.
   3.426 - * @n:    Number of bytes to copy.
   3.427 - *
   3.428 - * Context: User context only.  This function may sleep.
   3.429 - *
   3.430 - * Copy data from user space to kernel space.
   3.431 - *
   3.432 - * Returns number of bytes that could not be copied.
   3.433 - * On success, this will be zero.
   3.434 - *
   3.435 - * If some data could not be copied, this function will pad the copied
   3.436 - * data to the requested size using zero bytes.
   3.437 - */
   3.438 -unsigned long
   3.439 -copy_from_user(void *to, const void __user *from, unsigned long n)
   3.440 -{
   3.441 -	if (access_ok(from, n))
   3.442 -		n = __copy_from_user(to, from, n);
   3.443 -	else
   3.444 -		memset(to, 0, n);
   3.445 -	return n;
   3.446 -}
     4.1 --- a/xen/arch/x86/x86_64/usercopy.c	Mon Jun 06 09:28:15 2005 +0000
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,183 +0,0 @@
     4.4 -/* 
     4.5 - * User address space access functions.
     4.6 - *
     4.7 - * Copyright 1997 Andi Kleen <ak@muc.de>
     4.8 - * Copyright 1997 Linus Torvalds
     4.9 - * Copyright 2002 Andi Kleen <ak@suse.de>
    4.10 - */
    4.11 -
    4.12 -#include <xen/config.h>
    4.13 -#include <xen/lib.h>
    4.14 -#include <asm/uaccess.h>
    4.15 -
    4.16 -/*
    4.17 - * Zero Userspace
    4.18 - */
    4.19 -
    4.20 -unsigned long __clear_user(void *addr, unsigned long size)
    4.21 -{
    4.22 -	long __d0;
    4.23 -	/* no memory constraint because it doesn't change any memory gcc knows
    4.24 -	   about */
    4.25 -	asm volatile(
    4.26 -		"	testq  %[size8],%[size8]\n"
    4.27 -		"	jz     4f\n"
    4.28 -		"0:	movq %[zero],(%[dst])\n"
    4.29 -		"	addq   %[eight],%[dst]\n"
    4.30 -		"	decl %%ecx ; jnz   0b\n"
    4.31 -		"4:	movq  %[size1],%%rcx\n"
    4.32 -		"	testl %%ecx,%%ecx\n"
    4.33 -		"	jz     2f\n"
    4.34 -		"1:	movb   %b[zero],(%[dst])\n"
    4.35 -		"	incq   %[dst]\n"
    4.36 -		"	decl %%ecx ; jnz  1b\n"
    4.37 -		"2:\n"
    4.38 -		".section .fixup,\"ax\"\n"
    4.39 -		"3:	lea 0(%[size1],%[size8],8),%[size8]\n"
    4.40 -		"	jmp 2b\n"
    4.41 -		".previous\n"
    4.42 -		".section __ex_table,\"a\"\n"
    4.43 -		"       .align 8\n"
    4.44 -		"	.quad 0b,3b\n"
    4.45 -		"	.quad 1b,2b\n"
    4.46 -		".previous"
    4.47 -		: [size8] "=c"(size), [dst] "=&D" (__d0)
    4.48 -		: [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
    4.49 -		  [zero] "r" (0UL), [eight] "r" (8UL));
    4.50 -	return size;
    4.51 -}
    4.52 -
    4.53 -unsigned long __copy_to_user_ll(void __user *to, const void *from, unsigned n)
    4.54 -{
    4.55 -	unsigned long __d0, __d1, __d2, __n = n;
    4.56 -	__asm__ __volatile__(
    4.57 -		"	cmpq  $15,%0\n"
    4.58 -		"	jbe  1f\n"
    4.59 -		"	mov  %1,%0\n"
    4.60 -		"	neg  %0\n"
    4.61 -		"	and  $7,%0\n"
    4.62 -		"	sub  %0,%3\n"
    4.63 -		"4:	rep; movsb\n" /* make 'to' address aligned */
    4.64 -		"	mov  %3,%0\n"
    4.65 -		"	shr  $3,%0\n"
    4.66 -		"	and  $7,%3\n"
    4.67 -		"	.align 2,0x90\n"
    4.68 -		"0:	rep; movsq\n" /* as many quadwords as possible... */
    4.69 -		"	mov  %3,%0\n"
    4.70 -		"1:	rep; movsb\n" /* ...remainder copied as bytes */
    4.71 -		"2:\n"
    4.72 -		".section .fixup,\"ax\"\n"
    4.73 -		"5:	add %3,%0\n"
    4.74 -		"	jmp 2b\n"
    4.75 -		"3:	lea 0(%3,%0,8),%0\n"
    4.76 -		"	jmp 2b\n"
    4.77 -		".previous\n"
    4.78 -		".section __ex_table,\"a\"\n"
    4.79 -		"	.align 8\n"
    4.80 -		"	.quad 4b,5b\n"
    4.81 -		"	.quad 0b,3b\n"
    4.82 -		"	.quad 1b,2b\n"
    4.83 -		".previous"
    4.84 -		: "=&c"(__n), "=&D" (__d0), "=&S" (__d1), "=r"(__d2)
    4.85 -		: "3"(__n), "0"(__n), "1"(to), "2"(from)
    4.86 -		: "memory");
    4.87 -	return (unsigned)__n;
    4.88 -}
    4.89 -
    4.90 -unsigned long
    4.91 -__copy_from_user_ll(void *to, const void __user *from, unsigned n)
    4.92 -{
    4.93 -	unsigned long __d0, __d1, __d2, __n = n;
    4.94 -	__asm__ __volatile__(
    4.95 -		"	cmp  $15,%0\n"
    4.96 -		"	jbe  1f\n"
    4.97 -		"	mov  %1,%0\n"
    4.98 -		"	neg  %0\n"
    4.99 -		"	and  $7,%0\n"
   4.100 -		"	sub  %0,%3\n"
   4.101 -		"4:	rep; movsb\n" /* make 'to' address aligned */
   4.102 -		"	mov  %3,%0\n"
   4.103 -		"	shr  $3,%0\n"
   4.104 -		"	and  $7,%3\n"
   4.105 -		"	.align 2,0x90\n"
   4.106 -		"0:	rep; movsq\n" /* as many quadwords as possible... */
   4.107 -		"	mov  %3,%0\n"
   4.108 -		"1:	rep; movsb\n" /* ...remainder copied as bytes */
   4.109 -		"2:\n"
   4.110 -		".section .fixup,\"ax\"\n"
   4.111 -		"5:	add %3,%0\n"
   4.112 -		"	jmp 6f\n"
   4.113 -		"3:	lea 0(%3,%0,8),%0\n"
   4.114 -		"6:	push %0\n"
   4.115 -		"	push %%rax\n"
   4.116 -		"	xor  %%rax,%%rax\n"
   4.117 -		"	rep; stosb\n"
   4.118 -		"	pop  %%rax\n"
   4.119 -		"	pop  %0\n"
   4.120 -		"	jmp 2b\n"
   4.121 -		".previous\n"
   4.122 -		".section __ex_table,\"a\"\n"
   4.123 -		"	.align 8\n"
   4.124 -		"	.quad 4b,5b\n"
   4.125 -		"	.quad 0b,3b\n"
   4.126 -		"	.quad 1b,6b\n"
   4.127 -		".previous"
   4.128 -		: "=&c"(__n), "=&D" (__d0), "=&S" (__d1), "=r"(__d2)
   4.129 -		: "3"(__n), "0"(__n), "1"(to), "2"(from)
   4.130 -		: "memory");
   4.131 -	return (unsigned)__n;
   4.132 -}
   4.133 -
   4.134 -unsigned long clear_user(void *to, unsigned long n)
   4.135 -{
   4.136 -	if (access_ok(to, n))
   4.137 -		return __clear_user(to, n);
   4.138 -	return n;
   4.139 -}
   4.140 -
   4.141 -/**
   4.142 - * copy_to_user: - Copy a block of data into user space.
   4.143 - * @to:   Destination address, in user space.
   4.144 - * @from: Source address, in kernel space.
   4.145 - * @n:    Number of bytes to copy.
   4.146 - *
   4.147 - * Context: User context only.  This function may sleep.
   4.148 - *
   4.149 - * Copy data from kernel space to user space.
   4.150 - *
   4.151 - * Returns number of bytes that could not be copied.
   4.152 - * On success, this will be zero.
   4.153 - */
   4.154 -unsigned long
   4.155 -copy_to_user(void __user *to, const void *from, unsigned n)
   4.156 -{
   4.157 -	if (access_ok(to, n))
   4.158 -		n = __copy_to_user(to, from, n);
   4.159 -	return n;
   4.160 -}
   4.161 -
   4.162 -/**
   4.163 - * copy_from_user: - Copy a block of data from user space.
   4.164 - * @to:   Destination address, in kernel space.
   4.165 - * @from: Source address, in user space.
   4.166 - * @n:    Number of bytes to copy.
   4.167 - *
   4.168 - * Context: User context only.  This function may sleep.
   4.169 - *
   4.170 - * Copy data from user space to kernel space.
   4.171 - *
   4.172 - * Returns number of bytes that could not be copied.
   4.173 - * On success, this will be zero.
   4.174 - *
   4.175 - * If some data could not be copied, this function will pad the copied
   4.176 - * data to the requested size using zero bytes.
   4.177 - */
   4.178 -unsigned long
   4.179 -copy_from_user(void *to, const void __user *from, unsigned n)
   4.180 -{
   4.181 -	if (access_ok(from, n))
   4.182 -		n = __copy_from_user(to, from, n);
   4.183 -	else
   4.184 -		memset(to, 0, n);
   4.185 -	return n;
   4.186 -}
     5.1 --- a/xen/include/asm-x86/types.h	Mon Jun 06 09:28:15 2005 +0000
     5.2 +++ b/xen/include/asm-x86/types.h	Mon Jun 06 10:52:53 2005 +0000
     5.3 @@ -43,6 +43,8 @@ typedef unsigned int u32;
     5.4  typedef signed long long s64;
     5.5  typedef unsigned long long u64;
     5.6  #define BITS_PER_LONG 32
     5.7 +#define BYTES_PER_LONG 4
     5.8 +#define LONG_BYTEORDER 2
     5.9  typedef unsigned int size_t;
    5.10  #if defined(CONFIG_X86_PAE)
    5.11  typedef u64 physaddr_t;
    5.12 @@ -53,6 +55,8 @@ typedef u32 physaddr_t;
    5.13  typedef signed long s64;
    5.14  typedef unsigned long u64;
    5.15  #define BITS_PER_LONG 64
    5.16 +#define BYTES_PER_LONG 8
    5.17 +#define LONG_BYTEORDER 3
    5.18  typedef unsigned long size_t;
    5.19  typedef u64 physaddr_t;
    5.20  #endif
     6.1 --- a/xen/include/asm-x86/uaccess.h	Mon Jun 06 09:28:15 2005 +0000
     6.2 +++ b/xen/include/asm-x86/uaccess.h	Mon Jun 06 10:52:53 2005 +0000
     6.3 @@ -2,12 +2,265 @@
     6.4  #ifndef __X86_UACCESS_H__
     6.5  #define __X86_UACCESS_H__
     6.6  
     6.7 +#include <xen/config.h>
     6.8 +#include <xen/compiler.h>
     6.9 +#include <xen/errno.h>
    6.10 +#include <xen/prefetch.h>
    6.11 +#include <asm/page.h>
    6.12 +
    6.13 +#define __user
    6.14 +
    6.15  #ifdef __x86_64__
    6.16  #include <asm/x86_64/uaccess.h>
    6.17  #else
    6.18  #include <asm/x86_32/uaccess.h>
    6.19  #endif
    6.20  
    6.21 +unsigned long copy_to_user(void *to, const void *from, unsigned len); 
    6.22 +unsigned long copy_from_user(void *to, const void *from, unsigned len); 
    6.23 +/* Handles exceptions in both to and from, but doesn't do access_ok */
    6.24 +unsigned long __copy_to_user_ll(void *to, const void *from, unsigned n);
    6.25 +unsigned long __copy_from_user_ll(void *to, const void *from, unsigned n);
    6.26 +
    6.27 +extern long __get_user_bad(void);
    6.28 +extern void __put_user_bad(void);
    6.29 +
    6.30 +/**
    6.31 + * get_user: - Get a simple variable from user space.
    6.32 + * @x:   Variable to store result.
    6.33 + * @ptr: Source address, in user space.
    6.34 + *
    6.35 + * Context: User context only.  This function may sleep.
    6.36 + *
    6.37 + * This macro copies a single simple variable from user space to kernel
    6.38 + * space.  It supports simple types like char and int, but not larger
    6.39 + * data types like structures or arrays.
    6.40 + *
    6.41 + * @ptr must have pointer-to-simple-variable type, and the result of
    6.42 + * dereferencing @ptr must be assignable to @x without a cast.
    6.43 + *
    6.44 + * Returns zero on success, or -EFAULT on error.
    6.45 + * On error, the variable @x is set to zero.
    6.46 + */
    6.47 +#define get_user(x,ptr)	\
    6.48 +  __get_user_check((x),(ptr),sizeof(*(ptr)))
    6.49 +
    6.50 +/**
    6.51 + * put_user: - Write a simple value into user space.
    6.52 + * @x:   Value to copy to user space.
    6.53 + * @ptr: Destination address, in user space.
    6.54 + *
    6.55 + * Context: User context only.  This function may sleep.
    6.56 + *
    6.57 + * This macro copies a single simple value from kernel space to user
    6.58 + * space.  It supports simple types like char and int, but not larger
    6.59 + * data types like structures or arrays.
    6.60 + *
    6.61 + * @ptr must have pointer-to-simple-variable type, and @x must be assignable
    6.62 + * to the result of dereferencing @ptr.
    6.63 + *
    6.64 + * Returns zero on success, or -EFAULT on error.
    6.65 + */
    6.66 +#define put_user(x,ptr)							\
    6.67 +  __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
    6.68 +
    6.69 +/**
    6.70 + * __get_user: - Get a simple variable from user space, with less checking.
    6.71 + * @x:   Variable to store result.
    6.72 + * @ptr: Source address, in user space.
    6.73 + *
    6.74 + * Context: User context only.  This function may sleep.
    6.75 + *
    6.76 + * This macro copies a single simple variable from user space to kernel
    6.77 + * space.  It supports simple types like char and int, but not larger
    6.78 + * data types like structures or arrays.
    6.79 + *
    6.80 + * @ptr must have pointer-to-simple-variable type, and the result of
    6.81 + * dereferencing @ptr must be assignable to @x without a cast.
    6.82 + *
    6.83 + * Caller must check the pointer with access_ok() before calling this
    6.84 + * function.
    6.85 + *
    6.86 + * Returns zero on success, or -EFAULT on error.
    6.87 + * On error, the variable @x is set to zero.
    6.88 + */
    6.89 +#define __get_user(x,ptr) \
    6.90 +  __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
    6.91 +
    6.92 +/**
    6.93 + * __put_user: - Write a simple value into user space, with less checking.
    6.94 + * @x:   Value to copy to user space.
    6.95 + * @ptr: Destination address, in user space.
    6.96 + *
    6.97 + * Context: User context only.  This function may sleep.
    6.98 + *
    6.99 + * This macro copies a single simple value from kernel space to user
   6.100 + * space.  It supports simple types like char and int, but not larger
   6.101 + * data types like structures or arrays.
   6.102 + *
   6.103 + * @ptr must have pointer-to-simple-variable type, and @x must be assignable
   6.104 + * to the result of dereferencing @ptr.
   6.105 + *
   6.106 + * Caller must check the pointer with access_ok() before calling this
   6.107 + * function.
   6.108 + *
   6.109 + * Returns zero on success, or -EFAULT on error.
   6.110 + */
   6.111 +#define __put_user(x,ptr) \
   6.112 +  __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
   6.113 +
   6.114 +#define __put_user_nocheck(x,ptr,size)				\
   6.115 +({								\
   6.116 +	long __pu_err;						\
   6.117 +	__put_user_size((x),(ptr),(size),__pu_err,-EFAULT);	\
   6.118 +	__pu_err;						\
   6.119 +})
   6.120 +
   6.121 +#define __put_user_check(x,ptr,size)					\
   6.122 +({									\
   6.123 +	long __pu_err = -EFAULT;					\
   6.124 +	__typeof__(*(ptr)) __user *__pu_addr = (ptr);			\
   6.125 +	if (__addr_ok(__pu_addr))					\
   6.126 +		__put_user_size((x),__pu_addr,(size),__pu_err,-EFAULT);	\
   6.127 +	__pu_err;							\
   6.128 +})							
   6.129 +
   6.130 +#define __get_user_nocheck(x,ptr,size)				\
   6.131 +({								\
   6.132 +	long __gu_err, __gu_val;				\
   6.133 +	__get_user_size(__gu_val,(ptr),(size),__gu_err,-EFAULT);\
   6.134 +	(x) = (__typeof__(*(ptr)))__gu_val;			\
   6.135 +	__gu_err;						\
   6.136 +})
   6.137 +
   6.138 +#define __get_user_check(x,ptr,size)					\
   6.139 +({									\
   6.140 +	long __gu_err, __gu_val;					\
   6.141 +	__typeof__(*(ptr)) __user *__gu_addr = (ptr);			\
   6.142 +	__get_user_size(__gu_val,__gu_addr,(size),__gu_err,-EFAULT);	\
   6.143 +	(x) = (__typeof__(*(ptr)))__gu_val;				\
   6.144 +	if (!__addr_ok(__gu_addr)) __gu_err = -EFAULT;			\
   6.145 +	__gu_err;							\
   6.146 +})							
   6.147 +
   6.148 +struct __large_struct { unsigned long buf[100]; };
   6.149 +#define __m(x) (*(struct __large_struct *)(x))
   6.150 +
   6.151 +/*
   6.152 + * Tell gcc we read from memory instead of writing: this is because
   6.153 + * we do not write to any memory gcc knows about, so there are no
   6.154 + * aliasing issues.
   6.155 + */
   6.156 +#define __put_user_asm(x, addr, err, itype, rtype, ltype, errret)	\
   6.157 +	__asm__ __volatile__(						\
   6.158 +		"1:	mov"itype" %"rtype"1,%2\n"			\
   6.159 +		"2:\n"							\
   6.160 +		".section .fixup,\"ax\"\n"				\
   6.161 +		"3:	mov %3,%0\n"					\
   6.162 +		"	jmp 2b\n"					\
   6.163 +		".previous\n"						\
   6.164 +		".section __ex_table,\"a\"\n"				\
   6.165 +		"	"__FIXUP_ALIGN"\n"				\
   6.166 +		"	"__FIXUP_WORD" 1b,3b\n"				\
   6.167 +		".previous"						\
   6.168 +		: "=r"(err)						\
   6.169 +		: ltype (x), "m"(__m(addr)), "i"(errret), "0"(err))
   6.170 +
   6.171 +#define __get_user_asm(x, addr, err, itype, rtype, ltype, errret)	\
   6.172 +	__asm__ __volatile__(						\
   6.173 +		"1:	mov"itype" %2,%"rtype"1\n"			\
   6.174 +		"2:\n"							\
   6.175 +		".section .fixup,\"ax\"\n"				\
   6.176 +		"3:	mov %3,%0\n"					\
   6.177 +		"	xor"itype" %"rtype"1,%"rtype"1\n"		\
   6.178 +		"	jmp 2b\n"					\
   6.179 +		".previous\n"						\
   6.180 +		".section __ex_table,\"a\"\n"				\
   6.181 +		"	"__FIXUP_ALIGN"\n"				\
   6.182 +		"	"__FIXUP_WORD" 1b,3b\n"				\
   6.183 +		".previous"						\
   6.184 +		: "=r"(err), ltype (x)					\
   6.185 +		: "m"(__m(addr)), "i"(errret), "0"(err))
   6.186 +
   6.187 +/**
   6.188 + * __copy_to_user: - Copy a block of data into user space, with less checking
   6.189 + * @to:   Destination address, in user space.
   6.190 + * @from: Source address, in kernel space.
   6.191 + * @n:    Number of bytes to copy.
   6.192 + *
   6.193 + * Context: User context only.  This function may sleep.
   6.194 + *
   6.195 + * Copy data from kernel space to user space.  Caller must check
   6.196 + * the specified block with access_ok() before calling this function.
   6.197 + *
   6.198 + * Returns number of bytes that could not be copied.
   6.199 + * On success, this will be zero.
   6.200 + */
   6.201 +static always_inline unsigned long
   6.202 +__copy_to_user(void __user *to, const void *from, unsigned long n)
   6.203 +{
   6.204 +    if (__builtin_constant_p(n)) {
   6.205 +        unsigned long ret;
   6.206 +
   6.207 +        switch (n) {
   6.208 +        case 1:
   6.209 +            __put_user_size(*(u8 *)from, (u8 __user *)to, 1, ret, 1);
   6.210 +            return ret;
   6.211 +        case 2:
   6.212 +            __put_user_size(*(u16 *)from, (u16 __user *)to, 2, ret, 2);
   6.213 +            return ret;
   6.214 +        case 4:
   6.215 +            __put_user_size(*(u32 *)from, (u32 __user *)to, 4, ret, 4);
   6.216 +            return ret;
   6.217 +        case 8:
   6.218 +            __put_user_size(*(u64 *)from, (u64 __user *)to, 8, ret, 8);
   6.219 +            return ret;
   6.220 +        }
   6.221 +    }
   6.222 +    return __copy_to_user_ll(to, from, n);
   6.223 +}
   6.224 +
   6.225 +/**
   6.226 + * __copy_from_user: - Copy a block of data from user space, with less checking
   6.227 + * @to:   Destination address, in kernel space.
   6.228 + * @from: Source address, in user space.
   6.229 + * @n:    Number of bytes to copy.
   6.230 + *
   6.231 + * Context: User context only.  This function may sleep.
   6.232 + *
   6.233 + * Copy data from user space to kernel space.  Caller must check
   6.234 + * the specified block with access_ok() before calling this function.
   6.235 + *
   6.236 + * Returns number of bytes that could not be copied.
   6.237 + * On success, this will be zero.
   6.238 + *
   6.239 + * If some data could not be copied, this function will pad the copied
   6.240 + * data to the requested size using zero bytes.
   6.241 + */
   6.242 +static always_inline unsigned long
   6.243 +__copy_from_user(void *to, const void __user *from, unsigned long n)
   6.244 +{
   6.245 +    if (__builtin_constant_p(n)) {
   6.246 +        unsigned long ret;
   6.247 +
   6.248 +        switch (n) {
   6.249 +        case 1:
   6.250 +            __get_user_size(*(u8 *)to, from, 1, ret, 1);
   6.251 +            return ret;
   6.252 +        case 2:
   6.253 +            __get_user_size(*(u16 *)to, from, 2, ret, 2);
   6.254 +            return ret;
   6.255 +        case 4:
   6.256 +            __get_user_size(*(u32 *)to, from, 4, ret, 4);
   6.257 +            return ret;
   6.258 +        case 8:
   6.259 +            __get_user_size(*(u64*)to, from, 8, ret, 8);
   6.260 +            return ret; 
   6.261 +        }
   6.262 +    }
   6.263 +    return __copy_from_user_ll(to, from, n);
   6.264 +}
   6.265 +
   6.266  /*
   6.267   * The exception table consists of pairs of addresses: the first is the
   6.268   * address of an instruction that is allowed to fault, and the second is
     7.1 --- a/xen/include/asm-x86/x86_32/uaccess.h	Mon Jun 06 09:28:15 2005 +0000
     7.2 +++ b/xen/include/asm-x86/x86_32/uaccess.h	Mon Jun 06 10:52:53 2005 +0000
     7.3 @@ -1,25 +1,6 @@
     7.4  #ifndef __i386_UACCESS_H
     7.5  #define __i386_UACCESS_H
     7.6  
     7.7 -/*
     7.8 - * User space memory access functions
     7.9 - */
    7.10 -#include <xen/config.h>
    7.11 -#include <xen/errno.h>
    7.12 -#include <xen/prefetch.h>
    7.13 -#include <xen/string.h>
    7.14 -
    7.15 -#define __user
    7.16 -
    7.17 -/*
    7.18 - * movsl can be slow when source and dest are not both 8-byte aligned
    7.19 - */
    7.20 -#ifdef CONFIG_X86_INTEL_USERCOPY
    7.21 -extern struct movsl_mask {
    7.22 -    int mask;
    7.23 -} __cacheline_aligned movsl_mask;
    7.24 -#endif
    7.25 -
    7.26  #define __addr_ok(addr) ((unsigned long)(addr) < HYPERVISOR_VIRT_START)
    7.27  
    7.28  /*
    7.29 @@ -41,112 +22,7 @@ extern struct movsl_mask {
    7.30  #define array_access_ok(addr,count,size) \
    7.31      (likely(count < (~0UL/size)) && access_ok(addr,count*size))
    7.32  
    7.33 -extern long __get_user_bad(void);
    7.34 -extern void __put_user_bad(void);
    7.35 -
    7.36 -/**
    7.37 - * get_user: - Get a simple variable from user space.
    7.38 - * @x:   Variable to store result.
    7.39 - * @ptr: Source address, in user space.
    7.40 - *
    7.41 - * Context: User context only.  This function may sleep.
    7.42 - *
    7.43 - * This macro copies a single simple variable from user space to kernel
    7.44 - * space.  It supports simple types like char and int, but not larger
    7.45 - * data types like structures or arrays.
    7.46 - *
    7.47 - * @ptr must have pointer-to-simple-variable type, and the result of
    7.48 - * dereferencing @ptr must be assignable to @x without a cast.
    7.49 - *
    7.50 - * Returns zero on success, or -EFAULT on error.
    7.51 - * On error, the variable @x is set to zero.
    7.52 - */
    7.53 -#define get_user(x,ptr)	\
    7.54 -  __get_user_check((x),(ptr),sizeof(*(ptr)))
    7.55 -
    7.56 -/**
    7.57 - * put_user: - Write a simple value into user space.
    7.58 - * @x:   Value to copy to user space.
    7.59 - * @ptr: Destination address, in user space.
    7.60 - *
    7.61 - * Context: User context only.  This function may sleep.
    7.62 - *
    7.63 - * This macro copies a single simple value from kernel space to user
    7.64 - * space.  It supports simple types like char and int, but not larger
    7.65 - * data types like structures or arrays.
    7.66 - *
    7.67 - * @ptr must have pointer-to-simple-variable type, and @x must be assignable
    7.68 - * to the result of dereferencing @ptr.
    7.69 - *
    7.70 - * Returns zero on success, or -EFAULT on error.
    7.71 - */
    7.72 -#define put_user(x,ptr)							\
    7.73 -  __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
    7.74 -
    7.75 -
    7.76 -/**
    7.77 - * __get_user: - Get a simple variable from user space, with less checking.
    7.78 - * @x:   Variable to store result.
    7.79 - * @ptr: Source address, in user space.
    7.80 - *
    7.81 - * Context: User context only.  This function may sleep.
    7.82 - *
    7.83 - * This macro copies a single simple variable from user space to kernel
    7.84 - * space.  It supports simple types like char and int, but not larger
    7.85 - * data types like structures or arrays.
    7.86 - *
    7.87 - * @ptr must have pointer-to-simple-variable type, and the result of
    7.88 - * dereferencing @ptr must be assignable to @x without a cast.
    7.89 - *
    7.90 - * Caller must check the pointer with access_ok() before calling this
    7.91 - * function.
    7.92 - *
    7.93 - * Returns zero on success, or -EFAULT on error.
    7.94 - * On error, the variable @x is set to zero.
    7.95 - */
    7.96 -#define __get_user(x,ptr) \
    7.97 -  __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
    7.98 -
    7.99 -
   7.100 -/**
   7.101 - * __put_user: - Write a simple value into user space, with less checking.
   7.102 - * @x:   Value to copy to user space.
   7.103 - * @ptr: Destination address, in user space.
   7.104 - *
   7.105 - * Context: User context only.  This function may sleep.
   7.106 - *
   7.107 - * This macro copies a single simple value from kernel space to user
   7.108 - * space.  It supports simple types like char and int, but not larger
   7.109 - * data types like structures or arrays.
   7.110 - *
   7.111 - * @ptr must have pointer-to-simple-variable type, and @x must be assignable
   7.112 - * to the result of dereferencing @ptr.
   7.113 - *
   7.114 - * Caller must check the pointer with access_ok() before calling this
   7.115 - * function.
   7.116 - *
   7.117 - * Returns zero on success, or -EFAULT on error.
   7.118 - */
   7.119 -#define __put_user(x,ptr) \
   7.120 -  __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
   7.121 -
   7.122 -#define __put_user_nocheck(x,ptr,size)				\
   7.123 -({								\
   7.124 -	long __pu_err;						\
   7.125 -	__put_user_size((x),(ptr),(size),__pu_err,-EFAULT);	\
   7.126 -	__pu_err;						\
   7.127 -})
   7.128 -
   7.129 -#define __put_user_check(x,ptr,size)					\
   7.130 -({									\
   7.131 -	long __pu_err = -EFAULT;					\
   7.132 -	__typeof__(*(ptr)) __user *__pu_addr = (ptr);			\
   7.133 -	if (__addr_ok(__pu_addr))					\
   7.134 -		__put_user_size((x),__pu_addr,(size),__pu_err,-EFAULT);	\
   7.135 -	__pu_err;							\
   7.136 -})							
   7.137 -
   7.138 -#define __put_user_u64(x, addr, err)				\
   7.139 +#define __put_user_u64(x, addr, retval, errret)			\
   7.140  	__asm__ __volatile__(					\
   7.141  		"1:	movl %%eax,0(%2)\n"			\
   7.142  		"2:	movl %%edx,4(%2)\n"			\
   7.143 @@ -160,8 +36,8 @@ extern void __put_user_bad(void);
   7.144  		"	.long 1b,4b\n"				\
   7.145  		"	.long 2b,4b\n"				\
   7.146  		".previous"					\
   7.147 -		: "=r"(err)					\
   7.148 -		: "A" (x), "r" (addr), "i"(-EFAULT), "0"(err))
   7.149 +		: "=r"(retval)					\
   7.150 +		: "A" (x), "r" (addr), "i"(errret), "0"(retval))
   7.151  
   7.152  #define __put_user_size(x,ptr,size,retval,errret)			\
   7.153  do {									\
   7.154 @@ -170,52 +46,29 @@ do {									\
   7.155  	case 1: __put_user_asm(x,ptr,retval,"b","b","iq",errret);break;	\
   7.156  	case 2: __put_user_asm(x,ptr,retval,"w","w","ir",errret);break; \
   7.157  	case 4: __put_user_asm(x,ptr,retval,"l","","ir",errret); break;	\
   7.158 -	case 8: __put_user_u64((__typeof__(*ptr))(x),ptr,retval); break;\
   7.159 -	  default: __put_user_bad();					\
   7.160 +	case 8: __put_user_u64((__typeof__(*ptr))(x),ptr,retval,errret);break;\
   7.161 +	default: __put_user_bad();					\
   7.162  	}								\
   7.163  } while (0)
   7.164  
   7.165 -struct __large_struct { unsigned long buf[100]; };
   7.166 -#define __m(x) (*(struct __large_struct *)(x))
   7.167 -
   7.168 -/*
   7.169 - * Tell gcc we read from memory instead of writing: this is because
   7.170 - * we do not write to any memory gcc knows about, so there are no
   7.171 - * aliasing issues.
   7.172 - */
   7.173 -#define __put_user_asm(x, addr, err, itype, rtype, ltype, errret)	\
   7.174 -	__asm__ __volatile__(						\
   7.175 -		"1:	mov"itype" %"rtype"1,%2\n"			\
   7.176 -		"2:\n"							\
   7.177 -		".section .fixup,\"ax\"\n"				\
   7.178 -		"3:	movl %3,%0\n"					\
   7.179 -		"	jmp 2b\n"					\
   7.180 -		".previous\n"						\
   7.181 -		".section __ex_table,\"a\"\n"				\
   7.182 -		"	.align 4\n"					\
   7.183 -		"	.long 1b,3b\n"					\
   7.184 -		".previous"						\
   7.185 -		: "=r"(err)						\
   7.186 -		: ltype (x), "m"(__m(addr)), "i"(errret), "0"(err))
   7.187 -
   7.188 -
   7.189 -#define __get_user_nocheck(x,ptr,size)				\
   7.190 -({								\
   7.191 -	long __gu_err, __gu_val;				\
   7.192 -	__get_user_size(__gu_val,(ptr),(size),__gu_err,-EFAULT);\
   7.193 -	(x) = (__typeof__(*(ptr)))__gu_val;			\
   7.194 -	__gu_err;						\
   7.195 -})
   7.196 -
   7.197 -#define __get_user_check(x,ptr,size)					\
   7.198 -({									\
   7.199 -	long __gu_err, __gu_val;					\
   7.200 -	__typeof__(*(ptr)) __user *__gu_addr = (ptr);			\
   7.201 -	__get_user_size(__gu_val,__gu_addr,(size),__gu_err,-EFAULT);	\
   7.202 -	(x) = (__typeof__(*(ptr)))__gu_val;				\
   7.203 -	if (!__addr_ok(__gu_addr)) __gu_err = -EFAULT;			\
   7.204 -	__gu_err;							\
   7.205 -})							
   7.206 +#define __get_user_u64(x, addr, retval, errret)			\
   7.207 +	__asm__ __volatile__(					\
   7.208 +		"1:	movl 0(%2),%%eax\n"			\
   7.209 +		"2:	movl 4(%2),%%edx\n"			\
   7.210 +		"3:\n"						\
   7.211 +		".section .fixup,\"ax\"\n"			\
   7.212 +		"4:	movl %3,%0\n"				\
   7.213 +		"	xorl %%eax,%%eax\n"			\
   7.214 +		"	xorl %%edx,%%edx\n"			\
   7.215 +		"	jmp 3b\n"				\
   7.216 +		".previous\n"					\
   7.217 +		".section __ex_table,\"a\"\n"			\
   7.218 +		"	.align 4\n"				\
   7.219 +		"	.long 1b,4b\n"				\
   7.220 +		"	.long 2b,4b\n"				\
   7.221 +		".previous"					\
   7.222 +		: "=r" (retval), "=A" (x)			\
   7.223 +		: "r" (addr), "i"(errret), "0"(retval))
   7.224  
   7.225  #define __get_user_size(x,ptr,size,retval,errret)			\
   7.226  do {									\
   7.227 @@ -224,115 +77,9 @@ do {									\
   7.228  	case 1: __get_user_asm(x,ptr,retval,"b","b","=q",errret);break;	\
   7.229  	case 2: __get_user_asm(x,ptr,retval,"w","w","=r",errret);break;	\
   7.230  	case 4: __get_user_asm(x,ptr,retval,"l","","=r",errret);break;	\
   7.231 +	case 8: __get_user_u64(x,ptr,retval,errret);break;		\
   7.232  	default: (x) = __get_user_bad();				\
   7.233  	}								\
   7.234  } while (0)
   7.235  
   7.236 -#define __get_user_asm(x, addr, err, itype, rtype, ltype, errret)	\
   7.237 -	__asm__ __volatile__(						\
   7.238 -		"1:	mov"itype" %2,%"rtype"1\n"			\
   7.239 -		"2:\n"							\
   7.240 -		".section .fixup,\"ax\"\n"				\
   7.241 -		"3:	movl %3,%0\n"					\
   7.242 -		"	xor"itype" %"rtype"1,%"rtype"1\n"		\
   7.243 -		"	jmp 2b\n"					\
   7.244 -		".previous\n"						\
   7.245 -		".section __ex_table,\"a\"\n"				\
   7.246 -		"	.align 4\n"					\
   7.247 -		"	.long 1b,3b\n"					\
   7.248 -		".previous"						\
   7.249 -		: "=r"(err), ltype (x)					\
   7.250 -		: "m"(__m(addr)), "i"(errret), "0"(err))
   7.251 -
   7.252 -
   7.253 -unsigned long __copy_to_user_ll(void __user *to, const void *from, unsigned long n);
   7.254 -unsigned long __copy_from_user_ll(void *to, const void __user *from, unsigned long n);
   7.255 -
   7.256 -/*
   7.257 - * Here we special-case 1, 2 and 4-byte copy_*_user invocations.  On a fault
   7.258 - * we return the initial request size (1, 2 or 4), as copy_*_user should do.
   7.259 - * If a store crosses a page boundary and gets a fault, the x86 will not write
   7.260 - * anything, so this is accurate.
   7.261 - */
   7.262 -
   7.263 -/**
   7.264 - * __copy_to_user: - Copy a block of data into user space, with less checking.
   7.265 - * @to:   Destination address, in user space.
   7.266 - * @from: Source address, in kernel space.
   7.267 - * @n:    Number of bytes to copy.
   7.268 - *
   7.269 - * Context: User context only.  This function may sleep.
   7.270 - *
   7.271 - * Copy data from kernel space to user space.  Caller must check
   7.272 - * the specified block with access_ok() before calling this function.
   7.273 - *
   7.274 - * Returns number of bytes that could not be copied.
   7.275 - * On success, this will be zero.
   7.276 - */
   7.277 -static always_inline unsigned long
   7.278 -__copy_to_user(void __user *to, const void *from, unsigned long n)
   7.279 -{
   7.280 -    if (__builtin_constant_p(n)) {
   7.281 -        unsigned long ret;
   7.282 -
   7.283 -        switch (n) {
   7.284 -        case 1:
   7.285 -            __put_user_size(*(u8 *)from, (u8 __user *)to, 1, ret, 1);
   7.286 -            return ret;
   7.287 -        case 2:
   7.288 -            __put_user_size(*(u16 *)from, (u16 __user *)to, 2, ret, 2);
   7.289 -            return ret;
   7.290 -        case 4:
   7.291 -            __put_user_size(*(u32 *)from, (u32 __user *)to, 4, ret, 4);
   7.292 -            return ret;
   7.293 -        }
   7.294 -    }
   7.295 -    return __copy_to_user_ll(to, from, n);
   7.296 -}
   7.297 -
   7.298 -/**
   7.299 - * __copy_from_user: - Copy a block of data from user space, with less checking.
   7.300 - * @to:   Destination address, in kernel space.
   7.301 - * @from: Source address, in user space.
   7.302 - * @n:    Number of bytes to copy.
   7.303 - *
   7.304 - * Context: User context only.  This function may sleep.
   7.305 - *
   7.306 - * Copy data from user space to kernel space.  Caller must check
   7.307 - * the specified block with access_ok() before calling this function.
   7.308 - *
   7.309 - * Returns number of bytes that could not be copied.
   7.310 - * On success, this will be zero.
   7.311 - *
   7.312 - * If some data could not be copied, this function will pad the copied
   7.313 - * data to the requested size using zero bytes.
   7.314 - */
   7.315 -static always_inline unsigned long
   7.316 -__copy_from_user(void *to, const void __user *from, unsigned long n)
   7.317 -{
   7.318 -    if (__builtin_constant_p(n)) {
   7.319 -        unsigned long ret;
   7.320 -
   7.321 -        switch (n) {
   7.322 -        case 1:
   7.323 -            __get_user_size(*(u8 *)to, from, 1, ret, 1);
   7.324 -            return ret;
   7.325 -        case 2:
   7.326 -            __get_user_size(*(u16 *)to, from, 2, ret, 2);
   7.327 -            return ret;
   7.328 -        case 4:
   7.329 -            __get_user_size(*(u32 *)to, from, 4, ret, 4);
   7.330 -            return ret;
   7.331 -        }
   7.332 -    }
   7.333 -    return __copy_from_user_ll(to, from, n);
   7.334 -}
   7.335 -
   7.336 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n);
   7.337 -unsigned long copy_from_user(void *to,
   7.338 -                             const void __user *from, unsigned long n);
   7.339 -
   7.340 -unsigned long clear_user(void __user *mem, unsigned long len);
   7.341 -unsigned long __clear_user(void __user *mem, unsigned long len);
   7.342 -
   7.343  #endif /* __i386_UACCESS_H */
     8.1 --- a/xen/include/asm-x86/x86_64/uaccess.h	Mon Jun 06 09:28:15 2005 +0000
     8.2 +++ b/xen/include/asm-x86/x86_64/uaccess.h	Mon Jun 06 10:52:53 2005 +0000
     8.3 @@ -2,17 +2,6 @@
     8.4  #define __X86_64_UACCESS_H
     8.5  
     8.6  /*
     8.7 - * User space memory access functions
     8.8 - */
     8.9 -#include <xen/config.h>
    8.10 -#include <xen/compiler.h>
    8.11 -#include <xen/errno.h>
    8.12 -#include <xen/prefetch.h>
    8.13 -#include <asm/page.h>
    8.14 -
    8.15 -#define __user
    8.16 -
    8.17 -/*
    8.18   * Valid if in +ve half of 48-bit address space, or above Xen-reserved area.
    8.19   * This is also valid for range checks (addr, addr+size). As long as the
    8.20   * start address is outside the Xen-reserved area then we will access a
    8.21 @@ -26,111 +15,6 @@
    8.22  
    8.23  #define array_access_ok(addr, count, size) (__addr_ok(addr))
    8.24  
    8.25 -extern long __get_user_bad(void);
    8.26 -extern void __put_user_bad(void);
    8.27 -
    8.28 -/**
    8.29 - * get_user: - Get a simple variable from user space.
    8.30 - * @x:   Variable to store result.
    8.31 - * @ptr: Source address, in user space.
    8.32 - *
    8.33 - * Context: User context only.  This function may sleep.
    8.34 - *
    8.35 - * This macro copies a single simple variable from user space to kernel
    8.36 - * space.  It supports simple types like char and int, but not larger
    8.37 - * data types like structures or arrays.
    8.38 - *
    8.39 - * @ptr must have pointer-to-simple-variable type, and the result of
    8.40 - * dereferencing @ptr must be assignable to @x without a cast.
    8.41 - *
    8.42 - * Returns zero on success, or -EFAULT on error.
    8.43 - * On error, the variable @x is set to zero.
    8.44 - */
    8.45 -#define get_user(x,ptr)	\
    8.46 -  __get_user_check((x),(ptr),sizeof(*(ptr)))
    8.47 -
    8.48 -/**
    8.49 - * put_user: - Write a simple value into user space.
    8.50 - * @x:   Value to copy to user space.
    8.51 - * @ptr: Destination address, in user space.
    8.52 - *
    8.53 - * Context: User context only.  This function may sleep.
    8.54 - *
    8.55 - * This macro copies a single simple value from kernel space to user
    8.56 - * space.  It supports simple types like char and int, but not larger
    8.57 - * data types like structures or arrays.
    8.58 - *
    8.59 - * @ptr must have pointer-to-simple-variable type, and @x must be assignable
    8.60 - * to the result of dereferencing @ptr.
    8.61 - *
    8.62 - * Returns zero on success, or -EFAULT on error.
    8.63 - */
    8.64 -#define put_user(x,ptr)							\
    8.65 -  __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
    8.66 -
    8.67 -
    8.68 -/**
    8.69 - * __get_user: - Get a simple variable from user space, with less checking.
    8.70 - * @x:   Variable to store result.
    8.71 - * @ptr: Source address, in user space.
    8.72 - *
    8.73 - * Context: User context only.  This function may sleep.
    8.74 - *
    8.75 - * This macro copies a single simple variable from user space to kernel
    8.76 - * space.  It supports simple types like char and int, but not larger
    8.77 - * data types like structures or arrays.
    8.78 - *
    8.79 - * @ptr must have pointer-to-simple-variable type, and the result of
    8.80 - * dereferencing @ptr must be assignable to @x without a cast.
    8.81 - *
    8.82 - * Caller must check the pointer with access_ok() before calling this
    8.83 - * function.
    8.84 - *
    8.85 - * Returns zero on success, or -EFAULT on error.
    8.86 - * On error, the variable @x is set to zero.
    8.87 - */
    8.88 -#define __get_user(x,ptr) \
    8.89 -  __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
    8.90 -
    8.91 -
    8.92 -/**
    8.93 - * __put_user: - Write a simple value into user space, with less checking.
    8.94 - * @x:   Value to copy to user space.
    8.95 - * @ptr: Destination address, in user space.
    8.96 - *
    8.97 - * Context: User context only.  This function may sleep.
    8.98 - *
    8.99 - * This macro copies a single simple value from kernel space to user
   8.100 - * space.  It supports simple types like char and int, but not larger
   8.101 - * data types like structures or arrays.
   8.102 - *
   8.103 - * @ptr must have pointer-to-simple-variable type, and @x must be assignable
   8.104 - * to the result of dereferencing @ptr.
   8.105 - *
   8.106 - * Caller must check the pointer with access_ok() before calling this
   8.107 - * function.
   8.108 - *
   8.109 - * Returns zero on success, or -EFAULT on error.
   8.110 - */
   8.111 -#define __put_user(x,ptr) \
   8.112 -  __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
   8.113 -
   8.114 -#define __put_user_nocheck(x,ptr,size)				\
   8.115 -({								\
   8.116 -	long __pu_err;						\
   8.117 -	__put_user_size((x),(ptr),(size),__pu_err,-EFAULT);	\
   8.118 -	__pu_err;						\
   8.119 -})
   8.120 -
   8.121 -#define __put_user_check(x,ptr,size)					\
   8.122 -({									\
   8.123 -	long __pu_err = -EFAULT;					\
   8.124 -	__typeof__(*(ptr)) __user *__pu_addr = (ptr);			\
   8.125 -	if (__addr_ok(__pu_addr))					\
   8.126 -		__put_user_size((x),__pu_addr,(size),__pu_err,-EFAULT);	\
   8.127 -	__pu_err;							\
   8.128 -})							
   8.129 -
   8.130  #define __put_user_size(x,ptr,size,retval,errret)			\
   8.131  do {									\
   8.132  	retval = 0;							\
   8.133 @@ -143,47 +27,6 @@ do {									\
   8.134  	}								\
   8.135  } while (0)
   8.136  
   8.137 -struct __large_struct { unsigned long buf[100]; };
   8.138 -#define __m(x) (*(struct __large_struct *)(x))
   8.139 -
   8.140 -/*
   8.141 - * Tell gcc we read from memory instead of writing: this is because
   8.142 - * we do not write to any memory gcc knows about, so there are no
   8.143 - * aliasing issues.
   8.144 - */
   8.145 -#define __put_user_asm(x, addr, err, itype, rtype, ltype, errret)	\
   8.146 -	__asm__ __volatile__(						\
   8.147 -		"1:	mov"itype" %"rtype"1,%2\n"			\
   8.148 -		"2:\n"							\
   8.149 -		".section .fixup,\"ax\"\n"				\
   8.150 -		"3:	mov %3,%0\n"					\
   8.151 -		"	jmp 2b\n"					\
   8.152 -		".previous\n"						\
   8.153 -		".section __ex_table,\"a\"\n"				\
   8.154 -		"	.align 8\n"					\
   8.155 -		"	.quad 1b,3b\n"					\
   8.156 -		".previous"						\
   8.157 -		: "=r"(err)						\
   8.158 -		: ltype (x), "m"(__m(addr)), "i"(errret), "0"(err))
   8.159 -
   8.160 -#define __get_user_nocheck(x,ptr,size)				\
   8.161 -({								\
   8.162 -	long __gu_err, __gu_val;				\
   8.163 -	__get_user_size(__gu_val,(ptr),(size),__gu_err,-EFAULT);\
   8.164 -	(x) = (__typeof__(*(ptr)))__gu_val;			\
   8.165 -	__gu_err;						\
   8.166 -})
   8.167 -
   8.168 -#define __get_user_check(x,ptr,size)					\
   8.169 -({									\
   8.170 -	long __gu_err, __gu_val;					\
   8.171 -	__typeof__(*(ptr)) __user *__gu_addr = (ptr);			\
   8.172 -	__get_user_size(__gu_val,__gu_addr,(size),__gu_err,-EFAULT);	\
   8.173 -	(x) = (__typeof__(*(ptr)))__gu_val;				\
   8.174 -	if (!__addr_ok(__gu_addr)) __gu_err = -EFAULT;			\
   8.175 -	__gu_err;							\
   8.176 -})							
   8.177 -
   8.178  #define __get_user_size(x,ptr,size,retval,errret)			\
   8.179  do {									\
   8.180  	retval = 0;							\
   8.181 @@ -196,95 +39,4 @@ do {									\
   8.182  	}								\
   8.183  } while (0)
   8.184  
   8.185 -#define __get_user_asm(x, addr, err, itype, rtype, ltype, errret)	\
   8.186 -	__asm__ __volatile__(						\
   8.187 -		"1:	mov"itype" %2,%"rtype"1\n"			\
   8.188 -		"2:\n"							\
   8.189 -		".section .fixup,\"ax\"\n"				\
   8.190 -		"3:	mov %3,%0\n"					\
   8.191 -		"	xor"itype" %"rtype"1,%"rtype"1\n"		\
   8.192 -		"	jmp 2b\n"					\
   8.193 -		".previous\n"						\
   8.194 -		".section __ex_table,\"a\"\n"				\
   8.195 -		"	.align 8\n"					\
   8.196 -		"	.quad 1b,3b\n"					\
   8.197 -		".previous"						\
   8.198 -		: "=r"(err), ltype (x)					\
   8.199 -		: "m"(__m(addr)), "i"(errret), "0"(err))
   8.200 -
   8.201 -
   8.202 -/*
   8.203 - * Copy To/From Userspace
   8.204 - */
   8.205 -
   8.206 -/* Handles exceptions in both to and from, but doesn't do access_ok */
   8.207 -unsigned long __copy_to_user_ll(void __user *to, const void *from, unsigned n);
   8.208 -unsigned long __copy_from_user_ll(void *to, const void __user *from, unsigned n);
   8.209 -
   8.210 -unsigned long copy_to_user(void __user *to, const void *from, unsigned len); 
   8.211 -unsigned long copy_from_user(void *to, const void __user *from, unsigned len); 
   8.212 -
   8.213 -static always_inline int __copy_from_user(void *dst, const void __user *src, unsigned size) 
   8.214 -{ 
   8.215 -    int ret = 0;
   8.216 -    if (!__builtin_constant_p(size))
   8.217 -        return __copy_from_user_ll(dst,(void *)src,size);
   8.218 -    switch (size) { 
   8.219 -    case 1:__get_user_asm(*(u8*)dst,(u8 __user *)src,ret,"b","b","=q",1); 
   8.220 -        return ret;
   8.221 -    case 2:__get_user_asm(*(u16*)dst,(u16 __user *)src,ret,"w","w","=r",2);
   8.222 -        return ret;
   8.223 -    case 4:__get_user_asm(*(u32*)dst,(u32 __user *)src,ret,"l","k","=r",4);
   8.224 -        return ret;
   8.225 -    case 8:__get_user_asm(*(u64*)dst,(u64 __user *)src,ret,"q","","=r",8);
   8.226 -        return ret; 
   8.227 -    case 10:
   8.228 -        __get_user_asm(*(u64*)dst,(u64 __user *)src,ret,"q","","=r",16);
   8.229 -        if (unlikely(ret)) return ret;
   8.230 -        __get_user_asm(*(u16*)(8+(char*)dst),(u16 __user *)(8+(char __user *)src),ret,"w","w","=r",2);
   8.231 -        return ret; 
   8.232 -    case 16:
   8.233 -        __get_user_asm(*(u64*)dst,(u64 __user *)src,ret,"q","","=r",16);
   8.234 -        if (unlikely(ret)) return ret;
   8.235 -        __get_user_asm(*(u64*)(8+(char*)dst),(u64 __user *)(8+(char __user *)src),ret,"q","","=r",8);
   8.236 -        return ret; 
   8.237 -    default:
   8.238 -        return __copy_from_user_ll(dst,(void *)src,size); 
   8.239 -    }
   8.240 -}	
   8.241 -
   8.242 -static always_inline int __copy_to_user(void __user *dst, const void *src, unsigned size) 
   8.243 -{ 
   8.244 -    int ret = 0;
   8.245 -    if (!__builtin_constant_p(size))
   8.246 -        return __copy_to_user_ll((void *)dst,src,size);
   8.247 -    switch (size) { 
   8.248 -    case 1:__put_user_asm(*(u8*)src,(u8 __user *)dst,ret,"b","b","iq",1); 
   8.249 -        return ret;
   8.250 -    case 2:__put_user_asm(*(u16*)src,(u16 __user *)dst,ret,"w","w","ir",2);
   8.251 -        return ret;
   8.252 -    case 4:__put_user_asm(*(u32*)src,(u32 __user *)dst,ret,"l","k","ir",4);
   8.253 -        return ret;
   8.254 -    case 8:__put_user_asm(*(u64*)src,(u64 __user *)dst,ret,"q","","ir",8);
   8.255 -        return ret; 
   8.256 -    case 10:
   8.257 -        __put_user_asm(*(u64*)src,(u64 __user *)dst,ret,"q","","ir",10);
   8.258 -        if (unlikely(ret)) return ret;
   8.259 -        asm("":::"memory");
   8.260 -        __put_user_asm(4[(u16*)src],4+(u16 __user *)dst,ret,"w","w","ir",2);
   8.261 -        return ret; 
   8.262 -    case 16:
   8.263 -        __put_user_asm(*(u64*)src,(u64 __user *)dst,ret,"q","","ir",16);
   8.264 -        if (unlikely(ret)) return ret;
   8.265 -        asm("":::"memory");
   8.266 -        __put_user_asm(1[(u64*)src],1+(u64 __user *)dst,ret,"q","","ir",8);
   8.267 -        return ret; 
   8.268 -    default:
   8.269 -        return __copy_to_user_ll((void *)dst,src,size); 
   8.270 -    }
   8.271 -}	
   8.272 -
   8.273 -unsigned long clear_user(void __user *mem, unsigned long len);
   8.274 -unsigned long __clear_user(void __user *mem, unsigned long len);
   8.275 -
   8.276  #endif /* __X86_64_UACCESS_H */