Received: by 10.213.65.68 with SMTP id h4csp516256imn; Fri, 16 Mar 2018 10:07:35 -0700 (PDT) X-Google-Smtp-Source: AG47ELuq0e9Sycv6awIqrbMYFNCxnrpuSFDrgUCRqmpnAlO6quX2huN5ywoViYbFFuIPwEsBVmFG X-Received: by 10.98.209.13 with SMTP id z13mr2119858pfg.85.1521220055154; Fri, 16 Mar 2018 10:07:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521220055; cv=none; d=google.com; s=arc-20160816; b=0YnG3POZcU4/26iTB7/Xt8PKHZBXBr6iqj7+WTGhtdN8K7gEOkbneSy9W5UBsEVFo2 IeUXP6u6q9LbLXyJiM/akziHbK8q9yOmG83e3ErmpC4HIgb3G5sqDjfUxJeM0RhKgJI1 210klTuvZg4M8paXQ+tSUgmcVYv/GuQ5d/V2DigjVjescWmpe8ypKRv1mW9xPVya2Zh6 nSUBITnslb22U14Z9cQEO/eYt7YqPqvZwD6QFTjqYKk2QJ6u+++eEjjKQ2jPRyel/5az e2/H9NqkXJq3ljNiv5oWnGGXI8TLTxMcBVcL1N/Im9FatRfril434sr+WCvcPLn0Ursa W6nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=1GFXUn+yaZ/Ttlk2banZJy8O8hV+f6wU5zJBhbl6kIc=; b=SktQaMdVRoWbfKlxC0vt6Vt9939pwshl0/tBxaK+aBAOn7GqyS3eIOJ6Wfg2yTVmjx bNXMm8R+GgsSqP8BO6C8ulYFChXwCRqUkst5Hgsp9Sih5tI547aYLx1O5ALyIwmKRFaE q9l73BzBHOXmW9CFRHrcoyjT10Fxn6QlfwQq4AKhjZoVEdYr2Q8UuPR2I7MJiaWlSY8A xm8iVQ0GppzB977XHUfCh2rwSki4EHp1Dow4YNtZFpwSAoSnil8GpCoXuPX/8R89iuHj s8roxqscvS+exPGJNVZi+/WdELaXdcGDXXnl/pqiDbyd1HUoY+Knwd2v5KKwXXWhMi17 BTMA== 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 s2-v6si5729082plq.674.2018.03.16.10.07.20; Fri, 16 Mar 2018 10:07:35 -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; 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 S1753643AbeCPRFi (ORCPT + 99 others); Fri, 16 Mar 2018 13:05:38 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37584 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933400AbeCPPbe (ORCPT ); Fri, 16 Mar 2018 11:31:34 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7C29E117A; Fri, 16 Mar 2018 15:31:33 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Woodhouse , Thomas Gleixner , Linus Torvalds , Peter Zijlstra , arjan.van.de.ven@intel.com, bp@alien8.de, dave.hansen@intel.com, jmattson@google.com, karahmed@amazon.de, kvm@vger.kernel.org, pbonzini@redhat.com, rkrcmar@redhat.com, Ingo Molnar Subject: [PATCH 4.9 42/86] x86/retpoline: Support retpoline builds with Clang Date: Fri, 16 Mar 2018 16:23:05 +0100 Message-Id: <20180316152320.293252344@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152317.167709497@linuxfoundation.org> References: <20180316152317.167709497@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Woodhouse commit 87358710c1fb4f1bf96bbe2349975ff9953fc9b2 upstream. 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 Signed-off-by: Greg Kroah-Hartman --- 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(-) --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -184,7 +184,10 @@ KBUILD_AFLAGS += $(mflags-y) # 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 --- a/include/linux/compiler-clang.h +++ b/include/linux/compiler-clang.h @@ -15,3 +15,8 @@ * with any version that can compile the kernel */ #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) + +/* Clang doesn't have a way to turn it off per-function, yet. */ +#ifdef __noretpoline +#undef __noretpoline +#endif --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -88,6 +88,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 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -5,10 +5,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 @@ -46,7 +46,7 @@ /* These are for everybody (although not all archs will actually discard it in modules) */ -#define __init __section(.init.text) __cold notrace __latent_entropy __noretpoline +#define __init __section(.init.text) __cold notrace __latent_entropy __noinitretpoline #define __initdata __section(.init.data) #define __initconst __section(.init.rodata) #define __exitdata __section(.exit.data)