This source file includes following definitions.
- x86_spec_ctrl_set_guest
- x86_spec_ctrl_restore_host
- ssbd_tif_to_spec_ctrl
- stibp_tif_to_spec_ctrl
- ssbd_spec_ctrl_to_tif
- stibp_spec_ctrl_to_tif
- ssbd_tif_to_amd_ls_cfg
- speculative_store_bypass_ht_init
1
2 #ifndef _ASM_X86_SPECCTRL_H_
3 #define _ASM_X86_SPECCTRL_H_
4
5 #include <linux/thread_info.h>
6 #include <asm/nospec-branch.h>
7
8
9
10
11
12
13
14
15
16 extern void x86_virt_spec_ctrl(u64 guest_spec_ctrl, u64 guest_virt_spec_ctrl, bool guest);
17
18
19
20
21
22
23
24
25
26 static inline
27 void x86_spec_ctrl_set_guest(u64 guest_spec_ctrl, u64 guest_virt_spec_ctrl)
28 {
29 x86_virt_spec_ctrl(guest_spec_ctrl, guest_virt_spec_ctrl, true);
30 }
31
32
33
34
35
36
37
38
39
40 static inline
41 void x86_spec_ctrl_restore_host(u64 guest_spec_ctrl, u64 guest_virt_spec_ctrl)
42 {
43 x86_virt_spec_ctrl(guest_spec_ctrl, guest_virt_spec_ctrl, false);
44 }
45
46
47 extern u64 x86_amd_ls_cfg_base;
48 extern u64 x86_amd_ls_cfg_ssbd_mask;
49
50 static inline u64 ssbd_tif_to_spec_ctrl(u64 tifn)
51 {
52 BUILD_BUG_ON(TIF_SSBD < SPEC_CTRL_SSBD_SHIFT);
53 return (tifn & _TIF_SSBD) >> (TIF_SSBD - SPEC_CTRL_SSBD_SHIFT);
54 }
55
56 static inline u64 stibp_tif_to_spec_ctrl(u64 tifn)
57 {
58 BUILD_BUG_ON(TIF_SPEC_IB < SPEC_CTRL_STIBP_SHIFT);
59 return (tifn & _TIF_SPEC_IB) >> (TIF_SPEC_IB - SPEC_CTRL_STIBP_SHIFT);
60 }
61
62 static inline unsigned long ssbd_spec_ctrl_to_tif(u64 spec_ctrl)
63 {
64 BUILD_BUG_ON(TIF_SSBD < SPEC_CTRL_SSBD_SHIFT);
65 return (spec_ctrl & SPEC_CTRL_SSBD) << (TIF_SSBD - SPEC_CTRL_SSBD_SHIFT);
66 }
67
68 static inline unsigned long stibp_spec_ctrl_to_tif(u64 spec_ctrl)
69 {
70 BUILD_BUG_ON(TIF_SPEC_IB < SPEC_CTRL_STIBP_SHIFT);
71 return (spec_ctrl & SPEC_CTRL_STIBP) << (TIF_SPEC_IB - SPEC_CTRL_STIBP_SHIFT);
72 }
73
74 static inline u64 ssbd_tif_to_amd_ls_cfg(u64 tifn)
75 {
76 return (tifn & _TIF_SSBD) ? x86_amd_ls_cfg_ssbd_mask : 0ULL;
77 }
78
79 #ifdef CONFIG_SMP
80 extern void speculative_store_bypass_ht_init(void);
81 #else
82 static inline void speculative_store_bypass_ht_init(void) { }
83 #endif
84
85 extern void speculation_ctrl_update(unsigned long tif);
86 extern void speculation_ctrl_update_current(void);
87
88 #endif