RE: [RFC PATCH 31/56] x86/alternative: Prepend nops with retpolines

Kaplan, David
2025-10-16T14:16:10Z

[AMD Official Use Only - AMD Internal Distribution Only]

> -----Original Message-----
> From: Peter Zijlstra <peterz@infradead.org>
> Sent: Thursday, October 16, 2025 9:08 AM
> To: Kaplan, David <David.Kaplan@amd.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>; Borislav Petkov <bp@alien8.de>; Josh
> Poimboeuf <jpoimboe@kernel.org>; Pawan Gupta
> <pawan.kumar.gupta@linux.intel.com>; Ingo Molnar <mingo@redhat.com>; Dave
> Hansen <dave.hansen@linux.intel.com>; x86@kernel.org; H . Peter Anvin
> <hpa@zytor.com>; Alexander Graf <graf@amazon.com>; Boris Ostrovsky
> <boris.ostrovsky@oracle.com>; linux-kernel@vger.kernel.org
> Subject: Re: [RFC PATCH 31/56] x86/alternative: Prepend nops with retpolines
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> On Thu, Oct 16, 2025 at 01:27:53PM +0000, Kaplan, David wrote:
>
> > > Ah, I found it, you freeze everything, which puts it at safe points.
> >
> > Yes. In fact, I think you were the one who pointed me in that direction :)
>
> Heh, yeah, I remembered talking to you about this, but had forgotten all
> details. I quickly checked the cover letter, but found insufficient
> detail there, so I went and asked. Then later memory started coming back
> and I went looking for it in later patches.
>
> > Despite the freezer though, this patch is necessary in particular
> > because stop_machine_nmi() uses an indirect branch to run the handler.
> > Which means that while patching is going on, all cores are inside a
> > function which is going to return to after the indirect call site.
> > And so that needs to be the end of the 5 (or 6) byte sequence.
>
> Yeah, makes sense. But I like I wrote, I think prefix stuffing might be
> a better option.

Ok, and that's because we need at most 3 prefixes as Intel uarch's don't have significant penalties at 3 prefixes, only at 4+?

I'll need to check on this on the AMD side too.

--David Kaplan