Re: [PATCH v5 1/8] x86/bugs: Allow forcing Automatic IBRS with SNP active using spectre_v2=eibrs

From: Pawan Gupta

Date: Thu Aug 27 2026 - 00:32:52 EST


On Wed, Aug 26, 2026 at 05:35:03PM -0500, Kim Phillips wrote:
> spectre_v2=eibrs currently enables retpolines when SNP is enabled,
> instead of AutoIBRS (EIBRS) because the commit that disabled
> AutoIBRS if SNP is enabled stopped short of enabling
> X86_FEATURE_IBRS_ENHANCED.
>
> Change the logic to enable X86_FEATURE_IBRS_ENHANCED, and move the
> decision to switch to retpolines in the default/"auto" case in
> spectre_v2_select_mitigation(). This allows the existing
> spectre_v2=eibrs logic to work as intended.
>
> Condition that switch on CONFIG_MITIGATION_RETPOLINE being built in.
> Otherwise spectre_v2_select_retpoline() returns SPECTRE_V2_NONE and an
> SNP host with AutoIBRS available would be left completely unmitigated
> against Spectre v2 in the default/auto case, which is worse than the
> userspace indirect branch performance loss AutoIBRS costs.
>
> Also emit a performance loss warning for using AutoIBRS with SNP
> enabled. AutoIBRS is activated for all three eIBRS modes via
> spectre_v2_in_eibrs_mode(), so use that helper to cover
> spectre_v2=eibrs, spectre_v2=eibrs,lfence, and
> spectre_v2=eibrs,retpoline uniformly. Word the warning in terms of the
> eIBRS mitigation enabling AutoIBRS, rather than naming AutoIBRS as the
> selected mitigation, so it reads correctly for the ,lfence and
> ,retpoline variants where another component is also active.
>
> Fixes: acaa4b5c4c85 ("x86/speculation: Do not enable Automatic IBRS if SEV-SNP is enabled")
> Reported-by: Tom Lendacky <thomas.lendacky@xxxxxxx>
> Cc: Borislav Petkov (AMD) <bp@xxxxxxxxx>
> Cc: Pawan Gupta <pawan.kumar.gupta@xxxxxxxxxxxxxxx>
> Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
> Cc: Sean Christopherson <seanjc@xxxxxxxxxx>
> Signed-off-by: Kim Phillips <kim.phillips@xxxxxxx>

Reviewed-by: Pawan Gupta <pawan.kumar.gupta@xxxxxxxxxxxxxxx>