1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_SPECCTRL_H_
3 #define _ASM_X86_SPECCTRL_H_
5 #include <linux/thread_info.h>
6 #include <asm/nospec-branch.h>
9 * On VMENTER we must preserve whatever view of the SPEC_CTRL MSR
10 * the guest has, while on VMEXIT we restore the host view. This
11 * would be easier if SPEC_CTRL were architecturally maskable or
12 * shadowable for guests but this is not (currently) the case.
13 * Takes the guest view of SPEC_CTRL MSR as a parameter.
15 extern void x86_spec_ctrl_set_guest(u64);
16 extern void x86_spec_ctrl_restore_host(u64);
18 /* AMD specific Speculative Store Bypass MSR data */
19 extern u64 x86_amd_ls_cfg_base;
20 extern u64 x86_amd_ls_cfg_rds_mask;
22 /* The Intel SPEC CTRL MSR base value cache */
23 extern u64 x86_spec_ctrl_base;
25 static inline u64 rds_tif_to_spec_ctrl(u64 tifn)
27 BUILD_BUG_ON(TIF_RDS < SPEC_CTRL_RDS_SHIFT);
28 return (tifn & _TIF_RDS) >> (TIF_RDS - SPEC_CTRL_RDS_SHIFT);
31 static inline u64 rds_tif_to_amd_ls_cfg(u64 tifn)
33 return (tifn & _TIF_RDS) ? x86_amd_ls_cfg_rds_mask : 0ULL;
36 extern void speculative_store_bypass_update(void);