* [PATCH v4 0/7] Retbleed fixes
@ 2025-06-11 17:28 Pawan Gupta
2025-06-11 17:29 ` [PATCH v4 1/7] x86/retbleed: Avoid AUTO after the select step Pawan Gupta
` (7 more replies)
0 siblings, 8 replies; 19+ messages in thread
From: Pawan Gupta @ 2025-06-11 17:28 UTC (permalink / raw)
To: x86
Cc: David Kaplan, linux-kernel, H. Peter Anvin, Josh Poimboeuf,
Borislav Petkov, Nikolay Borisov
v4:
- Replace the warning message in set_return_thunk() with an info. (Borislav)
- Collected tags.
- Rebased to v6.16-rc1.
v3: https://lore.kernel.org/r/20250522-eibrs-fix-v3-0-12704e291e1e@linux.intel.com
- Get rid of AUTO check in retbleed mitigation. (Borislav)
- Update commit message to mention the preparatory patch. (Nikolay)
- Collected tags.
v2: https://lore.kernel.org/r/20250521-eibrs-fix-v2-0-70e2598e932c@linux.intel.com
- Split the ITS stuffing patch into smaller patches. (Borislav)
- Zap spectre_v2_in_retpoline_mode() helper. (Borislav)
v1: https://lore.kernel.org/r/20250520-eibrs-fix-v1-2-91bacd35ed09@linux.intel.com
This series untangles retbleed and ITS mitigation.
Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
---
Pawan Gupta (7):
x86/retbleed: Avoid AUTO after the select step
x86/retbleed: Simplify the =stuff checks
x86/bugs: Avoid warning when overriding return thunk
x86/its: Use switch/case to apply mitigation
x86/retbleed: Introduce cdt_possible()
x86/its: Remove =stuff dependency on retbleed
x86/its: Allow stuffing in eIBRS+retpoline mode also
arch/x86/kernel/cpu/bugs.c | 93 ++++++++++++++++++++++++++--------------------
1 file changed, 52 insertions(+), 41 deletions(-)
---
base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
change-id: 20250520-eibrs-fix-6c452b697dbf
Best regards,
--
Thanks,
Pawan
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v4 1/7] x86/retbleed: Avoid AUTO after the select step
2025-06-11 17:28 [PATCH v4 0/7] Retbleed fixes Pawan Gupta
@ 2025-06-11 17:29 ` Pawan Gupta
2025-06-24 10:05 ` [tip: x86/bugs] x86/bugs: Avoid AUTO after the select step in the retbleed mitigation tip-bot2 for Pawan Gupta
2025-06-11 17:29 ` [PATCH v4 2/7] x86/retbleed: Simplify the =stuff checks Pawan Gupta
` (6 subsequent siblings)
7 siblings, 1 reply; 19+ messages in thread
From: Pawan Gupta @ 2025-06-11 17:29 UTC (permalink / raw)
To: x86
Cc: David Kaplan, linux-kernel, H. Peter Anvin, Josh Poimboeuf,
Borislav Petkov
Retbleed select function leaves the mitigation to AUTO in some cases.
Moreover, the update function can also set the mitigation to AUTO. This is
inconsistent with other mitigations and requires explicit handling of AUTO
at the end of update step.
Make sure a mitigation gets selected in the select step, and do not change
it to AUTO in the update step. When no mitigation can be selected leave it
to NONE, which is what AUTO was getting changed to in the end.
Suggested-by: Borislav Petkov <bp@alien8.de>
Acked-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
---
arch/x86/kernel/cpu/bugs.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 7f94e6a5497d9a2d312a76095e48d6b364565777..53649df2c4d66c6bd3aa34dec69af9df253bccfc 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1247,6 +1247,14 @@ static void __init retbleed_select_mitigation(void)
retbleed_mitigation = RETBLEED_MITIGATION_IBPB;
else
retbleed_mitigation = RETBLEED_MITIGATION_NONE;
+ } else if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) {
+ /* Final mitigation depends on spectre-v2 selection */
+ if (boot_cpu_has(X86_FEATURE_IBRS_ENHANCED))
+ retbleed_mitigation = RETBLEED_MITIGATION_EIBRS;
+ else if (boot_cpu_has(X86_FEATURE_IBRS))
+ retbleed_mitigation = RETBLEED_MITIGATION_IBRS;
+ else
+ retbleed_mitigation = RETBLEED_MITIGATION_NONE;
}
}
@@ -1255,9 +1263,6 @@ static void __init retbleed_update_mitigation(void)
if (!boot_cpu_has_bug(X86_BUG_RETBLEED) || cpu_mitigations_off())
return;
- if (retbleed_mitigation == RETBLEED_MITIGATION_NONE)
- goto out;
-
/*
* retbleed=stuff is only allowed on Intel. If stuffing can't be used
* then a different mitigation will be selected below.
@@ -1268,7 +1273,7 @@ static void __init retbleed_update_mitigation(void)
its_mitigation == ITS_MITIGATION_RETPOLINE_STUFF) {
if (spectre_v2_enabled != SPECTRE_V2_RETPOLINE) {
pr_err("WARNING: retbleed=stuff depends on spectre_v2=retpoline\n");
- retbleed_mitigation = RETBLEED_MITIGATION_AUTO;
+ retbleed_mitigation = RETBLEED_MITIGATION_NONE;
} else {
if (retbleed_mitigation != RETBLEED_MITIGATION_STUFF)
pr_info("Retbleed mitigation updated to stuffing\n");
@@ -1294,15 +1299,11 @@ static void __init retbleed_update_mitigation(void)
if (retbleed_mitigation != RETBLEED_MITIGATION_STUFF)
pr_err(RETBLEED_INTEL_MSG);
}
- /* If nothing has set the mitigation yet, default to NONE. */
- if (retbleed_mitigation == RETBLEED_MITIGATION_AUTO)
- retbleed_mitigation = RETBLEED_MITIGATION_NONE;
}
-out:
+
pr_info("%s\n", retbleed_strings[retbleed_mitigation]);
}
-
static void __init retbleed_apply_mitigation(void)
{
bool mitigate_smt = false;
--
2.34.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v4 2/7] x86/retbleed: Simplify the =stuff checks
2025-06-11 17:28 [PATCH v4 0/7] Retbleed fixes Pawan Gupta
2025-06-11 17:29 ` [PATCH v4 1/7] x86/retbleed: Avoid AUTO after the select step Pawan Gupta
@ 2025-06-11 17:29 ` Pawan Gupta
2025-06-24 10:05 ` [tip: x86/bugs] x86/bugs: Simplify the retbleed=stuff checks tip-bot2 for Pawan Gupta
2025-06-11 17:29 ` [PATCH v4 3/7] x86/bugs: Avoid warning when overriding return thunk Pawan Gupta
` (5 subsequent siblings)
7 siblings, 1 reply; 19+ messages in thread
From: Pawan Gupta @ 2025-06-11 17:29 UTC (permalink / raw)
To: x86
Cc: David Kaplan, linux-kernel, H. Peter Anvin, Josh Poimboeuf,
Nikolay Borisov, Borislav Petkov (AMD)
Simplify the nested checks, remove redundant print and comment.
Reviewed-by: Nikolay Borisov <nik.borisov@suse.com>
Acked-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
---
arch/x86/kernel/cpu/bugs.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 53649df2c4d66c6bd3aa34dec69af9df253bccfc..94d0de3e61aec32b3b67c8d21f89a8c67b93dff3 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1263,24 +1263,16 @@ static void __init retbleed_update_mitigation(void)
if (!boot_cpu_has_bug(X86_BUG_RETBLEED) || cpu_mitigations_off())
return;
- /*
- * retbleed=stuff is only allowed on Intel. If stuffing can't be used
- * then a different mitigation will be selected below.
- *
- * its=stuff will also attempt to enable stuffing.
- */
- if (retbleed_mitigation == RETBLEED_MITIGATION_STUFF ||
- its_mitigation == ITS_MITIGATION_RETPOLINE_STUFF) {
- if (spectre_v2_enabled != SPECTRE_V2_RETPOLINE) {
- pr_err("WARNING: retbleed=stuff depends on spectre_v2=retpoline\n");
- retbleed_mitigation = RETBLEED_MITIGATION_NONE;
- } else {
- if (retbleed_mitigation != RETBLEED_MITIGATION_STUFF)
- pr_info("Retbleed mitigation updated to stuffing\n");
+ /* ITS can also enable stuffing */
+ if (its_mitigation == ITS_MITIGATION_RETPOLINE_STUFF)
+ retbleed_mitigation = RETBLEED_MITIGATION_STUFF;
- retbleed_mitigation = RETBLEED_MITIGATION_STUFF;
- }
+ if (retbleed_mitigation == RETBLEED_MITIGATION_STUFF &&
+ spectre_v2_enabled != SPECTRE_V2_RETPOLINE) {
+ pr_err("WARNING: retbleed=stuff depends on spectre_v2=retpoline\n");
+ retbleed_mitigation = RETBLEED_MITIGATION_NONE;
}
+
/*
* Let IBRS trump all on Intel without affecting the effects of the
* retbleed= cmdline option except for call depth based stuffing
--
2.34.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v4 3/7] x86/bugs: Avoid warning when overriding return thunk
2025-06-11 17:28 [PATCH v4 0/7] Retbleed fixes Pawan Gupta
2025-06-11 17:29 ` [PATCH v4 1/7] x86/retbleed: Avoid AUTO after the select step Pawan Gupta
2025-06-11 17:29 ` [PATCH v4 2/7] x86/retbleed: Simplify the =stuff checks Pawan Gupta
@ 2025-06-11 17:29 ` Pawan Gupta
2025-06-24 10:05 ` [tip: x86/bugs] " tip-bot2 for Pawan Gupta
2025-06-11 17:29 ` [PATCH v4 4/7] x86/its: Use switch/case to apply mitigation Pawan Gupta
` (4 subsequent siblings)
7 siblings, 1 reply; 19+ messages in thread
From: Pawan Gupta @ 2025-06-11 17:29 UTC (permalink / raw)
To: x86
Cc: David Kaplan, linux-kernel, H. Peter Anvin, Josh Poimboeuf,
Borislav Petkov
The purpose of the warning is to prevent an unexpected change to the return
thunk mitigation. However, there are legitimate cases where the return
thunk is intentionally set more than once. For example, ITS and SRSO both
can set the return thunk after retbleed has set it. In both the cases
retbleed is still mitigated.
Replace the warning with an info about the active return thunk.
Suggested-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
---
arch/x86/kernel/cpu/bugs.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 94d0de3e61aec32b3b67c8d21f89a8c67b93dff3..20696abd1bef90aaf852fef1299b93d27c1f4da6 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -113,10 +113,9 @@ void (*x86_return_thunk)(void) __ro_after_init = __x86_return_thunk;
static void __init set_return_thunk(void *thunk)
{
- if (x86_return_thunk != __x86_return_thunk)
- pr_warn("x86/bugs: return thunk changed\n");
-
x86_return_thunk = thunk;
+
+ pr_info("active return thunk: %ps\n", thunk);
}
/* Update SPEC_CTRL MSR and its cached copy unconditionally */
--
2.34.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v4 4/7] x86/its: Use switch/case to apply mitigation
2025-06-11 17:28 [PATCH v4 0/7] Retbleed fixes Pawan Gupta
` (2 preceding siblings ...)
2025-06-11 17:29 ` [PATCH v4 3/7] x86/bugs: Avoid warning when overriding return thunk Pawan Gupta
@ 2025-06-11 17:29 ` Pawan Gupta
2025-06-24 10:05 ` [tip: x86/bugs] x86/bugs: Use switch/case in its_apply_mitigation() tip-bot2 for Pawan Gupta
2025-06-11 17:30 ` [PATCH v4 5/7] x86/retbleed: Introduce cdt_possible() Pawan Gupta
` (3 subsequent siblings)
7 siblings, 1 reply; 19+ messages in thread
From: Pawan Gupta @ 2025-06-11 17:29 UTC (permalink / raw)
To: x86
Cc: David Kaplan, linux-kernel, H. Peter Anvin, Josh Poimboeuf,
Nikolay Borisov
Prepare to apply stuffing mitigation in its_apply_mitigation(). This is
currently only done via retbleed mitigation. Also using switch/case makes
it evident that mitigation mode like VMEXIT_ONLY doesn't need any special
handling.
Reviewed-by: Nikolay Borisov <nik.borisov@suse.com>
Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
---
arch/x86/kernel/cpu/bugs.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 20696abd1bef90aaf852fef1299b93d27c1f4da6..e861e8884d6b5e16f08d5bda0f47d5056d26c1f4 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1468,15 +1468,21 @@ static void __init its_update_mitigation(void)
static void __init its_apply_mitigation(void)
{
+ switch (its_mitigation) {
+ case ITS_MITIGATION_OFF:
+ case ITS_MITIGATION_AUTO:
+ case ITS_MITIGATION_VMEXIT_ONLY:
/* its=stuff forces retbleed stuffing and is enabled there. */
- if (its_mitigation != ITS_MITIGATION_ALIGNED_THUNKS)
- return;
-
- if (!boot_cpu_has(X86_FEATURE_RETPOLINE))
- setup_force_cpu_cap(X86_FEATURE_INDIRECT_THUNK_ITS);
+ case ITS_MITIGATION_RETPOLINE_STUFF:
+ break;
+ case ITS_MITIGATION_ALIGNED_THUNKS:
+ if (!boot_cpu_has(X86_FEATURE_RETPOLINE))
+ setup_force_cpu_cap(X86_FEATURE_INDIRECT_THUNK_ITS);
- setup_force_cpu_cap(X86_FEATURE_RETHUNK);
- set_return_thunk(its_return_thunk);
+ setup_force_cpu_cap(X86_FEATURE_RETHUNK);
+ set_return_thunk(its_return_thunk);
+ break;
+ }
}
#undef pr_fmt
--
2.34.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v4 5/7] x86/retbleed: Introduce cdt_possible()
2025-06-11 17:28 [PATCH v4 0/7] Retbleed fixes Pawan Gupta
` (3 preceding siblings ...)
2025-06-11 17:29 ` [PATCH v4 4/7] x86/its: Use switch/case to apply mitigation Pawan Gupta
@ 2025-06-11 17:30 ` Pawan Gupta
2025-06-24 10:05 ` [tip: x86/bugs] x86/bugs: " tip-bot2 for Pawan Gupta
2025-06-11 17:30 ` [PATCH v4 6/7] x86/its: Remove =stuff dependency on retbleed Pawan Gupta
` (2 subsequent siblings)
7 siblings, 1 reply; 19+ messages in thread
From: Pawan Gupta @ 2025-06-11 17:30 UTC (permalink / raw)
To: x86; +Cc: David Kaplan, linux-kernel, H. Peter Anvin, Josh Poimboeuf
In preparation to allow ITS to also enable stuffing a.k.a. Call Depth
Tracking(CDT) independently of retbleed, introduce a helper cdt_possible().
Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
---
arch/x86/kernel/cpu/bugs.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index e861e8884d6b5e16f08d5bda0f47d5056d26c1f4..387610ad222d4dbd196bfb219145510a37979d73 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1119,6 +1119,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
@@ -1267,7 +1280,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;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v4 6/7] x86/its: Remove =stuff dependency on retbleed
2025-06-11 17:28 [PATCH v4 0/7] Retbleed fixes Pawan Gupta
` (4 preceding siblings ...)
2025-06-11 17:30 ` [PATCH v4 5/7] x86/retbleed: Introduce cdt_possible() Pawan Gupta
@ 2025-06-11 17:30 ` Pawan Gupta
2025-06-24 10:05 ` [tip: x86/bugs] x86/bugs: Remove its=stuff " tip-bot2 for Pawan Gupta
2025-06-11 17:30 ` [PATCH v4 7/7] x86/its: Allow stuffing in eIBRS+retpoline mode also Pawan Gupta
2025-06-22 16:01 ` [PATCH v4 0/7] Retbleed fixes Borislav Petkov
7 siblings, 1 reply; 19+ messages in thread
From: Pawan Gupta @ 2025-06-11 17:30 UTC (permalink / raw)
To: x86; +Cc: David Kaplan, linux-kernel, H. Peter Anvin, Josh Poimboeuf
Allow ITS to enable stuffing independent of retbleed. The dependency is
only on retpoline. It is a valid case for retbleed to be mitigated by eIBRS
while ITS deploys stuffing at the same time.
Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
---
arch/x86/kernel/cpu/bugs.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 387610ad222d4dbd196bfb219145510a37979d73..31f3db0a514ea3d6e2513c0f6e072b84e0117f08 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1467,13 +1467,8 @@ static void __init its_update_mitigation(void)
break;
}
- /*
- * retbleed_update_mitigation() will try to do stuffing if its=stuff.
- * If it can't, such as if spectre_v2!=retpoline, then fall back to
- * aligned thunks.
- */
if (its_mitigation == ITS_MITIGATION_RETPOLINE_STUFF &&
- retbleed_mitigation != RETBLEED_MITIGATION_STUFF)
+ !cdt_possible(spectre_v2_enabled))
its_mitigation = ITS_MITIGATION_ALIGNED_THUNKS;
pr_info("%s\n", its_strings[its_mitigation]);
@@ -1485,8 +1480,6 @@ static void __init its_apply_mitigation(void)
case ITS_MITIGATION_OFF:
case ITS_MITIGATION_AUTO:
case ITS_MITIGATION_VMEXIT_ONLY:
- /* its=stuff forces retbleed stuffing and is enabled there. */
- case ITS_MITIGATION_RETPOLINE_STUFF:
break;
case ITS_MITIGATION_ALIGNED_THUNKS:
if (!boot_cpu_has(X86_FEATURE_RETPOLINE))
@@ -1495,6 +1488,11 @@ static void __init its_apply_mitigation(void)
setup_force_cpu_cap(X86_FEATURE_RETHUNK);
set_return_thunk(its_return_thunk);
break;
+ case ITS_MITIGATION_RETPOLINE_STUFF:
+ setup_force_cpu_cap(X86_FEATURE_RETHUNK);
+ setup_force_cpu_cap(X86_FEATURE_CALL_DEPTH);
+ set_return_thunk(call_depth_return_thunk);
+ break;
}
}
--
2.34.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v4 7/7] x86/its: Allow stuffing in eIBRS+retpoline mode also
2025-06-11 17:28 [PATCH v4 0/7] Retbleed fixes Pawan Gupta
` (5 preceding siblings ...)
2025-06-11 17:30 ` [PATCH v4 6/7] x86/its: Remove =stuff dependency on retbleed Pawan Gupta
@ 2025-06-11 17:30 ` Pawan Gupta
2025-06-24 10:05 ` [tip: x86/bugs] x86/bugs: Allow ITS " tip-bot2 for Pawan Gupta
2025-06-24 12:23 ` tip-bot2 for Pawan Gupta
2025-06-22 16:01 ` [PATCH v4 0/7] Retbleed fixes Borislav Petkov
7 siblings, 2 replies; 19+ messages in thread
From: Pawan Gupta @ 2025-06-11 17:30 UTC (permalink / raw)
To: x86; +Cc: David Kaplan, linux-kernel, H. Peter Anvin, Josh Poimboeuf
After a recent restructuring of ITS mitigation, RSB stuffing can no
longer be enabled in eIBRS+Retpoline mode. Before ITS, retbleed
mitigation only allowed stuffing when eIBRS was not enabled. This was
perfectly fine since eIBRS mitigates retbleed.
However, RSB stuffing mitigation for ITS is still needed with eIBRS. The
restructuring solely relies on retbleed to deploy stuffing, and does not
allow it when eIBRS is enabled. This behavior is different from what was
before the restructuring. Fix it by allowing stuffing in eIBRS+retpoline
mode also.
Fixes: 8c57ca583ebf ("x86/bugs: Restructure ITS mitigation")
Closes: https://lore.kernel.org/lkml/20250519235101.2vm6sc5txyoykb2r@desk/
Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
---
arch/x86/kernel/cpu/bugs.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 31f3db0a514ea3d6e2513c0f6e072b84e0117f08..bdef2c9aa1b8b85a8e0ee7c959ea7afde81d443e 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1126,7 +1126,8 @@ static inline bool cdt_possible(enum spectre_v2_mitigation mode)
!IS_ENABLED(CONFIG_MITIGATION_RETPOLINE))
return false;
- if (mode == SPECTRE_V2_RETPOLINE)
+ if (mode == SPECTRE_V2_RETPOLINE ||
+ mode == SPECTRE_V2_EIBRS_RETPOLINE)
return true;
return false;
@@ -1281,7 +1282,7 @@ static void __init retbleed_update_mitigation(void)
if (retbleed_mitigation == RETBLEED_MITIGATION_STUFF &&
!cdt_possible(spectre_v2_enabled)) {
- pr_err("WARNING: retbleed=stuff depends on spectre_v2=retpoline\n");
+ pr_err("WARNING: retbleed=stuff depends on retpoline\n");
retbleed_mitigation = RETBLEED_MITIGATION_NONE;
}
@@ -1454,6 +1455,7 @@ static void __init its_update_mitigation(void)
its_mitigation = ITS_MITIGATION_OFF;
break;
case SPECTRE_V2_RETPOLINE:
+ case SPECTRE_V2_EIBRS_RETPOLINE:
/* Retpoline+CDT mitigates ITS */
if (retbleed_mitigation == RETBLEED_MITIGATION_STUFF)
its_mitigation = ITS_MITIGATION_RETPOLINE_STUFF;
--
2.34.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v4 0/7] Retbleed fixes
2025-06-11 17:28 [PATCH v4 0/7] Retbleed fixes Pawan Gupta
` (6 preceding siblings ...)
2025-06-11 17:30 ` [PATCH v4 7/7] x86/its: Allow stuffing in eIBRS+retpoline mode also Pawan Gupta
@ 2025-06-22 16:01 ` Borislav Petkov
2025-06-23 18:35 ` Pawan Gupta
7 siblings, 1 reply; 19+ messages in thread
From: Borislav Petkov @ 2025-06-22 16:01 UTC (permalink / raw)
To: Pawan Gupta
Cc: x86, David Kaplan, linux-kernel, H. Peter Anvin, Josh Poimboeuf,
Nikolay Borisov
On Wed, Jun 11, 2025 at 10:28:44AM -0700, Pawan Gupta wrote:
> Pawan Gupta (7):
> x86/retbleed: Avoid AUTO after the select step
> x86/retbleed: Simplify the =stuff checks
> x86/bugs: Avoid warning when overriding return thunk
> x86/its: Use switch/case to apply mitigation
> x86/retbleed: Introduce cdt_possible()
> x86/its: Remove =stuff dependency on retbleed
> x86/its: Allow stuffing in eIBRS+retpoline mode also
Note that the subject prefixes are "x86/bugs:" not the mitigations themselves.
https://kernel.org/doc/html/latest/process/maintainer-tip.html#patch-subject
I've fixed them up.
Otherwise looks ok to me, lemme put them through the test.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v4 0/7] Retbleed fixes
2025-06-22 16:01 ` [PATCH v4 0/7] Retbleed fixes Borislav Petkov
@ 2025-06-23 18:35 ` Pawan Gupta
2025-06-24 14:53 ` Borislav Petkov
0 siblings, 1 reply; 19+ messages in thread
From: Pawan Gupta @ 2025-06-23 18:35 UTC (permalink / raw)
To: Borislav Petkov
Cc: x86, David Kaplan, linux-kernel, H. Peter Anvin, Josh Poimboeuf,
Nikolay Borisov
On Sun, Jun 22, 2025 at 06:01:22PM +0200, Borislav Petkov wrote:
> On Wed, Jun 11, 2025 at 10:28:44AM -0700, Pawan Gupta wrote:
> > Pawan Gupta (7):
> > x86/retbleed: Avoid AUTO after the select step
> > x86/retbleed: Simplify the =stuff checks
> > x86/bugs: Avoid warning when overriding return thunk
> > x86/its: Use switch/case to apply mitigation
> > x86/retbleed: Introduce cdt_possible()
> > x86/its: Remove =stuff dependency on retbleed
> > x86/its: Allow stuffing in eIBRS+retpoline mode also
>
> Note that the subject prefixes are "x86/bugs:" not the mitigations themselves.
>
> https://kernel.org/doc/html/latest/process/maintainer-tip.html#patch-subject
Ok.
Do you think also appending the vulnerability name like "x86/bugs/retbleed"
would be useful for someone filtering commits based on vulnerability?
> I've fixed them up.
Thanks.
^ permalink raw reply [flat|nested] 19+ messages in thread
* [tip: x86/bugs] x86/bugs: Allow ITS stuffing in eIBRS+retpoline mode also
2025-06-11 17:30 ` [PATCH v4 7/7] x86/its: Allow stuffing in eIBRS+retpoline mode also Pawan Gupta
@ 2025-06-24 10:05 ` tip-bot2 for Pawan Gupta
2025-06-24 12:23 ` tip-bot2 for Pawan Gupta
1 sibling, 0 replies; 19+ messages in thread
From: tip-bot2 for Pawan Gupta @ 2025-06-24 10:05 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Pawan Gupta, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: e88b1627b86eb756406ca0738c3db86351a58e4f
Gitweb: https://git.kernel.org/tip/e88b1627b86eb756406ca0738c3db86351a58e4f
Author: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
AuthorDate: Wed, 11 Jun 2025 10:30:33 -07:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Mon, 23 Jun 2025 12:29:49 +02:00
x86/bugs: Allow ITS stuffing in eIBRS+retpoline mode also
After a recent restructuring of the ITS mitigation, RSB stuffing can no longer
be enabled in eIBRS+Retpoline mode. Before ITS, retbleed mitigation only
allowed stuffing when eIBRS was not enabled. This was perfectly fine since
eIBRS mitigates retbleed.
However, RSB stuffing mitigation for ITS is still needed with eIBRS. The
restructuring solely relies on retbleed to deploy stuffing, and does not allow
it when eIBRS is enabled. This behavior is different from what was before the
restructuring. Fix it by allowing stuffing in eIBRS+retpoline mode also.
Fixes: 8c57ca583ebf ("x86/bugs: Restructure ITS mitigation")
Closes: https://lore.kernel.org/lkml/20250519235101.2vm6sc5txyoykb2r@desk/
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-7-5ff86cac6c61@linux.intel.com
---
arch/x86/kernel/cpu/bugs.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 31f3db0..bdef2c9 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1126,7 +1126,8 @@ static inline bool cdt_possible(enum spectre_v2_mitigation mode)
!IS_ENABLED(CONFIG_MITIGATION_RETPOLINE))
return false;
- if (mode == SPECTRE_V2_RETPOLINE)
+ if (mode == SPECTRE_V2_RETPOLINE ||
+ mode == SPECTRE_V2_EIBRS_RETPOLINE)
return true;
return false;
@@ -1281,7 +1282,7 @@ static void __init retbleed_update_mitigation(void)
if (retbleed_mitigation == RETBLEED_MITIGATION_STUFF &&
!cdt_possible(spectre_v2_enabled)) {
- pr_err("WARNING: retbleed=stuff depends on spectre_v2=retpoline\n");
+ pr_err("WARNING: retbleed=stuff depends on retpoline\n");
retbleed_mitigation = RETBLEED_MITIGATION_NONE;
}
@@ -1454,6 +1455,7 @@ static void __init its_update_mitigation(void)
its_mitigation = ITS_MITIGATION_OFF;
break;
case SPECTRE_V2_RETPOLINE:
+ case SPECTRE_V2_EIBRS_RETPOLINE:
/* Retpoline+CDT mitigates ITS */
if (retbleed_mitigation == RETBLEED_MITIGATION_STUFF)
its_mitigation = ITS_MITIGATION_RETPOLINE_STUFF;
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [tip: x86/bugs] x86/bugs: Introduce cdt_possible()
2025-06-11 17:30 ` [PATCH v4 5/7] x86/retbleed: Introduce cdt_possible() Pawan Gupta
@ 2025-06-24 10:05 ` tip-bot2 for Pawan Gupta
0 siblings, 0 replies; 19+ messages in thread
From: tip-bot2 for Pawan Gupta @ 2025-06-24 10:05 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Pawan Gupta, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 8374a2719df2a00781e6821e373d7de71390d1b4
Gitweb: https://git.kernel.org/tip/8374a2719df2a00781e6821e373d7de71390d1b4
Author: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
AuthorDate: Wed, 11 Jun 2025 10:30:03 -07:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Mon, 23 Jun 2025 12:26:57 +02:00
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
---
arch/x86/kernel/cpu/bugs.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index e861e88..387610a 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1119,6 +1119,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
@@ -1267,7 +1280,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;
}
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [tip: x86/bugs] x86/bugs: Remove its=stuff dependency on retbleed
2025-06-11 17:30 ` [PATCH v4 6/7] x86/its: Remove =stuff dependency on retbleed Pawan Gupta
@ 2025-06-24 10:05 ` tip-bot2 for Pawan Gupta
0 siblings, 0 replies; 19+ messages in thread
From: tip-bot2 for Pawan Gupta @ 2025-06-24 10:05 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Pawan Gupta, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: e2a9c03192f54bb53a5422bf5106bdc4d04a7426
Gitweb: https://git.kernel.org/tip/e2a9c03192f54bb53a5422bf5106bdc4d04a7426
Author: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
AuthorDate: Wed, 11 Jun 2025 10:30:18 -07:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Mon, 23 Jun 2025 12:29:04 +02:00
x86/bugs: Remove its=stuff dependency on retbleed
Allow ITS to enable stuffing independent of retbleed. The dependency is only
on retpoline. It is a valid case for retbleed to be mitigated by eIBRS while
ITS deploys stuffing at the same time.
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-6-5ff86cac6c61@linux.intel.com
---
arch/x86/kernel/cpu/bugs.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 387610a..31f3db0 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1467,13 +1467,8 @@ static void __init its_update_mitigation(void)
break;
}
- /*
- * retbleed_update_mitigation() will try to do stuffing if its=stuff.
- * If it can't, such as if spectre_v2!=retpoline, then fall back to
- * aligned thunks.
- */
if (its_mitigation == ITS_MITIGATION_RETPOLINE_STUFF &&
- retbleed_mitigation != RETBLEED_MITIGATION_STUFF)
+ !cdt_possible(spectre_v2_enabled))
its_mitigation = ITS_MITIGATION_ALIGNED_THUNKS;
pr_info("%s\n", its_strings[its_mitigation]);
@@ -1485,8 +1480,6 @@ static void __init its_apply_mitigation(void)
case ITS_MITIGATION_OFF:
case ITS_MITIGATION_AUTO:
case ITS_MITIGATION_VMEXIT_ONLY:
- /* its=stuff forces retbleed stuffing and is enabled there. */
- case ITS_MITIGATION_RETPOLINE_STUFF:
break;
case ITS_MITIGATION_ALIGNED_THUNKS:
if (!boot_cpu_has(X86_FEATURE_RETPOLINE))
@@ -1495,6 +1488,11 @@ static void __init its_apply_mitigation(void)
setup_force_cpu_cap(X86_FEATURE_RETHUNK);
set_return_thunk(its_return_thunk);
break;
+ case ITS_MITIGATION_RETPOLINE_STUFF:
+ setup_force_cpu_cap(X86_FEATURE_RETHUNK);
+ setup_force_cpu_cap(X86_FEATURE_CALL_DEPTH);
+ set_return_thunk(call_depth_return_thunk);
+ break;
}
}
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [tip: x86/bugs] x86/bugs: Use switch/case in its_apply_mitigation()
2025-06-11 17:29 ` [PATCH v4 4/7] x86/its: Use switch/case to apply mitigation Pawan Gupta
@ 2025-06-24 10:05 ` tip-bot2 for Pawan Gupta
0 siblings, 0 replies; 19+ messages in thread
From: tip-bot2 for Pawan Gupta @ 2025-06-24 10:05 UTC (permalink / raw)
To: linux-tip-commits
Cc: Pawan Gupta, Borislav Petkov (AMD), Nikolay Borisov, x86,
linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 7e44909e0ea8346ba08b244ecc275fc3394e2b8e
Gitweb: https://git.kernel.org/tip/7e44909e0ea8346ba08b244ecc275fc3394e2b8e
Author: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
AuthorDate: Wed, 11 Jun 2025 10:29:47 -07:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Mon, 23 Jun 2025 12:22:44 +02:00
x86/bugs: Use switch/case in its_apply_mitigation()
Prepare to apply stuffing mitigation in its_apply_mitigation(). This is
currently only done via retbleed mitigation. Also using switch/case
makes it evident that mitigation mode like VMEXIT_ONLY doesn't need any
special handling.
Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Nikolay Borisov <nik.borisov@suse.com>
Link: https://lore.kernel.org/20250611-eibrs-fix-v4-4-5ff86cac6c61@linux.intel.com
---
arch/x86/kernel/cpu/bugs.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 20696ab..e861e88 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1468,15 +1468,21 @@ static void __init its_update_mitigation(void)
static void __init its_apply_mitigation(void)
{
+ switch (its_mitigation) {
+ case ITS_MITIGATION_OFF:
+ case ITS_MITIGATION_AUTO:
+ case ITS_MITIGATION_VMEXIT_ONLY:
/* its=stuff forces retbleed stuffing and is enabled there. */
- if (its_mitigation != ITS_MITIGATION_ALIGNED_THUNKS)
- return;
-
- if (!boot_cpu_has(X86_FEATURE_RETPOLINE))
- setup_force_cpu_cap(X86_FEATURE_INDIRECT_THUNK_ITS);
+ case ITS_MITIGATION_RETPOLINE_STUFF:
+ break;
+ case ITS_MITIGATION_ALIGNED_THUNKS:
+ if (!boot_cpu_has(X86_FEATURE_RETPOLINE))
+ setup_force_cpu_cap(X86_FEATURE_INDIRECT_THUNK_ITS);
- setup_force_cpu_cap(X86_FEATURE_RETHUNK);
- set_return_thunk(its_return_thunk);
+ setup_force_cpu_cap(X86_FEATURE_RETHUNK);
+ set_return_thunk(its_return_thunk);
+ break;
+ }
}
#undef pr_fmt
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [tip: x86/bugs] x86/bugs: Avoid warning when overriding return thunk
2025-06-11 17:29 ` [PATCH v4 3/7] x86/bugs: Avoid warning when overriding return thunk Pawan Gupta
@ 2025-06-24 10:05 ` tip-bot2 for Pawan Gupta
0 siblings, 0 replies; 19+ messages in thread
From: tip-bot2 for Pawan Gupta @ 2025-06-24 10:05 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Borislav Petkov, Pawan Gupta, x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 9f85fdb9fc5a1bd308a10a0a7d7e34f2712ba58b
Gitweb: https://git.kernel.org/tip/9f85fdb9fc5a1bd308a10a0a7d7e34f2712ba58b
Author: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
AuthorDate: Wed, 11 Jun 2025 10:29:31 -07:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Mon, 23 Jun 2025 12:21:30 +02:00
x86/bugs: Avoid warning when overriding return thunk
The purpose of the warning is to prevent an unexpected change to the return
thunk mitigation. However, there are legitimate cases where the return
thunk is intentionally set more than once. For example, ITS and SRSO both
can set the return thunk after retbleed has set it. In both the cases
retbleed is still mitigated.
Replace the warning with an info about the active return thunk.
Suggested-by: Borislav Petkov <bp@alien8.de>
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-3-5ff86cac6c61@linux.intel.com
---
arch/x86/kernel/cpu/bugs.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 94d0de3..20696ab 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -113,10 +113,9 @@ void (*x86_return_thunk)(void) __ro_after_init = __x86_return_thunk;
static void __init set_return_thunk(void *thunk)
{
- if (x86_return_thunk != __x86_return_thunk)
- pr_warn("x86/bugs: return thunk changed\n");
-
x86_return_thunk = thunk;
+
+ pr_info("active return thunk: %ps\n", thunk);
}
/* Update SPEC_CTRL MSR and its cached copy unconditionally */
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [tip: x86/bugs] x86/bugs: Simplify the retbleed=stuff checks
2025-06-11 17:29 ` [PATCH v4 2/7] x86/retbleed: Simplify the =stuff checks Pawan Gupta
@ 2025-06-24 10:05 ` tip-bot2 for Pawan Gupta
0 siblings, 0 replies; 19+ messages in thread
From: tip-bot2 for Pawan Gupta @ 2025-06-24 10:05 UTC (permalink / raw)
To: linux-tip-commits
Cc: Pawan Gupta, Borislav Petkov (AMD), Nikolay Borisov, x86,
linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 530e80648bff083e1d19ad7248c0540812a9a35f
Gitweb: https://git.kernel.org/tip/530e80648bff083e1d19ad7248c0540812a9a35f
Author: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
AuthorDate: Wed, 11 Jun 2025 10:29:15 -07:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Mon, 23 Jun 2025 12:16:30 +02:00
x86/bugs: Simplify the retbleed=stuff checks
Simplify the nested checks, remove redundant print and comment.
Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Nikolay Borisov <nik.borisov@suse.com>
Acked-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250611-eibrs-fix-v4-2-5ff86cac6c61@linux.intel.com
---
arch/x86/kernel/cpu/bugs.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 53649df..94d0de3 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1263,24 +1263,16 @@ static void __init retbleed_update_mitigation(void)
if (!boot_cpu_has_bug(X86_BUG_RETBLEED) || cpu_mitigations_off())
return;
- /*
- * retbleed=stuff is only allowed on Intel. If stuffing can't be used
- * then a different mitigation will be selected below.
- *
- * its=stuff will also attempt to enable stuffing.
- */
- if (retbleed_mitigation == RETBLEED_MITIGATION_STUFF ||
- its_mitigation == ITS_MITIGATION_RETPOLINE_STUFF) {
- if (spectre_v2_enabled != SPECTRE_V2_RETPOLINE) {
- pr_err("WARNING: retbleed=stuff depends on spectre_v2=retpoline\n");
- retbleed_mitigation = RETBLEED_MITIGATION_NONE;
- } else {
- if (retbleed_mitigation != RETBLEED_MITIGATION_STUFF)
- pr_info("Retbleed mitigation updated to stuffing\n");
+ /* ITS can also enable stuffing */
+ if (its_mitigation == ITS_MITIGATION_RETPOLINE_STUFF)
+ retbleed_mitigation = RETBLEED_MITIGATION_STUFF;
- retbleed_mitigation = RETBLEED_MITIGATION_STUFF;
- }
+ if (retbleed_mitigation == RETBLEED_MITIGATION_STUFF &&
+ spectre_v2_enabled != SPECTRE_V2_RETPOLINE) {
+ pr_err("WARNING: retbleed=stuff depends on spectre_v2=retpoline\n");
+ retbleed_mitigation = RETBLEED_MITIGATION_NONE;
}
+
/*
* Let IBRS trump all on Intel without affecting the effects of the
* retbleed= cmdline option except for call depth based stuffing
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [tip: x86/bugs] x86/bugs: Avoid AUTO after the select step in the retbleed mitigation
2025-06-11 17:29 ` [PATCH v4 1/7] x86/retbleed: Avoid AUTO after the select step Pawan Gupta
@ 2025-06-24 10:05 ` tip-bot2 for Pawan Gupta
0 siblings, 0 replies; 19+ messages in thread
From: tip-bot2 for Pawan Gupta @ 2025-06-24 10:05 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Borislav Petkov, Pawan Gupta, x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: 98ff5c071d1cde9426b0bfa449c43d49ec58f1c4
Gitweb: https://git.kernel.org/tip/98ff5c071d1cde9426b0bfa449c43d49ec58f1c4
Author: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
AuthorDate: Wed, 11 Jun 2025 10:29:00 -07:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Mon, 23 Jun 2025 12:16:23 +02:00
x86/bugs: Avoid AUTO after the select step in the retbleed mitigation
The retbleed select function leaves the mitigation to AUTO in some cases.
Moreover, the update function can also set the mitigation to AUTO. This
is inconsistent with other mitigations and requires explicit handling of
AUTO at the end of update step.
Make sure a mitigation gets selected in the select step, and do not change
it to AUTO in the update step. When no mitigation can be selected leave it
to NONE, which is what AUTO was getting changed to in the end.
Suggested-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Acked-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250611-eibrs-fix-v4-1-5ff86cac6c61@linux.intel.com
---
arch/x86/kernel/cpu/bugs.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 7f94e6a..53649df 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1247,6 +1247,14 @@ static void __init retbleed_select_mitigation(void)
retbleed_mitigation = RETBLEED_MITIGATION_IBPB;
else
retbleed_mitigation = RETBLEED_MITIGATION_NONE;
+ } else if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) {
+ /* Final mitigation depends on spectre-v2 selection */
+ if (boot_cpu_has(X86_FEATURE_IBRS_ENHANCED))
+ retbleed_mitigation = RETBLEED_MITIGATION_EIBRS;
+ else if (boot_cpu_has(X86_FEATURE_IBRS))
+ retbleed_mitigation = RETBLEED_MITIGATION_IBRS;
+ else
+ retbleed_mitigation = RETBLEED_MITIGATION_NONE;
}
}
@@ -1255,9 +1263,6 @@ static void __init retbleed_update_mitigation(void)
if (!boot_cpu_has_bug(X86_BUG_RETBLEED) || cpu_mitigations_off())
return;
- if (retbleed_mitigation == RETBLEED_MITIGATION_NONE)
- goto out;
-
/*
* retbleed=stuff is only allowed on Intel. If stuffing can't be used
* then a different mitigation will be selected below.
@@ -1268,7 +1273,7 @@ static void __init retbleed_update_mitigation(void)
its_mitigation == ITS_MITIGATION_RETPOLINE_STUFF) {
if (spectre_v2_enabled != SPECTRE_V2_RETPOLINE) {
pr_err("WARNING: retbleed=stuff depends on spectre_v2=retpoline\n");
- retbleed_mitigation = RETBLEED_MITIGATION_AUTO;
+ retbleed_mitigation = RETBLEED_MITIGATION_NONE;
} else {
if (retbleed_mitigation != RETBLEED_MITIGATION_STUFF)
pr_info("Retbleed mitigation updated to stuffing\n");
@@ -1294,15 +1299,11 @@ static void __init retbleed_update_mitigation(void)
if (retbleed_mitigation != RETBLEED_MITIGATION_STUFF)
pr_err(RETBLEED_INTEL_MSG);
}
- /* If nothing has set the mitigation yet, default to NONE. */
- if (retbleed_mitigation == RETBLEED_MITIGATION_AUTO)
- retbleed_mitigation = RETBLEED_MITIGATION_NONE;
}
-out:
+
pr_info("%s\n", retbleed_strings[retbleed_mitigation]);
}
-
static void __init retbleed_apply_mitigation(void)
{
bool mitigate_smt = false;
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [tip: x86/bugs] x86/bugs: Allow ITS stuffing in eIBRS+retpoline mode also
2025-06-11 17:30 ` [PATCH v4 7/7] x86/its: Allow stuffing in eIBRS+retpoline mode also Pawan Gupta
2025-06-24 10:05 ` [tip: x86/bugs] x86/bugs: Allow ITS " tip-bot2 for Pawan Gupta
@ 2025-06-24 12:23 ` tip-bot2 for Pawan Gupta
1 sibling, 0 replies; 19+ messages in thread
From: tip-bot2 for Pawan Gupta @ 2025-06-24 12:23 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Pawan Gupta, Borislav Petkov (AMD), x86, linux-kernel
The following commit has been merged into the x86/bugs branch of tip:
Commit-ID: ab9f2388e0b99cd164ddbd74a6133d3070e2788d
Gitweb: https://git.kernel.org/tip/ab9f2388e0b99cd164ddbd74a6133d3070e2788d
Author: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
AuthorDate: Wed, 11 Jun 2025 10:30:33 -07:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Tue, 24 Jun 2025 14:12:41 +02:00
x86/bugs: Allow ITS stuffing in eIBRS+retpoline mode also
After a recent restructuring of the ITS mitigation, RSB stuffing can no longer
be enabled in eIBRS+Retpoline mode. Before ITS, retbleed mitigation only
allowed stuffing when eIBRS was not enabled. This was perfectly fine since
eIBRS mitigates retbleed.
However, RSB stuffing mitigation for ITS is still needed with eIBRS. The
restructuring solely relies on retbleed to deploy stuffing, and does not allow
it when eIBRS is enabled. This behavior is different from what was before the
restructuring. Fix it by allowing stuffing in eIBRS+retpoline mode also.
Fixes: 61ab72c2c6bf ("x86/bugs: Restructure ITS mitigation")
Closes: https://lore.kernel.org/lkml/20250519235101.2vm6sc5txyoykb2r@desk/
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-7-5ff86cac6c61@linux.intel.com
---
arch/x86/kernel/cpu/bugs.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 31f3db0..bdef2c9 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1126,7 +1126,8 @@ static inline bool cdt_possible(enum spectre_v2_mitigation mode)
!IS_ENABLED(CONFIG_MITIGATION_RETPOLINE))
return false;
- if (mode == SPECTRE_V2_RETPOLINE)
+ if (mode == SPECTRE_V2_RETPOLINE ||
+ mode == SPECTRE_V2_EIBRS_RETPOLINE)
return true;
return false;
@@ -1281,7 +1282,7 @@ static void __init retbleed_update_mitigation(void)
if (retbleed_mitigation == RETBLEED_MITIGATION_STUFF &&
!cdt_possible(spectre_v2_enabled)) {
- pr_err("WARNING: retbleed=stuff depends on spectre_v2=retpoline\n");
+ pr_err("WARNING: retbleed=stuff depends on retpoline\n");
retbleed_mitigation = RETBLEED_MITIGATION_NONE;
}
@@ -1454,6 +1455,7 @@ static void __init its_update_mitigation(void)
its_mitigation = ITS_MITIGATION_OFF;
break;
case SPECTRE_V2_RETPOLINE:
+ case SPECTRE_V2_EIBRS_RETPOLINE:
/* Retpoline+CDT mitigates ITS */
if (retbleed_mitigation == RETBLEED_MITIGATION_STUFF)
its_mitigation = ITS_MITIGATION_RETPOLINE_STUFF;
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v4 0/7] Retbleed fixes
2025-06-23 18:35 ` Pawan Gupta
@ 2025-06-24 14:53 ` Borislav Petkov
0 siblings, 0 replies; 19+ messages in thread
From: Borislav Petkov @ 2025-06-24 14:53 UTC (permalink / raw)
To: Pawan Gupta
Cc: x86, David Kaplan, linux-kernel, H. Peter Anvin, Josh Poimboeuf,
Nikolay Borisov
On Mon, Jun 23, 2025 at 11:35:31AM -0700, Pawan Gupta wrote:
> Do you think also appending the vulnerability name like "x86/bugs/retbleed"
> would be useful for someone filtering commits based on vulnerability?
I've moved the vuln into the commit title. bugs.c is not that special enough
to have it be an exception.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2025-06-24 14:53 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-11 17:28 [PATCH v4 0/7] Retbleed fixes Pawan Gupta
2025-06-11 17:29 ` [PATCH v4 1/7] x86/retbleed: Avoid AUTO after the select step Pawan Gupta
2025-06-24 10:05 ` [tip: x86/bugs] x86/bugs: Avoid AUTO after the select step in the retbleed mitigation tip-bot2 for Pawan Gupta
2025-06-11 17:29 ` [PATCH v4 2/7] x86/retbleed: Simplify the =stuff checks Pawan Gupta
2025-06-24 10:05 ` [tip: x86/bugs] x86/bugs: Simplify the retbleed=stuff checks tip-bot2 for Pawan Gupta
2025-06-11 17:29 ` [PATCH v4 3/7] x86/bugs: Avoid warning when overriding return thunk Pawan Gupta
2025-06-24 10:05 ` [tip: x86/bugs] " tip-bot2 for Pawan Gupta
2025-06-11 17:29 ` [PATCH v4 4/7] x86/its: Use switch/case to apply mitigation Pawan Gupta
2025-06-24 10:05 ` [tip: x86/bugs] x86/bugs: Use switch/case in its_apply_mitigation() tip-bot2 for Pawan Gupta
2025-06-11 17:30 ` [PATCH v4 5/7] x86/retbleed: Introduce cdt_possible() Pawan Gupta
2025-06-24 10:05 ` [tip: x86/bugs] x86/bugs: " tip-bot2 for Pawan Gupta
2025-06-11 17:30 ` [PATCH v4 6/7] x86/its: Remove =stuff dependency on retbleed Pawan Gupta
2025-06-24 10:05 ` [tip: x86/bugs] x86/bugs: Remove its=stuff " tip-bot2 for Pawan Gupta
2025-06-11 17:30 ` [PATCH v4 7/7] x86/its: Allow stuffing in eIBRS+retpoline mode also Pawan Gupta
2025-06-24 10:05 ` [tip: x86/bugs] x86/bugs: Allow ITS " tip-bot2 for Pawan Gupta
2025-06-24 12:23 ` tip-bot2 for Pawan Gupta
2025-06-22 16:01 ` [PATCH v4 0/7] Retbleed fixes Borislav Petkov
2025-06-23 18:35 ` Pawan Gupta
2025-06-24 14:53 ` Borislav Petkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).