x86/cpu: Add facility to force-enable CPU caps and bugs
Subsystems (2)
v2 cover x86/cpu: Add facility to force-enable CPU caps and bugs
For testing, development, and experimentation, add the ability to force the kernel to behave as if the CPU has a bug, even if it doesn't, using a command-line param.
Also do this in general for CPU flags, since:
- The infrastructure is the same so there is almost no extra implementation complexity.
- While setting random CPU flags is certain to break the kernel in mysterious and horrifying ways, this is not dramatically worse than setting CPU bugs. Although CPU bug mitigations don't have any very obvious ways to break the system if run on the wrong hardware, it's still very much an unsupported configuration, even beyond the security concern implied breaking mitigation logic.
Since a taint and scary docs are necessary regardless, supporting arbitrary CPU flags doesn't add significant maintenance/support burden either.
---
Changes in v2:
- Switched from a bugs-only force_cpu_bug= to a more general setcpuid=.
- Made it taint the kernel.
- Made docs sound scarier.
- Spellchecked and avoided new usage of personal pronouns.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Brendan Jackman (3):
x86/cpu: Create helper to parse clearcpuid param x86/cpu: Add setcpuid cmdline param
x86/cpu: Enable modifying bug flags with {clear,set}puid
arch/x86/include/asm/cpufeature.h | 1 + arch/x86/kernel/cpu/common.c | 139 +++++++++++++++++++++++--------------- 2 files changed, 87 insertions(+), 53 deletions(-)
---
base-commit: eabcdba3ad4098460a376538df2ae36500223c1e
change-id: 20241119-force-cpu-bug-94a08ab0239f
Best regards,
Signature · 1 line
Brendan Jackman <[email protected]>
PATCH v2 1/3 x86/cpu: Create helper to parse clearcpuid param
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.
--- arch/x86/kernel/cpu/common.c | 96 ++++++++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 44 deletions(-)
arch/x86/kernel/cpu/common.c +52 -44
@@ -1477,56 +1477,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
@@ -1568,10 +1530,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); }/*
Signature · 1 line
2.47.1.613.gc27f4b7a9f-goog
[tip: x86/cpu] x86/cpu: Create helper function to parse the 'clearcpuid=' boot parameter
The following commit has been merged into the x86/cpu branch of tip:
The following commit has been merged into the x86/cpu branch of tip:
Commit-ID: f034937f5af32188cd1c07865c885b2f171e17bf Gitweb: https://git.kernel.org/tip/f034937f5af32188cd1c07865c885b2f171e17bf Author: Brendan Jackman <[email protected]> AuthorDate: Fri, 20 Dec 2024 15:18:31 Committer: Ingo Molnar <[email protected]> CommitterDate: Fri, 28 Feb 2025 10:57:49 +01: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.
--- arch/x86/kernel/cpu/common.c | 96 ++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 44 deletions(-)
arch/x86/kernel/cpu/common.c +52 -44
@@ -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); }/*
PATCH v2 2/3 x86/cpu: Add setcpuid cmdline param
In reply to Brendan JackmanIn preparation for adding support to fake out CPU bugs, add a general facility to force enablement of CPU flags.
The flag taints the kernel and the documentation attempts to be clear that this is highly unsuitable for uses outside of kernel development and platform experimentation.
The new arg is parsed just like clearcpuid, but instead of leading to setup_clear_cpu_cap() it leads to setup_force_cpu_cap().
I've tested this by booting a nested QEMU guest on an Intel host, which with setcpuid=svm will claim that it supports AMD virtualization.
--- arch/x86/kernel/cpu/common.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-)
arch/x86/kernel/cpu/common.c +26 -9
@@ -1477,12 +1477,12 @@ static void detect_nopl(void)#endif } -static inline void parse_clearcpuid (char *arg) +static inline void parse_set_clear_cpuid (char *arg,bool set) {char *opt;int taint =0 ; -pr_info ("Clearing CPUID bits:" ); +pr_info ("%s CPUID bits:" , set ?"Force-enabling" :"Clearing" );while (arg) {bool found__maybe_unused = false;
@@ -1503,7 +1503,10 @@ static inline void parse_clearcpuid(char *arg)else pr_cont (" " X86_CAP_FMT ,x86_cap_flag (bit)); -setup_clear_cpu_cap (bit); +if (set) +setup_force_cpu_cap (bit); +else +setup_clear_cpu_cap (bit); taint++; }/*
@@ -1521,7 +1524,10 @@ static inline void parse_clearcpuid(char *arg)continue ;pr_cont (" %s" , opt); -setup_clear_cpu_cap (bit); +if (set) +setup_force_cpu_cap (bit); +else +setup_clear_cpu_cap (bit); taint++; found = true;break ;
@@ -1577,9 +1583,12 @@ static void __init cpu_parse_early_param(void)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); +if (arglen >0 ) +parse_set_clear_cpuid (arg, false); + + arglen =cmdline_find_option (boot_command_line,"setcpuid" , arg,sizeof (arg)); +if (arglen >0 ) +parse_set_clear_cpuid (arg, true); }/*
@@ -2011,15 +2020,23 @@ void print_cpu_info(struct cpuinfo_x86 *c) }/* -* clearcpuid= was already parsed in cpu_parse_early_param(). This dummy -* function prevents it from becoming an environment variable for init. +* clearcpuid= and setcpuid= were already parsed in cpu_parse_early_param(). +* These dummy functions prevent them from becoming an environment variable for +* init. */ +static __init int setup_clearcpuid (char *arg) {return 1 ; }__setup ("clearcpuid=" , setup_clearcpuid); +static __init int setup_setcpuid (char *arg) +{ +return 1 ; +} +__setup ("setcpuid=" , setup_setcpuid); + DEFINE_PER_CPU_ALIGNED(struct pcpu_hot, pcpu_hot) = { .current_task = &init_task, .preempt_count =INIT_PREEMPT_COUNT ,
Signature · 1 line
2.47.1.613.gc27f4b7a9f-goog
[tip: x86/cpu] x86/cpu: Add the 'setcpuid=' boot parameter
The following commit has been merged into the x86/cpu branch of tip:
The following commit has been merged into the x86/cpu branch of tip:
Commit-ID: 814165e9fd1f62332b5444d730b8d6e432328463 Gitweb: https://git.kernel.org/tip/814165e9fd1f62332b5444d730b8d6e432328463 Author: Brendan Jackman <[email protected]> AuthorDate: Fri, 20 Dec 2024 15:18:32 Committer: Ingo Molnar <[email protected]> CommitterDate: Fri, 28 Feb 2025 10:57:49 +01:00
x86/cpu: Add the 'setcpuid=' boot parameter
In preparation for adding support to inject fake CPU bugs at boot-time, add a general facility to force enablement of CPU flags.
The flag taints the kernel and the documentation attempts to be clear that this is highly unsuitable for uses outside of kernel development and platform experimentation.
The new arg is parsed just like clearcpuid, but instead of leading to setup_clear_cpu_cap() it leads to setup_force_cpu_cap().
I've tested this by booting a nested QEMU guest on an Intel host, which with setcpuid=svm will claim that it supports AMD virtualization.
--- arch/x86/kernel/cpu/common.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-)
arch/x86/kernel/cpu/common.c +26 -9
@@ -1479,12 +1479,12 @@ static void detect_nopl(void)#endif } -static inline void parse_clearcpuid (char *arg) +static inline void parse_set_clear_cpuid (char *arg,bool set) {char *opt;int taint =0 ; -pr_info ("Clearing CPUID bits:" ); +pr_info ("%s CPUID bits:" , set ?"Force-enabling" :"Clearing" );while (arg) {bool found__maybe_unused = false;
@@ -1505,7 +1505,10 @@ static inline void parse_clearcpuid(char *arg)else pr_cont (" " X86_CAP_FMT ,x86_cap_flag (bit)); -setup_clear_cpu_cap (bit); +if (set) +setup_force_cpu_cap (bit); +else +setup_clear_cpu_cap (bit); taint++; }/*
@@ -1523,7 +1526,10 @@ static inline void parse_clearcpuid(char *arg)continue ;pr_cont (" %s" , opt); -setup_clear_cpu_cap (bit); +if (set) +setup_force_cpu_cap (bit); +else +setup_clear_cpu_cap (bit); taint++; found = true;break ;
@@ -1579,9 +1585,12 @@ static void __init cpu_parse_early_param(void)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); +if (arglen >0 ) +parse_set_clear_cpuid (arg, false); + + arglen =cmdline_find_option (boot_command_line,"setcpuid" , arg,sizeof (arg)); +if (arglen >0 ) +parse_set_clear_cpuid (arg, true); }/*
@@ -2013,15 +2022,23 @@ void print_cpu_info(struct cpuinfo_x86 *c) }/* -* clearcpuid= was already parsed in cpu_parse_early_param(). This dummy -* function prevents it from becoming an environment variable for init. +* clearcpuid= and setcpuid= were already parsed in cpu_parse_early_param(). +* These dummy functions prevent them from becoming an environment variable for +* init. */ +static __init int setup_clearcpuid (char *arg) {return 1 ; }__setup ("clearcpuid=" , setup_clearcpuid); +static __init int setup_setcpuid (char *arg) +{ +return 1 ; +} +__setup ("setcpuid=" , setup_setcpuid); + DEFINE_PER_CPU_ALIGNED(struct pcpu_hot, pcpu_hot) = { .current_task = &init_task, .preempt_count =INIT_PREEMPT_COUNT ,
PATCH v2 3/3 x86/cpu: Enable modifying bug flags with {clear,set}puid
In reply to Brendan JackmanSometimes it can be very useful to run CPU vulnerability mitigations on systems where they aren't known to mitigate any real-world vulnerabilities. This can be handy for mundane reasons like debugging HW-agnostic logic on whatever machine is to hand, but also for research
reasons: while some mitigations are focused on individual vulns and uarches, others are fairly general, and it's strategically useful to have an idea how they'd perform on systems where they aren't currently needed.
As evidence for this being useful, a flag specifically for Retbleed was added in commit 5c9a92dec323 ("x86/bugs: Add retbleed=force").
Since CPU bugs are tracked using the same basic mechanism as features, and there are already parameters for manipulating them by hand, extend that mechanism to support bug as well as capabilities.
With this patch and setcpuid=srso, a QEMU guest running on an Intel host will boot with Safe-RET enabled.
--- arch/x86/include/asm/cpufeature.h | 1 + arch/x86/kernel/cpu/common.c | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-)
arch/x86/include/asm/cpufeature.h +1 -0
@@ -50,6 +50,7 @@ extern const char * const x86_power_flags[32];* X86_BUG_<name> - NCAPINTS*32. */ extern const char *const x86_bug_flags[NBUGINTS *32 ]; +#define x86_bug_flag (flag) x86_bug_flags[flag]#define test_cpu_cap (c, bit) \ arch_test_bit(bit, (unsigned long *)((c)->x86_capability))
arch/x86/kernel/cpu/common.c +12 -4
@@ -1492,7 +1492,8 @@ static inline void parse_set_clear_cpuid(char *arg, bool set)/* * Handle naked numbers first for feature flags which don't -* have names. +* have names. It doesn't make sense for a bug not to have a +* name so don't handle bug flags here. */ if (!kstrtouint (opt,10 , &bit)) {if (bit <NCAPINTS *32 ) {
@@ -1516,11 +1517,18 @@ static inline void parse_set_clear_cpuid(char *arg, bool set)continue ; } -for (bit =0 ; bit <32 *NCAPINTS ; bit++) { -if (!x86_cap_flag (bit)) +for (bit =0 ; bit <32 * (NCAPINTS +NBUGINTS ); bit++) { +const char *flag; + +if (bit <32 *NCAPINTS ) + flag =x86_cap_flag (bit); +else + flag =x86_bug_flag (bit - (32 *NCAPINTS )); + +if (!flag)continue ; -if (strcmp (x86_cap_flag (bit), opt)) +if (strcmp (flag, opt))continue ;pr_cont (" %s" , opt);
Signature · 1 line
2.47.1.613.gc27f4b7a9f-goog
[tip: x86/cpu] x86/cpu: Enable modifying CPU bug flags with '{clear,set}puid='
The following commit has been merged into the x86/cpu branch of tip:
The following commit has been merged into the x86/cpu branch of tip:
Commit-ID: ab68d2e36532806b8f86ff2f60861dbb8443f0be Gitweb: https://git.kernel.org/tip/ab68d2e36532806b8f86ff2f60861dbb8443f0be Author: Brendan Jackman <[email protected]> AuthorDate: Fri, 20 Dec 2024 15:18:33 Committer: Ingo Molnar <[email protected]> CommitterDate: Fri, 28 Feb 2025 10:57:50 +01:00
x86/cpu: Enable modifying CPU bug flags with '{clear,set}puid='
Sometimes it can be very useful to run CPU vulnerability mitigations on systems where they aren't known to mitigate any real-world vulnerabilities. This can be handy for mundane reasons like debugging HW-agnostic logic on whatever machine is to hand, but also for research
reasons: while some mitigations are focused on individual vulns and uarches, others are fairly general, and it's strategically useful to have an idea how they'd perform on systems where they aren't currently needed.
As evidence for this being useful, a flag specifically for Retbleed was added in:
5c9a92dec323 ("x86/bugs: Add retbleed=force").
Since CPU bugs are tracked using the same basic mechanism as features, and there are already parameters for manipulating them by hand, extend that mechanism to support bug as well as capabilities.
With this patch and setcpuid=srso, a QEMU guest running on an Intel host will boot with Safe-RET enabled.
--- arch/x86/include/asm/cpufeature.h | 1 + arch/x86/kernel/cpu/common.c | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-)
arch/x86/include/asm/cpufeature.h +1 -0
@@ -50,6 +50,7 @@ extern const char * const x86_power_flags[32];* X86_BUG_<name> - NCAPINTS*32. */ extern const char *const x86_bug_flags[NBUGINTS *32 ]; +#define x86_bug_flag (flag) x86_bug_flags[flag]#define test_cpu_cap (c, bit) \ arch_test_bit(bit, (unsigned long *)((c)->x86_capability))
arch/x86/kernel/cpu/common.c +12 -4
@@ -1494,7 +1494,8 @@ static inline void parse_set_clear_cpuid(char *arg, bool set)/* * Handle naked numbers first for feature flags which don't -* have names. +* have names. It doesn't make sense for a bug not to have a +* name so don't handle bug flags here. */ if (!kstrtouint (opt,10 , &bit)) {if (bit <NCAPINTS *32 ) {
@@ -1518,11 +1519,18 @@ static inline void parse_set_clear_cpuid(char *arg, bool set)continue ; } -for (bit =0 ; bit <32 *NCAPINTS ; bit++) { -if (!x86_cap_flag (bit)) +for (bit =0 ; bit <32 * (NCAPINTS +NBUGINTS ); bit++) { +const char *flag; + +if (bit <32 *NCAPINTS ) + flag =x86_cap_flag (bit); +else + flag =x86_bug_flag (bit - (32 *NCAPINTS )); + +if (!flag)continue ; -if (strcmp (x86_cap_flag (bit), opt)) +if (strcmp (flag, opt))continue ;pr_cont (" %s" , opt);
Hi folks, happy new year. I hope this ping isn't too aggressive given the season - please let me know if it is.
Any new thoughts on this?
Quoted 4 lines · Brendan Jackman
Hi folks, happy new year. I hope this ping isn't too aggressive given the season - please let me know if it is.
Any new thoughts on this?
Sorry, this series got lost in the holiday season (apparently you weren't nearly pushy enough to breach the maintainer patch-detection noise/signal level :-), and this functionality is definitely useful and the series looks good to me.
Integration with clearcpuid= is so much more generic than the original variant and reuses a lot of that logic, so that's a big plus.
I've applied it to the x86 tree under the tip:x86/cpu branch and if everything goes fine in testing it should hit v6.15 in a couple of weeks.
One additional thing - which I'd suggest we make a 4th patch, because it affects the existing clearcpuid= behavior - is to extend set/clearcpuid= with a bit more boot time verbosity, right now it taints the kernel:
/* empty-string, i.e., ""-defined feature flags */
if (!x86_cap_flags[bit])
pr_cont(" " X86_CAP_FMT_NUM, x86_cap_flag_num(bit));
else
pr_cont(" " X86_CAP_FMT, x86_cap_flag(bit));
if (set)
setup_force_cpu_cap(bit);
else
setup_clear_cpu_cap(bit);
taint++;I'd suggest we do what PeterZ suggested back in December: in addition to the tainting, also emit an informative pr_warn() for every CPU feature bit enabled/disabled over what was present, and maybe make a bit of a distinction between 'feature' and 'bug' feature bits.
Thanks,
Ingo
Quoted 38 lines · Ingo Molnar
Quoted 4 lines · Brendan Jackman
Hi folks, happy new year. I hope this ping isn't too aggressive given the season - please let me know if it is.
Any new thoughts on this?
Sorry, this series got lost in the holiday season (apparently you weren't nearly pushy enough to breach the maintainer patch-detection noise/signal level :-), and this functionality is definitely useful and the series looks good to me.
Integration with clearcpuid= is so much more generic than the original variant and reuses a lot of that logic, so that's a big plus.
I've applied it to the x86 tree under the tip:x86/cpu branch and if everything goes fine in testing it should hit v6.15 in a couple of weeks.
One additional thing - which I'd suggest we make a 4th patch, because it affects the existing clearcpuid= behavior - is to extend set/clearcpuid= with a bit more boot time verbosity, right now it taints the kernel:
/* empty-string, i.e., ""-defined feature flags */ if (!x86_cap_flags[bit]) pr_cont(" " X86_CAP_FMT_NUM, x86_cap_flag_num(bit)); else pr_cont(" " X86_CAP_FMT, x86_cap_flag(bit)); if (set) setup_force_cpu_cap(bit); else setup_clear_cpu_cap(bit); taint++;
Quoted 4 lines
I'd suggest we do what PeterZ suggested back in December: in addition to the tainting, also emit an informative
pr_warn()for every CPU feature bit enabled/disabled over what was present, and maybe make a bit of a distinction between 'feature' and 'bug' feature bits.
Ie. what I mean is that at minimum upgrade the output from pr_info() to pr_warn() - but maybe also make it clear in the output that the kernel is tainted and things may break as a result of modifying the feature bits.
Thanks,
Ingo
Quoted 7 lines · Ingo Molnar
Quoted 6 lines · Ingo Molnar
Integration with clearcpuid= is so much more generic than the original variant and reuses a lot of that logic, so that's a big plus.
I've applied it to the x86 tree under the tip:x86/cpu branch and if everything goes fine in testing it should hit v6.15 in a couple of weeks.
It seems you applied this version (v2) while there was actually a review from Boris on this and it led to v3:
https://lore.kernel.org/linux-kernel/[email protected]/
This is weird, I can't see Boris' comments on Lore, even though they are Cc'd to [email protected]. I think there was some downtime on Lore recently, maybe they got lost?
Quoted 23 lines
Quoted 18 lines
One additional thing - which I'd suggest we make a 4th patch, because it affects the existing clearcpuid= behavior - is to extend set/clearcpuid= with a bit more boot time verbosity, right now it taints the kernel:
/* empty-string, i.e., ""-defined feature flags */ if (!x86_cap_flags[bit]) pr_cont(" " X86_CAP_FMT_NUM, x86_cap_flag_num(bit)); else pr_cont(" " X86_CAP_FMT, x86_cap_flag(bit)); if (set) setup_force_cpu_cap(bit); else setup_clear_cpu_cap(bit); taint++;Quoted 4 lines
I'd suggest we do what PeterZ suggested back in December: in addition to the tainting, also emit an informative
pr_warn()for every CPU feature bit enabled/disabled over what was present, and maybe make a bit of a distinction between 'feature' and 'bug' feature bits.
Quoted 4 lines
Ie. what I mean is that at minimum upgrade the output from
pr_info()topr_warn()- but maybe also make it clear in the output that the kernel is tainted and things may break as a result of modifying the feature bits.
Anyway, yep, I will send some upgrades to the logging, plus any diff that got lost from v2 to v3 as a new series.
Thanks for taking a look!