|
|
|
|
|
by 1vuio0pswjnm7
1061 days ago
|
|
"OpenBSD does not use the AVX instructions to the same extent that Linux and Microsoft do, so this is not as important. On Linux, glibc has AVX-based optimizations for simple functions (string and memory copies) which will store secrets into the register file which can be extracted trivially, so the impact on glibc-based systems is HUGE." Perhaps I missed something, but it appears musl does not use AVX instructions much if at all. |
|
Right, or at least, not explicitly (a sufficiently smart compiler might be able to auto-vectorize it). The author is (reasonably) suggesting that most Linux systems use glibc, rather than musl.
Here's musl:
strlen: https://git.musl-libc.org/cgit/musl/tree/src/string/strlen.c (64-bit words at a time)
memcpy (generic): https://git.musl-libc.org/cgit/musl/tree/src/string/memcpy.c (32-bit copies, unrolled to 4 at a time for a suitably long copy)
(Throwing the generic memcpy into godbolt -O3 shows Clang does choose to implement this in part with XMM and YMM registers: https://godbolt.org/z/dh6hqG77j as does GCC: https://godbolt.org/z/aKraqPaPs )
memcpy (x86_64 asm): https://git.musl-libc.org/cgit/musl/tree/src/string/x86_64/m... (rep movsq -- 64-bit words at a time, implemented by the CPU microcode)