Re: [PATCH v2 2/3] x86/cpufeatures: Generate a feature mask header based on build config

From: Xin Li
Date: Tue Jun 18 2024 - 06:11:38 EST


On 6/17/2024 9:34 AM, Brian Gerst wrote:
On Sun, Jun 16, 2024 at 4:58 AM Xin Li (Intel) <xin@xxxxxxxxx> wrote:

From: "H. Peter Anvin (Intel)" <hpa@xxxxxxxxx>

Introduce an AWK script to auto-generate a header with required and
disabled feature masks based on <asm/cpufeatures.h> and current build
config. Thus for any CPU feature with a build config, e.g., X86_FRED,
simply add

+
+file == 2 && $1 ~ /^CONFIG_X86_[A-Z]*_FEATURE_/ {
+ on = ($2 == "y");
+ printf "/* %s = %s (%d) */\n", $1, $2, on;

This looks like extra debugging output that doesn't need to be in the
final release.

+ if (split($1, fs, "CONFIG_X86_|_FEATURE_") == 3) {
+ printf "/* %s %s = %d */\n", fs[2], fs[3], on;

Same.

Right, they are comments but better remove them.

+ printf "#define SSE_MASK\t\\\n";
+ printf "\t(REQUIRED_MASK0 & ((1<<(X86_FEATURE_XMM & 31)) | (1<<(X86_FEATURE_XMM2 & 31))))\n\n";

This could be moved to verify_cpu.S, since that is the only place it is used.

NP.

+ printf "#endif /* _ASM_X86_FEATUREMASKS_H */\n";
+}
--
2.45.1



You could also generate {REQUIRED|DISABLED}_MASK_BIT_SET() in this
script, so that they are always in sync with NCAPINTS.

Yeah, just better to make this an add-on patch.

Thanks!
Xin