[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YXEqpuKa5UiRNEfc@hirez.programming.kicks-ass.net>
Date: Thu, 21 Oct 2021 10:53:58 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Josh Poimboeuf <jpoimboe@...hat.com>
Cc: Alexei Starovoitov <alexei.starovoitov@...il.com>, x86@...nel.org,
andrew.cooper3@...rix.com, linux-kernel@...r.kernel.org,
ndesaulniers@...gle.com, bpf@...r.kernel.org, daniel@...earbox.net
Subject: Re: [PATCH v2 14/14] bpf,x86: Respect X86_FEATURE_RETPOLINE*
On Wed, Oct 20, 2021 at 05:18:08PM -0700, Josh Poimboeuf wrote:
> On Wed, Oct 20, 2021 at 05:07:53PM -0700, Alexei Starovoitov wrote:
> > On Wed, Oct 20, 2021 at 12:44:56PM +0200, Peter Zijlstra wrote:
> > > +
> > > + if (cpu_feature_enabled(X86_FEATURE_RETPOLINE_AMD)) {
> > > + EMIT_LFENCE();
> > > + EMIT2(0xFF, 0xE0 + reg);
> > > + } else if (cpu_feature_enabled(X86_FEATURE_RETPOLINE)) {
> > > + emit_jump(&prog, reg_thunk[reg], ip);
> > > + } else
> >
> > One more question.
> > What's a deal with AMD? I thought the retpoline is effective on it as well.
> > lfence is an optimization or retpoline turned out to be not enough
> > in some cases?
>
> Yes, it's basically an optimization. AMD recommends it presumably
> because it's quite a bit faster than a retpoline.
>
> According to AMD it shrinks the speculative execution window enough so
> that Spectre v2 isn't a threat.
Right, also note that we've been using alternatives to patch the thunk
to lfence;jmp for AMD pretty much forever.
Inlining it is better tho; just a shame clang seems to insist on r11,
which means we cannot fit it in the thunk call site for them :/
Powered by blists - more mailing lists