From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x225uNyuw6nItaJft5ZY3o/P1wW45xtU25Onkjxxdn+z8IAWTZEBTIjUox4kBY8PN694yP8so ARC-Seal: i=1; a=rsa-sha256; t=1516721590; cv=none; d=google.com; s=arc-20160816; b=u6Ws50+ZtKvlXJ0uaAlTA/hXFjpzVJunYL1IT2WFnEBRMhwJwVkcO+mARVnPPEtsZR mYOeWEKCPFRPkpc5/BbqR7HRyyN01YY3f7EQKAwZv4+pPNFf0SclBNusb3JawmMm6P44 mudNQkhBq/DMJBE8HHUtw7/L3XFd3TQtPAgzLk0z0ImD99q3QZ+P35NqliRfmvg+seyn tEp8OWmT1wsWm4l9vLmPZFPPjLQa/V3Kw7B6mQqIkxrTA9LzAX2+9MtGXhx0Pi4D/A6x lOh9zvhqOts05JNj6DM+7IcL9rJvVtd2gd58H9LYEQVu2eD8DSGTSgRRB1cDCHSIoKhf ttQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:references:subject:cc:to:from:date :user-agent:message-id:dkim-signature:arc-authentication-results; bh=S1ZfUyfFqmSu1U+iROLSQRkXCnn6Ep9gC/Ku+nIWC1o=; b=r7Aw8oXtkoKQ64WxWQd4hLZItt1sKcwWpDYeInPB9xaL4m2n8ObtdK8WcvA778TUgB lQPxZGNy/9EsS0bMB/oyyov5o/3qnA5+LW+npFPDWWd2bcjNvnYdDlf+RPUriCO1FOsV Bp4cvWNWgTDqEckw3Lf5tEINo+QQduC8f91+JBAdhEmCceIhfVlaz+0Bg5JfiCIakVqe UsP33TZdrTQxWtC5beypYw/xC2EWHHpWZyu4MCELQj14niQIzq5PqNI8RYpWY92kzA9i PdHR+TFTP+yfZ5Rxf+lrYCCkDatNpDeVg4UvYbyysxH56Im/AWKBGudjnXX1R/l+qX2w RUQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=syGg8324; spf=pass (google.com: best guess record for domain of peterz@infradead.org designates 205.233.59.134 as permitted sender) smtp.mailfrom=peterz@infradead.org Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=syGg8324; spf=pass (google.com: best guess record for domain of peterz@infradead.org designates 205.233.59.134 as permitted sender) smtp.mailfrom=peterz@infradead.org Message-Id: <20180123152639.343886310@infradead.org> User-Agent: quilt/0.63-1 Date: Tue, 23 Jan 2018 16:26:02 +0100 From: Peter Zijlstra To: David Woodhouse , Thomas Gleixner , Josh Poimboeuf Cc: linux-kernel@vger.kernel.org, Dave Hansen , Ashok Raj , Tim Chen , Andy Lutomirski , Linus Torvalds , Greg KH , Andrea Arcangeli , Andi Kleen , Arjan Van De Ven , Dan Williams , Paolo Bonzini , Jun Nakajima , Asit Mallick , Jason Baron , Peter Zijlstra Subject: [PATCH 23/24] x86: Force asm-goto References: <20180123152539.374360046@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline; filename=peterz-x86-force-asm-goto.patch X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1590397857781974230?= X-GMAIL-MSGID: =?utf-8?q?1590397857781974230?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: Now that we have objtool to validate the correctness of asm-goto constructs we can start using it to guarantee the absence of dynamic branches (and thus speculation). A primary prerequisite for this is of course that the compiler supports asm-goto. This effecively lifts the minimum GCC version to build an x86 kernel to gcc-4.5. Signed-off-by: Peter Zijlstra (Intel) --- Makefile | 13 +++++++------ arch/x86/Makefile | 4 ++++ 2 files changed, 11 insertions(+), 6 deletions(-) --- a/Makefile +++ b/Makefile @@ -513,6 +513,13 @@ ifneq ($(filter install,$(MAKECMDGOALS)) endif endif +# check for 'asm goto' +ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y) + CC_HAVE_ASM_GOTO := 1 + KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO + KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO +endif + ifeq ($(mixed-targets),1) # =========================================================================== # We're called with mixed targets (*config and build targets). @@ -652,12 +659,6 @@ KBUILD_CFLAGS += $(call cc-ifversion, -l # Tell gcc to never replace conditional load with a non-conditional one KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) -# check for 'asm goto' -ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y) - KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO - KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO -endif - include scripts/Makefile.gcc-plugins ifdef CONFIG_READABLE_ASM --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -186,6 +186,10 @@ ifdef CONFIG_FUNCTION_GRAPH_TRACER endif endif +ifndef CC_HAVE_ASM_GOTO + $(error Compiler lacks asm-goto support.) +endif + # # Jump labels need '-maccumulate-outgoing-args' for gcc < 4.5.2 to prevent a # GCC bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46226). There's no way