Received: by 10.192.165.156 with SMTP id m28csp337572imm; Mon, 16 Apr 2018 00:32:32 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/veYpFsN1uG8nUjDO4N5puyYcKVDIJds2QNDMGjN4X31+RU5xWGDZ223tkw2CCKAMctfo+ X-Received: by 2002:a17:902:2006:: with SMTP id n6-v6mr6294286pla.125.1523863952578; Mon, 16 Apr 2018 00:32:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523863952; cv=none; d=google.com; s=arc-20160816; b=JC5zlNEtpv086Qsj1H4T+2Kz1oRJWCJp6mtKd1fPlMCSv8DnmLwCUosqLesfuIXkWJ RmWD67VbQZ0CgLc3UsYZ4hfS7JI8zct2xXboYANFxdqUktMbuiNvEut1GaiBk1MBbDp+ jL0rmBq/N0sRljJN1u1vBc2jhnh8/b7/CPxog6UAYkMWtZwAxLlgYdq9t5TrSviXY4Bu lo4uVoFu8pXpM/9577i97sMiUsDB/5GgghX4tOhSBZnHTxVYRlD2i8P18zZo1zDZTTK1 6Fc2/b7HDNUwh+WSZGMYr6R744HQCET/v9V+yBuC6/j1icd9rBNgkyZYoRuCxLR4d9Q0 KqhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=fDyNrLiGjcsefOvZRqOVVdwdFMsINsJxD4ShgQ86FE4=; b=NS5J7dUH7v9W1EO9+3DjKn/2lkF1lOT+Pr7IetJTxZYt06TG3AO16RNDtpgJzOXiNf dWOd+sQNi1Hk3MxDVW3DdDdWRCGPmwZwxco/MuiLGwDNdRw/u3pOG/su16W7wef8naBN v4qc+ZnwiCdDxqrfh6Oi0F5HVI1YU3r0bxZT7yjCJ4kdKy31ki6P8i05Ua5ME5lYLDs7 ugIcMYJ8z3MbkDE87bMTz3GeqjfF6Bhfn/kj79AM8CpkeImEF0eqaAoa/l4Yz89of2j5 fccRTiepzPCa+BSbCZqOX6eLZ1OF3UTUcdCwcSdljRZd6a9PZCYY4iLqKX9aXyCtk5Ha AFEQ== 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 h1-v6si11565593plh.375.2018.04.16.00.31.48; Mon, 16 Apr 2018 00:32:32 -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 S1753680AbeDPHFG (ORCPT + 99 others); Mon, 16 Apr 2018 03:05:06 -0400 Received: from mga11.intel.com ([192.55.52.93]:25777 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752896AbeDPHFF (ORCPT ); Mon, 16 Apr 2018 03:05:05 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Apr 2018 00:04:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,458,1517904000"; d="scan'208";a="43609605" Received: from unknown (HELO linux-youquan.bj.intel.com) ([10.238.155.175]) by orsmga003.jf.intel.com with ESMTP; 16 Apr 2018 00:04:26 -0700 From: Youquan Song To: youquan.song@intel.com Cc: youquan.song@linux.intel.com, Ingo Molnar , 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, linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: [PATCH 14/23] x86/speculation: Move firmware_restrict_branch_speculation_*() from C to CPP Date: Mon, 16 Apr 2018 14:32:53 -0400 Message-Id: <1523903583-14881-14-git-send-email-youquan.song@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1523903583-14881-1-git-send-email-youquan.song@intel.com> References: <1523903583-14881-1-git-send-email-youquan.song@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ingo Molnar (cherry picked from commit d72f4e29e6d84b7ec02ae93088aa459ac70e733b) 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 [Youquan Song: port to 4.4] Signed-off-by: Youquan Song --- arch/x86/include/asm/nospec-branch.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h index 27582aa..4675f65 100644 --- 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_prediction_barrier(void) /* * 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__ */ -- 1.9.1