[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250822114918.GQaKhZPrvA7zP33TX4@fat_crate.local>
Date: Fri, 22 Aug 2025 13:49:18 +0200
From: Borislav Petkov <bp@...en8.de>
To: David Kaplan <david.kaplan@....com>
Cc: Thomas Gleixner <tglx@...utronix.de>,
Peter Zijlstra <peterz@...radead.org>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>,
Ingo Molnar <mingo@...hat.com>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
"H . Peter Anvin" <hpa@...or.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/5] x86/bugs: Use early_param for spectre_v2
On Tue, Aug 19, 2025 at 02:21:57PM -0500, David Kaplan wrote:
> +static void __init spectre_v2_check_cmd(void)
Why the separate function?
This can simply go in spectre_v2_select_mitigation() before the switch-case
like with all the others *_select_mitigation() functions...
> +{
> + if ((spectre_v2_cmd == SPECTRE_V2_CMD_RETPOLINE ||
> + spectre_v2_cmd == SPECTRE_V2_CMD_RETPOLINE_LFENCE ||
> + spectre_v2_cmd == SPECTRE_V2_CMD_RETPOLINE_GENERIC ||
> + spectre_v2_cmd == SPECTRE_V2_CMD_EIBRS_LFENCE ||
> + spectre_v2_cmd == SPECTRE_V2_CMD_EIBRS_RETPOLINE) &&
> + !IS_ENABLED(CONFIG_MITIGATION_RETPOLINE)) {
> + pr_err("RETPOLINE selected but not compiled in. Switching to AUTO select\n");
> + spectre_v2_cmd = SPECTRE_V2_CMD_AUTO;
> + }
> +
> + if ((spectre_v2_cmd == SPECTRE_V2_CMD_EIBRS ||
> + spectre_v2_cmd == SPECTRE_V2_CMD_EIBRS_LFENCE ||
> + spectre_v2_cmd == SPECTRE_V2_CMD_EIBRS_RETPOLINE) &&
> + !boot_cpu_has(X86_FEATURE_IBRS_ENHANCED)) {
> + pr_err("EIBRS selected but CPU doesn't have Enhanced or Automatic IBRS. Switching to AUTO select\n");
> + spectre_v2_cmd = SPECTRE_V2_CMD_AUTO;
> + }
> +
> + if ((spectre_v2_cmd == SPECTRE_V2_CMD_RETPOLINE_LFENCE ||
> + spectre_v2_cmd == SPECTRE_V2_CMD_EIBRS_LFENCE) &&
> + !boot_cpu_has(X86_FEATURE_LFENCE_RDTSC)) {
> + pr_err("LFENCE selected, but CPU doesn't have a serializing LFENCE. Switching to AUTO select\n");
> + spectre_v2_cmd = SPECTRE_V2_CMD_AUTO;
> + }
> +
> + if (spectre_v2_cmd == SPECTRE_V2_CMD_IBRS && !IS_ENABLED(CONFIG_MITIGATION_IBRS_ENTRY)) {
> + pr_err("IBRS selected but not compiled in. Switching to AUTO select\n");
> + spectre_v2_cmd = SPECTRE_V2_CMD_AUTO;
> + }
> +
> + if (spectre_v2_cmd == SPECTRE_V2_CMD_IBRS && boot_cpu_data.x86_vendor != X86_VENDOR_INTEL) {
> + pr_err("IBRS selected but not Intel CPU. Switching to AUTO select\n");
> + spectre_v2_cmd = SPECTRE_V2_CMD_AUTO;
> + }
> +
> + if (spectre_v2_cmd == SPECTRE_V2_CMD_IBRS && !boot_cpu_has(X86_FEATURE_IBRS)) {
> + pr_err("IBRS selected but CPU doesn't have IBRS. Switching to AUTO select\n");
> + spectre_v2_cmd = SPECTRE_V2_CMD_AUTO;
> + }
> +
> + if (spectre_v2_cmd == SPECTRE_V2_CMD_IBRS && cpu_feature_enabled(X86_FEATURE_XENPV)) {
> + pr_err("IBRS selected but running as XenPV guest. Switching to AUTO select\n");
> + spectre_v2_cmd = SPECTRE_V2_CMD_AUTO;
> + }
> +}
> +
> static void __init spectre_v2_select_mitigation(void)
> {
> - spectre_v2_cmd = spectre_v2_parse_cmdline();
> + spectre_v2_check_cmd();
>
> if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V2) &&
> (spectre_v2_cmd == SPECTRE_V2_CMD_NONE || spectre_v2_cmd == SPECTRE_V2_CMD_AUTO))
> --
> 2.34.1
>
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
Powered by blists - more mailing lists