]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lscpu: add nooverwrite flag for ARM implementer table
authorKarel Zak <kzak@redhat.com>
Thu, 28 May 2026 10:03:28 +0000 (12:03 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 1 Jun 2026 10:49:43 +0000 (12:49 +0200)
Add a nooverwrite flag to struct hw_impl. When set, vendor and model
name already provided by the kernel in /proc/cpuinfo are preserved
rather than being overwritten by the hardcoded lookup tables. The
tables serve as a fallback when the kernel does not provide the
information.

This approach keeps all implementer entries in the table, which is
also required for "lscpu --arm-id" to list all known vendors and
part IDs.

Addresses: https://github.com/util-linux/util-linux/pull/4362
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/lscpu-arm.c

index ca12893a152245593b60ea6eae981551d53bb291..978066e390d58980d1c75a8f509d14f3a2ff1ee4 100644 (file)
@@ -300,10 +300,13 @@ static const struct id_part unknown_part[] = {
     { -1, "unknown" },
 };
 
+#define HW_IMPL_NOOVERWRITE    true    /* don't overwrite vendor and model from /proc/cpuinfo */
+
 struct hw_impl {
    const int    id;
    const struct id_part     *parts;
    const char   *name;
+   const bool   nooverwrite;
 };
 
 static const struct hw_impl hw_implementer[] = {
@@ -413,8 +416,10 @@ static int arm_ids_decode(struct lscpu_cputype *ct)
                return 0;
 
        /* decode vendor */
-       free(ct->vendor);
-       ct->vendor = xstrdup(hw->name);
+       if (!ct->vendor || !hw->nooverwrite) {
+               free(ct->vendor);
+               ct->vendor = xstrdup(hw->name);
+       }
 
        /* decode model */
        part = parse_model_id(ct);
@@ -423,8 +428,10 @@ static int arm_ids_decode(struct lscpu_cputype *ct)
 
        for (j = 0; hw->parts[j].id != -1; j++) {
                if (hw->parts[j].id == part) {
-                       free(ct->modelname);
-                       ct->modelname = xstrdup(hw->parts[j].name);
+                       if (!ct->modelname || !hw->nooverwrite) {
+                               free(ct->modelname);
+                               ct->modelname = xstrdup(hw->parts[j].name);
+                       }
                        break;
                }
        }