Received: by 10.192.165.156 with SMTP id m28csp869619imm; Mon, 16 Apr 2018 10:00:45 -0700 (PDT) X-Google-Smtp-Source: AIpwx48mgEMyHYJ0BBwY8VMDXgkbbGlndH/tqDHnQJbDmjuUCTzjg1xwTwtqRbvc7fhz8aQ0eAi5 X-Received: by 2002:a17:902:a603:: with SMTP id u3-v6mr9419838plq.214.1523898045430; Mon, 16 Apr 2018 10:00:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523898045; cv=none; d=google.com; s=arc-20160816; b=LMplYSmdxsoKg+swAjIaT1Rfzfv5SlXjrHqdHgN6zxScUoQA55dY0OZ7noUbGnjZ+x EpCP1OwbI35wGrFeZDXTwoFP15TBxn4W1VwYLF0Ty1Tk2EPN3zMfwdNMB7b0rwCPYUPt zgck3vWnOQCZa1+bfXSHD9NOlhf4wpwKJgSYPzr1WEiH+E8rCNjnL9FM1zYgF/UW0D3b FGWuBdZXOxNLZdG5fMyo2MZBhEcpcn8iiu9APINbj2rDozfznvb/EII6uVcpfJwh5gJZ KsUNlqtAKtGyghfQnsx9k5zpIHO+96ivJ3tMlxWS7DKXTPHV1mc+0ufxvlezQA/Y6p+d V55w== 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=nncuq4mVXrYaJ7IoeVyxqMcXRBO+XcciQ1p5d2aGH5oRj7LA/iiT0WjSy+yBq4cRk8 kQM5iXWdK7wfQBwNFEOMYMqdczWnaBgMjXUvvQEF73laCGR8AS4GPjwbfSAW3jFGdQc4 v98d2ndaWwDF4NSdmg7W5xkc3Qkgd51GUsWyITkgbBYSN79zqpjLSJsQ05A7kIGa6jBj 0M0jrmiQCq322MNpkmTZC7yDwltXVJZCXrdNgpoZ8XyV+zPKmezzGWYis3JVV2c/IgmC fHpRDU3xzgu80WO+/tdBXBw+/VajxIa4iPsS7dPCLbXfw/g0+lhDQ0m6qZehM82bkX6x wCAA== 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 g28-v6si6205992plj.529.2018.04.16.10.00.06; Mon, 16 Apr 2018 10:00:45 -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 S1753057AbeDPQ6a (ORCPT + 99 others); Mon, 16 Apr 2018 12:58:30 -0400 Received: from mga09.intel.com ([134.134.136.24]:60647 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752947AbeDPQ62 (ORCPT ); Mon, 16 Apr 2018 12:58:28 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Apr 2018 09:58:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,459,1517904000"; d="scan'208";a="33033993" Received: from unknown (HELO linux-youquan.bj.intel.com) ([10.238.155.175]) by fmsmga008.fm.intel.com with ESMTP; 16 Apr 2018 09:58:24 -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: Tue, 17 Apr 2018 00:27:10 -0400 Message-Id: <1523939240-16508-14-git-send-email-youquan.song@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1523939240-16508-1-git-send-email-youquan.song@intel.com> References: <1523939240-16508-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