mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 02:24:24 +02:00
x86/cpu: Create helper function to parse the 'clearcpuid=' boot parameter
This is in preparation for a later commit that will reuse this code, to make review convenient. Factor out a helper function which does the full handling for this arg including printing info to the console. No functional change intended. Signed-off-by: Brendan Jackman <jackmanb@google.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lore.kernel.org/r/20241220-force-cpu-bug-v2-1-7dc71bce742a@google.com
This commit is contained in:
parent
a4248ee16f
commit
f034937f5a
|
|
@ -1479,56 +1479,18 @@ static void detect_nopl(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* We parse cpu parameters early because fpu__init_system() is executed
|
||||
* before parse_early_param().
|
||||
*/
|
||||
static void __init cpu_parse_early_param(void)
|
||||
static inline void parse_clearcpuid(char *arg)
|
||||
{
|
||||
char arg[128];
|
||||
char *argptr = arg, *opt;
|
||||
int arglen, taint = 0;
|
||||
|
||||
#ifdef CONFIG_X86_32
|
||||
if (cmdline_find_option_bool(boot_command_line, "no387"))
|
||||
#ifdef CONFIG_MATH_EMULATION
|
||||
setup_clear_cpu_cap(X86_FEATURE_FPU);
|
||||
#else
|
||||
pr_err("Option 'no387' required CONFIG_MATH_EMULATION enabled.\n");
|
||||
#endif
|
||||
|
||||
if (cmdline_find_option_bool(boot_command_line, "nofxsr"))
|
||||
setup_clear_cpu_cap(X86_FEATURE_FXSR);
|
||||
#endif
|
||||
|
||||
if (cmdline_find_option_bool(boot_command_line, "noxsave"))
|
||||
setup_clear_cpu_cap(X86_FEATURE_XSAVE);
|
||||
|
||||
if (cmdline_find_option_bool(boot_command_line, "noxsaveopt"))
|
||||
setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT);
|
||||
|
||||
if (cmdline_find_option_bool(boot_command_line, "noxsaves"))
|
||||
setup_clear_cpu_cap(X86_FEATURE_XSAVES);
|
||||
|
||||
if (cmdline_find_option_bool(boot_command_line, "nousershstk"))
|
||||
setup_clear_cpu_cap(X86_FEATURE_USER_SHSTK);
|
||||
|
||||
/* Minimize the gap between FRED is available and available but disabled. */
|
||||
arglen = cmdline_find_option(boot_command_line, "fred", arg, sizeof(arg));
|
||||
if (arglen != 2 || strncmp(arg, "on", 2))
|
||||
setup_clear_cpu_cap(X86_FEATURE_FRED);
|
||||
|
||||
arglen = cmdline_find_option(boot_command_line, "clearcpuid", arg, sizeof(arg));
|
||||
if (arglen <= 0)
|
||||
return;
|
||||
char *opt;
|
||||
int taint = 0;
|
||||
|
||||
pr_info("Clearing CPUID bits:");
|
||||
|
||||
while (argptr) {
|
||||
while (arg) {
|
||||
bool found __maybe_unused = false;
|
||||
unsigned int bit;
|
||||
|
||||
opt = strsep(&argptr, ",");
|
||||
opt = strsep(&arg, ",");
|
||||
|
||||
/*
|
||||
* Handle naked numbers first for feature flags which don't
|
||||
|
|
@ -1570,10 +1532,56 @@ static void __init cpu_parse_early_param(void)
|
|||
if (!found)
|
||||
pr_cont(" (unknown: %s)", opt);
|
||||
}
|
||||
pr_cont("\n");
|
||||
|
||||
if (taint)
|
||||
add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK);
|
||||
|
||||
pr_cont("\n");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* We parse cpu parameters early because fpu__init_system() is executed
|
||||
* before parse_early_param().
|
||||
*/
|
||||
static void __init cpu_parse_early_param(void)
|
||||
{
|
||||
char arg[128];
|
||||
int arglen;
|
||||
|
||||
#ifdef CONFIG_X86_32
|
||||
if (cmdline_find_option_bool(boot_command_line, "no387"))
|
||||
#ifdef CONFIG_MATH_EMULATION
|
||||
setup_clear_cpu_cap(X86_FEATURE_FPU);
|
||||
#else
|
||||
pr_err("Option 'no387' required CONFIG_MATH_EMULATION enabled.\n");
|
||||
#endif
|
||||
|
||||
if (cmdline_find_option_bool(boot_command_line, "nofxsr"))
|
||||
setup_clear_cpu_cap(X86_FEATURE_FXSR);
|
||||
#endif
|
||||
|
||||
if (cmdline_find_option_bool(boot_command_line, "noxsave"))
|
||||
setup_clear_cpu_cap(X86_FEATURE_XSAVE);
|
||||
|
||||
if (cmdline_find_option_bool(boot_command_line, "noxsaveopt"))
|
||||
setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT);
|
||||
|
||||
if (cmdline_find_option_bool(boot_command_line, "noxsaves"))
|
||||
setup_clear_cpu_cap(X86_FEATURE_XSAVES);
|
||||
|
||||
if (cmdline_find_option_bool(boot_command_line, "nousershstk"))
|
||||
setup_clear_cpu_cap(X86_FEATURE_USER_SHSTK);
|
||||
|
||||
/* Minimize the gap between FRED is available and available but disabled. */
|
||||
arglen = cmdline_find_option(boot_command_line, "fred", arg, sizeof(arg));
|
||||
if (arglen != 2 || strncmp(arg, "on", 2))
|
||||
setup_clear_cpu_cap(X86_FEATURE_FRED);
|
||||
|
||||
arglen = cmdline_find_option(boot_command_line, "clearcpuid", arg, sizeof(arg));
|
||||
if (arglen <= 0)
|
||||
return;
|
||||
parse_clearcpuid(arg);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user