2 * Copyright 2002, 2003 Andi Kleen, SuSE Labs.
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file COPYING in the main directory of this archive
6 * for more details. No warranty for anything given at all.
8 #include <linux/linkage.h>
13 * Checksum copy with exception handling.
14 * On exceptions src_err_ptr or dst_err_ptr is set to -EFAULT and the
15 * destination is zeroed.
23 * eax 64bit sum. undefined in case of exception.
25 * Wrappers need to take care of valid exception sum and zeroing.
26 * They also should align source or destination to 8 bytes.
31 _ASM_EXTABLE_UA(10b, .Lfault)
36 _ASM_EXTABLE_UA(20b, .Lfault)
39 SYM_FUNC_START(csum_partial_copy_generic)
59 jz .Lhandle_tail /* < 64 */
63 /* main loop. clear in 64 byte blocks */
64 /* r9: zero, r8: temp2, rbx: temp1, rax: sum, rcx: saved length */
65 /* r11: temp3, rdx: temp4, r12 loopcnt */
66 /* r10: temp5, r15: temp6, r14 temp7, r13 temp8 */
89 * No _ASM_EXTABLE_UA; this is used for intentional prefetch on a
90 * potentially unmapped kernel address.
131 /* do last up to 56 bytes */
133 /* ecx: count, rcx.63: the end result needs to be rol8 */
147 leaq 8(%rsi), %rsi /* preserve carry */
150 adcq %r9, %rax /* add in carry */
153 /* reduce checksum to 32bits */
159 /* do last up to 6 bytes */
163 .L1: /* .Lshort rejoins the common path here */
180 adcl %r9d, %eax /* add in carry */
182 /* handle last odd byte */
192 adcl %r9d, %eax /* carry */
241 /* decrement, set MSB */
242 leaq -1(%rcx, %rcx), %rcx
252 /* Exception: just return 0 */
256 SYM_FUNC_END(csum_partial_copy_generic)