Re: [PATCHv9 02/16] x86/alternatives: Disable LASS when patching kernel alternatives
From: H. Peter Anvin
Date: Mon Jul 28 2025 - 15:30:20 EST
On July 28, 2025 12:11:37 PM PDT, David Laight <david.laight.linux@xxxxxxxxx> wrote:
>On Mon, 7 Jul 2025 11:03:02 +0300
>"Kirill A. Shutemov" <kirill.shutemov@xxxxxxxxxxxxxxx> wrote:
>
>> From: Sohil Mehta <sohil.mehta@xxxxxxxxx>
>>
>> For patching, the kernel initializes a temporary mm area in the lower
>> half of the address range. See commit 4fc19708b165 ("x86/alternatives:
>> Initialize temporary mm for patching").
>>
>> Disable LASS enforcement during patching to avoid triggering a #GP
>> fault.
>>
>> The objtool warns due to a call to a non-allowed function that exists
>> outside of the stac/clac guard, or references to any function with a
>> dynamic function pointer inside the guard. See the Objtool warnings
>> section #9 in the document tools/objtool/Documentation/objtool.txt.
>>
>> Considering that patching is usually small, replace the memcpy() and
>> memset() functions in the text poking functions with their open coded
>> versions.
>...
>
>Or just write a byte copy loop in C with (eg) barrier() inside it
>to stop gcc converting it to memcpy().
>
> David
Great. It's rep movsb without any of the performance.