From 8014104bea78f6f82cb82e16329b562e60ecdc87 Mon Sep 17 00:00:00 2001 From: Masayoshi Mizuma Date: Fri, 13 Nov 2020 10:06:26 +0100 Subject: [PATCH] lscpu-arm: Add "BIOS Vendor ID" and "BIOS Model name" to show the SMBIOS information. After commit: 367c85c47 ("lscpu: use SMBIOS tables on ARM for lscpu"), Model name for A64FX shows like as: Model name: 461F0010 That's because 367c85c47 changes to get the modelname from Processor Version of SMBIOS. To fix that, use the hard corded table to show the "Model name" and add two new lines; "BIOS Vendor ID" and "BIOS Model name" to show the SMBIOS information. lscpu shows the SMBIOS information when root user runs it because accessing the SMBIOS information requires root privilege. [kzak@redhat.com: - port the patch to new lscpu code] Signed-off-by: Masayoshi Mizuma Signed-off-by: Karel Zak --- sys-utils/lscpu-arm.c | 19 +++++++------------ sys-utils/lscpu.c | 20 +++++++++----------- sys-utils/lscpu.h | 2 ++ 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/sys-utils/lscpu-arm.c b/sys-utils/lscpu-arm.c index 73c8b45f32..1cbc9775fa 100644 --- a/sys-utils/lscpu-arm.c +++ b/sys-utils/lscpu-arm.c @@ -283,7 +283,7 @@ done: } /* use "rXpY" string as stepping */ -static int arm_decode_rXpY(struct lscpu_cputype *ct) +static int arm_rXpY_decode(struct lscpu_cputype *ct) { int impl, revision, variant; char *end = NULL; @@ -340,13 +340,13 @@ static int arm_smbios_decode(struct lscpu_cputype *ct) str = dmi_string(&h, data[PROC_MFR_OFFSET]); if (str) { xstrncpy(buf, str, 127); - ct->vendor = xstrdup(buf); + ct->bios_vendor = xstrdup(buf); } str = dmi_string(&h, data[PROC_VERSION_OFFSET]); if (str) { xstrncpy(buf, str, 127); - ct->modelname = xstrdup(buf); + ct->bios_modelname = xstrdup(buf); } return 0; @@ -354,17 +354,12 @@ static int arm_smbios_decode(struct lscpu_cputype *ct) static void arm_decode(struct lscpu_cxt *cxt, struct lscpu_cputype *ct) { - int rc = -1; - - /* use SMBIOS Type 4 data if available, else fall back to manual - * decoding using the tables above - */ + /* use SMBIOS Type 4 data if available */ if (!cxt->noalive && access(_PATH_SYS_DMI_TYPE4, R_OK) == 0) - rc = arm_smbios_decode(ct); - if (rc) - arm_ids_decode(ct); + arm_smbios_decode(ct); - arm_decode_rXpY(ct); + arm_ids_decode(ct); + arm_rXpY_decode(ct); } void lscpu_decode_arm(struct lscpu_cxt *cxt) diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index ef655ec429..93b0860d3f 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -831,12 +831,10 @@ print_summary_cputype(struct lscpu_cxt *cxt, struct libscols_table *tb, struct libscols_line *sec) { - if (ct->modelname) { - struct libscols_line *tmp = add_summary_s(tb, sec, _("Model name:"), ct->modelname); - if (!sec) - sec= tmp; - } - + if (ct->modelname) + sec = add_summary_s(tb, sec, _("Model name:"), ct->modelname); + if (ct->bios_modelname) + add_summary_s(tb, sec, _("BIOS Model name:"), ct->bios_modelname); if (ct->machinetype) add_summary_s(tb, sec, _("Machine type:"), ct->machinetype); if (ct->family) @@ -983,16 +981,16 @@ static void print_summary(struct lscpu_cxt *cxt) _("Off-line CPU(s) list:"), set); cpuset_free(set); } + sec = NULL; /* Section: cpu type description */ if (ct->vendor) sec = add_summary_s(tb, NULL, _("Vendor ID:"), ct->vendor); + if (ct->bios_vendor) + add_summary_s(tb, sec, _("BIOS Vendor ID:"), ct->bios_vendor); - for (i = 0; i < cxt->ncputypes; i++) { - print_summary_cputype(cxt, cxt->cputypes[i], - tb, cxt->ncputypes == 1 ? sec : NULL); - - } + for (i = 0; i < cxt->ncputypes; i++) + print_summary_cputype(cxt, cxt->cputypes[i], tb, sec); sec = NULL; /* Section: vitualiazation */ diff --git a/sys-utils/lscpu.h b/sys-utils/lscpu.h index 013d58f3c6..465bd3fe24 100644 --- a/sys-utils/lscpu.h +++ b/sys-utils/lscpu.h @@ -58,10 +58,12 @@ struct lscpu_cputype { char *vendor; int vendor_id; /* created by lscpu_decode_arm() */ + char *bios_vendor; /* aarch64 */ char *machinetype; /* s390 */ char *family; char *model; char *modelname; + char *bios_modelname; /* aarch64 */ char *revision; /* alternative for model (ppc) */ char *stepping; char *bogomips; -- 2.47.3