aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/include/sysdep-i386/checksum.h
diff options
context:
space:
mode:
authorBodo Stroesser <bstroesser@fujitsu-siemens.com>2005-05-05 19:15:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-05 19:36:38 -0400
commit7d37c6d52fce13008f20344790a81a6a5a0003b3 (patch)
treeebf98bc32d8c0e29627f7be8a4dd349a32efff1d /arch/um/include/sysdep-i386/checksum.h
parentc52ac046757deebc514483e407dca39a9c774aa3 (diff)
[PATCH] uml: s390 preparation, checksumming done in arch code
Checksum handling largely depends on the subarch. Thus, I renamed i386 arch_csum_partial in arch/um/sys-i386/checksum.S back to csum_partial, removed csum_partial from arch/um/kernel/checksum.c and shifted EXPORT_SYMBOL(csum_partial) to arch/um/sys-i386/ksyms.c. Then, csum_partial_copy_to and csum_partial_copy_from were shifted from arch/um/kernel/checksum.c to arch/um/include/sysdep-i386/checksum.h and inserted in the calling functions csum_partial_copy_from_user() and csum_and_copy_to_user(). Now, arch/um/kernel/checksum.c is empty and removed. Signed-off-by: Bodo Stroesser <bstroesser@fujitsu-siemens.com> Signed-off-by: Jeff Dike <jdike@addtoit.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/include/sysdep-i386/checksum.h')
-rw-r--r--arch/um/include/sysdep-i386/checksum.h39
1 files changed, 22 insertions, 17 deletions
diff --git a/arch/um/include/sysdep-i386/checksum.h b/arch/um/include/sysdep-i386/checksum.h
index 3a2a45811aa3..764ba4db4788 100644
--- a/arch/um/include/sysdep-i386/checksum.h
+++ b/arch/um/include/sysdep-i386/checksum.h
@@ -24,19 +24,6 @@ unsigned int csum_partial(const unsigned char * buff, int len,
24 unsigned int sum); 24 unsigned int sum);
25 25
26/* 26/*
27 * the same as csum_partial, but copies from src while it
28 * checksums, and handles user-space pointer exceptions correctly, when needed.
29 *
30 * here even more important to align src and dst on a 32-bit (or even
31 * better 64-bit) boundary
32 */
33
34unsigned int csum_partial_copy_to(const unsigned char *src, unsigned char *dst,
35 int len, int sum, int *err_ptr);
36unsigned int csum_partial_copy_from(const unsigned char *src, unsigned char *dst,
37 int len, int sum, int *err_ptr);
38
39/*
40 * Note: when you get a NULL pointer exception here this means someone 27 * Note: when you get a NULL pointer exception here this means someone
41 * passed in an incorrect kernel address to one of these functions. 28 * passed in an incorrect kernel address to one of these functions.
42 * 29 *
@@ -52,11 +39,24 @@ unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned char *
52 return(csum_partial(dst, len, sum)); 39 return(csum_partial(dst, len, sum));
53} 40}
54 41
42/*
43 * the same as csum_partial, but copies from src while it
44 * checksums, and handles user-space pointer exceptions correctly, when needed.
45 *
46 * here even more important to align src and dst on a 32-bit (or even
47 * better 64-bit) boundary
48 */
49
55static __inline__ 50static __inline__
56unsigned int csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst, 51unsigned int csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst,
57 int len, int sum, int *err_ptr) 52 int len, int sum, int *err_ptr)
58{ 53{
59 return csum_partial_copy_from(src, dst, len, sum, err_ptr); 54 if(copy_from_user(dst, src, len)){
55 *err_ptr = -EFAULT;
56 return(-1);
57 }
58
59 return csum_partial(dst, len, sum);
60} 60}
61 61
62/* 62/*
@@ -67,7 +67,6 @@ unsigned int csum_partial_copy_from_user(const unsigned char *src, unsigned char
67 */ 67 */
68 68
69#define csum_partial_copy_fromuser csum_partial_copy_from_user 69#define csum_partial_copy_fromuser csum_partial_copy_from_user
70unsigned int csum_partial_copy(const unsigned char *src, unsigned char *dst, int len, int sum);
71 70
72/* 71/*
73 * This is a version of ip_compute_csum() optimized for IP headers, 72 * This is a version of ip_compute_csum() optimized for IP headers,
@@ -196,8 +195,14 @@ static __inline__ unsigned int csum_and_copy_to_user(const unsigned char *src,
196 unsigned char *dst, 195 unsigned char *dst,
197 int len, int sum, int *err_ptr) 196 int len, int sum, int *err_ptr)
198{ 197{
199 if (access_ok(VERIFY_WRITE, dst, len)) 198 if (access_ok(VERIFY_WRITE, dst, len)){
200 return(csum_partial_copy_to(src, dst, len, sum, err_ptr)); 199 if(copy_to_user(dst, src, len)){
200 *err_ptr = -EFAULT;
201 return(-1);
202 }
203
204 return csum_partial(src, len, sum);
205 }
201 206
202 if (len) 207 if (len)
203 *err_ptr = -EFAULT; 208 *err_ptr = -EFAULT;