Received: by 10.213.65.68 with SMTP id h4csp39261imn; Mon, 19 Mar 2018 18:49:57 -0700 (PDT) X-Google-Smtp-Source: AG47ELtwJxijTuDqPt9frRCEq6xuPJ0yRX7dFxya8tKONJb6Jb6PbG7a1cgXoWEvveEpQ5TquQK+ X-Received: by 2002:a17:902:44c:: with SMTP id 70-v6mr14791777ple.354.1521510597318; Mon, 19 Mar 2018 18:49:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521510597; cv=none; d=google.com; s=arc-20160816; b=S0RlkTHzqsICB2NcgUxZtXUN2GA9V87hwIFv/H8LetbhzGes+sYeH7rPDngaUwCaA+ 5ExqPiQA8S+Xobzm518kAqotqhub/8sAVJvg2n3T5Y0kMW97KpZ2I+qCQ4uU+dgtg5MJ cSbsg6R2tQiTLUCqnyHFoDDjX8FSmJvf+YeETojifLeALqrffoeWIblRnYuA/NFyzf4Z Dm2eAYheMqS+LmG3j5Awm/mueVoxN8Z1sW678v0EVMfsQDcJrTUhnS2SYLoOLA7xAV19 XoE4Lic728Zu6/RHNUfqR4zIC+sGWm3YEMX9eSC5RxpklLkw2/ti/cyuwtsCNEoXVoBW AF4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=k2Xqmm+CGG8MqjQ8aqfg2yTO+j5mVf3Y+5dLYNPTPy4=; b=v7+589Z2gwUqEdduJiFF19/NvmVw2UNlbUBF/nBe+R2fUyXwlKop0SAuFgjsCwrdy4 qF/k/yKWni5yTwFHrOMV1fm2PJ3gvFpC5nhRWQ3nrZm2OiuFIhBSBGy/DZYWu03Eip56 UrkaRWVpowKtjM6cKinrILpt/+WLcUktQ5S/rmeBiGWVvKbrJpwsmuvajW4WmJvoMQko VYlRieuFrIB82yP6PrSk98fe/w3Ejc999HgFV2B/IjGxnwKwDHNfJYN0TYBHpIAI9C3B oTYcY9kQqtFzlXYP+vMyNXGT0yGCxihh5IJSiSGSTBn4fjlNTkkJT8Xd73KWv+9VzYK6 7CMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=glVGgZlV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h67si399057pgc.353.2018.03.19.18.49.43; Mon, 19 Mar 2018 18:49:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=glVGgZlV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S971219AbeCSUNn (ORCPT + 99 others); Mon, 19 Mar 2018 16:13:43 -0400 Received: from merlin.infradead.org ([205.233.59.134]:54420 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S969087AbeCSUNe (ORCPT ); Mon, 19 Mar 2018 16:13:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=k2Xqmm+CGG8MqjQ8aqfg2yTO+j5mVf3Y+5dLYNPTPy4=; b=glVGgZlVy8tYffuLi2dtp27Q2 IUKlNcOgTwvmfjhR9rxzyuAEal4KpGucQHtBZAnTZTNCq1Ebr4dPi1PoALf7eIoAnjI0EC36Q9IYg oZmZtUYUzyAILYzHbhyqlj6kRM90JQmRKYLNgpBC1UgRJtMUwd03NRjnbqypPRTwDdTqOPCgig5if rOXx2PPK65WjZMea7v7DUOWRqXFa0BcOw1x8CIQJlT2UGnBa0LlN86pmMTj6bu7gk0q9KaJi3q9Yj X0ovGx8hTpm7FxF6sxnFanoHbA1iXrQ8JiJT0ajEZBafBu2E+t9uHFftFhM7wLCJGg+KvTV4La23r yT+OaP2Cg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1ey19u-0006vk-LK; Mon, 19 Mar 2018 20:13:30 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 0EE3B2026831F; Mon, 19 Mar 2018 21:13:27 +0100 (CET) Date: Mon, 19 Mar 2018 21:13:27 +0100 From: Peter Zijlstra To: Thomas Gleixner Cc: mingo@kernel.org, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org Subject: Re: [PATCH 1/2] x86: Force asm-goto Message-ID: <20180319201327.GJ4043@hirez.programming.kicks-ass.net> References: <20180319154124.337947038@infradead.org> <20180319154717.652679334@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 19, 2018 at 08:57:48PM +0100, Thomas Gleixner wrote: > On Mon, 19 Mar 2018, Peter Zijlstra wrote: > > > We want to start using asm-goto 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 > > @@ -494,6 +494,13 @@ RETPOLINE_CFLAGS_CLANG := -mretpoline-ex > > RETPOLINE_CFLAGS := $(call cc-option,$(RETPOLINE_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_CFLAGS_CLANG))) > > export RETPOLINE_CFLAGS > > > > +# check for 'asm goto' > > +ifeq ($(shell $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y) > > Why are you not using the shell-cached version which you remove further > down? Bah, I'm an idiot. I fixed that up at least two times, but clearly I forgot to check that again before sending. --- Subject: x86: Force asm-goto From: Peter Zijlstra Date: Wed Jan 17 11:42:07 CET 2018 We want to start using asm-goto 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 @@ -494,6 +494,13 @@ RETPOLINE_CFLAGS_CLANG := -mretpoline-ex RETPOLINE_CFLAGS := $(call cc-option,$(RETPOLINE_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_CFLAGS_CLANG))) export RETPOLINE_CFLAGS +# check for 'asm goto' +ifeq ($(call shell-cached,$(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 ($(config-targets),1) # =========================================================================== # *config targets only - make sure prerequisites are updated, and descend @@ -658,12 +665,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 ($(call shell-cached,$(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.kcov include scripts/Makefile.gcc-plugins --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -181,6 +181,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