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(10b, .Lbad_source)
39 _ASM_EXTABLE(20b, .Lbad_dest)
42 .macro ignore L=.Lignore
48 ENTRY(csum_partial_copy_generic)
70 jz .Lhandle_tail /* < 64 */
74 /* main loop. clear in 64 byte blocks */
75 /* r9: zero, r8: temp2, rbx: temp1, rax: sum, rcx: saved length */
76 /* r11: temp3, rdx: temp4, r12 loopcnt */
77 /* r10: temp5, r15: temp6, r14 temp7, r13 temp8 */
139 /* do last up to 56 bytes */
155 leaq 8(%rsi), %rsi /* preserve carry */
158 adcq %r9, %rax /* add in carry */
161 /* reduce checksum to 32bits */
167 /* do last up to 6 bytes */
187 adcl %r9d, %eax /* add in carry */
189 /* handle last odd byte */
199 adcl %r9d, %eax /* carry */
210 /* Exception handlers. Very simple, zeroing is done in the wrappers */
215 movl $-EFAULT, (%rax)
222 movl $-EFAULT, (%rax)
224 ENDPROC(csum_partial_copy_generic)