Received: by 10.213.65.68 with SMTP id h4csp457463imn; Tue, 13 Mar 2018 09:39:51 -0700 (PDT) X-Google-Smtp-Source: AG47ELtK3qnVWeE7AO6PB39JcQaHx/i7dMlUJx+v1wEVJpPgkzZgEIQG6UliI2Zak6a1xHHJQ7Y1 X-Received: by 10.99.97.130 with SMTP id v124mr973362pgb.351.1520959191273; Tue, 13 Mar 2018 09:39:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520959191; cv=none; d=google.com; s=arc-20160816; b=P1wz6RwouR7WHynrbJWO8smr6297WmcsZ/fnG4i77xvgqWOOYftGVRmQS80zZmE0Xz 6uQ0QSHfZrpcVXrHB3C5Q0PVfdLw3p7qn7M5Sk50//NOAza1YrUmkuRYAEAsbzHwsS+4 SBolb3QmDyymzDsZkXAur8lQGtrIOYTAfeN6hT3aevPNE9V3u/uFcnEgU/EjvD9eMYFA u8C8+cNWi86zfv0TbACN+vC8Ncx63qi45e5CkD6DTcb6vojdRmh6c0842rCOjo4rimzc 1wJdskBr4E9YyOKc+cZ6cEMpNcVedpSksrfmWKoFTMzvLo4Li7jJhtOkAaU4KMC8boUg 05nw== 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=yGQ8WUZgSO9/0/bXeECF03v4eemCPMpgFaYZu4CsicQ=; b=BH7j/LrAEPDh8DcLlSptt82vPoTEmrsSLoVbCGSVh8pxFqUV+69nXyxyg9ySmyQIp8 b5bYFcre/BHr4BdHPdWA5qu3g4R05dvM+DT64FkI8xyWVJrlxWy2ORD/kZE2TpfctWwt xS8veXutlA3EfVCu/P/iFBUihjcKDbhL6TfMDjFSU6naqz/5HeiTM8jXia10yjPQ35qb Q/Tx+Qoo54nXXC2dG3zX25Tqa9FSHeHvcektoM2KnOPHeBJjrxDnsCJZdFt2tkCY9rCD RBG/eZiruQiiatA5RiTyLLKarnGSa4o3A904W6iHHikeMA25a6V5y3nD/n8g5k8EJLa+ 9o4A== 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 j17si275295pga.495.2018.03.13.09.39.36; Tue, 13 Mar 2018 09:39:51 -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 S1752815AbeCMPb5 (ORCPT + 99 others); Tue, 13 Mar 2018 11:31:57 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59576 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752007AbeCMPby (ORCPT ); Tue, 13 Mar 2018 11:31:54 -0400 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id BB8C21113; Tue, 13 Mar 2018 15:31:53 +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.15 093/146] x86/speculation: Move firmware_restrict_branch_speculation_*() from C to CPP Date: Tue, 13 Mar 2018 16:24:20 +0100 Message-Id: <20180313152327.844201107@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180313152320.439085687@linuxfoundation.org> References: <20180313152320.439085687@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.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ingo Molnar commit d72f4e29e6d84b7ec02ae93088aa459ac70e733b upstream. firmware_restrict_branch_speculation_*() recently started using preempt_enable()/disable(), but those are relatively high level primitives and cause build failures on some 32-bit builds. Since we want to keep low level, convert them to macros to avoid header hell... Cc: David Woodhouse Cc: 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 Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/nospec-branch.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -257,20 +257,22 @@ static inline void indirect_branch_predi /* * With retpoline, we must use IBRS to restrict branch prediction * before calling into firmware. + * + * (Implemented as CPP macros due to header hell.) */ -static inline void firmware_restrict_branch_speculation_start(void) -{ - preempt_disable(); - alternative_msr_write(MSR_IA32_SPEC_CTRL, SPEC_CTRL_IBRS, - X86_FEATURE_USE_IBRS_FW); -} +#define firmware_restrict_branch_speculation_start() \ +do { \ + preempt_disable(); \ + alternative_msr_write(MSR_IA32_SPEC_CTRL, SPEC_CTRL_IBRS, \ + X86_FEATURE_USE_IBRS_FW); \ +} while (0) -static inline void firmware_restrict_branch_speculation_end(void) -{ - alternative_msr_write(MSR_IA32_SPEC_CTRL, 0, - X86_FEATURE_USE_IBRS_FW); - preempt_enable(); -} +#define firmware_restrict_branch_speculation_end() \ +do { \ + alternative_msr_write(MSR_IA32_SPEC_CTRL, 0, \ + X86_FEATURE_USE_IBRS_FW); \ + preempt_enable(); \ +} while (0) #endif /* __ASSEMBLY__ */