-
-
Save heatd/166eaf0f52d5e6b2e364b75bd7f6c0d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/kernel/lib/libk/arch/x86_64/memcpy_impl.S b/kernel/lib/libk/arch/x86_64/memcpy_impl.S | |
index a2366c51..d5bb54ce 100644 | |
--- a/kernel/lib/libk/arch/x86_64/memcpy_impl.S | |
+++ b/kernel/lib/libk/arch/x86_64/memcpy_impl.S | |
@@ -129,6 +129,23 @@ L(1_byte): | |
ALIGN_TEXT | |
L(erms): | |
+ /* Align the dest to 32 bytes (optimal alignment) */ | |
+ /* Hopefully source gets aligned to 32 in the process */ | |
+ movq (%rsi), %rcx | |
+ movq 8(%rsi), %r8 | |
+ movq 16(%rsi), %r9 | |
+ movq 24(%rsi), %r10 | |
+ movq %rcx, (%rdi) | |
+ movq %r8, 8(%rdi) | |
+ movq %r9, 16(%rdi) | |
+ movq %r10, 24(%rdi) | |
+ lea 32(%rdi), %rcx | |
+ and $-32, %rcx | |
+ mov %rcx, %r8 | |
+ sub %rdi, %r8 | |
+ mov %rcx, %rdi | |
+ add %r8, %rsi | |
+ sub %r8, %rdx | |
mov %rdx, %rcx | |
rep movsb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment