18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * csum_partial_copy - do IP checksumming and copy
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * (C) Copyright 1996 Linus Torvalds
68c2ecf20Sopenharmony_ci * accelerated versions (and 21264 assembly versions ) contributed by
78c2ecf20Sopenharmony_ci *	Rick Gorton	<rick.gorton@alpha-processor.com>
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci * Don't look at this too closely - you'll go mad. The things
108c2ecf20Sopenharmony_ci * we do for performance..
118c2ecf20Sopenharmony_ci */
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <linux/types.h>
148c2ecf20Sopenharmony_ci#include <linux/string.h>
158c2ecf20Sopenharmony_ci#include <linux/uaccess.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#define ldq_u(x,y) \
198c2ecf20Sopenharmony_ci__asm__ __volatile__("ldq_u %0,%1":"=r" (x):"m" (*(const unsigned long *)(y)))
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#define stq_u(x,y) \
228c2ecf20Sopenharmony_ci__asm__ __volatile__("stq_u %1,%0":"=m" (*(unsigned long *)(y)):"r" (x))
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#define extql(x,y,z) \
258c2ecf20Sopenharmony_ci__asm__ __volatile__("extql %1,%2,%0":"=r" (z):"r" (x),"r" (y))
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#define extqh(x,y,z) \
288c2ecf20Sopenharmony_ci__asm__ __volatile__("extqh %1,%2,%0":"=r" (z):"r" (x),"r" (y))
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#define mskql(x,y,z) \
318c2ecf20Sopenharmony_ci__asm__ __volatile__("mskql %1,%2,%0":"=r" (z):"r" (x),"r" (y))
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#define mskqh(x,y,z) \
348c2ecf20Sopenharmony_ci__asm__ __volatile__("mskqh %1,%2,%0":"=r" (z):"r" (x),"r" (y))
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#define insql(x,y,z) \
378c2ecf20Sopenharmony_ci__asm__ __volatile__("insql %1,%2,%0":"=r" (z):"r" (x),"r" (y))
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#define insqh(x,y,z) \
408c2ecf20Sopenharmony_ci__asm__ __volatile__("insqh %1,%2,%0":"=r" (z):"r" (x),"r" (y))
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci#define __get_word(insn,x,ptr)				\
438c2ecf20Sopenharmony_ci({							\
448c2ecf20Sopenharmony_ci	long __guu_err;					\
458c2ecf20Sopenharmony_ci	__asm__ __volatile__(				\
468c2ecf20Sopenharmony_ci	"1:	"#insn" %0,%2\n"			\
478c2ecf20Sopenharmony_ci	"2:\n"						\
488c2ecf20Sopenharmony_ci	EXC(1b,2b,%0,%1)				\
498c2ecf20Sopenharmony_ci		: "=r"(x), "=r"(__guu_err)		\
508c2ecf20Sopenharmony_ci		: "m"(__m(ptr)), "1"(0));		\
518c2ecf20Sopenharmony_ci	__guu_err;					\
528c2ecf20Sopenharmony_ci})
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_cistatic inline unsigned short from64to16(unsigned long x)
558c2ecf20Sopenharmony_ci{
568c2ecf20Sopenharmony_ci	/* Using extract instructions is a bit more efficient
578c2ecf20Sopenharmony_ci	   than the original shift/bitmask version.  */
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci	union {
608c2ecf20Sopenharmony_ci		unsigned long	ul;
618c2ecf20Sopenharmony_ci		unsigned int	ui[2];
628c2ecf20Sopenharmony_ci		unsigned short	us[4];
638c2ecf20Sopenharmony_ci	} in_v, tmp_v, out_v;
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci	in_v.ul = x;
668c2ecf20Sopenharmony_ci	tmp_v.ul = (unsigned long) in_v.ui[0] + (unsigned long) in_v.ui[1];
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci	/* Since the bits of tmp_v.sh[3] are going to always be zero,
698c2ecf20Sopenharmony_ci	   we don't have to bother to add that in.  */
708c2ecf20Sopenharmony_ci	out_v.ul = (unsigned long) tmp_v.us[0] + (unsigned long) tmp_v.us[1]
718c2ecf20Sopenharmony_ci			+ (unsigned long) tmp_v.us[2];
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci	/* Similarly, out_v.us[2] is always zero for the final add.  */
748c2ecf20Sopenharmony_ci	return out_v.us[0] + out_v.us[1];
758c2ecf20Sopenharmony_ci}
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci/*
808c2ecf20Sopenharmony_ci * Ok. This isn't fun, but this is the EASY case.
818c2ecf20Sopenharmony_ci */
828c2ecf20Sopenharmony_cistatic inline unsigned long
838c2ecf20Sopenharmony_cicsum_partial_cfu_aligned(const unsigned long __user *src, unsigned long *dst,
848c2ecf20Sopenharmony_ci			 long len)
858c2ecf20Sopenharmony_ci{
868c2ecf20Sopenharmony_ci	unsigned long checksum = ~0U;
878c2ecf20Sopenharmony_ci	unsigned long carry = 0;
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci	while (len >= 0) {
908c2ecf20Sopenharmony_ci		unsigned long word;
918c2ecf20Sopenharmony_ci		if (__get_word(ldq, word, src))
928c2ecf20Sopenharmony_ci			return 0;
938c2ecf20Sopenharmony_ci		checksum += carry;
948c2ecf20Sopenharmony_ci		src++;
958c2ecf20Sopenharmony_ci		checksum += word;
968c2ecf20Sopenharmony_ci		len -= 8;
978c2ecf20Sopenharmony_ci		carry = checksum < word;
988c2ecf20Sopenharmony_ci		*dst = word;
998c2ecf20Sopenharmony_ci		dst++;
1008c2ecf20Sopenharmony_ci	}
1018c2ecf20Sopenharmony_ci	len += 8;
1028c2ecf20Sopenharmony_ci	checksum += carry;
1038c2ecf20Sopenharmony_ci	if (len) {
1048c2ecf20Sopenharmony_ci		unsigned long word, tmp;
1058c2ecf20Sopenharmony_ci		if (__get_word(ldq, word, src))
1068c2ecf20Sopenharmony_ci			return 0;
1078c2ecf20Sopenharmony_ci		tmp = *dst;
1088c2ecf20Sopenharmony_ci		mskql(word, len, word);
1098c2ecf20Sopenharmony_ci		checksum += word;
1108c2ecf20Sopenharmony_ci		mskqh(tmp, len, tmp);
1118c2ecf20Sopenharmony_ci		carry = checksum < word;
1128c2ecf20Sopenharmony_ci		*dst = word | tmp;
1138c2ecf20Sopenharmony_ci		checksum += carry;
1148c2ecf20Sopenharmony_ci	}
1158c2ecf20Sopenharmony_ci	return checksum;
1168c2ecf20Sopenharmony_ci}
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci/*
1198c2ecf20Sopenharmony_ci * This is even less fun, but this is still reasonably
1208c2ecf20Sopenharmony_ci * easy.
1218c2ecf20Sopenharmony_ci */
1228c2ecf20Sopenharmony_cistatic inline unsigned long
1238c2ecf20Sopenharmony_cicsum_partial_cfu_dest_aligned(const unsigned long __user *src,
1248c2ecf20Sopenharmony_ci			      unsigned long *dst,
1258c2ecf20Sopenharmony_ci			      unsigned long soff,
1268c2ecf20Sopenharmony_ci			      long len)
1278c2ecf20Sopenharmony_ci{
1288c2ecf20Sopenharmony_ci	unsigned long first;
1298c2ecf20Sopenharmony_ci	unsigned long word, carry;
1308c2ecf20Sopenharmony_ci	unsigned long lastsrc = 7+len+(unsigned long)src;
1318c2ecf20Sopenharmony_ci	unsigned long checksum = ~0U;
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci	if (__get_word(ldq_u, first,src))
1348c2ecf20Sopenharmony_ci		return 0;
1358c2ecf20Sopenharmony_ci	carry = 0;
1368c2ecf20Sopenharmony_ci	while (len >= 0) {
1378c2ecf20Sopenharmony_ci		unsigned long second;
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci		if (__get_word(ldq_u, second, src+1))
1408c2ecf20Sopenharmony_ci			return 0;
1418c2ecf20Sopenharmony_ci		extql(first, soff, word);
1428c2ecf20Sopenharmony_ci		len -= 8;
1438c2ecf20Sopenharmony_ci		src++;
1448c2ecf20Sopenharmony_ci		extqh(second, soff, first);
1458c2ecf20Sopenharmony_ci		checksum += carry;
1468c2ecf20Sopenharmony_ci		word |= first;
1478c2ecf20Sopenharmony_ci		first = second;
1488c2ecf20Sopenharmony_ci		checksum += word;
1498c2ecf20Sopenharmony_ci		*dst = word;
1508c2ecf20Sopenharmony_ci		dst++;
1518c2ecf20Sopenharmony_ci		carry = checksum < word;
1528c2ecf20Sopenharmony_ci	}
1538c2ecf20Sopenharmony_ci	len += 8;
1548c2ecf20Sopenharmony_ci	checksum += carry;
1558c2ecf20Sopenharmony_ci	if (len) {
1568c2ecf20Sopenharmony_ci		unsigned long tmp;
1578c2ecf20Sopenharmony_ci		unsigned long second;
1588c2ecf20Sopenharmony_ci		if (__get_word(ldq_u, second, lastsrc))
1598c2ecf20Sopenharmony_ci			return 0;
1608c2ecf20Sopenharmony_ci		tmp = *dst;
1618c2ecf20Sopenharmony_ci		extql(first, soff, word);
1628c2ecf20Sopenharmony_ci		extqh(second, soff, first);
1638c2ecf20Sopenharmony_ci		word |= first;
1648c2ecf20Sopenharmony_ci		mskql(word, len, word);
1658c2ecf20Sopenharmony_ci		checksum += word;
1668c2ecf20Sopenharmony_ci		mskqh(tmp, len, tmp);
1678c2ecf20Sopenharmony_ci		carry = checksum < word;
1688c2ecf20Sopenharmony_ci		*dst = word | tmp;
1698c2ecf20Sopenharmony_ci		checksum += carry;
1708c2ecf20Sopenharmony_ci	}
1718c2ecf20Sopenharmony_ci	return checksum;
1728c2ecf20Sopenharmony_ci}
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci/*
1758c2ecf20Sopenharmony_ci * This is slightly less fun than the above..
1768c2ecf20Sopenharmony_ci */
1778c2ecf20Sopenharmony_cistatic inline unsigned long
1788c2ecf20Sopenharmony_cicsum_partial_cfu_src_aligned(const unsigned long __user *src,
1798c2ecf20Sopenharmony_ci			     unsigned long *dst,
1808c2ecf20Sopenharmony_ci			     unsigned long doff,
1818c2ecf20Sopenharmony_ci			     long len,
1828c2ecf20Sopenharmony_ci			     unsigned long partial_dest)
1838c2ecf20Sopenharmony_ci{
1848c2ecf20Sopenharmony_ci	unsigned long carry = 0;
1858c2ecf20Sopenharmony_ci	unsigned long word;
1868c2ecf20Sopenharmony_ci	unsigned long second_dest;
1878c2ecf20Sopenharmony_ci	unsigned long checksum = ~0U;
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_ci	mskql(partial_dest, doff, partial_dest);
1908c2ecf20Sopenharmony_ci	while (len >= 0) {
1918c2ecf20Sopenharmony_ci		if (__get_word(ldq, word, src))
1928c2ecf20Sopenharmony_ci			return 0;
1938c2ecf20Sopenharmony_ci		len -= 8;
1948c2ecf20Sopenharmony_ci		insql(word, doff, second_dest);
1958c2ecf20Sopenharmony_ci		checksum += carry;
1968c2ecf20Sopenharmony_ci		stq_u(partial_dest | second_dest, dst);
1978c2ecf20Sopenharmony_ci		src++;
1988c2ecf20Sopenharmony_ci		checksum += word;
1998c2ecf20Sopenharmony_ci		insqh(word, doff, partial_dest);
2008c2ecf20Sopenharmony_ci		carry = checksum < word;
2018c2ecf20Sopenharmony_ci		dst++;
2028c2ecf20Sopenharmony_ci	}
2038c2ecf20Sopenharmony_ci	len += 8;
2048c2ecf20Sopenharmony_ci	if (len) {
2058c2ecf20Sopenharmony_ci		checksum += carry;
2068c2ecf20Sopenharmony_ci		if (__get_word(ldq, word, src))
2078c2ecf20Sopenharmony_ci			return 0;
2088c2ecf20Sopenharmony_ci		mskql(word, len, word);
2098c2ecf20Sopenharmony_ci		len -= 8;
2108c2ecf20Sopenharmony_ci		checksum += word;
2118c2ecf20Sopenharmony_ci		insql(word, doff, second_dest);
2128c2ecf20Sopenharmony_ci		len += doff;
2138c2ecf20Sopenharmony_ci		carry = checksum < word;
2148c2ecf20Sopenharmony_ci		partial_dest |= second_dest;
2158c2ecf20Sopenharmony_ci		if (len >= 0) {
2168c2ecf20Sopenharmony_ci			stq_u(partial_dest, dst);
2178c2ecf20Sopenharmony_ci			if (!len) goto out;
2188c2ecf20Sopenharmony_ci			dst++;
2198c2ecf20Sopenharmony_ci			insqh(word, doff, partial_dest);
2208c2ecf20Sopenharmony_ci		}
2218c2ecf20Sopenharmony_ci		doff = len;
2228c2ecf20Sopenharmony_ci	}
2238c2ecf20Sopenharmony_ci	ldq_u(second_dest, dst);
2248c2ecf20Sopenharmony_ci	mskqh(second_dest, doff, second_dest);
2258c2ecf20Sopenharmony_ci	stq_u(partial_dest | second_dest, dst);
2268c2ecf20Sopenharmony_ciout:
2278c2ecf20Sopenharmony_ci	checksum += carry;
2288c2ecf20Sopenharmony_ci	return checksum;
2298c2ecf20Sopenharmony_ci}
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_ci/*
2328c2ecf20Sopenharmony_ci * This is so totally un-fun that it's frightening. Don't
2338c2ecf20Sopenharmony_ci * look at this too closely, you'll go blind.
2348c2ecf20Sopenharmony_ci */
2358c2ecf20Sopenharmony_cistatic inline unsigned long
2368c2ecf20Sopenharmony_cicsum_partial_cfu_unaligned(const unsigned long __user * src,
2378c2ecf20Sopenharmony_ci			   unsigned long * dst,
2388c2ecf20Sopenharmony_ci			   unsigned long soff, unsigned long doff,
2398c2ecf20Sopenharmony_ci			   long len, unsigned long partial_dest)
2408c2ecf20Sopenharmony_ci{
2418c2ecf20Sopenharmony_ci	unsigned long carry = 0;
2428c2ecf20Sopenharmony_ci	unsigned long first;
2438c2ecf20Sopenharmony_ci	unsigned long lastsrc;
2448c2ecf20Sopenharmony_ci	unsigned long checksum = ~0U;
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_ci	if (__get_word(ldq_u, first, src))
2478c2ecf20Sopenharmony_ci		return 0;
2488c2ecf20Sopenharmony_ci	lastsrc = 7+len+(unsigned long)src;
2498c2ecf20Sopenharmony_ci	mskql(partial_dest, doff, partial_dest);
2508c2ecf20Sopenharmony_ci	while (len >= 0) {
2518c2ecf20Sopenharmony_ci		unsigned long second, word;
2528c2ecf20Sopenharmony_ci		unsigned long second_dest;
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci		if (__get_word(ldq_u, second, src+1))
2558c2ecf20Sopenharmony_ci			return 0;
2568c2ecf20Sopenharmony_ci		extql(first, soff, word);
2578c2ecf20Sopenharmony_ci		checksum += carry;
2588c2ecf20Sopenharmony_ci		len -= 8;
2598c2ecf20Sopenharmony_ci		extqh(second, soff, first);
2608c2ecf20Sopenharmony_ci		src++;
2618c2ecf20Sopenharmony_ci		word |= first;
2628c2ecf20Sopenharmony_ci		first = second;
2638c2ecf20Sopenharmony_ci		insql(word, doff, second_dest);
2648c2ecf20Sopenharmony_ci		checksum += word;
2658c2ecf20Sopenharmony_ci		stq_u(partial_dest | second_dest, dst);
2668c2ecf20Sopenharmony_ci		carry = checksum < word;
2678c2ecf20Sopenharmony_ci		insqh(word, doff, partial_dest);
2688c2ecf20Sopenharmony_ci		dst++;
2698c2ecf20Sopenharmony_ci	}
2708c2ecf20Sopenharmony_ci	len += doff;
2718c2ecf20Sopenharmony_ci	checksum += carry;
2728c2ecf20Sopenharmony_ci	if (len >= 0) {
2738c2ecf20Sopenharmony_ci		unsigned long second, word;
2748c2ecf20Sopenharmony_ci		unsigned long second_dest;
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci		if (__get_word(ldq_u, second, lastsrc))
2778c2ecf20Sopenharmony_ci			return 0;
2788c2ecf20Sopenharmony_ci		extql(first, soff, word);
2798c2ecf20Sopenharmony_ci		extqh(second, soff, first);
2808c2ecf20Sopenharmony_ci		word |= first;
2818c2ecf20Sopenharmony_ci		first = second;
2828c2ecf20Sopenharmony_ci		mskql(word, len-doff, word);
2838c2ecf20Sopenharmony_ci		checksum += word;
2848c2ecf20Sopenharmony_ci		insql(word, doff, second_dest);
2858c2ecf20Sopenharmony_ci		carry = checksum < word;
2868c2ecf20Sopenharmony_ci		stq_u(partial_dest | second_dest, dst);
2878c2ecf20Sopenharmony_ci		if (len) {
2888c2ecf20Sopenharmony_ci			ldq_u(second_dest, dst+1);
2898c2ecf20Sopenharmony_ci			insqh(word, doff, partial_dest);
2908c2ecf20Sopenharmony_ci			mskqh(second_dest, len, second_dest);
2918c2ecf20Sopenharmony_ci			stq_u(partial_dest | second_dest, dst+1);
2928c2ecf20Sopenharmony_ci		}
2938c2ecf20Sopenharmony_ci		checksum += carry;
2948c2ecf20Sopenharmony_ci	} else {
2958c2ecf20Sopenharmony_ci		unsigned long second, word;
2968c2ecf20Sopenharmony_ci		unsigned long second_dest;
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_ci		if (__get_word(ldq_u, second, lastsrc))
2998c2ecf20Sopenharmony_ci			return 0;
3008c2ecf20Sopenharmony_ci		extql(first, soff, word);
3018c2ecf20Sopenharmony_ci		extqh(second, soff, first);
3028c2ecf20Sopenharmony_ci		word |= first;
3038c2ecf20Sopenharmony_ci		ldq_u(second_dest, dst);
3048c2ecf20Sopenharmony_ci		mskql(word, len-doff, word);
3058c2ecf20Sopenharmony_ci		checksum += word;
3068c2ecf20Sopenharmony_ci		mskqh(second_dest, len, second_dest);
3078c2ecf20Sopenharmony_ci		carry = checksum < word;
3088c2ecf20Sopenharmony_ci		insql(word, doff, word);
3098c2ecf20Sopenharmony_ci		stq_u(partial_dest | word | second_dest, dst);
3108c2ecf20Sopenharmony_ci		checksum += carry;
3118c2ecf20Sopenharmony_ci	}
3128c2ecf20Sopenharmony_ci	return checksum;
3138c2ecf20Sopenharmony_ci}
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_cistatic __wsum __csum_and_copy(const void __user *src, void *dst, int len)
3168c2ecf20Sopenharmony_ci{
3178c2ecf20Sopenharmony_ci	unsigned long soff = 7 & (unsigned long) src;
3188c2ecf20Sopenharmony_ci	unsigned long doff = 7 & (unsigned long) dst;
3198c2ecf20Sopenharmony_ci	unsigned long checksum;
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_ci	if (!doff) {
3228c2ecf20Sopenharmony_ci		if (!soff)
3238c2ecf20Sopenharmony_ci			checksum = csum_partial_cfu_aligned(
3248c2ecf20Sopenharmony_ci				(const unsigned long __user *) src,
3258c2ecf20Sopenharmony_ci				(unsigned long *) dst, len-8);
3268c2ecf20Sopenharmony_ci		else
3278c2ecf20Sopenharmony_ci			checksum = csum_partial_cfu_dest_aligned(
3288c2ecf20Sopenharmony_ci				(const unsigned long __user *) src,
3298c2ecf20Sopenharmony_ci				(unsigned long *) dst,
3308c2ecf20Sopenharmony_ci				soff, len-8);
3318c2ecf20Sopenharmony_ci	} else {
3328c2ecf20Sopenharmony_ci		unsigned long partial_dest;
3338c2ecf20Sopenharmony_ci		ldq_u(partial_dest, dst);
3348c2ecf20Sopenharmony_ci		if (!soff)
3358c2ecf20Sopenharmony_ci			checksum = csum_partial_cfu_src_aligned(
3368c2ecf20Sopenharmony_ci				(const unsigned long __user *) src,
3378c2ecf20Sopenharmony_ci				(unsigned long *) dst,
3388c2ecf20Sopenharmony_ci				doff, len-8, partial_dest);
3398c2ecf20Sopenharmony_ci		else
3408c2ecf20Sopenharmony_ci			checksum = csum_partial_cfu_unaligned(
3418c2ecf20Sopenharmony_ci				(const unsigned long __user *) src,
3428c2ecf20Sopenharmony_ci				(unsigned long *) dst,
3438c2ecf20Sopenharmony_ci				soff, doff, len-8, partial_dest);
3448c2ecf20Sopenharmony_ci	}
3458c2ecf20Sopenharmony_ci	return (__force __wsum)from64to16 (checksum);
3468c2ecf20Sopenharmony_ci}
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_ci__wsum
3498c2ecf20Sopenharmony_cicsum_and_copy_from_user(const void __user *src, void *dst, int len)
3508c2ecf20Sopenharmony_ci{
3518c2ecf20Sopenharmony_ci	if (!access_ok(src, len))
3528c2ecf20Sopenharmony_ci		return 0;
3538c2ecf20Sopenharmony_ci	return __csum_and_copy(src, dst, len);
3548c2ecf20Sopenharmony_ci}
3558c2ecf20Sopenharmony_ciEXPORT_SYMBOL(csum_and_copy_from_user);
3568c2ecf20Sopenharmony_ci
3578c2ecf20Sopenharmony_ci__wsum
3588c2ecf20Sopenharmony_cicsum_partial_copy_nocheck(const void *src, void *dst, int len)
3598c2ecf20Sopenharmony_ci{
3608c2ecf20Sopenharmony_ci	return __csum_and_copy((__force const void __user *)src,
3618c2ecf20Sopenharmony_ci						dst, len);
3628c2ecf20Sopenharmony_ci}
3638c2ecf20Sopenharmony_ciEXPORT_SYMBOL(csum_partial_copy_nocheck);
364