Add new cpu model name of arm Kunpeng

This commit is contained in:
YunYi Yang 2025-03-31 17:11:57 +08:00
parent 0edf3433f5
commit 2992df4396
2 changed files with 88 additions and 1 deletions

View File

@ -0,0 +1,80 @@
From b3128c17d74233a4de449464559f26094be41d5e Mon Sep 17 00:00:00 2001
From: YunYi Yang <yangyunyi2@huawei.com>
Date: Sat, 29 Mar 2025 15:31:39 +0800
Subject: [PATCH] Add new cpu model name of arm Kunpeng
Add the display of the CPU model name when the CPU part id is 0xd02/0xd03
for Kunpeng. The ID may correspond to multiple cpu model names. Therefore,
refer to the bios model name.
https://gitee.com/src-openeuler/util-linux/issues/IBBNGQ
---
sys-utils/lscpu-arm.c | 37 ++++++++++++++++++++++++++++++++++---
1 file changed, 34 insertions(+), 3 deletions(-)
diff --git a/sys-utils/lscpu-arm.c b/sys-utils/lscpu-arm.c
index 79b8e3a..4c60973 100644
--- a/sys-utils/lscpu-arm.c
+++ b/sys-utils/lscpu-arm.c
@@ -29,6 +29,7 @@
struct id_part {
const int id;
const char* name;
+ char* (*inner)(const int, const char*, struct lscpu_cputype *ct);
};
static const struct id_part arm_part[] = {
@@ -183,9 +184,13 @@ static const struct id_part fujitsu_part[] = {
{ -1, "unknown" },
};
+
+char* hisi_get_inner_name_compatible(const int id, const char* name, struct lscpu_cputype *ct);
+
static const struct id_part hisi_part[] = {
- { 0xd01, "Kunpeng-920" }, /* aka tsv110 */
- { -1, "unknown" },
+ { 0xd01, "Kunpeng-920", NULL },
+ { 0xd02, "unknown", hisi_get_inner_name_compatible},
+ { -1, "unknown", NULL },
};
static const struct id_part ft_part[] = {
@@ -252,6 +2597,19 @@ static inline int parse_implementer_id(struct lscpu_cputype *ct)
return ct->vendor_id;
}
+char* hisi_get_inner_name_compatible(const int id __attribute__((unused)), const char* name, struct lscpu_cputype *ct)
+{
+ char* bios_modelname = ct->bios_modelname;
+ if (bios_modelname == NULL) {
+ return (char*)name;
+ }
+ // Compatible with HUAWEI Kunpeng 920 7282C models
+ if (strstr(bios_modelname, "7282C") != NULL) {
+ return "Kunpeng 920 7282C";
+ }
+ return bios_modelname;
+}
+
/*
* Use model and vendor IDs to decode to human readable names.
*/
@@ -285,7 +303,13 @@ static int arm_ids_decode(struct lscpu_cputype *ct)
for (j = 0; parts[j].id != -1; j++) {
if (parts[j].id == part) {
free(ct->modelname);
- ct->modelname = xstrdup(parts[j].name);
+ char* real_name = NULL;
+ if (parts[j].inner != NULL) {
+ real_name = parts[j].inner(parts[j].id, parts[j].name, ct);
+ } else {
+ real_name = (char*)parts[j].name;
+ }
+ ct->modelname = xstrdup(real_name);
break;
}
}
--
2.33.0

View File

@ -3,7 +3,7 @@
Name: util-linux
Version: 2.37.2
Release: 40
Release: 41
Summary: A random collection of Linux utilities
License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain
URL: https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git
@ -177,6 +177,7 @@ Patch9002: util-linux-Add-sw64-architecture.patch
%endif
Patch9003: backport-uuidd-fix-open-lock-state-issue.patch
Patch9004: sfdisk-fix-crash-casued-by-out-of-bounds-access.patch
Patch9005: Add-new-cpu-model-name-of-arm-Kunpeng.patch
BuildRequires: audit-libs-devel >= 1.0.6 gettext-devel libselinux-devel ncurses-devel pam-devel zlib-devel popt-devel
BuildRequires: libutempter-devel systemd-devel systemd libuser-devel libcap-ng-devel python3-devel gcc autoconf automake
@ -547,6 +548,12 @@ fi
%{_mandir}/man8/{swapoff.8*,swapon.8*,switch_root.8*,umount.8*,wdctl.8.gz,wipefs.8*,zramctl.8*}
%changelog
* Mon Mar 31 2025 YunYi Yang <yangyunyi2@huawei.com> - 2.37.2-41
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:Add new cpu model name of arm Kunpeng
* Mon Mar 03 2025 zhangyao <zhangyao108@huawei.com> - 2.37.2-40
- Type:bugfix
- CVE:NA