Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5763978imm; Mon, 23 Jul 2018 05:47:46 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcMtOFsFr9OfT7ejCNWqEEnVOX1sTt1yHeHF85qhP1/yNlD2GG1bLCXlLeLj5w0K0iWG2T6 X-Received: by 2002:a65:4783:: with SMTP id e3-v6mr12224511pgs.235.1532350066065; Mon, 23 Jul 2018 05:47:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532350066; cv=none; d=google.com; s=arc-20160816; b=ZqnLCfCtFzuzm88aZ5vM+lob+qiZJQJxtTaaYr8JHW0YTJFxKlsRwvFPS8nLkBUscL W42GUOStcllQAZj6DKmPFGrRsYz0Mxfh/rpFyK9eczlgx6ech+URx+YNw0390RQJmHfJ SQBBVN2St2oC5Nm2QrS6QSc+0WrVkh2VFen+XNu8umXtdks7MU+KoMgbl89Z8JsHU4Mr qtzFHggX4WaMfKmLrpMoXVmNnODLGjDRQj0NFxT86/8hLe507BqN0fDrmav93tmhlt2j vgREbm3j/Is4wtvS4DUvaU0Hio32eEL3oQfq4b4eFWcLCbTvKoXHahLzLgSwKA4QO+Ba 1MHA== 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=jcNMcr3Miazpuis96fxv6GUpARXsvRvOYujR0jl37D8=; b=K5U0SCrRz4lQeOtLO6WEKdSBjE9ZJ8fwtFGqxYmmDhONqN0JJtFJlYrzH1U+PzMDV2 R0M9joEC4I30pPqF9q54b6G878rOLYY9qIVu/Swk8kQ+MYuLEYPIWyKVq2Zb06mT1UoD Z9VbfiEasVE6y49ahEMjjrXXRC5ar2XjT1DscxtGFjCEdZASkIBD4vxR93hR8aFHOHX2 QihRqJE66kC9jk4jFkK2mHa4yc63a+U03Y0CBXYezBIF0VkEwDGCUBpCKrjknu1M4Ib5 YsPFsZegTDRfHXj47d0RkP74wjPtayrJnFfdiwQWQVdZqn5FUoEQjKBPZob9fyJ6B6W/ RCMg== 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 j124-v6si9361930pfb.191.2018.07.23.05.47.31; Mon, 23 Jul 2018 05: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 S2389058AbeGWNr2 (ORCPT + 99 others); Mon, 23 Jul 2018 09:47:28 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50852 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388007AbeGWNr1 (ORCPT ); Mon, 23 Jul 2018 09:47:27 -0400 Received: from localhost (LFbn-1-12238-233.w90-92.abo.wanadoo.fr [90.92.53.233]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id CB657CA5; Mon, 23 Jul 2018 12:44:22 +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 , "Srivatsa S. Bhat" , "Matt Helsley (VMware)" , Alexey Makhalov , Bo Gan Subject: [PATCH 4.4 042/107] x86/speculation: Move firmware_restrict_branch_speculation_*() from C to CPP Date: Mon, 23 Jul 2018 14:41:36 +0200 Message-Id: <20180723122414.989603876@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180723122413.003644357@linuxfoundation.org> References: <20180723122413.003644357@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.4-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 Signed-off-by: Srivatsa S. Bhat Reviewed-by: Matt Helsley (VMware) Reviewed-by: Alexey Makhalov Reviewed-by: Bo Gan 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 @@ -214,20 +214,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__ */