1 /* Copyright 2002 Andi Kleen */
3 #include <linux/linkage.h>
5 #include <asm/cpufeature.h>
6 #include <asm/dwarf2.h>
9 * memcpy - Copy a memory block.
17 * rax original destination
21 * memcpy_c() - fast string ops (REP MOVSQ) based variant.
23 * Calls to this get patched into the kernel image via the
24 * alternative instructions framework:
46 * Put the number of full 64-byte blocks into %ecx.
47 * Tail portion is handled at the end:
57 * We decrement the loop index here - and the zero-flag is
58 * checked at the end of the loop (instructions inbetween do
59 * not change the zero flag):
64 * Move in blocks of 4x16 bytes:
127 * Some CPUs run faster using the string copy instructions.
128 * It is also a lot simpler. Use this when possible:
131 .section .altinstr_replacement, "ax"
132 1: .byte 0xeb /* jmp <disp8> */
133 .byte (memcpy_c - memcpy) - (2f - 1b) /* offset */
137 .section .altinstructions, "a"
141 .byte X86_FEATURE_REP_GOOD
144 * Replace only beginning, memcpy is used to apply alternatives,
145 * so it is silly to overwrite itself with nops - reboot is the