Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8096998imu; Tue, 4 Dec 2018 02:57:44 -0800 (PST) X-Google-Smtp-Source: AFSGD/WX0cYSFfJ2lUujv7RBiXU34aNABzr/BbpVtvbu+Kumjp+9WcYZvxDzh6b/6hGRTM4WCa2Y X-Received: by 2002:a65:520a:: with SMTP id o10mr16925057pgp.276.1543921064777; Tue, 04 Dec 2018 02:57:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543921064; cv=none; d=google.com; s=arc-20160816; b=jzZMB0lsiGOjo7I9qtREE6kINySK60hhEJtJJfg0smxc5ohUFHwwDTCCCnef95e+mo 6KnnWWyHavagE4NQ2XNqZAnR4mb78l8CqtxQyO8zTTITkgQrX282F6s6arE6bT23tO1R H7n5dkNV635IU8V2nnkf3FaILwSL0AUV4F9nc/tYzdkRuILdqFan6ixDOC6cqcaGltUU WeOr0SZ8nKU1Xr1S/azuEnAOMPkOJBNHSQO8vtHezG10diBZmFcVC/VVOL6HWXBzvJ1x 7NRZuPuJRD+S9/5QAtbMU3OSLN9i/jj4p6z0/IxPoBaLA1DK+1+KTXW85r90jGx78h5y rjjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1X5eCJAI2ZlQWXz+tjc1H7rEmsrXkW00I2xNPYTbY50=; b=vmBOs6SyHwM7y1gZrLId1rTIQpnKDBPY5dJocGUhpyx8E36mgNnHrdkkDlkUVh7J4q /hQrf0ujYufVJuLaXtzH6KHkJ9zrxdeAtsWkIMLYTOltXmRzPdn4emx8EaZ07ntAo+t/ lo0aAdCiuws6fnSBn6iacVn/CXVaqARV/fVyjpZnja3MArmaaImPKH04XgracIYIkU2F SFBe57R0QmmStejjx9KBi5kLQh80cGUuxrWY+0khsaxftjZ65w2u1kZo503hfUmuFbIl OmEgcUBNeMRhYGdCtDVVbt/pmod7ogDZqHu5Vmr9KzRexlgh3/lvxV4HdILzwC1dmuCl arsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=H00PwhP7; 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 t130si15282429pgb.521.2018.12.04.02.57.29; Tue, 04 Dec 2018 02:57:44 -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; dkim=pass header.i=@kernel.org header.s=default header.b=H00PwhP7; 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 S1726459AbeLDK4U (ORCPT + 99 others); Tue, 4 Dec 2018 05:56:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:39432 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726440AbeLDK4R (ORCPT ); Tue, 4 Dec 2018 05:56:17 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 126FA2146D; Tue, 4 Dec 2018 10:56:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543920975; bh=2pyVjl05kj8qShDhe+i54CHApb52RhFWD1nnXTFGa94=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H00PwhP7ux5c8Ur28xpaG5bOObUUXoJ0r2/diC1WMiq1UWLUR7aDF6cb8tIPFi6yv NiDgfkO9ic1q7DbP+0HkMF8QYXoEsJ9hme1eIKqXKfcVBfATeL1gbGJH1gvGPtGxVX AOI5fNGTEQOWgGwmiE9JqemQy9LOPHazLhsAasS8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Zijlstra , Zhenzhong Duan , Thomas Gleixner , David Woodhouse , Borislav Petkov , Daniel Borkmann , "H. Peter Anvin" , Konrad Rzeszutek Wilk , Andy Lutomirski , Masahiro Yamada , Michal Marek , srinivas.eeda@oracle.com Subject: [PATCH 4.19 031/139] x86/retpoline: Make CONFIG_RETPOLINE depend on compiler support Date: Tue, 4 Dec 2018 11:48:32 +0100 Message-Id: <20181204103651.263926410@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181204103649.950154335@linuxfoundation.org> References: <20181204103649.950154335@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhenzhong Duan zhenzhong.duan@oracle.com commit 4cd24de3a0980bf3100c9dcb08ef65ca7c31af48 upstream 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." [dwmw: Fail the build with non-retpoline compiler] 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: Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/cca0cb20-f9e2-4094-840b-fb0f8810cd34@default Signed-off-by: Greg Kroah-Hartman --- 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(-) --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -441,10 +441,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" default n --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -223,9 +223,10 @@ KBUILD_CFLAGS += -fno-asynchronous-unwin # 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 --- 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) --- 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 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) --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -248,10 +248,8 @@ ifdef CONFIG_GCOV_KERNEL objtool_args += --no-unreachable endif ifdef CONFIG_RETPOLINE -ifneq ($(RETPOLINE_CFLAGS),) objtool_args += --retpoline endif -endif ifdef CONFIG_MODVERSIONS