Re: [PATCH v12 2/4] x86/cpu: Check if feature string is non-zero

From: Borislav Petkov

Date: Mon Mar 30 2026 - 16:06:08 EST


On Fri, Mar 27, 2026 at 03:10:52PM +0000, Maciej Wieczor-Retman wrote:
> diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
> index 76339e988304..7cfd124b3fbf 100644
> --- a/arch/x86/kernel/cpu/common.c
> +++ b/arch/x86/kernel/cpu/common.c
> @@ -678,6 +678,7 @@ cpuid_dependent_features[] = {
> static void filter_cpuid_features(struct cpuinfo_x86 *c, bool warn)
> {
> const struct cpuid_dependent_feature *df;
> + char feature_buf[X86_NAMELESS_FEAT_BUFLEN];

The tip-tree preferred ordering of variable declarations at the
beginning of a function is reverse fir tree order::

struct long_struct_name *descriptive_name;
unsigned long foo, bar;
unsigned int tmp;
int ret;

The above is faster to parse than the reverse ordering::

int ret;
unsigned int tmp;
unsigned long foo, bar;
struct long_struct_name *descriptive_name;

And even more so than random ordering::

unsigned long foo, bar;
int ret;
struct long_struct_name *descriptive_name;
unsigned int tmp;

Check your whole set pls.

...

> +/*
> + * Return the feature "name" if available, otherwise return the
> + * X86_FEATURE_* numerals to make it easier to identify the feature.

"return the X86_FEATURE word number and bit position...."

Might as well correct it to be more precise.

> + * Callers of this function need to pass a char * buffer of size
> + * X86_NAMELESS_FEAT_BUFLEN.
> + */
> +const char *x86_feature_name(unsigned int bit, char *buf)

...

> void check_cpufeature_deps(struct cpuinfo_x86 *c)
> {
> - char feature_buf[16], depends_buf[16];
> + char feature_buf[X86_NAMELESS_FEAT_BUFLEN], depends_buf[X86_NAMELESS_FEAT_BUFLEN];

Blergh, that define is too long. ;-\

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette