[RFC PATCH 18/56] x86/bugs: Reset VMSCAPE mitigations

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

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

diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 6a3e079a85fc..fcb1337026f1 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -3446,6 +3446,15 @@ static void __init vmscape_apply_mitigation(void)
 		setup_force_cpu_cap(X86_FEATURE_IBPB_EXIT_TO_USER);
 }
 
+#ifdef CONFIG_DYNAMIC_MITIGATIONS
+static void vmscape_reset_mitigation(void)
+{
+	setup_clear_cpu_cap(X86_FEATURE_IBPB_EXIT_TO_USER);
+	vmscape_mitigation = IS_ENABLED(CONFIG_MITIGATION_VMSCAPE) ?
+		VMSCAPE_MITIGATION_AUTO : VMSCAPE_MITIGATION_NONE;
+}
+#endif
+
 #undef pr_fmt
 #define pr_fmt(fmt) fmt
 
@@ -3990,5 +3999,6 @@ void arch_cpu_reset_mitigations(void)
 	bhi_reset_mitigation();
 	its_reset_mitigation();
 	tsa_reset_mitigation();
+	vmscape_reset_mitigation();
 }
 #endif
-- 
2.34.1