]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
x86/bugs: Introduce cdt_possible()
authorPawan Gupta <pawan.kumar.gupta@linux.intel.com>
Wed, 11 Jun 2025 17:30:03 +0000 (10:30 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Aug 2025 14:38:28 +0000 (16:38 +0200)
[ Upstream commit 8374a2719df2a00781e6821e373d7de71390d1b4 ]

In preparation to allow ITS to also enable stuffing aka Call Depth
Tracking (CDT) independently of retbleed, introduce a helper
cdt_possible().

Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250611-eibrs-fix-v4-5-5ff86cac6c61@linux.intel.com
Stable-dep-of: ab9f2388e0b9 ("x86/bugs: Allow ITS stuffing in eIBRS+retpoline mode also")
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/kernel/cpu/bugs.c

index 937971fde749d5df1f66933e5417a82daece588a..0426500307f07153a62af58310cb2a0df430f1b3 100644 (file)
@@ -1124,6 +1124,19 @@ early_param("nospectre_v1", nospectre_v1_cmdline);
 
 enum spectre_v2_mitigation spectre_v2_enabled __ro_after_init = SPECTRE_V2_NONE;
 
+/* Depends on spectre_v2 mitigation selected already */
+static inline bool cdt_possible(enum spectre_v2_mitigation mode)
+{
+       if (!IS_ENABLED(CONFIG_MITIGATION_CALL_DEPTH_TRACKING) ||
+           !IS_ENABLED(CONFIG_MITIGATION_RETPOLINE))
+               return false;
+
+       if (mode == SPECTRE_V2_RETPOLINE)
+               return true;
+
+       return false;
+}
+
 #undef pr_fmt
 #define pr_fmt(fmt)     "RETBleed: " fmt
 
@@ -1272,7 +1285,7 @@ static void __init retbleed_update_mitigation(void)
                retbleed_mitigation = RETBLEED_MITIGATION_STUFF;
 
        if (retbleed_mitigation == RETBLEED_MITIGATION_STUFF &&
-           spectre_v2_enabled != SPECTRE_V2_RETPOLINE) {
+           !cdt_possible(spectre_v2_enabled)) {
                pr_err("WARNING: retbleed=stuff depends on spectre_v2=retpoline\n");
                retbleed_mitigation = RETBLEED_MITIGATION_NONE;
        }