[RFC PATCH 13/56] x86/bugs: Reset SRSO mitigations

David Kaplan
2025-10-13T14:35:29Z

Add function to reset SRSO mitigations back to their boot-time defaults.

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

diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 9a9d5309aa56..112553058ccc 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -3312,6 +3312,21 @@ static void __init srso_apply_mitigation(void)
}
}

+#ifdef CONFIG_DYNAMIC_MITIGATIONS
+static void srso_reset_mitigation(void)
+{
+ setup_clear_cpu_cap(X86_FEATURE_RETHUNK);
+ setup_clear_cpu_cap(X86_FEATURE_UNRET);
+ setup_clear_cpu_cap(X86_FEATURE_SRSO_ALIAS);
+ setup_clear_cpu_cap(X86_FEATURE_SRSO);
+ setup_clear_cpu_cap(X86_FEATURE_ENTRY_IBPB);
+ setup_clear_cpu_cap(X86_FEATURE_IBPB_ON_VMEXIT);
+ x86_pred_cmd = PRED_CMD_IBPB;
+ x86_return_thunk = __x86_return_thunk;
+ srso_mitigation = SRSO_MITIGATION_AUTO;
+}
+#endif
+
#undef pr_fmt
#define pr_fmt(fmt) "VMSCAPE: " fmt

@@ -3925,5 +3940,6 @@ void arch_cpu_reset_mitigations(void)
mds_reset_mitigation();
mmio_reset_mitigation();
srbds_reset_mitigation();
+ srso_reset_mitigation();
}
#endif
--
2.34.1