Skip to contentSkip to conversation

x86/speculation/srbds: do not try to turn mitigation off when not supported

PATCH Applied Ricardo Cañuelo 2 participants 2 messages Apr 1, 2022 – Apr 6, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 x86/speculation/srbds: do not try to turn mitigation off when not supported

When SRBDS is mitigated by TSX OFF, update_srbds_msr will still read and write to MSR_IA32_MCU_OPT_CTRL even when that is not supported by the microcode.

Checking for X86_FEATURE_SRBDS_CTRL as a CPU feature available makes more sense than checking for SRBDS_MITIGATION_UCODE_NEEDED as the found "mitigation".

---

Changes in v3:
- Simplified and more explicit solution proposed by Boris

 arch/x86/kernel/cpu/bugs.c | 7 +++++++
 1 file changed, 7 insertions(+)
arch/x86/kernel/cpu/bugs.c +7 -0
index 6296e1ebed1d..d879a6c93609 100644
@@ -446,6 +446,13 @@ void update_srbds_msr(void)
 	if (srbds_mitigation == SRBDS_MITIGATION_UCODE_NEEDED)
 		return;
 
+	/*
+	 * A MDS_NO CPU for which SRBDS mitigation is not needed due to TSX
+	 * being disabled and it hasn't received the SRBDS MSR microcode.
+	 */
+	if (!boot_cpu_has(X86_FEATURE_SRBDS_CTRL))
+		return;
+
 	rdmsrl(MSR_IA32_MCU_OPT_CTRL, mcu_ctrl);
 
 	switch (srbds_mitigation) {
Signature · 1 line
2.25.1
#1 lore raw

[tip: x86/cpu] x86/speculation/srbds: Do not try to turn mitigation off when not supported

The following commit has been merged into the x86/cpu branch of tip:

The following commit has been merged into the x86/cpu branch of tip:

Commit-ID:     0205f8a738ab9e62d849e88e543cfa6ce4c13163
Gitweb:        https://git.kernel.org/tip/0205f8a738ab9e62d849e88e543cfa6ce4c13163
Author:        Ricardo Cañuelo <[email protected]>
AuthorDate:    Fri, 01 Apr 2022 09:45:17 +02:00
Committer:     Borislav Petkov <[email protected]>
CommitterDate: Tue, 05 Apr 2022 21:55:57 +02:00

x86/speculation/srbds: Do not try to turn mitigation off when not supported

When SRBDS is mitigated by TSX OFF, update_srbds_msr() will still read and write to MSR_IA32_MCU_OPT_CTRL even when that MSR is not supported due to not having loaded the appropriate microcode.

Check for X86_FEATURE_SRBDS_CTRL which is set only when the respective microcode which adds MSR_IA32_MCU_OPT_CTRL is loaded.

Based on a patch by Thadeu Lima de Souza Cascardo <[email protected]>.

[ bp: Massage commit message. ]

---
 arch/x86/kernel/cpu/bugs.c | 7 +++++++
 1 file changed, 7 insertions(+)
arch/x86/kernel/cpu/bugs.c +7 -0
index 6296e1e..d879a6c 100644
@@ -446,6 +446,13 @@ void update_srbds_msr(void)
 	if (srbds_mitigation == SRBDS_MITIGATION_UCODE_NEEDED)
 		return;
 
+	/*
+	 * A MDS_NO CPU for which SRBDS mitigation is not needed due to TSX
+	 * being disabled and it hasn't received the SRBDS MSR microcode.
+	 */
+	if (!boot_cpu_has(X86_FEATURE_SRBDS_CTRL))
+		return;
+
 	rdmsrl(MSR_IA32_MCU_OPT_CTRL, mcu_ctrl);
 
 	switch (srbds_mitigation) {