Received: by 10.213.65.68 with SMTP id h4csp429474imn; Tue, 13 Mar 2018 08:47:46 -0700 (PDT) X-Google-Smtp-Source: AG47ELsx1pIzeUsXj/Bbu2gvMtNw0IRp2uiNd5WBxBwHmsEdYBptlfou8e7WtMSW5WrKqXV6Pwgv X-Received: by 10.101.68.82 with SMTP id e18mr845492pgq.329.1520956066353; Tue, 13 Mar 2018 08:47:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520956066; cv=none; d=google.com; s=arc-20160816; b=HfOD1D22KrqznVScNZRM45nsQ+0vRrrNV1gs4Y73daJdjEtFUHV/6XESQ3YqLN54mf D55nzm3606JqR3FRUgd1ozuqS8ejJfzQqOC31eD40MCWI1x2KFLcIUWdhvdDel8/GyrJ ifU7CvtTRTvNnXE8JvrfkyEST9Bn2y7H1UTd0L67TfWIhcgPaw2MCUHkYeJY3T0ZnuPu /tc68HI/W8KYTG0vZY4qpYoAW23W1mQEvuSUzLNPw4/grs+edIl99MzPAZU94ikpPW+v 6Avd+tKww2SVcETVDuHutwyA1kUCjehZ7h8ZhD8lnCgSXQkXFpdQra9kvfY4Nyt61cit x/rA== 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=qqdTLy3x0uqVPPuwsQeAhdD6jKFHF9JqKQ/pHfwQN5A=; b=deLuHwdHT6KaJ8i35K+EnB1SVCMhLn5EhTXUd777yILMio0zqSGaGGmhPkbOQmJ6oL 97hDqCltAzIlDqUQLK69Ajqg1akWIH1HjpR2t2g6Oc2tPsMNDYss4bIIQw+87OgnVFIB SGjRQGLTjgwuK243TZHWsyJI6ibt7rA5H9m4ioP0nP4lJN6pBQA6s0goL08gVUAECMhc vaTSmP7LEKZu8StALr/YlXpEue3Ei+EMImX5uQK5edbnkYfJTMcf01NvWUqYdgcg94aJ /oOHNaHc5RwWjEdknUDYVYykN4RhAYYYZaGSUkUx+xzMgoA8V/Y0rWOVaxl9iYtcXeBr FJ5g== 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 m1-v6si289465pls.673.2018.03.13.08.47.31; Tue, 13 Mar 2018 08:47:46 -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 S935084AbeCMPqL (ORCPT + 99 others); Tue, 13 Mar 2018 11:46:11 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36854 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964817AbeCMPlZ (ORCPT ); Tue, 13 Mar 2018 11:41:25 -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 499F911F1; Tue, 13 Mar 2018 15:41:02 +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.14 127/140] x86/speculation: Move firmware_restrict_branch_speculation_*() from C to CPP Date: Tue, 13 Mar 2018 16:25:30 +0100 Message-Id: <20180313152506.718774430@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180313152458.201155692@linuxfoundation.org> References: <20180313152458.201155692@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.14-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__ */