[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180221131207.GS25235@hirez.programming.kicks-ass.net>
Date: Wed, 21 Feb 2018 14:12:07 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: David Woodhouse <dwmw2@...radead.org>
Cc: hpa@...or.com, luto@...nel.org, arjan@...ux.intel.com,
tglx@...utronix.de, dan.j.williams@...el.com,
torvalds@...ux-foundation.org, gregkh@...uxfoundation.org,
mingo@...nel.org, bp@...en8.de, linux-kernel@...r.kernel.org,
dave.hansen@...ux.intel.com, jpoimboe@...hat.com,
linux-tip-commits@...r.kernel.org
Subject: Re: [tip:x86/pti] objtool, retpolines: Integrate objtool with
retpoline support more closely
On Wed, Feb 21, 2018 at 01:53:57PM +0100, Peter Zijlstra wrote:
> That's because this crossed with the llvm cruft, right? I'll have a
> look.
Best I could come up with that seems to work is something like the
below. Ingo, can you backmerge or stuff on top as appropriate?
---
Makefile | 8 ++++----
arch/x86/Makefile | 10 +++-------
scripts/Makefile.build | 2 +-
3 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/Makefile b/Makefile
index e1a155a50fdc..3aa0a115eafb 100644
--- a/Makefile
+++ b/Makefile
@@ -489,10 +489,10 @@ KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
endif
-ifneq ($(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register),)
- CC_HAS_RETPOLINE := 1
-endif
-export CC_HAS_RETPOLINE
+RETPOLINE_CFLAGS_GCC := -mindirect-branch=thunk-extern -mindirect-branch-register
+RETPOLINE_CFLAGS_CLANG := -mretpoline-external-thunk
+RETPOLINE_CFLAGS := $(call cc-option,$(RETPOLINE_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_CFLAGS_CLANG)))
+export RETPOLINE_CFLAGS
ifeq ($(config-targets),1)
# ===========================================================================
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index dbc7d0ed2eaa..498c1b812300 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -232,13 +232,9 @@ KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
# Avoid indirect branches in kernel to deal with Spectre
ifdef CONFIG_RETPOLINE
- RETPOLINE_CFLAGS_GCC := -mindirect-branch=thunk-extern -mindirect-branch-register
- RETPOLINE_CFLAGS_CLANG := -mretpoline-external-thunk
-
- RETPOLINE_CFLAGS += $(call cc-option,$(RETPOLINE_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_CFLAGS_CLANG)))
- ifneq ($(RETPOLINE_CFLAGS),)
- KBUILD_CFLAGS += $(RETPOLINE_CFLAGS) -DRETPOLINE
- endif
+ifneq ($(RETPOLINE_CFLAGS),)
+ KBUILD_CFLAGS += $(RETPOLINE_CFLAGS) -DRETPOLINE
+endif
endif
archscripts: scripts_basic
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 07e5802e324b..4f2b25d43ec9 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -267,7 +267,7 @@ else
objtool_args += $(call cc-ifversion, -lt, 0405, --no-unreachable)
endif
ifdef CONFIG_RETPOLINE
-ifdef CC_HAS_RETPOLINE
+ifneq ($(RETPOLINE_CFLAGS),)
objtool_args += --retpoline
endif
endif
Powered by blists - more mailing lists