Re: [PATCH] x86/bugs: Default retbleed to =stuff when retpoline is auto enabled

From: Josh Poimboeuf
Date: Fri Feb 09 2024 - 13:59:27 EST


On Thu, Feb 08, 2024 at 05:12:15PM -0800, Pawan Gupta wrote:
> @@ -1025,10 +1041,17 @@ static void __init retbleed_select_mitigation(void)
> retbleed_mitigation = RETBLEED_MITIGATION_UNRET;
> else if (IS_ENABLED(CONFIG_CPU_IBPB_ENTRY) && boot_cpu_has(X86_FEATURE_IBPB))
> retbleed_mitigation = RETBLEED_MITIGATION_IBPB;
> + } else if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
> + spectre_v2_parse_cmdline() == SPECTRE_V2_CMD_AUTO &&

spectre_v2_parse_cmdline() has side effects (printks) and shouldn't be
called twice.

And what's the point of checking spectre_v2= anyway? Shouldn't retbleed
be mitigated by default, independently of whatever the user may have
specified for Spectre v2?

> + spectre_v2_enabled == SPECTRE_V2_RETPOLINE) {
> + if (IS_ENABLED(CONFIG_CALL_DEPTH_TRACKING))
> + retbleed_mitigation = RETBLEED_MITIGATION_STUFF;
> + else
> + pr_err("WARNING: Retpoline enabled, but kernel not compiled with CALL_DEPTH_TRACKING.\n");

If retbleed is vulnerable then the sysfs file should show that.

Also, I think this pr_err() is redundant with RETBLEED_INTEL_MSG and can
be removed.

--
Josh