Re: [PATCH] x86/lib: Use REP MOVSB for large memcpy() on ERMS CPUs without FSRM

From: Linus Torvalds

Date: Wed Oct 21 2026 - 14:18:56 EST


On Tue, 20 Oct 2026 at 23:55, Kiryl Shutsemau <kas@xxxxxxxxxx> wrote:
>
> Moving MOVQ inside ALTERNATIVE_2 is ugly...

Yeah, maybe it would make sense to make that function be

movq %rdi, %rax
movq %rdx, %rcx
ALTERNATIVE "jmp memcpy_orig", "rep movsb", X86_FEATURE_FSRM
RET

instead? No nop instructions at all, and both alternatives are two bytes.

Then do any ERMS logic at the top of memcpy_orig, which now has the
registers ready for string instructions anyway.

Hmm?

Linus