[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <3902CABB-184E-4E23-9458-9D62401F908F@zytor.com>
Date: Mon, 20 Oct 2025 19:13:14 -0700
From: "H. Peter Anvin" <hpa@...or.com>
To: "Kaplan, David" <David.Kaplan@....com>,
Peter Zijlstra <peterz@...radead.org>
CC: Thomas Gleixner <tglx@...utronix.de>, Borislav Petkov <bp@...en8.de>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>,
Ingo Molnar <mingo@...hat.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"x86@...nel.org" <x86@...nel.org>, Alexander Graf <graf@...zon.com>,
Boris Ostrovsky <boris.ostrovsky@...cle.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [RFC PATCH 40/56] x86/alternative: Use sync_core_nmi_safe()
On October 20, 2025 7:49:56 AM PDT, "Kaplan, David" <David.Kaplan@....com> wrote:
>[AMD Official Use Only - AMD Internal Distribution Only]
>
>> -----Original Message-----
>> From: Peter Zijlstra <peterz@...radead.org>
>> Sent: Thursday, October 16, 2025 9:48 AM
>> To: Kaplan, David <David.Kaplan@....com>
>> Cc: Thomas Gleixner <tglx@...utronix.de>; Borislav Petkov <bp@...en8.de>; Josh
>> Poimboeuf <jpoimboe@...nel.org>; Pawan Gupta
>> <pawan.kumar.gupta@...ux.intel.com>; Ingo Molnar <mingo@...hat.com>; Dave
>> Hansen <dave.hansen@...ux.intel.com>; x86@...nel.org; H . Peter Anvin
>> <hpa@...or.com>; Alexander Graf <graf@...zon.com>; Boris Ostrovsky
>> <boris.ostrovsky@...cle.com>; linux-kernel@...r.kernel.org
>> Subject: Re: [RFC PATCH 40/56] x86/alternative: Use sync_core_nmi_safe()
>>
>> Caution: This message originated from an External Source. Use proper caution
>> when opening attachments, clicking links, or responding.
>>
>>
>> On Thu, Oct 16, 2025 at 02:40:51PM +0000, Kaplan, David wrote:
>>
>> > > Can we please keep this in sync_core()? Something like:
>> > >
>> > > static __always_inline void sync_core(void)
>> > > {
>> > > if (static_cpu_has(X86_FEATURE_SERIALIZE)) {
>> > > serialize();
>> > > return;
>> > > }
>> > >
>> > > + if (repatch_in_progress) {
>> > > + sync_core_nmi_safe();
>> > > + return;
>> > > + }
>> > > +
>> > > iret_to_self();
>> > > }
>> > >
>> > > That way all the modern stuff that has SERIALIZE will still use that.
>> >
>> > Hmm, I can't quite do that because sync_core() is used in a number of
>> > other places too (unless we make repatch_in_progress a true global).
>>
>> We could just out-of-line the thing; nothing using this should care
>> about cycles -- all of this is quite expensive.
>>
>
>Coming back to this, are you thinking we should just create something like 'text_poke_sync_core()' inside alternative.c and that can use:
> 1. SERIALIZE (if available)
> 2. MOV-CR2 (if re-patching)
> 3. Else, IRET
>
>And maybe someday we put MFENCE into there too for AMD parts.
>
>Right now, of course this is the only logic that would care about an NMI-safe sync_core(). So maybe this makes sense vs creating a generic version that nobody else is using?
>
>--David Kaplan
>
This is something that can be done with a function call... not fast no matter how to slice it.
Powered by blists - more mailing lists