On Thu, Jan 04, 2018 at 01:24:41AM -0800, Paul Turner wrote: > On Thu, Jan 4, 2018 at 1:10 AM, Paul Turner <p...@google.com> wrote: > > Apologies for the discombobulation around today's disclosure. Obviously the > > original goal was to communicate this a little more coherently, but the > > unscheduled advances in the disclosure disrupted the efforts to pull this > > together more cleanly. > > > > I wanted to open discussion the "retpoline" approach and and define its > > requirements so that we can separate the core > > details from questions regarding any particular implementation thereof. > > > > As a starting point, a full write-up describing the approach is available > > at: > > https://support.google.com/faqs/answer/7625886 > > > > The 30 second version is: > > Returns are a special type of indirect branch. As function returns are > > intended > > to pair with function calls, processors often implement dedicated return > > stack > > predictors. The choice of this branch prediction allows us to generate an > > indirect branch in which speculative execution is intentionally redirected > > into > > a controlled location by a return stack target that we control. Preventing > > branch target injections (also known as "Spectre") against these binaries. > > > > On the targets (Intel Xeon) we have measured so far, cost is within cycles > > of a > > "native" indirect branch for which branch prediction hardware has been > > disabled. > > This is unfortunately measurable -- from 3 cycles on average to about 30. > > However the cost is largely mitigated for many workloads since the kernel > > uses > > comparatively few indirect branches (versus say, a C++ binary). With some > > effort we have the average overall overhead within the 0-1.5% range for our > > internal workloads, including some particularly high packet processing > > engines. > > > > There are several components, the majority of which are independent of > > kernel > > modifications: > > > > (1) A compiler supporting retpoline transformations. > > An implementation for LLVM is available at: > https://reviews.llvm.org/D41723
Nice, thanks for the link and the write up. There is also a patch for gcc floating around somewhere, does anyone have the link for that? thanks, greg k-h