[RFC PATCH 14/56] x86/bugs: Reset GDS mitigations

David Kaplan posted 56 patches 2 months, 1 week ago
[RFC PATCH 14/56] x86/bugs: Reset GDS mitigations
Posted by David Kaplan 2 months, 1 week ago
Add function to reset GDS mitigations back to their boot-time defaults.

Signed-off-by: David Kaplan <david.kaplan@amd.com>
---
 arch/x86/kernel/cpu/bugs.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 112553058ccc..e765ac0b9240 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1182,6 +1182,18 @@ static void __init gds_apply_mitigation(void)
 	pr_info("%s\n", gds_strings[gds_mitigation]);
 }
 
+#ifdef CONFIG_DYNAMIC_MITIGATIONS
+static void gds_reset_mitigation(void)
+{
+	/* To cause the MSR bit to be cleared. */
+	gds_mitigation = GDS_MITIGATION_OFF;
+	if (x86_arch_cap_msr & ARCH_CAP_GDS_CTRL)
+		update_gds_msr();
+	gds_mitigation =  IS_ENABLED(CONFIG_MITIGATION_GDS) ?
+		GDS_MITIGATION_AUTO : GDS_MITIGATION_OFF;
+}
+#endif
+
 static int __init gds_parse_cmdline(char *str)
 {
 	if (!str)
@@ -3941,5 +3953,6 @@ void arch_cpu_reset_mitigations(void)
 	mmio_reset_mitigation();
 	srbds_reset_mitigation();
 	srso_reset_mitigation();
+	gds_reset_mitigation();
 }
 #endif
-- 
2.34.1