Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.5:Update
util-linux-systemd.35484
util-linux-lscpu-skip-aarch64-decode.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File util-linux-lscpu-skip-aarch64-decode.patch of Package util-linux-systemd.35484
From 50a3efab6d126b28fcdcc28f1a0cd5cd596ae357 Mon Sep 17 00:00:00 2001 From: "Pratik R. Sampat" <pratikrajesh.sampat@amd.com> Date: Mon, 22 Jul 2024 16:00:46 +0000 Subject: [PATCH] lscpu: Skip aarch64 decode path for rest of the architectures lscpu behaves differently when run sudo vs non-sudo on AMD architectures. On sudo runs, it adds a BIOS model name and BIOS CPU family which it does not add for the latter. However since this parsing from the DMI is primarily catered to aarch64, for AMD platform the BIOS model name is printed out as follows "AMD XXX Processor *Unknown* CPU @ X.XGHz" due to the part number is not populated on the platform. The issue boils down to an unconditional call to arm_decode() which attempts to read the DMI path and populate the processor information such as processor version and part number which is set to Unknown on AMD CPUs. 81d6de9 (lscpu: remove the old code) changed the DMI path from /sys/firmware/dmi/entries/4-0/raw (non-existent) to /sys/firmware/dmi/tables/dmi (existent) which has brought this latent issue to light as DMI was starting to be parsed incorrectly. Therefore, do not perform aarch64 parsing for other architectures. Before ------ $ lscpu Vendor ID: AuthenticAMD Model name: AMD EPYC XXXX X-Core Processor CPU family: 26 $ sudo lscpu Vendor ID: AuthenticAMD BIOS Vendor ID: Advanced Micro Devices, Inc. Model name: AMD EPYC XXXX X-Core Processor BIOS Model name: AMD EPYC XXXX X-Core Processor Unknown CPU @ X.XGHz BIOS CPU family: 107 CPU family: 26 After ----- $ lscpu Vendor ID: AuthenticAMD Model name: AMD EPYC XXXX X-Core Processor CPU family: 26 $ sudo lscpu Vendor ID: AuthenticAMD Model name: AMD EPYC XXXX X-Core Processor CPU family: 26 Fixes: 81d6de9 ("lscpu: remove the old code") Co-developed-by: Karel Zak <kzak@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Pratik R. Sampat <pratikrajesh.sampat@amd.com> --- sys-utils/lscpu-arm.c | 37 ++++++++++++++++++++++++++++++++++++- sys-utils/lscpu.c | 3 ++- sys-utils/lscpu.h | 2 ++ 3 files changed, 40 insertions(+), 2 deletions(-) Contains parts of: commit 5d1129e6879a05aa9ac5804ffc8ace22cda735c1 Author: Karel Zak <kzak@redhat.com> Date: Mon Jul 29 10:21:28 2024 +0200 Index: util-linux-2.39.3/sys-utils/lscpu-arm.c =================================================================== --- util-linux-2.39.3.orig/sys-utils/lscpu-arm.c +++ util-linux-2.39.3/sys-utils/lscpu-arm.c @@ -332,14 +332,49 @@ static int parse_id(const char *str) #define parse_model_id(_cxt) (parse_id((_cxt)->model)) +static inline int get_implementer_id(struct lscpu_cputype *ct) +{ + if (ct->vendor_id) + return ct->vendor_id; + return parse_id(ct->vendor); +} + static inline int parse_implementer_id(struct lscpu_cputype *ct) { + int id; + if (ct->vendor_id) return ct->vendor_id; - ct->vendor_id = parse_id(ct->vendor); + id = get_implementer_id(ct); + if (id <= 0) + return id; + + ct->vendor_id = id; return ct->vendor_id; } +int is_arm(struct lscpu_cxt *cxt) +{ + size_t i; + + if (is_live(cxt)) + return strcmp(cxt->arch->name, "aarch64") == 0; + + /* dump; assume ARM if vendor ID is known */ + for (i = 0; i < cxt->ncputypes; i++) { + + int j, id = get_implementer_id(cxt->cputypes[i]); + if (id <= 0) + continue; + for (j = 0; hw_implementer[j].id != -1; j++) { + if (hw_implementer[j].id == id) + return 1; + } + } + + return 0; +} + /* * Use model and vendor IDs to decode to human readable names. */ Index: util-linux-2.39.3/sys-utils/lscpu.c =================================================================== --- util-linux-2.39.3.orig/sys-utils/lscpu.c +++ util-linux-2.39.3/sys-utils/lscpu.c @@ -1371,7 +1371,8 @@ int main(int argc, char *argv[]) lscpu_read_numas(cxt); lscpu_read_topology(cxt); - lscpu_decode_arm(cxt); + if (is_arm(cxt)) + lscpu_decode_arm(cxt); cxt->virt = lscpu_read_virtualization(cxt); Index: util-linux-2.39.3/sys-utils/lscpu.h =================================================================== --- util-linux-2.39.3.orig/sys-utils/lscpu.h +++ util-linux-2.39.3/sys-utils/lscpu.h @@ -252,6 +252,8 @@ struct lscpu_cxt { int is_cluster; /* For aarch64 if the machine doesn't have ACPI PPTT */ }; +#define is_live(_cxt) (!(_cxt)->noalive) + #define is_cpu_online(_cxt, _cpu) \ ((_cxt) && (_cpu) && (_cxt)->online && \ CPU_ISSET_S((_cpu)->logical_id, (_cxt)->setsize, (_cxt)->online)) @@ -260,6 +262,8 @@ struct lscpu_cxt { ((_cxt) && (_cpu) && (_cxt)->present && \ CPU_ISSET_S((_cpu)->logical_id, (_cxt)->setsize, (_cxt)->present)) +int is_arm(struct lscpu_cxt *cxt); + struct lscpu_cputype *lscpu_new_cputype(void); void lscpu_ref_cputype(struct lscpu_cputype *ct); void lscpu_unref_cputype(struct lscpu_cputype *ct);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor