Re: [PATCH v12 2/4] x86/cpu: Check if feature string is non-zero
From: Maciej Wieczor-Retman
Date: Mon Mar 30 2026 - 16:50:41 EST
On 2026-03-30 at 22:00:45 +0200, Borislav Petkov wrote:
>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.
Sorry, will do.
>
>...
>
>> +/*
>> + * 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.
so maybe:
+ * Return the feature's "name" if available, otherwise return the
+ * feature's bit numerals in "word:bit" format so it's easier to identify.
?
>> + * 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. ;-\
X86_NAMELESS_FEAT_BUF?
X86_NUM_FEAT_BUF?
Not sure how to make it much more shorter without making it also unreadable.
--
Kind regards
Maciej Wieczór-Retman