Re: [tip: objtool/core] objtool: Function to get the name of a CPU feature

From: Alexandre Chartre
Date: Mon Nov 24 2025 - 11:44:39 EST



On 11/24/25 13:26, Borislav Petkov wrote:
On Mon, Nov 24, 2025 at 12:59:42PM +0100, Peter Zijlstra wrote:
On Mon, Nov 24, 2025 at 10:44:01AM -0000, tip-bot2 for Alexandre Chartre wrote:
The following commit has been merged into the objtool/core branch of tip:

Commit-ID: afff4e5820e9a0d609740a83c366f3f0335db342
Gitweb: https://git.kernel.org/tip/afff4e5820e9a0d609740a83c366f3f0335db342
Author: Alexandre Chartre <alexandre.chartre@xxxxxxxxxx>
AuthorDate: Fri, 21 Nov 2025 10:53:36 +01:00
Committer: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
CommitterDate: Mon, 24 Nov 2025 11:35:06 +01:00

objtool: Function to get the name of a CPU feature

Also, this commit name needs a verb.

Ok, then:

objtool: Add function to get the name of a CPU feature

Boris just reported that this doesn't work on mawk, since it uses a GNU
awk extension (3rd argument for match()).

Could you please look at writing this in strict POSIX awk?

The fail is:

awk: ../arch/x86/tools/gen-cpu-feature-names-x86.awk: line 20: syntax error at or near ,
awk: ../arch/x86/tools/gen-cpu-feature-names-x86.awk: line 23: syntax error at or near }
awk: ../arch/x86/tools/gen-cpu-feature-names-x86.awk: line 26: syntax error at or near ,
awk: ../arch/x86/tools/gen-cpu-feature-names-x86.awk: line 29: syntax error at or near }
make[5]: *** [arch/x86/Build:21: /root/kernel/linux/tools/objtool/arch/x86/lib/cpu-feature-names.c] Error 2
make[5]: *** Deleting file '/root/kernel/linux/tools/objtool/arch/x86/lib/cpu-feature-names.c'
make[4]: *** [/root/kernel/linux/tools/build/Makefile.build:142: arch/x86] Error 2
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [Makefile:104: /root/kernel/linux/tools/objtool/objtool-in.o] Error 2
make[2]: *** [Makefile:73: objtool] Error 2
make[1]: *** [/root/kernel/linux/Makefile:1449: tools/objtool] Error 2
make: *** [Makefile:248: __sub-make] Error 2

ls -al /usr/bin/awk
lrwxrwxrwx 1 root root 21 Feb 19 2021 /usr/bin/awk -> /etc/alternatives/awk
ls -al /etc/alternatives/awk
lrwxrwxrwx 1 root root 13 Feb 19 2021 /etc/alternatives/awk -> /usr/bin/mawk


Here is a fix. It works with gawk and mawk:

diff --git a/tools/arch/x86/tools/gen-cpu-feature-names-x86.awk b/tools/arch/x86/tools/gen-cpu-feature-names-x86.awk
index 1b1c1d84225c2..cc4c7a3e6c2e2 100644
--- a/tools/arch/x86/tools/gen-cpu-feature-names-x86.awk
+++ b/tools/arch/x86/tools/gen-cpu-feature-names-x86.awk
@@ -12,19 +12,20 @@ BEGIN {
print
print "static const char *cpu_feature_names[(NCAPINTS+NBUGINTS)*32] = {"
- feature_expr = "(X86_FEATURE_[A-Z0-9_]+)\\s+\\(([0-9*+ ]+)\\)"
- debug_expr = "(X86_BUG_[A-Z0-9_]+)\\s+X86_BUG\\(([0-9*+ ]+)\\)"
+ value_expr = "\\([0-9*+ ]+\\)"
}
/^#define X86_FEATURE_/ {
- if (match($0, feature_expr, m)) {
- print "\t[" m[2] "] = \"" m[1] "\","
+ if (match($0, value_expr)) {
+ value = substr($0, RSTART + 1, RLENGTH - 2)
+ print "\t[" value "] = \"" $2 "\","
}
}
/^#define X86_BUG_/ {
- if (match($0, debug_expr, m)) {
- print "\t[NCAPINTS*32+(" m[2] ")] = \"" m[1] "\","
+ if (match($0, value_expr)) {
+ value = substr($0, RSTART + 1, RLENGTH - 2)
+ print "\t[NCAPINTS*32+(" value ")] = \"" $2 "\","
}
}
I am going to send the updated patch.

Rgds,

alex.