Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2335774imu; Tue, 6 Nov 2018 12:51:36 -0800 (PST) X-Google-Smtp-Source: AJdET5eH0Y2PQ3R0Z40zcRN9rJqytGTc7v7qWmYM9Ku+OAK4bpovspBwC45N6rHjycs6vrXAcdjD X-Received: by 2002:a63:c24c:: with SMTP id l12mr25119882pgg.146.1541537496008; Tue, 06 Nov 2018 12:51:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541537495; cv=none; d=google.com; s=arc-20160816; b=pPI9ezwftf+N99YQ03mnUp7uH/mMpg4dmzjCS7XjRO+WRKifAT1d3Jnb5fzTRL4Nxd jBZ2lhW63dxlcC2Hpg0+ruJV5ntIjOwrrcxHfUynsAv4I+slBC2e2TU/p4NSkDU+9tvZ NhWT1r9xIj6aF2dcWK1aj3iET+FJlkQGIFCGSya9KBTPTric8r87Bp6DYpfOUXSwXxQD NUjd3qk2CKENp5avUg5tsm1XdSxhhyCts9Dv9St3MPHhbjlsZrd/o8x9axgx/p5+IPzb nu/knnGc9owLZgxxb8jfq9br5uY0ApIi28iJ2BBWpm3RhyDIUy7dIA6/KtiLgTi/uELe EKaw== 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; bh=xD+mm5yOzh4SP6koChFgMASIJgJYriGM8vczSBzf+ZI=; b=mh+bm9bnp0NGBCoOBpqQsGzptQKh5Fwv4Z34nROz7XW9Y98igpGiU6tE1oJ7OWnYaI 4UcjjIQz3tx3hRIKOk0lnOyREljOWSHbSHqUApWAk1DZUdKwMQCchjeZJHrSaZFmdy30 XMmGQvs09Dsq1R3s14WPZquAQKw1jqW432Haj8dVggqivcoLGZnB9tZtUi2nsT9xF7Bw rzL5AGe+ZLQOolBrd+Cvnyzxcxgj1rDqJxNuPOm45nYV5V/Vc55xIF81rqOL6ZcJvtft 84mh1VxZt1m3nfKqjtvupdGYUdzvljp13LthLE3vY2jGGtyR/n39Xn1yxSZyTgfXGAEv cRag== 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 r7-v6si25570933ple.339.2018.11.06.12.51.20; Tue, 06 Nov 2018 12:51:35 -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 S1730603AbeKGGQ7 (ORCPT + 99 others); Wed, 7 Nov 2018 01:16:59 -0500 Received: from terminus.zytor.com ([198.137.202.136]:59313 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726157AbeKGGQ7 (ORCPT ); Wed, 7 Nov 2018 01:16:59 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id wA6KmrWm951380 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 6 Nov 2018 12:48:53 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id wA6KmrHo951376; Tue, 6 Nov 2018 12:48:53 -0800 Date: Tue, 6 Nov 2018 12:48:53 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Zhenzhong Duan Message-ID: Cc: luto@kernel.org, peterz@infradead.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, konrad.wilk@oracle.com, dwmw@amazon.co.uk, zhenzhong.duan@oracle.com, srinivas.eeda@oracle.com, hpa@zytor.com, michal.lkml@markovi.net, bp@suse.de, mingo@kernel.org, yamada.masahiro@socionext.com, daniel@iogearbox.net Reply-To: yamada.masahiro@socionext.com, daniel@iogearbox.net, mingo@kernel.org, dwmw@amazon.co.uk, bp@suse.de, michal.lkml@markovi.net, hpa@zytor.com, srinivas.eeda@oracle.com, zhenzhong.duan@oracle.com, linux-kernel@vger.kernel.org, luto@kernel.org, peterz@infradead.org, konrad.wilk@oracle.com, tglx@linutronix.de In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/pti] x86/retpoline: Make CONFIG_RETPOLINE depend on compiler support Git-Commit-ID: cf8f07269c7182f0e99abd3ac697870ea44d6f47 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, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: cf8f07269c7182f0e99abd3ac697870ea44d6f47 Gitweb: https://git.kernel.org/tip/cf8f07269c7182f0e99abd3ac697870ea44d6f47 Author: Zhenzhong Duan AuthorDate: Fri, 2 Nov 2018 01:45:41 -0700 Committer: Thomas Gleixner CommitDate: Tue, 6 Nov 2018 21:46:20 +0100 x86/retpoline: Make CONFIG_RETPOLINE depend on compiler support Since retpoline capable compilers are widely available, make CONFIG_RETPOLINE hard depend on the compiler capability. Break the build when CONFIG_RETPOLINE is enabled and the compiler does not support it. Emit an error message in that case: "arch/x86/Makefile:226: *** You are building kernel with non-retpoline compiler, please update your compiler.. Stop." Suggested-by: Peter Zijlstra Signed-off-by: Zhenzhong Duan Signed-off-by: Thomas Gleixner Cc: David Woodhouse Cc: Borislav Petkov Cc: Daniel Borkmann Cc: H. Peter Anvin Cc: Konrad Rzeszutek Wilk Cc: Andy Lutomirski Cc: Masahiro Yamada Cc: Michal Marek Cc: Link: https://lkml.kernel.org/r/cca0cb20-f9e2-4094-840b-fb0f8810cd34@default [dwmw@amazon.co.uk: fail the build with non-retpoline compiler] --- arch/x86/Kconfig | 4 ---- arch/x86/Makefile | 5 +++-- arch/x86/include/asm/nospec-branch.h | 10 ++++++---- arch/x86/kernel/cpu/bugs.c | 2 +- scripts/Makefile.build | 2 -- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index ba7e3464ee92..ea399744a18c 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -444,10 +444,6 @@ config RETPOLINE branches. Requires a compiler with -mindirect-branch=thunk-extern support for full protection. The kernel may run slower. - Without compiler support, at least indirect branches in assembler - code are eliminated. Since this includes the syscall entry path, - it is not entirely pointless. - config INTEL_RDT bool "Intel Resource Director Technology support" depends on X86 && CPU_SUP_INTEL diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 5b562e464009..6d94fe897983 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -222,9 +222,10 @@ KBUILD_CFLAGS += -fno-asynchronous-unwind-tables # Avoid indirect branches in kernel to deal with Spectre ifdef CONFIG_RETPOLINE -ifneq ($(RETPOLINE_CFLAGS),) - KBUILD_CFLAGS += $(RETPOLINE_CFLAGS) -DRETPOLINE +ifeq ($(RETPOLINE_CFLAGS),) + $(error You are building kernel with non-retpoline compiler, please update your compiler.) endif + KBUILD_CFLAGS += $(RETPOLINE_CFLAGS) endif archscripts: scripts_basic diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h index 80dc14422495..8b09cbb2d52c 100644 --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -162,11 +162,12 @@ _ASM_PTR " 999b\n\t" \ ".popsection\n\t" -#if defined(CONFIG_X86_64) && defined(RETPOLINE) +#ifdef CONFIG_RETPOLINE +#ifdef CONFIG_X86_64 /* - * Since the inline asm uses the %V modifier which is only in newer GCC, - * the 64-bit one is dependent on RETPOLINE not CONFIG_RETPOLINE. + * Inline asm uses the %V modifier which is only in newer GCC + * which is ensured when CONFIG_RETPOLINE is defined. */ # define CALL_NOSPEC \ ANNOTATE_NOSPEC_ALTERNATIVE \ @@ -181,7 +182,7 @@ X86_FEATURE_RETPOLINE_AMD) # define THUNK_TARGET(addr) [thunk_target] "r" (addr) -#elif defined(CONFIG_X86_32) && defined(CONFIG_RETPOLINE) +#else /* CONFIG_X86_32 */ /* * For i386 we use the original ret-equivalent retpoline, because * otherwise we'll run out of registers. We don't care about CET @@ -211,6 +212,7 @@ X86_FEATURE_RETPOLINE_AMD) # define THUNK_TARGET(addr) [thunk_target] "rm" (addr) +#endif #else /* No retpoline for C / inline asm */ # define CALL_NOSPEC "call *%[thunk_target]\n" # define THUNK_TARGET(addr) [thunk_target] "rm" (addr) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index c37e66e493bf..d0108fb6e4dd 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -252,7 +252,7 @@ static void __init spec2_print_if_secure(const char *reason) static inline bool retp_compiler(void) { - return __is_defined(RETPOLINE); + return __is_defined(CONFIG_RETPOLINE); } static inline bool match_option(const char *arg, int arglen, const char *opt) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index a8e7ba9f73e8..6a6be9f440cf 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -236,10 +236,8 @@ ifdef CONFIG_GCOV_KERNEL objtool_args += --no-unreachable endif ifdef CONFIG_RETPOLINE -ifneq ($(RETPOLINE_CFLAGS),) objtool_args += --retpoline endif -endif ifdef CONFIG_MODVERSIONS