x86/fred: Let command line option "fred" accept multiple options
Subsystems (2)
PATCH 1/1 x86/fred: Let command line option "fred" accept multiple options
Let command line option "fred" accept multiple options to make it easier to tweak its behavior.
Currently two options 'on' and 'off' are allowed, and the default behavior is to disable FRED. To enable FRED, append "fred=on" to the kernel command line.
--- .../admin-guide/kernel-parameters.txt | 7 +++-- arch/x86/kernel/cpu/common.c | 3 --- arch/x86/kernel/traps.c | 26 +++++++++++++++++++ 3 files changed, 31 insertions(+), 5 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +5 -2
@@ -1539,8 +1539,11 @@ Warning: use of this parameter will taint the kernel and may cause unknown problems. - fred [X86-64] - Enable flexible return and event delivery + fred= [X86-64] + Enable/disable Flexible Return and Event Delivery. + Format: { on | off } + on: enable FRED when it's present. + off: disable FRED, the default option in early stage. ftrace=[tracer] [FTRACE] will set and start the specified tracer
arch/x86/kernel/cpu/common.c +0 -3
@@ -1484,9 +1484,6 @@ static void __init cpu_parse_early_param(void)char *argptr = arg, *opt;int arglen, taint =0 ; -if (!cmdline_find_option_bool (boot_command_line,"fred" )) -setup_clear_cpu_cap (X86_FEATURE_FRED ); -#ifdef CONFIG_X86_32 if (cmdline_find_option_bool (boot_command_line,"no387" )) #ifdef CONFIG_MATH_EMULATION
arch/x86/kernel/traps.c +26 -0
@@ -1402,8 +1402,34 @@ DEFINE_IDTENTRY_SW(iret_error) }#endif +/* Do not enable FRED by default in its early stage. */ +static bool enable_fred__ro_after_init = false; + +#ifdef CONFIG_X86_FRED +static int __init fred_setup (char *str) +{ +if (!str) +return -EINVAL ; + +if (!boot_cpu_has (X86_FEATURE_FRED )) +return 0 ; + +if (!strcmp (str,"on" )) + enable_fred = true; +else if (!strcmp (str,"off" )) + enable_fred = false; +else +pr_warn ("invalid FRED option: 'fred=%s'\n" , str); +return 0 ; +} +early_param ("fred" , fred_setup); +#endif +void __init trap_init (void ) { +if (boot_cpu_has (X86_FEATURE_FRED ) && !enable_fred) +setup_clear_cpu_cap (X86_FEATURE_FRED ); +/* Init cpu_entry_area before IST entries are set up */ setup_cpu_entry_areas ();
base-commit: a9f26154bf5478fc155309fc69128415f3a1be08
Signature · 1 line
2.43.0
Quoted 9 lines
Let command line option "fred" accept multiple options to make it easier to tweak its behavior.
Currently two options 'on' and 'off' are allowed, and the default behavior is to disable FRED. To enable FRED, append "fred=on" to the kernel command line.
Suggested-by Borislav Petkov (AMD) <[email protected]>Signed-off-by Xin Li <[email protected]>
Hi Boris,
I kind of prefer to fold this patch into this commit:
https://git.kernel.org/pub/scm/linux/kernel/git/bp/bp.git/commit/?h=tip-x86-fred&id=7a1d75084df087dcae703d70a49274a3982e3681
but of course a maintainer knows the best way 😊
Thanks!
-Xin
Borislav Petkov
maintainerQuoted 2 lines · On Tue, Jan 30, 2024 at 04:44:22PM +0000, Li, Xin3 wrote:
I kind of prefer to fold this patch into this commit:
https://git.kernel.org/pub/scm/linux/kernel/git/bp/bp.git/commit/?h=tip-x86-fred&id=7a1d75084df087dcae703d70a49274a3982e3681
Yes, good point, I'll do that.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette