[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251124115942.GO4067720@noisy.programming.kicks-ass.net>
Date: Mon, 24 Nov 2025 12:59:42 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: linux-kernel@...r.kernel.org
Cc: linux-tip-commits@...r.kernel.org,
Alexandre Chartre <alexandre.chartre@...cle.com>,
Josh Poimboeuf <jpoimboe@...nel.org>, x86@...nel.org
Subject: Re: [tip: objtool/core] objtool: Function to get the name of a CPU
feature
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@...cle.com>
> AuthorDate: Fri, 21 Nov 2025 10:53:36 +01:00
> Committer: Peter Zijlstra <peterz@...radead.org>
> CommitterDate: Mon, 24 Nov 2025 11:35:06 +01:00
>
> objtool: Function to get the name of a CPU feature
>
> Add a function to get the name of a CPU feature. The function is
> architecture dependent and currently only implemented for x86. The
> feature names are automatically generated from the cpufeatures.h
> include file.
>
> Signed-off-by: Alexandre Chartre <alexandre.chartre@...cle.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
> Acked-by: Josh Poimboeuf <jpoimboe@...nel.org>
> Link: https://patch.msgid.link/20251121095340.464045-27-alexandre.chartre@oracle.com
> ---
> tools/arch/x86/tools/gen-cpu-feature-names-x86.awk | 33 +++++++++++++-
> tools/objtool/.gitignore | 1 +-
> tools/objtool/Makefile | 1 +-
> tools/objtool/arch/loongarch/special.c | 5 ++-
> tools/objtool/arch/powerpc/special.c | 5 ++-
> tools/objtool/arch/x86/Build | 13 ++++-
> tools/objtool/arch/x86/special.c | 10 ++++-
> tools/objtool/include/objtool/special.h | 2 +-
> 8 files changed, 69 insertions(+), 1 deletion(-)
> create mode 100644 tools/arch/x86/tools/gen-cpu-feature-names-x86.awk
>
> diff --git a/tools/arch/x86/tools/gen-cpu-feature-names-x86.awk b/tools/arch/x86/tools/gen-cpu-feature-names-x86.awk
> new file mode 100644
> index 0000000..1b1c1d8
> --- /dev/null
> +++ b/tools/arch/x86/tools/gen-cpu-feature-names-x86.awk
> @@ -0,0 +1,33 @@
> +#!/bin/awk -f
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# Copyright (c) 2025, Oracle and/or its affiliates.
> +#
> +# Usage: awk -f gen-cpu-feature-names-x86.awk cpufeatures.h > cpu-feature-names.c
> +#
> +
> +BEGIN {
> + print "/* cpu feature name array generated from cpufeatures.h */"
> + print "/* Do not change this code. */"
> + 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*+ ]+)\\)"
> +}
> +
> +/^#define X86_FEATURE_/ {
> + if (match($0, feature_expr, m)) {
> + print "\t[" m[2] "] = \"" m[1] "\","
> + }
> +}
> +
> +/^#define X86_BUG_/ {
> + if (match($0, debug_expr, m)) {
> + print "\t[NCAPINTS*32+(" m[2] ")] = \"" m[1] "\","
> + }
> +}
> +
> +END {
> + print "};"
> +}
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?
Powered by blists - more mailing lists