Re: [PATCH v8 1/3] x86/cpu: Clear feature bits disabled at compile-time
From: Sohil Mehta
Date: Mon Mar 09 2026 - 19:48:08 EST
On 3/2/2026 7:25 AM, Maciej Wieczor-Retman wrote:
> /* Aligned to unsigned long to avoid split lock in atomic bitmap ops */
> -__u32 cpu_caps_cleared[NCAPINTS + NBUGINTS] __aligned(sizeof(unsigned long));
> +__u32 cpu_caps_cleared[NCAPINTS + NBUGINTS] __aligned(sizeof(unsigned long)) =
> + DISABLED_MASK_INITIALIZER;
IIUC, DISABLED_MASK_INITIALIZER only contains the X86_FEATURE_* bits.
So, the NBUGINTS bits in cpu_caps_cleared[] are implicitly set to 0.
Should that be mentioned in the comment above? It wasn't obvious to me
when I first looked at it.
> __u32 cpu_caps_set[NCAPINTS + NBUGINTS] __aligned(sizeof(unsigned long));
>
> #ifdef CONFIG_X86_32
> diff --git a/arch/x86/tools/cpufeaturemasks.awk b/arch/x86/tools/cpufeaturemasks.awk
> index 173d5bf2d999..b7f4e775a365 100755
> --- a/arch/x86/tools/cpufeaturemasks.awk
> +++ b/arch/x86/tools/cpufeaturemasks.awk
> @@ -82,6 +82,12 @@ END {
> }
> printf " 0\t\\\n";
> printf "\t) & (1U << ((x) & 31)))\n\n";
> +
> + printf "\n#define %s_MASK_INITIALIZER\t\t\t\\", s;
> + printf "\n\t{\t\t\t\t\t\t\\";
> + for (i = 0; i < ncapints; i++)
> + printf "\n\t\t%s_MASK%d,\t\t\t\\", s, i;
> + printf "\n\t}\n\n";
> }
>
> printf "#endif /* _ASM_X86_CPUFEATUREMASKS_H */\n";