Re: [PATCH v4 02/10] cpu/bugs: Allow forcing Automatic IBRS with SNP active using spectre_v2=eibrs

From: Kim Phillips

Date: Wed Aug 26 2026 - 19:17:45 EST


On 8/18/26 7:12 PM, Pawan Gupta wrote:
On Tue, Aug 04, 2026 at 06:56:03PM -0500, Kim Phillips wrote:
...
@@ -2192,7 +2193,12 @@ static void __init spectre_v2_select_mitigation(void)
break;
fallthrough;
case SPECTRE_V2_CMD_FORCE:
- if (boot_cpu_has(X86_FEATURE_IBRS_ENHANCED)) {
+ /*
+ * Don't use AutoIBRS when SNP is enabled because it degrades
+ * host userspace indirect branch performance.
+ */
+ if (boot_cpu_has(X86_FEATURE_IBRS_ENHANCED) &&
+ !boot_cpu_has(X86_FEATURE_SEV_SNP)) {
spectre_v2_enabled = SPECTRE_V2_EIBRS;
break;
}
Can we also account for retpoline availability here? If both SNP and
retpoline are available, then only avoid AutoIBRS:

case SPECTRE_V2_CMD_FORCE:
/*
* Prefer retpoline when SNP is enabled because Auto-IBRS
* degrades host userspace indirect branch performance.
*/
if (boot_cpu_has(X86_FEATURE_IBRS_ENHANCED) &&
!(boot_cpu_has(X86_FEATURE_SEV_SNP) &&
IS_ENABLED(CONFIG_MITIGATION_RETPOLINE))) {
spectre_v2_enabled = SPECTRE_V2_EIBRS;
break;
}

With this, patch 1 & 3 can be omitted. Also avoids the ping pong: we don't
want AutoIBRS -> We don't have retpoline -> Lets have AutoIBRS.
Thank you for your constructive review - I have addressed this comment in v5:

https://lore.kernel.org/lkml/20260826223510.3669875-1-kim.phillips@xxxxxxx/

Thanks,

Kim