From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932776AbeARPJg (ORCPT ); Thu, 18 Jan 2018 10:09:36 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:58713 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754798AbeARO56 (ORCPT ); Thu, 18 Jan 2018 09:57:58 -0500 Message-Id: <20180118140152.955841165@infradead.org> User-Agent: quilt/0.63-1 Date: Thu, 18 Jan 2018 14:48:25 +0100 From: Peter Zijlstra From: Peter Zijlstra To: David Woodhouse , Thomas Gleixner , Josh Poimboeuf Cc: linux-kernel@vger.kernel.org, Dave Hansen , Ashok Raj , Tim Chen , Andy Lutomirski , Linus Torvalds , Greg KH , Andrea Arcangeli , Andi Kleen , Arjan Van De Ven , Dan Williams , Paolo Bonzini , Jun Nakajima , Asit Mallick , Jason Baron , Peter Zijlstra Subject: [PATCH 25/35] x86/speculation: Add inlines to control Indirect Branch Speculation References: <20180118134800.711245485@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline; filename=x86-specctrl--Add-inlines-to-control-Indirect-Branch-Speculation.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/nospec-branch.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -6,6 +6,7 @@ #include #include #include +#include /* * Fill the CPU return stack buffer. @@ -219,5 +220,16 @@ bool specctrl_force_enable_ibrs(void); bool specctrl_cond_enable_ibrs(bool full_retpoline); bool is_skylake_era(void); +static inline void stop_indirect_branch_speculation(void) +{ + if (static_cpu_has(X86_FEATURE_IBRS)) + native_wrmsrl(MSR_IA32_SPEC_CTRL, SPEC_CTRL_ENABLE_IBRS); +} + +static inline void restart_indirect_branch_speculation(void) +{ + if (static_cpu_has(X86_FEATURE_IBRS)) + native_wrmsrl(MSR_IA32_SPEC_CTRL, SPEC_CTRL_DISABLE_IBRS); +} #endif /* __ASSEMBLY__ */ #endif /* __NOSPEC_BRANCH_H__ */