Skip to contentSkip to conversation

lscpu-arm: Add "BIOS Vendor ID" and "BIOS Model name" to show the SMBIOS information.

PATCH In review Masayoshi Mizuma 3 participants 5 messages Nov 11, 2020 – Nov 13, 2020 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 lscpu-arm: Add "BIOS Vendor ID" and "BIOS Model name" to show the SMBIOS information.

From: Masayoshi Mizuma <[email protected]>

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.

---
 sys-utils/lscpu-arm.c | 22 ++++++++--------------
 sys-utils/lscpu.c     |  4 ++++
 sys-utils/lscpu.h     |  2 ++
 3 files changed, 14 insertions(+), 14 deletions(-)
sys-utils/lscpu-arm.c +8 -14
index 20c7291e5..52dbff804 100644
@@ -281,7 +281,7 @@ static void __arm_cpu_decode(struct lscpu_desc *desc)
 #define PROC_MFR_OFFSET		0x07
 #define PROC_VERSION_OFFSET	0x10
 
-static int __arm_cpu_smbios(struct lscpu_desc *desc)
+static void __arm_cpu_smbios(struct lscpu_desc *desc)
 {
 	uint8_t data[8192];
 	char buf[128], *str;
@@ -291,41 +291,35 @@ static int __arm_cpu_smbios(struct lscpu_desc *desc)
 
 	fd = open(_PATH_SYS_DMI_TYPE4, O_RDONLY);
 	if (fd < 0)
-		return fd;
+		return;
 
 	rs = read_all(fd, (char *) data, 8192);
 	close(fd);
 
 	if (rs == -1)
-		return -1;
+		return;
 
 	to_dmi_header(&h, data);
 
 	str = dmi_string(&h, data[PROC_MFR_OFFSET]);
 	if (str) {
 		xstrncpy(buf, str, 127);
-		desc->vendor = xstrdup(buf);
+		desc->bios_vendor = xstrdup(buf);
 	}
 
 	str = dmi_string(&h, data[PROC_VERSION_OFFSET]);
 	if (str) {
 		xstrncpy(buf, str, 127);
-		desc->modelname = xstrdup(buf);
+		desc->bios_modelname = xstrdup(buf);
 	}
-
-	return 0;
 }
 
 void arm_cpu_decode(struct lscpu_desc *desc, struct lscpu_modifier *mod)
 {
-	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 (mod->system == SYSTEM_LIVE &&
 	    access(_PATH_SYS_DMI_TYPE4, R_OK) == 0)
-		rc = __arm_cpu_smbios(desc);
+		__arm_cpu_smbios(desc);
 
-	if (rc)
-		__arm_cpu_decode(desc);
+	__arm_cpu_decode(desc);
 }
sys-utils/lscpu.c +4 -0
index b7dc4dfb5..a3e7b4445 100644
@@ -2146,6 +2146,8 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
 		add_summary_n(tb, _("NUMA node(s):"), desc->nnodes);
 	if (desc->vendor)
 		add_summary_s(tb, _("Vendor ID:"), desc->vendor);
+	if (desc->bios_vendor)
+		add_summary_s(tb, _("BIOS Vendor ID:"), desc->bios_vendor);
 	if (desc->machinetype)
 		add_summary_s(tb, _("Machine type:"), desc->machinetype);
 	if (desc->family)
@@ -2154,6 +2156,8 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
 		add_summary_s(tb, _("Model:"), desc->revision ? desc->revision : desc->model);
 	if (desc->modelname || desc->cpu)
 		add_summary_s(tb, _("Model name:"), desc->cpu ? desc->cpu : desc->modelname);
+	if (desc->bios_modelname)
+		add_summary_s(tb, _("BIOS Model name:"), desc->bios_modelname);
 	if (desc->stepping)
 		add_summary_s(tb, _("Stepping:"), desc->stepping);
 	if (desc->freqboost >= 0)
sys-utils/lscpu.h +2 -0
index 3de0abcce..d73583f77 100644
@@ -98,10 +98,12 @@ struct lscpu_desc {
 
 	char	*arch;
 	char	*vendor;
+	char	*bios_vendor;	/* aarch64 */
 	char	*machinetype;	/* s390 */
 	char	*family;
 	char	*model;
 	char	*modelname;
+	char	*bios_modelname;  /* aarch64 */
 	char	*revision;  /* alternative for model (ppc) */
 	char	*cpu;       /* alternative for modelname (ppc, sparc) */
 	char	*virtflag;	/* virtualization flag (vmx, svm) */
Signature · 1 line
2.27.0
maintainer
#1 lore raw
Quoted 17 lines · Masayoshi Mizuma

From: Masayoshi Mizuma <[email protected]>

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.

Quoted 6 lines
---
 sys-utils/lscpu-arm.c | 22 ++++++++--------------
 sys-utils/lscpu.c     |  4 ++++
 sys-utils/lscpu.h     |  2 ++
 3 files changed, 14 insertions(+), 14 deletions(-)

OK, I'll integrate it to my new lscpu later this week. Thanks!

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
maintainer
#2 lore raw
In reply to Masayoshi Mizuma
Quoted 4 lines · Masayoshi Mizuma
 sys-utils/lscpu-arm.c | 22 ++++++++--------------
 sys-utils/lscpu.c     |  4 ++++
 sys-utils/lscpu.h     |  2 ++
 3 files changed, 14 insertions(+), 14 deletions(-)

Ported to the new lscpu and merged. Thanks (and extra thanks for your patience :-).

I see one issue with the stuff from BIOS. It seems it reads the information always from the same place. How does it work if I have two different CPUs? I guess it always return the same model name, but what if I have Cortex-A53 and Cortex-A72 on the same board?

Maybe we should disable reading from BIOS on systems with more than one CPU type.

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#3 lore raw
Quoted 8 lines · Karel Zak
Quoted 4 lines · Masayoshi Mizuma
 sys-utils/lscpu-arm.c | 22 ++++++++--------------
 sys-utils/lscpu.c     |  4 ++++
 sys-utils/lscpu.h     |  2 ++
 3 files changed, 14 insertions(+), 14 deletions(-)

Ported to the new lscpu and merged. Thanks (and extra thanks for your patience :-).

Thank you so much!

Quoted 5 lines

I see one issue with the stuff from BIOS. It seems it reads the information always from the same place. How does it work if I have two different CPUs? I guess it always return the same model name, but what if I have Cortex-A53 and Cortex-A72 on the same board?

The first entry, /sys/firmware/dmi/entries/4-0/raw, is only used,
so lscpu will show the same information of the SMBIOS type4 from
the entry even if the system has two diffrent cpu models, like Cortex-A53 and Cortex-A72.
I'm not familiar with the heterogenous SoC, probably each
CPU model has own SMBIOS type4, right? for example, /sys/firmware/dmi/entries/4-0/raw is for Cortex-A53 and /sys/firmware/dmi/entries/4-1/raw is for Cortex-A72.

Quoted 3 lines

Maybe we should disable reading from BIOS on systems with more than one CPU type.

I agree with you.

Thanks,
Masa

#4 lore raw
Quoted 18 lines · Masayoshi Mizuma
Quoted 8 lines · Karel Zak
Quoted 4 lines · Masayoshi Mizuma
 sys-utils/lscpu-arm.c | 22 ++++++++--------------
 sys-utils/lscpu.c     |  4 ++++
 sys-utils/lscpu.h     |  2 ++
 3 files changed, 14 insertions(+), 14 deletions(-)

Ported to the new lscpu and merged. Thanks (and extra thanks for your patience :-).

Thank you so much!

Quoted 5 lines

I see one issue with the stuff from BIOS. It seems it reads the information always from the same place. How does it work if I have two different CPUs? I guess it always return the same model name, but what if I have Cortex-A53 and Cortex-A72 on the same board?

Quoted 7 lines

The first entry, /sys/firmware/dmi/entries/4-0/raw, is only used,
so lscpu will show the same information of the SMBIOS type4 from
the entry even if the system has two diffrent cpu models, like Cortex-A53 and Cortex-A72.
I'm not familiar with the heterogenous SoC, probably each
CPU model has own SMBIOS type4, right? for example, /sys/firmware/dmi/entries/4-0/raw is for Cortex-A53 and /sys/firmware/dmi/entries/4-1/raw is for Cortex-A72.

That's correct: there will be a 4-x/raw file for each CPU type. So far it's been safe to assume that all CPUs are the same in a system, but with ARM big.LITTLE, that's no longer a safe assumption. It will take a bit more work to associate each SMBIOS entry with each CPU in /proc/cpuinfo.

https://en.wikipedia.org/wiki/ARM_big.LITTLE

Signature · 3 lines
Jeff Bastian
Kernel QE - Hardware Enablement
Red Hat