From: Karel Zak Date: Thu, 28 May 2026 10:03:28 +0000 (+0200) Subject: lscpu: add nooverwrite flag for ARM implementer table X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a57533541324a03dcbbbfb97cca21e7029aa50a8;p=thirdparty%2Futil-linux.git lscpu: add nooverwrite flag for ARM implementer table 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 --- diff --git a/sys-utils/lscpu-arm.c b/sys-utils/lscpu-arm.c index ca12893a1..978066e39 100644 --- a/sys-utils/lscpu-arm.c +++ b/sys-utils/lscpu-arm.c @@ -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; } }