Re: [PATCH v2] x86/lib: Use REP MOVSB for large memcpy() on ERMS CPUs without FSRM
From: H. Peter Anvin
Date: Tue Nov 10 2026 - 19:28:21 EST
On November 10, 2026 1:00:55 PM PST, David Laight <david.laight.linux@xxxxxxxxx> wrote:
>On Tue, 10 Nov 2026 12:17:51 -0800
>"H. Peter Anvin" <hpa@xxxxxxxxx> wrote:
>
>> On November 10, 2026 9:53:07 AM PST, Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>> >On Wed, 4 Nov 2026 at 14:28, Usama Arif <usama.arif@xxxxxxxxx> wrote:
>> >>
>> >> + ALTERNATIVE __stringify(cmpq $0x20, %rcx; jb .Lhandle_tail), \
>> >> + __stringify(rep movsb; RET), X86_FEATURE_FSRM
>> >
>> >Let's not do that.
>> >
>> >Putting magic things like RET in alternatives is just a bad bad idea.
>> >
>> > Linus
>>
>> Why is that, *given that it is in assembly*?
>>
>> For C (or Rust, or C++, ...) it is obviously bad chicken.
>
>Because RET is a horrid sequence subject to a lot of patching
>to avoid multiple speculative execution issues.
>If is were just the 0xc3 opcode byte it wouldn't be an issue.
>
>David
Ugh. Right.