Received: by 10.223.185.116 with SMTP id b49csp474726wrg; Tue, 20 Feb 2018 02:36:12 -0800 (PST) X-Google-Smtp-Source: AH8x226GWK1yq5FtijXF94Tj0U/0X2FmuqfDYWmjdQng5Epz6iBHW3xbHKjNYclyjzaCGd7CNHoZ X-Received: by 10.98.225.2 with SMTP id q2mr6777034pfh.23.1519122972405; Tue, 20 Feb 2018 02:36:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519122972; cv=none; d=google.com; s=arc-20160816; b=nJdmsTpPlEeWLzJVEvRaazZQoYKs6nC7fXj0aovi5rOUjfRnRl4XbVuho82eyFGSiy DBL9xhOCFSoDlnVlR4mhz0G8S8JGgC09iYsrTcx7SyknlfOTB95R0tD3691sDtk7fH5v 2KzmH3uHsw1NhfeRdHeuv4OfdebQwRQqHvDzKSz2xRwvGn3vhrwgSlR7s98L5V31ZOxm DrL/RrDegghpZAW8pT0vDi5FfV8qlAuXbuzU2n//VJJE5nsDhNe+UpiD2hUAnryc12Ie yXZmbSzmZ8qXEqWlp7CqBjnskcEI7lOuNUoN0iUqna0G6XaiMRAPkpWh3ygZWgLmr/OZ Jo+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=5En/l/5NVSX8rK0i7dxW08srhqR422OAmFf6fI42dG8=; b=Wjnp7fckgTgsXKYcJ/77J1dcEuvyUtD9e6ztvOKc2aZgej0ePSS22p8m5QWns6SoHv LLhxnbdX/2awp7X9s4yeVm3ITEujkfMRVF8QFm+vV+PbZc6w+K7w4tRvR52cJk/sZdEv LqlPdtBN02xlcMUu3NmoX/lpuwDh8v8+okBEGTTxfgLWhMOmt0p9iPor+TS6h70YXQVj +dAmlrJ2HLfvbNmsrdXDViDVgr6Qi+7TogkPmCE9d+Cl8tDG9kcrkVlSwH8mAJ3yTVKH aZgfPDV+iJEFdxE0G2CxeGAm2VkiNdqcx4m4CUNO+Hwa/yAXGWxWkSC7wjpo2NbU3imJ UZFA== ARC-Authentication-Results: i=1; mx.google.com; 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 e5si5009517pgr.444.2018.02.20.02.35.58; Tue, 20 Feb 2018 02:36:12 -0800 (PST) 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; 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 S1751679AbeBTKfG (ORCPT + 99 others); Tue, 20 Feb 2018 05:35:06 -0500 Received: from terminus.zytor.com ([198.137.202.136]:47767 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751665AbeBTKfD (ORCPT ); Tue, 20 Feb 2018 05:35:03 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w1KATdN0020590; Tue, 20 Feb 2018 02:29:39 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w1KATceA020587; Tue, 20 Feb 2018 02:29:38 -0800 Date: Tue, 20 Feb 2018 02:29:38 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for David Woodhouse Message-ID: Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, hpa@zytor.com, torvalds@linux-foundation.org, mingo@kernel.org, tglx@linutronix.de, dwmw@amazon.co.uk Reply-To: mingo@kernel.org, dwmw@amazon.co.uk, tglx@linutronix.de, linux-kernel@vger.kernel.org, peterz@infradead.org, torvalds@linux-foundation.org, hpa@zytor.com In-Reply-To: <1519037457-7643-5-git-send-email-dwmw@amazon.co.uk> References: <1519037457-7643-5-git-send-email-dwmw@amazon.co.uk> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/pti] x86/retpoline: Support retpoline builds with Clang Git-Commit-ID: 87358710c1fb4f1bf96bbe2349975ff9953fc9b2 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 87358710c1fb4f1bf96bbe2349975ff9953fc9b2 Gitweb: https://git.kernel.org/tip/87358710c1fb4f1bf96bbe2349975ff9953fc9b2 Author: David Woodhouse AuthorDate: Mon, 19 Feb 2018 10:50:57 +0000 Committer: Ingo Molnar CommitDate: Tue, 20 Feb 2018 11:17:58 +0100 x86/retpoline: Support retpoline builds with Clang Signed-off-by: David Woodhouse Reviewed-by: Thomas Gleixner Cc: Linus Torvalds Cc: Peter Zijlstra Cc: arjan.van.de.ven@intel.com Cc: bp@alien8.de Cc: dave.hansen@intel.com Cc: jmattson@google.com Cc: karahmed@amazon.de Cc: kvm@vger.kernel.org Cc: pbonzini@redhat.com Cc: rkrcmar@redhat.com Link: http://lkml.kernel.org/r/1519037457-7643-5-git-send-email-dwmw@amazon.co.uk Signed-off-by: Ingo Molnar --- arch/x86/Makefile | 5 ++++- include/linux/compiler-clang.h | 5 +++++ include/linux/compiler-gcc.h | 4 ++++ include/linux/init.h | 8 ++++---- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/arch/x86/Makefile b/arch/x86/Makefile index fad5516..dbc7d0e 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -232,7 +232,10 @@ KBUILD_CFLAGS += -fno-asynchronous-unwind-tables # Avoid indirect branches in kernel to deal with Spectre ifdef CONFIG_RETPOLINE - RETPOLINE_CFLAGS += $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register) + 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 diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h index d02a4df..d3f264a 100644 --- a/include/linux/compiler-clang.h +++ b/include/linux/compiler-clang.h @@ -27,3 +27,8 @@ #if __has_feature(address_sanitizer) #define __SANITIZE_ADDRESS__ #endif + +/* Clang doesn't have a way to turn it off per-function, yet. */ +#ifdef __noretpoline +#undef __noretpoline +#endif diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index 73bc63e..673fbf9 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -93,6 +93,10 @@ #define __weak __attribute__((weak)) #define __alias(symbol) __attribute__((alias(#symbol))) +#ifdef RETPOLINE +#define __noretpoline __attribute__((indirect_branch("keep"))) +#endif + /* * it doesn't make sense on ARM (currently the only user of __naked) * to trace naked functions because then mcount is called without diff --git a/include/linux/init.h b/include/linux/init.h index 506a981..bc27cf0 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -6,10 +6,10 @@ #include /* Built-in __init functions needn't be compiled with retpoline */ -#if defined(RETPOLINE) && !defined(MODULE) -#define __noretpoline __attribute__((indirect_branch("keep"))) +#if defined(__noretpoline) && !defined(MODULE) +#define __noinitretpoline __noretpoline #else -#define __noretpoline +#define __noinitretpoline #endif /* These macros are used to mark some functions or @@ -47,7 +47,7 @@ /* These are for everybody (although not all archs will actually discard it in modules) */ -#define __init __section(.init.text) __cold __latent_entropy __noretpoline +#define __init __section(.init.text) __cold __latent_entropy __noinitretpoline #define __initdata __section(.init.data) #define __initconst __section(.init.rodata) #define __exitdata __section(.exit.data)