Skip to content

Commit 8374a27

Browse files
pa1guptabp3tk0v
authored andcommitted
x86/bugs: Introduce cdt_possible()
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
1 parent 7e44909 commit 8374a27

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

arch/x86/kernel/cpu/bugs.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,19 @@ early_param("nospectre_v1", nospectre_v1_cmdline);
11191119

11201120
enum spectre_v2_mitigation spectre_v2_enabled __ro_after_init = SPECTRE_V2_NONE;
11211121

1122+
/* Depends on spectre_v2 mitigation selected already */
1123+
static inline bool cdt_possible(enum spectre_v2_mitigation mode)
1124+
{
1125+
if (!IS_ENABLED(CONFIG_MITIGATION_CALL_DEPTH_TRACKING) ||
1126+
!IS_ENABLED(CONFIG_MITIGATION_RETPOLINE))
1127+
return false;
1128+
1129+
if (mode == SPECTRE_V2_RETPOLINE)
1130+
return true;
1131+
1132+
return false;
1133+
}
1134+
11221135
#undef pr_fmt
11231136
#define pr_fmt(fmt) "RETBleed: " fmt
11241137

@@ -1267,7 +1280,7 @@ static void __init retbleed_update_mitigation(void)
12671280
retbleed_mitigation = RETBLEED_MITIGATION_STUFF;
12681281

12691282
if (retbleed_mitigation == RETBLEED_MITIGATION_STUFF &&
1270-
spectre_v2_enabled != SPECTRE_V2_RETPOLINE) {
1283+
!cdt_possible(spectre_v2_enabled)) {
12711284
pr_err("WARNING: retbleed=stuff depends on spectre_v2=retpoline\n");
12721285
retbleed_mitigation = RETBLEED_MITIGATION_NONE;
12731286
}

0 commit comments

Comments
 (0)