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

Pawan Gupta <[email protected]>
Newsgroups dev.linux.lists.linux-coco,org.kernel.vger.kvm,org.kernel.vger.linux-kernel
Message-ID <lctyimdlenyb5kvfxarzajs2ggzkwn4yehxu233lojynqwa7ej@wjur3lh6szlr>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.