Re: [RFC PATCH 34/56] x86/alternative: Save old bytes for alternatives

Juergen Gross
2025-10-15T10:38:31Z

[-- Attachment #1.1.1: Type: text/plain, Size: 658 bytes --]

On 13.10.25 16:34, David Kaplan wrote:
> Save the existing instruction bytes at each alternative site when patching.
> This is only done the first time, and these will be used later to help
> restore the code back to its original form.
>
> Signed-off-by: David Kaplan <david.kaplan@amd.com>

Instead of saving the original instructions at runtime, why don't you
expand struct alt_instr to have an additional offset to a saved copy
of the original instruction, located in .altinstr_replacement?

The new field should be guarded with #ifdef CONFIG_DYNAMIC_MITIGATIONS,
of course, like the added handling in the ALTERNATIVE() macros.

Juergen

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3743 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]