]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
unify generic instances of csum_partial_copy_nocheck()
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 23 Jul 2020 02:14:36 +0000 (22:14 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 20 Aug 2020 19:45:14 +0000 (15:45 -0400)
quite a few architectures have the same csum_partial_copy_nocheck() -
simply memcpy() the data and then return the csum of the copy.

hexagon, parisc, ia64, s390, um: explicitly spelled out that way.

arc, arm64, csky, h8300, m68k/nommu, microblaze, mips/GENERIC_CSUM, nds32,
nios2, openrisc, riscv, unicore32: end up picking the same thing spelled
out in lib/checksum.h (with varying amounts of perversions along the way).

everybody else (alpha, arm, c6x, m68k/mmu, mips/!GENERIC_CSUM, powerpc,
sh, sparc, x86, xtensa) have non-generic variants.  For all except c6x
the declaration is in their asm/checksum.h.  c6x uses the wrapper
from asm-generic/checksum.h that would normally lead to the lib/checksum.h
instance, but in case of c6x we end up using an asm function from arch/c6x
instead.

Screw that mess - have architectures with private instances define
_HAVE_ARCH_CSUM_AND_COPY in their asm/checksum.h and have the default
one right in net/checksum.h conditional on _HAVE_ARCH_CSUM_AND_COPY
*not* defined.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
22 files changed:
arch/alpha/include/asm/checksum.h
arch/arm/include/asm/checksum.h
arch/c6x/include/asm/checksum.h
arch/hexagon/include/asm/checksum.h
arch/hexagon/lib/checksum.c
arch/ia64/include/asm/checksum.h
arch/ia64/lib/csum_partial_copy.c
arch/m68k/include/asm/checksum.h
arch/mips/include/asm/checksum.h
arch/nios2/include/asm/checksum.h
arch/parisc/include/asm/checksum.h
arch/parisc/lib/checksum.c
arch/powerpc/include/asm/checksum.h
arch/s390/include/asm/checksum.h
arch/sh/include/asm/checksum_32.h
arch/sparc/include/asm/checksum.h
arch/x86/include/asm/checksum.h
arch/x86/um/asm/checksum.h
arch/xtensa/include/asm/checksum.h
include/asm-generic/checksum.h
include/net/checksum.h
lib/checksum.c

index 0eac81624d01c2ebdd45c282892689b676339431..7e8e4fa4362dc008359764cc59b12ac789397acb 100644 (file)
@@ -42,6 +42,7 @@ extern __wsum csum_partial(const void *buff, int len, __wsum sum);
  * better 64-bit) boundary
  */
 #define _HAVE_ARCH_COPY_AND_CSUM_FROM_USER
+#define _HAVE_ARCH_CSUM_AND_COPY
 __wsum csum_and_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *errp);
 
 __wsum csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
index ed6073fee338aa67fbdf1a6a153d595a842dade8..53f76950854027aba31099950b5672eac06267ee 100644 (file)
@@ -41,6 +41,7 @@ __wsum
 csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
 
 #define _HAVE_ARCH_COPY_AND_CSUM_FROM_USER
+#define _HAVE_ARCH_CSUM_AND_COPY
 static inline
 __wsum csum_and_copy_from_user (const void __user *src, void *dst,
                                      int len, __wsum sum, int *err_ptr)
index 36770b8308d9d60927d4623c9f809749bf4ea193..fa31bdc186b237cc981c30fca147289ff9f52d82 100644 (file)
@@ -26,6 +26,9 @@ csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len,
 }
 #define csum_tcpudp_nofold csum_tcpudp_nofold
 
+#define _HAVE_ARCH_CSUM_AND_COPY
+extern __wsum csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
+
 #include <asm-generic/checksum.h>
 
 #endif /* _ASM_C6X_CHECKSUM_H */
index a5c42f4614c166a08ebebed0ee4174751f07defb..4bc6ad96c4c5f676768834c1ba263162995ddc66 100644 (file)
@@ -9,17 +9,6 @@
 #define do_csum        do_csum
 unsigned int do_csum(const void *voidptr, int len);
 
-/*
- * the same as csum_partial, but copies from src while it
- * checksums
- *
- * here even more important to align src and dst on a 32-bit (or even
- * better 64-bit) boundary
- */
-#define csum_partial_copy_nocheck csum_partial_copy_nocheck
-__wsum csum_partial_copy_nocheck(const void *src, void *dst,
-                                       int len, __wsum sum);
-
 /*
  * computes the checksum of the TCP/UDP pseudo-header
  * returns a 16-bit checksum, already complemented
index c4a6b72d97defca7460af6b021ae91b7cb9c823a..ba50822a0800bd72296aa3375b57f1f4c25837f3 100644 (file)
@@ -176,14 +176,3 @@ unsigned int do_csum(const void *voidptr, int len)
 
        return 0xFFFF & sum0;
 }
-
-/*
- * copy from ds while checksumming, otherwise like csum_partial
- */
-__wsum
-csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
-{
-       memcpy(dst, src, len);
-       return csum_partial(dst, len, sum);
-}
-EXPORT_SYMBOL(csum_partial_copy_nocheck);
index 2a1c64629cdcd91201e215d687cc75733e8d313a..f3026213aa32b9ef6b5e0215a39d8933f349e3e9 100644 (file)
@@ -37,9 +37,6 @@ extern __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
  */
 extern __wsum csum_partial(const void *buff, int len, __wsum sum);
 
-extern __wsum csum_partial_copy_nocheck(const void *src, void *dst,
-                                              int len, __wsum sum);
-
 /*
  * This routine is used for miscellaneous IP-like checksums, mainly in
  * icmp.c
index 6e82e0be80409aa823607943e257323b8ed0d9e4..917e3138b277c4ad47d07ab60cb658c8393e5285 100644 (file)
@@ -96,18 +96,3 @@ unsigned long do_csum_c(const unsigned char * buff, int len, unsigned int psum)
 out:
        return result;
 }
-
-/*
- * XXX Fixme
- *
- * This is very ugly but temporary. THIS NEEDS SERIOUS ENHANCEMENTS.
- * But it's very tricky to get right even in C.
- */
-__wsum
-csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
-{
-       memcpy(dst, src, len);
-       return csum_partial(dst, len, sum);
-}
-
-EXPORT_SYMBOL(csum_partial_copy_nocheck);
index 3f2c15d6f18c03bb3f73d3de21489dc9240811cf..ab16881d84cbdec015cd0e1a13a4f127217c5fd0 100644 (file)
@@ -31,6 +31,7 @@ __wsum csum_partial(const void *buff, int len, __wsum sum);
  */
 
 #define _HAVE_ARCH_COPY_AND_CSUM_FROM_USER
+#define _HAVE_ARCH_CSUM_AND_COPY
 extern __wsum csum_and_copy_from_user(const void __user *src,
                                                void *dst,
                                                int len, __wsum sum,
index 181f7d14efb98366c9e301d8a2ca9e528c9886c1..abdf1086873dfe8562808c5ff26de183733f6882 100644 (file)
@@ -101,9 +101,9 @@ __wsum csum_and_copy_to_user(const void *src, void __user *dst, int len,
  * the same as csum_partial, but copies from user space (but on MIPS
  * we have just one address space, so this is identical to the above)
  */
+#define _HAVE_ARCH_CSUM_AND_COPY
 __wsum csum_partial_copy_nocheck(const void *src, void *dst,
                                       int len, __wsum sum);
-#define csum_partial_copy_nocheck csum_partial_copy_nocheck
 
 /*
  *     Fold a partial checksum without adding pseudo headers
index b4316c361729f0e6b1e3ed430d7a595f4d3570d1..69004e07a1ba37af8da02906d4f529ebfcf2f9ff 100644 (file)
 
 /* Take these from lib/checksum.c */
 extern __wsum csum_partial(const void *buff, int len, __wsum sum);
-__wsum csum_partial_copy_nocheck(const void *src, void *dst, int len,
-                               __wsum sum);
-#define csum_partial_copy_nocheck csum_partial_copy_nocheck
-
 extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl);
 extern __sum16 ip_compute_csum(const void *buff, int len);
 
index fe8c63b2d2c3c42a66ae6a4e590753c8f948dd3f..522cd574c06879b22008f03ecc02e08e9ab7e23b 100644 (file)
  */
 extern __wsum csum_partial(const void *, int, __wsum);
 
-/*
- * The same as csum_partial, but copies from src while it checksums.
- *
- * Here even more important to align src and dst on a 32-bit (or even
- * better 64-bit) boundary
- */
-extern __wsum csum_partial_copy_nocheck(const void *, void *, int, __wsum);
-
 /*
  *     Optimized for IP headers, which always checksum on 4 octet boundaries.
  *
index c6f161583549fcb8cbed707472bc763368ee5b22..4818f3db84a5c5be043afc2bd16c756a99eef8dd 100644 (file)
@@ -106,20 +106,3 @@ __wsum csum_partial(const void *buff, int len, __wsum sum)
 }
 
 EXPORT_SYMBOL(csum_partial);
-
-/*
- * copy while checksumming, otherwise like csum_partial
- */
-__wsum csum_partial_copy_nocheck(const void *src, void *dst,
-                                      int len, __wsum sum)
-{
-       /*
-        * It's 2:30 am and I don't feel like doing it real ...
-        * This is lots slower than the real thing (tm)
-        */
-       sum = csum_partial(src, len, sum);
-       memcpy(dst, src, len);
-
-       return sum;
-}
-EXPORT_SYMBOL(csum_partial_copy_nocheck);
index 9cce06194dccd625cf0445a49d37b526f903e469..d75fc5bf8f3732b78158e65ca8246266d6bc9edd 100644 (file)
@@ -29,6 +29,7 @@ extern __wsum csum_and_copy_from_user(const void __user *src, void *dst,
 extern __wsum csum_and_copy_to_user(const void *src, void __user *dst,
                                    int len, __wsum sum, int *err_ptr);
 
+#define _HAVE_ARCH_CSUM_AND_COPY
 #define csum_partial_copy_nocheck(src, dst, len, sum)   \
         csum_partial_copy_generic((src), (dst), (len), (sum), NULL, NULL)
 
index 6d01c96aeb5c4e0eb47e8edd4b950e37770ece08..6813bfa1eeb788e09bf3a94b7f9f76dccb030b6f 100644 (file)
@@ -39,13 +39,6 @@ csum_partial(const void *buff, int len, __wsum sum)
        return sum;
 }
 
-static inline __wsum
-csum_partial_copy_nocheck (const void *src, void *dst, int len, __wsum sum)
-{
-        memcpy(dst,src,len);
-       return csum_partial(dst, len, sum);
-}
-
 /*
  *      Fold a partial checksum without adding pseudo headers
  */
index 91571a42e44ed6aaa24d5c7670414fa02b2f45d1..87269642d78d1b30cdc2dc51853d7faffae03dce 100644 (file)
@@ -34,6 +34,7 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
                                            int len, __wsum sum,
                                            int *src_err_ptr, int *dst_err_ptr);
 
+#define _HAVE_ARCH_CSUM_AND_COPY
 /*
  *     Note: when you get a NULL pointer exception here this means someone
  *     passed in an incorrect kernel address to one of these functions.
index a6256cb6fc5cc451ce54ba4944416c7d034eacda..deb4fe5aeafd32028e2cdfbe50248b98a1a99c7c 100644 (file)
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #ifndef ___ASM_SPARC_CHECKSUM_H
 #define ___ASM_SPARC_CHECKSUM_H
+#define _HAVE_ARCH_CSUM_AND_COPY
 #define _HAVE_ARCH_COPY_AND_CSUM_FROM_USER
 #if defined(__sparc__) && defined(__arch64__)
 #include <asm/checksum_64.h>
index 0ada98d5d09f7a476fa44e1493d00db4af4161bc..bca625a60186c9ad77eebefc6ce10c650a02d5f4 100644 (file)
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #define  _HAVE_ARCH_COPY_AND_CSUM_FROM_USER 1
 #define HAVE_CSUM_COPY_USER
+#define _HAVE_ARCH_CSUM_AND_COPY
 #ifdef CONFIG_X86_32
 # include <asm/checksum_32.h>
 #else
index ff6bba2c8ab61d9b85608327c599bd29d3e0216f..b07824500363fa1ecc065c9a3926b60e55cc1096 100644 (file)
  */
 extern __wsum csum_partial(const void *buff, int len, __wsum sum);
 
-/*
- *     Note: when you get a NULL pointer exception here this means someone
- *     passed in an incorrect kernel address to one of these functions.
- *
- *     If you use these functions directly please don't forget the
- *     access_ok().
- */
-
-static __inline__
-__wsum csum_partial_copy_nocheck(const void *src, void *dst,
-                                      int len, __wsum sum)
-{
-       memcpy(dst, src, len);
-       return csum_partial(dst, len, sum);
-}
-
 /**
  * csum_fold - Fold and invert a 32bit checksum.
  * sum: 32bit unfolded sum
index 243a5fe79d3cdfccc0d535e92d54a40ffaf217c1..0c879099977f1ae5f2905189e5b5e5ecdba38e94 100644 (file)
@@ -41,6 +41,7 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
                                            int len, __wsum sum,
                                            int *src_err_ptr, int *dst_err_ptr);
 
+#define _HAVE_ARCH_CSUM_AND_COPY
 /*
  *     Note: when you get a NULL pointer exception here this means someone
  *     passed in an incorrect kernel address to one of these functions.
index cd8b75aa770d00e6d899d47c57c1a52360deeecb..43e18db89c1439fc3aed1ed6a29a003fa66b899d 100644 (file)
  */
 extern __wsum csum_partial(const void *buff, int len, __wsum sum);
 
-/*
- * the same as csum_partial, but copies from src while it
- * checksums
- *
- * here even more important to align src and dst on a 32-bit (or even
- * better 64-bit) boundary
- */
-#ifndef csum_partial_copy_nocheck
-__wsum csum_partial_copy_nocheck(const void *src, void *dst, int len,
-               __wsum sum);
-#endif
-
 #ifndef ip_fast_csum
 /*
  * This is a version of ip_compute_csum() optimized for IP headers,
index 46754ba9d7b708f02a7fa813db6b98ad0482226d..db9d02b5f88ace991a62dfddb3bfe68f09f0da59 100644 (file)
@@ -47,6 +47,15 @@ static __inline__ __wsum csum_and_copy_to_user
 }
 #endif
 
+#ifndef _HAVE_ARCH_CSUM_AND_COPY
+static inline __wsum
+csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
+{
+       memcpy(dst, src, len);
+       return csum_partial(dst, len, sum);
+}
+#endif
+
 #ifndef HAVE_ARCH_CSUM_ADD
 static inline __wsum csum_add(__wsum csum, __wsum addend)
 {
index c7861e84c5261affc9a5ee01c94ad2401f789793..6860d6b05a171707391eace7fd371f7f9aa2291a 100644 (file)
@@ -145,17 +145,6 @@ __sum16 ip_compute_csum(const void *buff, int len)
 }
 EXPORT_SYMBOL(ip_compute_csum);
 
-/*
- * copy from ds while checksumming, otherwise like csum_partial
- */
-__wsum
-csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
-{
-       memcpy(dst, src, len);
-       return csum_partial(dst, len, sum);
-}
-EXPORT_SYMBOL(csum_partial_copy_nocheck);
-
 #ifndef csum_tcpudp_nofold
 static inline u32 from64to32(u64 x)
 {