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

From: Juergen Gross

Date: Wed Oct 15 2025 - 06:38:31 EST


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@xxxxxxx>

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: OpenPGP_0xB0DE9DD628BF132F.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature