Skip to content

Commit 612bc3b

Browse files
tlendackyIngo Molnar
authored andcommitted
x86/bugs: Fix the AMD SSBD usage of the SPEC_CTRL MSR
On AMD, the presence of the MSR_SPEC_CTRL feature does not imply that the SSBD mitigation support should use the SPEC_CTRL MSR. Other features could have caused the MSR_SPEC_CTRL feature to be set, while a different SSBD mitigation option is in place. Update the SSBD support to check for the actual SSBD features that will use the SPEC_CTRL MSR. Signed-off-by: Tom Lendacky <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: David Woodhouse <[email protected]> Cc: Konrad Rzeszutek Wilk <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Fixes: 6ac2f49 ("x86/bugs: Add AMD's SPEC_CTRL MSR usage") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 845d382 commit 612bc3b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

arch/x86/kernel/cpu/bugs.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ x86_virt_spec_ctrl(u64 guest_spec_ctrl, u64 guest_virt_spec_ctrl, bool setguest)
155155
guestval |= guest_spec_ctrl & x86_spec_ctrl_mask;
156156

157157
/* SSBD controlled in MSR_SPEC_CTRL */
158-
if (static_cpu_has(X86_FEATURE_SPEC_CTRL_SSBD))
158+
if (static_cpu_has(X86_FEATURE_SPEC_CTRL_SSBD) ||
159+
static_cpu_has(X86_FEATURE_AMD_SSBD))
159160
hostval |= ssbd_tif_to_spec_ctrl(ti->flags);
160161

161162
if (hostval != guestval) {
@@ -533,9 +534,10 @@ static enum ssb_mitigation __init __ssb_select_mitigation(void)
533534
* Intel uses the SPEC CTRL MSR Bit(2) for this, while AMD may
534535
* use a completely different MSR and bit dependent on family.
535536
*/
536-
if (!static_cpu_has(X86_FEATURE_MSR_SPEC_CTRL))
537+
if (!static_cpu_has(X86_FEATURE_SPEC_CTRL_SSBD) &&
538+
!static_cpu_has(X86_FEATURE_AMD_SSBD)) {
537539
x86_amd_ssb_disable();
538-
else {
540+
} else {
539541
x86_spec_ctrl_base |= SPEC_CTRL_SSBD;
540542
x86_spec_ctrl_mask |= SPEC_CTRL_SSBD;
541543
wrmsrl(MSR_IA32_SPEC_CTRL, x86_spec_ctrl_base);

0 commit comments

Comments
 (0)