Commit 7d37c6d52fce13008f20344790a81a6a5a0003b3

Authored by Bodo Stroesser
Committed by Linus Torvalds
1 parent c52ac04675

[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>

Showing 5 changed files with 27 additions and 59 deletions Side-by-side Diff

arch/um/include/sysdep-i386/checksum.h
... ... @@ -24,19 +24,6 @@
24 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   -
34   -unsigned int csum_partial_copy_to(const unsigned char *src, unsigned char *dst,
35   - int len, int sum, int *err_ptr);
36   -unsigned int csum_partial_copy_from(const unsigned char *src, unsigned char *dst,
37   - int len, int sum, int *err_ptr);
38   -
39   -/*
40 27 * Note: when you get a NULL pointer exception here this means someone
41 28 * passed in an incorrect kernel address to one of these functions.
42 29 *
43 30  
... ... @@ -52,11 +39,24 @@
52 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 +
55 50 static __inline__
56 51 unsigned int csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst,
57 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 @@
67 67 */
68 68  
69 69 #define csum_partial_copy_fromuser csum_partial_copy_from_user
70   -unsigned int csum_partial_copy(const unsigned char *src, unsigned char *dst, int len, int sum);
71 70  
72 71 /*
73 72 * This is a version of ip_compute_csum() optimized for IP headers,
... ... @@ -196,8 +195,14 @@
196 195 unsigned char *dst,
197 196 int len, int sum, int *err_ptr)
198 197 {
199   - if (access_ok(VERIFY_WRITE, dst, len))
200   - return(csum_partial_copy_to(src, dst, len, sum, err_ptr));
  198 + if (access_ok(VERIFY_WRITE, dst, len)){
  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 207 if (len)
203 208 *err_ptr = -EFAULT;
arch/um/kernel/Makefile
... ... @@ -6,7 +6,7 @@
6 6 extra-y := vmlinux.lds
7 7 clean-files :=
8 8  
9   -obj-y = checksum.o config.o exec_kern.o exitcode.o \
  9 +obj-y = config.o exec_kern.o exitcode.o \
10 10 helper.o init_task.o irq.o irq_user.o ksyms.o main.o mem.o mem_user.o \
11 11 physmem.o process.o process_kern.o ptrace.o reboot.o resource.o \
12 12 sigio_user.o sigio_kern.o signal_kern.o signal_user.o smp.o \
arch/um/kernel/checksum.c
1   -#include "asm/uaccess.h"
2   -#include "linux/errno.h"
3   -#include "linux/module.h"
4   -
5   -unsigned int arch_csum_partial(const unsigned char *buff, int len, int sum);
6   -
7   -unsigned int csum_partial(unsigned char *buff, int len, int sum)
8   -{
9   - return arch_csum_partial(buff, len, sum);
10   -}
11   -
12   -EXPORT_SYMBOL(csum_partial);
13   -
14   -unsigned int csum_partial_copy_to(const unsigned char *src,
15   - unsigned char __user *dst, int len, int sum,
16   - int *err_ptr)
17   -{
18   - if(copy_to_user(dst, src, len)){
19   - *err_ptr = -EFAULT;
20   - return(-1);
21   - }
22   -
23   - return(arch_csum_partial(src, len, sum));
24   -}
25   -
26   -unsigned int csum_partial_copy_from(const unsigned char __user *src,
27   - unsigned char *dst, int len, int sum,
28   - int *err_ptr)
29   -{
30   - if(copy_from_user(dst, src, len)){
31   - *err_ptr = -EFAULT;
32   - return(-1);
33   - }
34   -
35   - return arch_csum_partial(dst, len, sum);
36   -}
arch/um/sys-i386/checksum.S
... ... @@ -38,7 +38,7 @@
38 38  
39 39 .text
40 40 .align 4
41   -.globl arch_csum_partial
  41 +.globl csum_partial
42 42  
43 43 #ifndef CONFIG_X86_USE_PPRO_CHECKSUM
44 44  
... ... @@ -49,7 +49,7 @@
49 49 * Fortunately, it is easy to convert 2-byte alignment to 4-byte
50 50 * alignment for the unrolled loop.
51 51 */
52   -arch_csum_partial:
  52 +csum_partial:
53 53 pushl %esi
54 54 pushl %ebx
55 55 movl 20(%esp),%eax # Function arg: unsigned int sum
... ... @@ -119,7 +119,7 @@
119 119  
120 120 /* Version for PentiumII/PPro */
121 121  
122   -arch_csum_partial:
  122 +csum_partial:
123 123 pushl %esi
124 124 pushl %ebx
125 125 movl 20(%esp),%eax # Function arg: unsigned int sum
arch/um/sys-i386/ksyms.c
... ... @@ -13,6 +13,5 @@
13 13 EXPORT_SYMBOL(__up_wakeup);
14 14  
15 15 /* Networking helper routines. */
16   -EXPORT_SYMBOL(csum_partial_copy_from);
17   -EXPORT_SYMBOL(csum_partial_copy_to);
  16 +EXPORT_SYMBOL(csum_partial);