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.
22 * r8 src_err_ptr (int)
23 * r9 dst_err_ptr (int)
26 * eax 64bit sum. undefined in case of exception.
28 * Wrappers need to take care of valid exception sum and zeroing.
29 * They also should align source or destination to 8 bytes.
34 _ASM_EXTABLE_UA(10b, .Lbad_source)
39 _ASM_EXTABLE_UA(20b, .Lbad_dest)
43 * No _ASM_EXTABLE_UA; this is used for intentional prefetch on a
44 * potentially unmapped kernel address.
46 .macro ignore L=.Lignore
52 SYM_FUNC_START(csum_partial_copy_generic)
74 jz .Lhandle_tail /* < 64 */
78 /* main loop. clear in 64 byte blocks */
79 /* r9: zero, r8: temp2, rbx: temp1, rax: sum, rcx: saved length */
80 /* r11: temp3, rdx: temp4, r12 loopcnt */
81 /* r10: temp5, r15: temp6, r14 temp7, r13 temp8 */
103 prefetcht0 5*64(%rdi)
143 /* do last up to 56 bytes */
159 leaq 8(%rsi), %rsi /* preserve carry */
162 adcq %r9, %rax /* add in carry */
165 /* reduce checksum to 32bits */
171 /* do last up to 6 bytes */
191 adcl %r9d, %eax /* add in carry */
193 /* handle last odd byte */
203 adcl %r9d, %eax /* carry */
214 /* Exception handlers. Very simple, zeroing is done in the wrappers */
219 movl $-EFAULT, (%rax)
226 movl $-EFAULT, (%rax)
228 SYM_FUNC_END(csum_partial_copy_generic)