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__ */