Received: by 10.192.165.156 with SMTP id m28csp765566imm; Tue, 17 Apr 2018 20:21:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx48mkK030g29IiajQNgZMUC3bAtCdfDDwWL1bVOsFlsNjFvfgmzdIBFrVBBrsYqdfICbJMoy X-Received: by 10.98.211.82 with SMTP id q79mr389783pfg.45.1524021668870; Tue, 17 Apr 2018 20:21:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524021668; cv=none; d=google.com; s=arc-20160816; b=jSxhlhDYs6JcE/RE/2r8KxJ5/gppcO3D3Jb2RI3jzLntvCt7Iocw9lD7GLF9KAqi8o T1TN9f2flsSOHsg9uLRiD3j7UJ1TAbjVzypdkV2Xa/W/YkPt7O1J95PzH3+Re8xAKwvA jCkQzovQiADpjHt/e/n/CeG5QnVGz8LOYcx3P1jYf8VsHbv794QuDTq/LCgABEsav8Zq n4JZlv/uPR4mIrLypDAGQRo4WvkpkjiyHgU0bMfhGvevMHz2UN0tEwbZogD5AvYwms2G /f8NnCyfLqoFIM1UL+dPoWBMn/ujYdmle4l1xySpyu3FZOtFVesKdFlK2NNyZqnfhb8+ nNkQ== 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=L3Fa1hLE7gRLvHJGIVKv0bvTkfUhBLi156LLb2KS9/o=; b=x+2WddomBwHi5ED6ERiBSB1EBZW8fWuQqLz11lWZWPpFpsaWgOBrQZIxnGlQmf0pQU FcMTDuz1wb57NXX6K4uYaQuY/ponVnYt5detug3E1+nhQZU8SguCQOFNzpJNaQG/0SbH 7qAS8U5XMueH73M615uhXP9ovNnORGrGti2tkQvuVEvO9X4bhjKs8RA//BBOS3yODfbV gvOQe3EkG+Nn/5U1UXEpA0F4TvF6bsLX0B5BY2NmA+N5IzOnI5ffN+LsHQx6bBw+qBhp m1EOsW1pt9817lof0OH/65HMFJBKuisw/3A1LuipLw2iu/+MQUzv0b7IJ/DSDHFac3VU hIgw== 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 e3si254741pgr.400.2018.04.17.20.20.54; Tue, 17 Apr 2018 20:21:08 -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 S1753731AbeDRDTu (ORCPT + 99 others); Tue, 17 Apr 2018 23:19:50 -0400 Received: from mga06.intel.com ([134.134.136.31]:36369 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753690AbeDRDTq (ORCPT ); Tue, 17 Apr 2018 23:19:46 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Apr 2018 20:19:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,464,1517904000"; d="scan'208";a="35084908" Received: from unknown (HELO linux-youquan.bj.intel.com) ([10.238.155.175]) by orsmga006.jf.intel.com with ESMTP; 17 Apr 2018 20:19:41 -0700 From: Youquan Song To: stable@vger.kernel.org, gregkh@linuxfoundation.org Cc: tim.c.chen@linux.intel.com, ashok.raj@intel.com, dave.hansen@intel.com, yi.y.sun@linux.intel.com, youquan.song@intel.com, youquan.song@linux.intel.com, Ingo Molnar , David Woodhouse , Thomas Gleixner , Linus Torvalds , Peter Zijlstra , arjan.van.de.ven@intel.com, bp@alien8.de, jmattson@google.com, karahmed@amazon.de, kvm@vger.kernel.org, pbonzini@redhat.com, rkrcmar@redhat.com, linux-kernel@vger.kernel.org Subject: [PATCH 14/24] x86/speculation: Move firmware_restrict_branch_speculation_*() from C to CPP Date: Wed, 18 Apr 2018 11:18:22 +0800 Message-Id: <1524021512-24022-15-git-send-email-youquan.song@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1524021512-24022-1-git-send-email-youquan.song@intel.com> References: <1524021512-24022-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: Youquan Song [v4.4 backport] --- 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.8.3.1