Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752475AbeADSRw (ORCPT + 1 other); Thu, 4 Jan 2018 13:17:52 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:37036 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750959AbeADSRu (ORCPT ); Thu, 4 Jan 2018 13:17:50 -0500 X-Google-Smtp-Source: ACJfBosE9FMGD23ZadL0wFAxGT3/EZCf9SbrWtzrkKpsQ0W/wV25PQMEMKGc8ycxCSCQNiuUyuLHLg== Date: Thu, 4 Jan 2018 10:17:46 -0800 From: Alexei Starovoitov To: David Woodhouse Cc: ak@linux.intel.com, Paul Turner , LKML , Linus Torvalds , Greg Kroah-Hartman , Tim Chen , Dave Hansen , tglx@linutronix.de, Kees Cook , Rik van Riel , Peter Zijlstra , Andy Lutomirski , Jiri Kosina , gnomes@lxorguk.ukuu.org.uk Subject: Re: [PATCH v3 01/13] x86/retpoline: Add initial retpoline support Message-ID: <20180104181744.komdplek7nfdvlsw@ast-mbp> References: <1515058213.12987.89.camel@amazon.co.uk> <20180104143710.8961-1-dwmw@amazon.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180104143710.8961-1-dwmw@amazon.co.uk> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Thu, Jan 04, 2018 at 02:36:58PM +0000, David Woodhouse wrote: > Enable the use of -mindirect-branch=thunk-extern in newer GCC, and provide > the corresponding thunks. Provide assembler macros for invoking the thunks > in the same way that GCC does, from native and inline assembler. > > This adds an X86_BUG_NO_RETPOLINE "feature" for runtime patching out > of the thunks. This is a placeholder for now; the patches which support > the new Intel/AMD microcode features will flesh out the precise conditions > under which we disable the retpoline and do other things instead. > > [Andi Kleen: Rename the macros and add CONFIG_RETPOLINE option] > > Signed-off-by: David Woodhouse ... > +.macro THUNK sp reg > + .section .text.__x86.indirect_thunk.\reg > + > +ENTRY(__x86.indirect_thunk.\reg) > + CFI_STARTPROC > + ALTERNATIVE "call 2f", __stringify(jmp *%\reg), X86_BUG_NO_RETPOLINE > +1: > + lfence > + jmp 1b > +2: > + mov %\reg, (%\sp) > + ret > + CFI_ENDPROC > +ENDPROC(__x86.indirect_thunk.\reg) Clearly Paul's approach to retpoline without lfence is faster. I'm guessing it wasn't shared with amazon/intel until now and this set of patches going to adopt it, right? Paul, could you share a link to a set of alternative gcc patches that do retpoline similar to llvm diff ?