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>
9 #include <asm/dwarf2.h>
10 #include <asm/errno.h>
14 * Checksum copy with exception handling.
15 * On exceptions src_err_ptr or dst_err_ptr is set to -EFAULT and the
16 * destination is zeroed.
23 * r8 src_err_ptr (int)
24 * r9 dst_err_ptr (int)
27 * eax 64bit sum. undefined in case of exception.
29 * Wrappers need to take care of valid exception sum and zeroing.
30 * They also should align source or destination to 8 bytes.
35 _ASM_EXTABLE(10b, .Lbad_source)
40 _ASM_EXTABLE(20b, .Lbad_dest)
43 .macro ignore L=.Lignore
49 ENTRY(csum_partial_copy_generic)
56 CFI_ADJUST_CFA_OFFSET 7*8
58 CFI_REL_OFFSET rbx, 2*8
60 CFI_REL_OFFSET r12, 3*8
62 CFI_REL_OFFSET r14, 4*8
64 CFI_REL_OFFSET r13, 5*8
66 CFI_REL_OFFSET rbp, 6*8
78 jz .Lhandle_tail /* < 64 */
82 /* main loop. clear in 64 byte blocks */
83 /* r9: zero, r8: temp2, rbx: temp1, rax: sum, rcx: saved length */
84 /* r11: temp3, rdx: temp4, r12 loopcnt */
85 /* r10: temp5, rbp: temp6, r14 temp7, r13 temp8 */
107 prefetcht0 5*64(%rdi)
147 /* do last up to 56 bytes */
163 leaq 8(%rsi), %rsi /* preserve carry */
166 adcq %r9, %rax /* add in carry */
169 /* reduce checksum to 32bits */
175 /* do last up to 6 bytes */
195 adcl %r9d, %eax /* add in carry */
197 /* handle last odd byte */
207 adcl %r9d, %eax /* carry */
222 CFI_ADJUST_CFA_OFFSET -7*8
226 /* Exception handlers. Very simple, zeroing is done in the wrappers */
231 movl $-EFAULT, (%rax)
238 movl $-EFAULT, (%rax)
241 ENDPROC(csum_partial_copy_generic)