On Sat, Dec 3, 2016 at 7:02 AM, Borislav Petkov <b...@alien8.de> wrote: > On Fri, Dec 02, 2016 at 08:28:44PM +0100, Borislav Petkov wrote: >> Ah, it is called only from apply_alternatives() but sure, it is safer >> this way. Lemme do that and run it through the boxes to see whether >> anything catches fire. > > Looks good, ran it on a bunch of machines, two of them huge AMD and > Intel, 8-socket monsters. > > Here is a version with a commit message: > > --- > From: Borislav Petkov <b...@suse.de> > Date: Fri, 2 Dec 2016 23:18:51 +0100 > Subject: [PATCH] x86/alternatives: Do not use sync_core() to serialize I$ > > We use sync_core() in the alternatives code to stop speculative > execution of prefetched instructions because we are potentially changing > them and don't want to execute stale bytes. > > What it does on most machines is call CPUID which is a serializing > instruction. And that's expensive. > > However, the instruction cache is serialized when we're on the local CPU > and are changing the data through the same virtual address. So then, we > don't need the serializing CPUID but a simple control flow change. Last > being accomplished with a CALL/RET which the noinline causes. > > So let's try it.
I like it. Reviewed-by: Andy Lutomirski <l...@kernel.org>