Re: [tip: x86/core] x86/alternative: Patch a single alternative location only once

From: Jürgen Groß

Date: Tue Oct 14 2025 - 10:22:13 EST


On 14.10.25 16:12, Borislav Petkov wrote:
On Tue, Oct 14, 2025 at 04:08:47PM +0200, Jürgen Groß wrote:
And just for the record: NMI handling is using ALTERNATIVE_2, so you
can't just "disable interrupts" and be sure it will work.

Are you fixing anything you're actually hitting while patching alternatives or
are you talking hypothetically here?

I really ran into issues while writing my paravirt MSR series, as I had
an ALTERNATIVE3() invocation modifying the original instruction (the
indirect paravirt call) with an WRMSR and then trying to turn the no
longer existing indirect call into a direct one.

So I didn't have the intermediate issue in interrupt handling, but the
issue with rules how to place indirect call replacements in ALTERNATIVEn()
invocations.

The interrupt handling still might be a thing, while NMI is for sure rather
unlikely.


Because I can't think of an easy way to trigger NMIs that early during boot,
when not even SMP is up.


NMIs are probably really a more theoretical issue. And even if NMIs are
affected, they will still be affected in case they happen just when half of
the new instruction bytes have been written.


Juergen

Attachment: OpenPGP_0xB0DE9DD628BF132F.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature