Received: by 10.213.65.68 with SMTP id h4csp514557imn; Fri, 16 Mar 2018 10:04:46 -0700 (PDT) X-Google-Smtp-Source: AG47ELv17g5ANQtabcJR56xXfqUu3HM8N+N8fWX90c9K3fL4Bs6YesP05j5L6htaoCpZqOrPwPo3 X-Received: by 2002:a17:902:bf04:: with SMTP id bi4-v6mr2825474plb.59.1521219886822; Fri, 16 Mar 2018 10:04:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521219886; cv=none; d=google.com; s=arc-20160816; b=WdAJ5W9xDkXO3CdfvHBqWpNV1tiCpTf+aBlh7wP3NMvYYDZB39ua8QyN6rgo/jG0fl yW+/sm9LryytcLGYfKHfGQV6bGF8Cjr2pUvvnf0ad0B+eW3dAsgc+pgKUjJG2Z5hQNkW EHrJbnOrBKvXKao4+Hw0306wufrgERPJ62g05rV9XHbE5iwoJYxEvM9lR68DWzQuEvbY BlKyT49NSl5Pk/CPzewC7baxAFMeQakweUi/vYiiUGPwqKetedGPL0lu+mdUHAQ6ET4C ArtNVXugW/42LokwyfezPa2mn46jLQ7zfot9+DPk3evyZodpuk+5WMZrtaK4pt/byFTu hZag== 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=X7ApD6Lph2yKUs3bFhby+teuTrG1pRTP58dAsXJXNbE=; b=mT2pdheCuAF+nYZytsazA7uoEWWSe5OKaPPm5wFJ/FWgMTptPtNN6MRHUTjP6Wxd1j tg+I74thYLoeInB9h6O/O56jwbOuI/e7mhTMG9H2RZ4ZjByBfF8DEpzzwNmecHNaRPRP PgAt+OYRt8thMI5s0Bzn6zUu5phPlu5Dp6XQoWbncW9oFRODgzaNyfOi1wJ3Kt/5aa1K AqbniHEm0ez4aGbQqv50Zn537IXUsuFi6XRT+9HcqUJtqwXSwFHRIJLRexHmouwsgjje 6CsvZ/bS+yrX4uuncO/adQo/ASZij1XRkO0m2Nj2MTsHouoUQt3li9GAeICKvW1MC7gx aSpg== 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 o61-v6si6252771pld.692.2018.03.16.10.04.32; Fri, 16 Mar 2018 10:04: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 S933562AbeCPPcc (ORCPT + 99 others); Fri, 16 Mar 2018 11:32:32 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38022 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932303AbeCPPc3 (ORCPT ); Fri, 16 Mar 2018 11:32:29 -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 0856A11BF; Fri, 16 Mar 2018 15:32:28 +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 45/86] x86/speculation: Move firmware_restrict_branch_speculation_*() from C to CPP Date: Fri, 16 Mar 2018 16:23:08 +0100 Message-Id: <20180316152320.495213037@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: 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__ */