[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251013143444.3999-4-david.kaplan@amd.com>
Date: Mon, 13 Oct 2025 09:33:51 -0500
From: David Kaplan <david.kaplan@....com>
To: Thomas Gleixner <tglx@...utronix.de>, Borislav Petkov <bp@...en8.de>,
Peter Zijlstra <peterz@...radead.org>, Josh Poimboeuf <jpoimboe@...nel.org>,
Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>, Ingo Molnar
<mingo@...hat.com>, Dave Hansen <dave.hansen@...ux.intel.com>,
<x86@...nel.org>, "H . Peter Anvin" <hpa@...or.com>
CC: Alexander Graf <graf@...zon.com>, Boris Ostrovsky
<boris.ostrovsky@...cle.com>, <linux-kernel@...r.kernel.org>
Subject: [RFC PATCH 03/56] cpu: Reset global mitigations
Reset global mitigations, including attack vectors and then call the
arch-specific function to reset further mitigations.
Signed-off-by: David Kaplan <david.kaplan@....com>
---
include/linux/cpu.h | 3 +++
kernel/cpu.c | 18 ++++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 487b3bf2e1ea..3da629a76a49 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -208,6 +208,9 @@ enum smt_mitigations {
SMT_MITIGATIONS_ON,
};
+void cpu_reset_mitigations(void);
+void arch_cpu_reset_mitigations(void);
+
#ifdef CONFIG_CPU_MITIGATIONS
extern bool cpu_mitigations_off(void);
extern bool cpu_mitigations_auto_nosmt(void);
diff --git a/kernel/cpu.c b/kernel/cpu.c
index db9f6c539b28..910249f6217a 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -3171,6 +3171,7 @@ void __init boot_cpu_hotplug_init(void)
}
#ifdef CONFIG_CPU_MITIGATIONS
+
/*
* All except the cross-thread attack vector are mitigated by default.
* Cross-thread mitigation often requires disabling SMT which is expensive
@@ -3326,3 +3327,20 @@ static int __init mitigations_parse_cmdline(char *arg)
}
#endif
early_param("mitigations", mitigations_parse_cmdline);
+
+#ifdef CONFIG_DYNAMIC_MITIGATIONS
+void __weak arch_cpu_reset_mitigations(void)
+{
+}
+
+void cpu_reset_mitigations(void)
+{
+ smt_mitigations = SMT_MITIGATIONS_AUTO;
+ cpu_mitigations = CPU_MITIGATIONS_AUTO;
+ attack_vectors[CPU_MITIGATE_USER_KERNEL] = true;
+ attack_vectors[CPU_MITIGATE_USER_USER] = true;
+ attack_vectors[CPU_MITIGATE_GUEST_HOST] = IS_ENABLED(CONFIG_KVM);
+ attack_vectors[CPU_MITIGATE_GUEST_GUEST] = IS_ENABLED(CONFIG_KVM);
+ arch_cpu_reset_mitigations();
+}
+#endif
--
2.34.1
Powered by blists - more mailing lists