Reworking configurability of X86_FEATURE_NAMES
Subsystems (2)
cover Reworking configurability of X86_FEATURE_NAMES
Dear Dave, dear Boris, dear x86 maintainers,
as follow-up to the discussion on my initial patch on changing the visibility of X86_FEATURE_NAMES (see Link), here are two patches:
Patch 1 simply makes the minimal one-line change to make X86_FEATURE_NAMES disappear from the prompt.
Patch 2 is the more radical change to remove the whole config and see which code would generally be impacted; just as quick exploration.
The diffstat shows we are getting rid of a bit of code throughout arch/x86, but the change and reduction is not too complex either:
arch/x86/Kconfig | 12 ------------ arch/x86/Kconfig.cpu | 2 +- arch/x86/boot/Makefile | 2 -- arch/x86/boot/cpu.c | 13 ------------- arch/x86/include/asm/cpufeature.h | 5 ----- arch/x86/kernel/cpu/Makefile | 4 +--- arch/x86/kernel/cpu/common.c | 4 ---- 7 files changed, 2 insertions(+), 40 deletions(-)
Probably, you just want to pick patch 1 and wait for any complaints. Or if you are confident the compliants will not show up, simply apply both.
Otherwise, I will put it on my list to come back in a year or two, and if there were no complaints till then, provide the updated patch to remove the X86_FEATURE_NAMES config then.
Best regards,
Lukas
Lukas Bulwahn (2):
x86: make X86_FEATURE_NAMES non-configurable in prompt
x86: always build with X86_FEATURE_NAMES functionality
arch/x86/Kconfig | 12 ------------ arch/x86/Kconfig.cpu | 2 +- arch/x86/boot/Makefile | 2 -- arch/x86/boot/cpu.c | 13 ------------- arch/x86/include/asm/cpufeature.h | 5 ----- arch/x86/kernel/cpu/Makefile | 4 +--- arch/x86/kernel/cpu/common.c | 4 ---- 7 files changed, 2 insertions(+), 40 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/2 x86: make X86_FEATURE_NAMES non-configurable in prompt
While discussing to change the visibility of X86_FEATURE_NAMES (see Link) in order to remove CONFIG_EMBEDDED, Boris suggested to simply make the X86_FEATURE_NAMES functionality unconditional.
As a first step, make X86_FEATURE_NAMES disappear in the config prompt. So, as X86_FEATURE_NAMES defaults to yes, to disable it, one now needs to modify the .config file before compiling the kernel.
If there are no complaints on this config after a grace period, we can then further remove the config entirely.
--- arch/x86/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/Kconfig +1 -1
@@ -442,7 +442,7 @@ config SMP If you don't know what to do here, say N. config X86_FEATURE_NAMES - bool "Processor feature human-readable names" if EMBEDDED + bool default y help This option compiles in a table of x86 feature bits and corresponding
Signature · 1 line
2.17.1
PATCH 2/2 x86: always build with X86_FEATURE_NAMES functionality
In reply to Lukas BulwahnWhile discussing to change the visibility of X86_FEATURE_NAMES (see Link) in order to remove CONFIG_EMBEDDED, Boris suggested to simply make the X86_FEATURE_NAMES functionality unconditional.
As the need for really tiny kernel images has gone away and kernel images with !X86_FEATURE_NAMES is hardly tested, remove this config and the whole ifdeffery in the source code.
--- arch/x86/Kconfig | 12 ------------ arch/x86/Kconfig.cpu | 2 +- arch/x86/boot/Makefile | 2 -- arch/x86/boot/cpu.c | 13 ------------- arch/x86/include/asm/cpufeature.h | 5 ----- arch/x86/kernel/cpu/Makefile | 4 +--- arch/x86/kernel/cpu/common.c | 4 ---- 7 files changed, 2 insertions(+), 40 deletions(-)
arch/x86/Kconfig +0 -12
@@ -291,7 +291,6 @@ config X86 select TRACE_IRQFLAGS_NMI_SUPPORT select USER_STACKTRACE_SUPPORT select HAVE_ARCH_KCSAN if X86_64 - select X86_FEATURE_NAMES if PROC_FS select PROC_PID_ARCH_STATUS if PROC_FS select HAVE_ARCH_NODE_DEV_GROUP if X86_SGX select FUNCTION_ALIGNMENT_16B if X86_64 || X86_ALIGNMENT_16
@@ -441,17 +440,6 @@ config SMP If you don't know what to do here, say N. -config X86_FEATURE_NAMES - bool - default y - help - This option compiles in a table of x86 feature bits and corresponding - names. This is required to support /proc/cpuinfo and a few kernel - messages. You can disable this to save space, at the expense of - making those few kernel messages show numeric feature bits instead. - - If in doubt, say Y. - config X86_X2APIC bool "Support x2apic" depends on X86_LOCAL_APIC && X86_64 && (IRQ_REMAP || HYPERVISOR_GUEST)
arch/x86/Kconfig.cpu +1 -1
@@ -389,7 +389,7 @@ config IA32_FEAT_CTL config X86_VMX_FEATURE_NAMES def_bool y - depends on IA32_FEAT_CTL && X86_FEATURE_NAMES + depends on IA32_FEAT_CTL menuconfig PROCESSOR_SELECT bool "Supported processor vendors" if EXPERT
arch/x86/boot/Makefile +0 -2
@@ -55,14 +55,12 @@ HOST_EXTRACFLAGS += -I$(srctree)/tools/include \ -include include/generated/autoconf.h \ -D__EXPORTED_HEADERS__ -ifdef CONFIG_X86_FEATURE_NAMES $(obj)/cpu.o: $(obj)/cpustr.h quiet_cmd_cpustr = CPUSTR $@ cmd_cpustr = $(obj)/mkcpustr > $@ $(obj)/cpustr.h: $(obj)/mkcpustr FORCE $(call if_changed,cpustr) -endif targets += cpustr.h # ---------------------------------------------------------------------------
arch/x86/boot/cpu.c +0 -13
@@ -14,9 +14,7 @@*/ #include "boot.h" -#ifdef CONFIG_X86_FEATURE_NAMES #include "cpustr.h" -#endif static char *cpu_name (int level) {
@@ -35,7 +33,6 @@ static char *cpu_name(int level)static void show_cap_strs (u32 *err_flags) {int i, j; -#ifdef CONFIG_X86_FEATURE_NAMES const unsigned char *msg_strs = (const unsigned char *)x86_cap_strs;for (i =0 ; i <NCAPINTS ; i++) {u32 e = err_flags[i];
@@ -58,16 +55,6 @@ static void show_cap_strs(u32 *err_flags) e >>=1 ; } } -#else -for (i =0 ; i <NCAPINTS ; i++) { -u32 e = err_flags[i]; -for (j =0 ; j <32 ; j++) { -if (e &1 ) -printf ("%d:%d " , i, j); - e >>=1 ; - } - } -#endif }int validate_cpu (void )
arch/x86/include/asm/cpufeature.h +0 -5
@@ -38,15 +38,10 @@ enum cpuid_leafs#define X86_CAP_FMT_NUM "%d:%d"#define x86_cap_flag_num (flag) ((flag) >> 5), ((flag) & 31) -#ifdef CONFIG_X86_FEATURE_NAMES extern const char *const x86_cap_flags[NCAPINTS *32 ];extern const char *const x86_power_flags[32 ];#define X86_CAP_FMT "%s"#define x86_cap_flag (flag) x86_cap_flags[flag] -#else -#define X86_CAP_FMT X86_CAP_FMT_NUM -#define x86_cap_flag x86_cap_flag_num -#endif /* * In order to save room, we index into this array by doing
arch/x86/kernel/cpu/Makefile +1 -3
@@ -27,7 +27,7 @@ obj-y += cpuid-deps.o obj-y += umwait.o obj-$(CONFIG_PROC_FS) += proc.o -obj-$(CONFIG_X86_FEATURE_NAMES) += capflags.o powerflags.o +obj-y += capflags.o powerflags.o obj-$(CONFIG_IA32_FEAT_CTL) += feat_ctl.o ifdef CONFIG_CPU_SUP_INTEL
@@ -54,7 +54,6 @@ obj-$(CONFIG_X86_LOCAL_APIC) += perfctr-watchdog.o obj-$(CONFIG_HYPERVISOR_GUEST) += vmware.o hypervisor.o mshyperv.o obj-$(CONFIG_ACRN_GUEST) += acrn.o -ifdef CONFIG_X86_FEATURE_NAMES quiet_cmd_mkcapflags = MKCAP $@ cmd_mkcapflags = $(CONFIG_SHELL) $(srctree)/$(src)/mkcapflags.sh $@ $^
@@ -63,5 +62,4 @@ vmxfeature = $(src)/../../include/asm/vmxfeatures.h $(obj)/capflags.c: $(cpufeature) $(vmxfeature) $(src)/mkcapflags.sh FORCE $(call if_changed,mkcapflags) -endif targets += capflags.c
arch/x86/kernel/cpu/common.c +0 -4
@@ -1502,12 +1502,10 @@ static void __init cpu_parse_early_param(void)if (!kstrtouint (opt,10 , &bit)) {if (bit <NCAPINTS *32 ) { -#ifdef CONFIG_X86_FEATURE_NAMES /* empty-string, i.e., ""-defined feature flags */ if (!x86_cap_flags[bit])pr_cont (" " X86_CAP_FMT_NUM ,x86_cap_flag_num (bit));else -#endif pr_cont (" " X86_CAP_FMT ,x86_cap_flag (bit));setup_clear_cpu_cap (bit);
@@ -1520,7 +1518,6 @@ static void __init cpu_parse_early_param(void)continue ; } -#ifdef CONFIG_X86_FEATURE_NAMES for (bit =0 ; bit <32 *NCAPINTS ; bit++) {if (!x86_cap_flag (bit))continue ;
@@ -1537,7 +1534,6 @@ static void __init cpu_parse_early_param(void)if (!found)pr_cont (" (unknown: %s)" , opt); -#endif }pr_cont ("\n" );
Signature · 1 line
2.17.1
[tip: x86/cpu] x86/cpu: Remove X86_FEATURE_NAMES
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: 7583e8fbdc49a4dbd916d14863cf1deeddb982f9 Gitweb: https://git.kernel.org/tip/7583e8fbdc49a4dbd916d14863cf1deeddb982f9 Author: Lukas Bulwahn <[email protected]> AuthorDate: Wed, 10 May 2023 08:57:13 +02:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Mon, 15 May 2023 20:03:08 +02:00
x86/cpu: Remove X86_FEATURE_NAMES
While discussing to change the visibility of X86_FEATURE_NAMES (see Link) in order to remove CONFIG_EMBEDDED, Boris suggested to simply make the X86_FEATURE_NAMES functionality unconditional.
As the need for really tiny kernel images has gone away and kernel images with !X86_FEATURE_NAMES are hardly tested, remove this config and the whole ifdeffery in the source code.
--- arch/x86/Kconfig | 12 ------------ arch/x86/Kconfig.cpu | 2 +- arch/x86/boot/Makefile | 2 -- arch/x86/boot/cpu.c | 13 ------------- arch/x86/include/asm/cpufeature.h | 5 ----- arch/x86/kernel/cpu/Makefile | 4 +--- arch/x86/kernel/cpu/common.c | 4 ---- 7 files changed, 2 insertions(+), 40 deletions(-)
arch/x86/Kconfig +0 -12
@@ -291,7 +291,6 @@ config X86 select TRACE_IRQFLAGS_NMI_SUPPORT select USER_STACKTRACE_SUPPORT select HAVE_ARCH_KCSAN if X86_64 - select X86_FEATURE_NAMES if PROC_FS select PROC_PID_ARCH_STATUS if PROC_FS select HAVE_ARCH_NODE_DEV_GROUP if X86_SGX select FUNCTION_ALIGNMENT_16B if X86_64 || X86_ALIGNMENT_16
@@ -441,17 +440,6 @@ config SMP If you don't know what to do here, say N. -config X86_FEATURE_NAMES - bool - default y - help - This option compiles in a table of x86 feature bits and corresponding - names. This is required to support /proc/cpuinfo and a few kernel - messages. You can disable this to save space, at the expense of - making those few kernel messages show numeric feature bits instead. - - If in doubt, say Y. - config X86_X2APIC bool "Support x2apic" depends on X86_LOCAL_APIC && X86_64 && (IRQ_REMAP || HYPERVISOR_GUEST)
arch/x86/Kconfig.cpu +1 -1
@@ -389,7 +389,7 @@ config IA32_FEAT_CTL config X86_VMX_FEATURE_NAMES def_bool y - depends on IA32_FEAT_CTL && X86_FEATURE_NAMES + depends on IA32_FEAT_CTL menuconfig PROCESSOR_SELECT bool "Supported processor vendors" if EXPERT
arch/x86/boot/Makefile +0 -2
@@ -55,14 +55,12 @@ HOST_EXTRACFLAGS += -I$(srctree)/tools/include \ -include include/generated/autoconf.h \ -D__EXPORTED_HEADERS__ -ifdef CONFIG_X86_FEATURE_NAMES $(obj)/cpu.o: $(obj)/cpustr.h quiet_cmd_cpustr = CPUSTR $@ cmd_cpustr = $(obj)/mkcpustr > $@ $(obj)/cpustr.h: $(obj)/mkcpustr FORCE $(call if_changed,cpustr) -endif targets += cpustr.h # ---------------------------------------------------------------------------
arch/x86/boot/cpu.c +0 -13
@@ -14,9 +14,7 @@*/ #include "boot.h" -#ifdef CONFIG_X86_FEATURE_NAMES #include "cpustr.h" -#endif static char *cpu_name (int level) {
@@ -35,7 +33,6 @@ static char *cpu_name(int level)static void show_cap_strs (u32 *err_flags) {int i, j; -#ifdef CONFIG_X86_FEATURE_NAMES const unsigned char *msg_strs = (const unsigned char *)x86_cap_strs;for (i =0 ; i <NCAPINTS ; i++) {u32 e = err_flags[i];
@@ -58,16 +55,6 @@ static void show_cap_strs(u32 *err_flags) e >>=1 ; } } -#else -for (i =0 ; i <NCAPINTS ; i++) { -u32 e = err_flags[i]; -for (j =0 ; j <32 ; j++) { -if (e &1 ) -printf ("%d:%d " , i, j); - e >>=1 ; - } - } -#endif }int validate_cpu (void )
arch/x86/include/asm/cpufeature.h +0 -5
@@ -38,15 +38,10 @@ enum cpuid_leafs#define X86_CAP_FMT_NUM "%d:%d"#define x86_cap_flag_num (flag) ((flag) >> 5), ((flag) & 31) -#ifdef CONFIG_X86_FEATURE_NAMES extern const char *const x86_cap_flags[NCAPINTS *32 ];extern const char *const x86_power_flags[32 ];#define X86_CAP_FMT "%s"#define x86_cap_flag (flag) x86_cap_flags[flag] -#else -#define X86_CAP_FMT X86_CAP_FMT_NUM -#define x86_cap_flag x86_cap_flag_num -#endif /* * In order to save room, we index into this array by doing
arch/x86/kernel/cpu/Makefile +1 -3
@@ -27,7 +27,7 @@ obj-y += cpuid-deps.o obj-y += umwait.o obj-$(CONFIG_PROC_FS) += proc.o -obj-$(CONFIG_X86_FEATURE_NAMES) += capflags.o powerflags.o +obj-y += capflags.o powerflags.o obj-$(CONFIG_IA32_FEAT_CTL) += feat_ctl.o ifdef CONFIG_CPU_SUP_INTEL
@@ -54,7 +54,6 @@ obj-$(CONFIG_X86_LOCAL_APIC) += perfctr-watchdog.o obj-$(CONFIG_HYPERVISOR_GUEST) += vmware.o hypervisor.o mshyperv.o obj-$(CONFIG_ACRN_GUEST) += acrn.o -ifdef CONFIG_X86_FEATURE_NAMES quiet_cmd_mkcapflags = MKCAP $@ cmd_mkcapflags = $(CONFIG_SHELL) $(srctree)/$(src)/mkcapflags.sh $@ $^
@@ -63,5 +62,4 @@ vmxfeature = $(src)/../../include/asm/vmxfeatures.h $(obj)/capflags.c: $(cpufeature) $(vmxfeature) $(src)/mkcapflags.sh FORCE $(call if_changed,mkcapflags) -endif targets += capflags.c
arch/x86/kernel/cpu/common.c +0 -4
@@ -1502,12 +1502,10 @@ static void __init cpu_parse_early_param(void)if (!kstrtouint (opt,10 , &bit)) {if (bit <NCAPINTS *32 ) { -#ifdef CONFIG_X86_FEATURE_NAMES /* empty-string, i.e., ""-defined feature flags */ if (!x86_cap_flags[bit])pr_cont (" " X86_CAP_FMT_NUM ,x86_cap_flag_num (bit));else -#endif pr_cont (" " X86_CAP_FMT ,x86_cap_flag (bit));setup_clear_cpu_cap (bit);
@@ -1520,7 +1518,6 @@ static void __init cpu_parse_early_param(void)continue ; } -#ifdef CONFIG_X86_FEATURE_NAMES for (bit =0 ; bit <32 *NCAPINTS ; bit++) {if (!x86_cap_flag (bit))continue ;
@@ -1537,7 +1534,6 @@ static void __init cpu_parse_early_param(void)if (!found)pr_cont (" (unknown: %s)" , opt); -#endif }pr_cont ("\n" );