diff options
Diffstat (limited to 'arch/x86/kernel/cpu/bugs.c')
-rw-r--r-- | arch/x86/kernel/cpu/bugs.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 8e327bfec513..7416fc206b4a 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c | |||
@@ -162,6 +162,36 @@ x86_virt_spec_ctrl(u64 guest_spec_ctrl, u64 guest_virt_spec_ctrl, bool setguest) | |||
162 | wrmsrl(MSR_IA32_SPEC_CTRL, msrval); | 162 | wrmsrl(MSR_IA32_SPEC_CTRL, msrval); |
163 | } | 163 | } |
164 | } | 164 | } |
165 | |||
166 | /* | ||
167 | * If SSBD is not handled in MSR_SPEC_CTRL on AMD, update | ||
168 | * MSR_AMD64_L2_CFG or MSR_VIRT_SPEC_CTRL if supported. | ||
169 | */ | ||
170 | if (!static_cpu_has(X86_FEATURE_LS_CFG_SSBD) && | ||
171 | !static_cpu_has(X86_FEATURE_VIRT_SSBD)) | ||
172 | return; | ||
173 | |||
174 | /* | ||
175 | * If the host has SSBD mitigation enabled, force it in the host's | ||
176 | * virtual MSR value. If its not permanently enabled, evaluate | ||
177 | * current's TIF_SSBD thread flag. | ||
178 | */ | ||
179 | if (static_cpu_has(X86_FEATURE_SPEC_STORE_BYPASS_DISABLE)) | ||
180 | hostval = SPEC_CTRL_SSBD; | ||
181 | else | ||
182 | hostval = ssbd_tif_to_spec_ctrl(ti->flags); | ||
183 | |||
184 | /* Sanitize the guest value */ | ||
185 | guestval = guest_virt_spec_ctrl & SPEC_CTRL_SSBD; | ||
186 | |||
187 | if (hostval != guestval) { | ||
188 | unsigned long tif; | ||
189 | |||
190 | tif = setguest ? ssbd_spec_ctrl_to_tif(guestval) : | ||
191 | ssbd_spec_ctrl_to_tif(hostval); | ||
192 | |||
193 | speculative_store_bypass_update(tif); | ||
194 | } | ||
165 | } | 195 | } |
166 | EXPORT_SYMBOL_GPL(x86_virt_spec_ctrl); | 196 | EXPORT_SYMBOL_GPL(x86_virt_spec_ctrl); |
167 | 197 | ||