Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2264513imm; Thu, 7 Jun 2018 07:55:55 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLEROZ5W4g3gZILJZowrQFzQYb6r+v4ngeMxOGT3t6trOhD4+5fg4Y4Hjlo2lvA6AGVBnHH X-Received: by 2002:a63:7b07:: with SMTP id w7-v6mr1787539pgc.199.1528383355538; Thu, 07 Jun 2018 07:55:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528383355; cv=none; d=google.com; s=arc-20160816; b=fpgjhMNcDIsWkq/w+mHqUBtOYK/96X9swiqrfgyTKfQj1OnA6LlfkdfaNgzVgWmTEV ohQsTSRO27CtBBl++4WhqNN/W2a1j4fIAQQdtiaBQvgGtxoAsJzorRzOqUP0HFryNuR7 1LQhir0X1S1f/dJaC6mLbcAF44GOfzOmgQoY4y7GApkbjSlmRAObB5RnMi7IwSjnK7lf C7Y5uqXGuEwQvPUQv6MngInVRMvxOuuJmKtdctV/CMyAtY8HPkBm3CeX3IzkarazxEEU tTMN2LuY1rcAEP9EP1YhS7UGJ3yi7mDvsPBsGo0+/iJTTFyVVVCUrTGdwN8PTWxJDwye bVoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=w+CbAw+ySAPfXB1r5S/KMiG13nvPLdTJ50Bz/DueULk=; b=Me/5FNZwdVNFmv77dmoq0+LUn+Sbz5K/xstQJ1VBSk4y8qqtmdYXyyphJMesGjOoBe 62yNJKkWbxJqTwXnh4lsNdKxWPk8/d6bvAMb/JvjQZqRTWki4rt9lPDRB/3mYGYtrK7H GRdovSKCyRR/Ar0Ie5HQmgBGAC904MZvcEC8bRA6DjX47NCbaSQr/EH0ayQQ+OrjOAhf Gwy6C9hXgU5Iu+8gNk72jHOh2AaBzdr0zO0BYxHJ/JQyWmF1EMqLzCmcZv88QUN68UZ/ EJV9Si+eKNywEXx4wccyxNWNxDE9Ar9lEH4/xsI2i5JYgBB7LMYo2zGWU/XkprLjv3nq ViWA== 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 j33-v6si54317819pld.151.2018.06.07.07.55.40; Thu, 07 Jun 2018 07:55:55 -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 S935385AbeFGOyg (ORCPT + 99 others); Thu, 7 Jun 2018 10:54:36 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:41002 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933205AbeFGOyd (ORCPT ); Thu, 7 Jun 2018 10:54:33 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbw-0005Zl-W4; Thu, 07 Jun 2018 15:09:57 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvaz-0002kw-GW; Thu, 07 Jun 2018 15:08:57 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, rkrcmar@redhat.com, dave.hansen@intel.com, arjan.van.de.ven@intel.com, "Linus Torvalds" , "Thomas Gleixner" , kvm@vger.kernel.org, karahmed@amazon.de, "Ingo Molnar" , pbonzini@redhat.com, jmattson@google.com, "Peter Zijlstra" , bp@alien8.de, "David Woodhouse" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 060/410] x86/speculation: Move firmware_restrict_branch_speculation_*() from C to CPP In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 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: Ben Hutchings --- arch/x86/include/asm/nospec-branch.h | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -213,20 +213,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__ */ #endif /* _ASM_X86_NOSPEC_BRANCH_H_ */