// SPDX-License-Identifier: GPL-2.0-only1/*2* Copyright 2002, 2003 Andi Kleen, SuSE Labs.3*4* Wrappers of assembly checksum functions for x86-64.5*/6#include <asm/checksum.h>7#include <linux/export.h>8#include <linux/uaccess.h>9#include <asm/smap.h>1011/**12* csum_and_copy_from_user - Copy and checksum from user space.13* @src: source address (user space)14* @dst: destination address15* @len: number of bytes to be copied.16*17* Returns an 32bit unfolded checksum of the buffer.18* src and dst are best aligned to 64bits.19*/20__wsum21csum_and_copy_from_user(const void __user *src, void *dst, int len)22{23__wsum sum;2425might_sleep();26if (!user_access_begin(src, len))27return 0;28sum = csum_partial_copy_generic((__force const void *)src, dst, len);29user_access_end();30return sum;31}3233/**34* csum_and_copy_to_user - Copy and checksum to user space.35* @src: source address36* @dst: destination address (user space)37* @len: number of bytes to be copied.38*39* Returns an 32bit unfolded checksum of the buffer.40* src and dst are best aligned to 64bits.41*/42__wsum43csum_and_copy_to_user(const void *src, void __user *dst, int len)44{45__wsum sum;4647might_sleep();48if (!user_access_begin(dst, len))49return 0;50sum = csum_partial_copy_generic(src, (void __force *)dst, len);51user_access_end();52return sum;53}5455/**56* csum_partial_copy_nocheck - Copy and checksum.57* @src: source address58* @dst: destination address59* @len: number of bytes to be copied.60*61* Returns an 32bit unfolded checksum of the buffer.62*/63__wsum64csum_partial_copy_nocheck(const void *src, void *dst, int len)65{66return csum_partial_copy_generic(src, dst, len);67}68EXPORT_SYMBOL(csum_partial_copy_nocheck);69707172