|
|
531551 |
From 6999f3f3ca525bb6b132f4ed804e7f8fe62e5f79 Mon Sep 17 00:00:00 2001
|
|
|
531551 |
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
|
|
|
531551 |
Date: Wed, 12 Apr 2017 10:11:29 +0100
|
|
|
531551 |
Subject: [PATCH] lscpu: use sysfs for table access if available
|
|
|
531551 |
|
|
|
531551 |
On ARM systems, accessing SMBIOS tables via /dev/mem using read()
|
|
|
531551 |
calls is not supported. The reason is that such tables are usually
|
|
|
531551 |
located in EFI_RUNTIME_SERVICE_DATA memory, which is not covered
|
|
|
531551 |
by the linear mapping on those systems, and so read() calls will
|
|
|
531551 |
fail.
|
|
|
531551 |
|
|
|
531551 |
So instead, use the /sys/firmware/dmi/tables/DMI sysfs file, which
|
|
|
531551 |
contains the entire structure table array, and will be available
|
|
|
531551 |
on any recent Linux system, even on ones that only export the rev3
|
|
|
531551 |
SMBIOS entry point, which is currently ignored by lscpu.
|
|
|
531551 |
|
|
|
531551 |
Note that the max 'num' value is inferred from the size. This is not
|
|
|
531551 |
a limitation of the sysfs interface, but a limitation of the rev3
|
|
|
531551 |
entry point, which no longer carries a number of array elements.
|
|
|
531551 |
|
|
|
531551 |
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1455664
|
|
|
531551 |
Upstream: http://github.com/karelzak/util-linux/commit/92a6392c41c11bcb49af9f129dfbd1fed651f044
|
|
|
531551 |
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
|
|
|
531551 |
Tested-by: Alexander Graf <agraf@suse.de>
|
|
|
531551 |
Reviewed-by: Alexander Graf <agraf@suse.de>
|
|
|
531551 |
---
|
|
|
531551 |
sys-utils/lscpu-dmi.c | 16 ++++++++++++++++
|
|
|
531551 |
1 file changed, 16 insertions(+)
|
|
|
531551 |
|
|
|
531551 |
diff --git a/sys-utils/lscpu-dmi.c b/sys-utils/lscpu-dmi.c
|
|
|
531551 |
index 0e497d1..a8298ff 100644
|
|
|
531551 |
--- a/sys-utils/lscpu-dmi.c
|
|
|
531551 |
+++ b/sys-utils/lscpu-dmi.c
|
|
|
531551 |
@@ -192,6 +192,18 @@ static int hypervisor_decode_smbios(uint8_t *buf, const char *devmem)
|
|
|
531551 |
devmem);
|
|
|
531551 |
}
|
|
|
531551 |
|
|
|
531551 |
+static int hypervisor_decode_sysfw(void)
|
|
|
531551 |
+{
|
|
|
531551 |
+ static char const sys_fw_dmi_tables[] = "/sys/firmware/dmi/tables/DMI";
|
|
|
531551 |
+ struct stat st;
|
|
|
531551 |
+
|
|
|
531551 |
+ if (stat(sys_fw_dmi_tables, &st))
|
|
|
531551 |
+ return -1;
|
|
|
531551 |
+
|
|
|
531551 |
+ return hypervisor_from_dmi_table(0, st.st_size, st.st_size / 4,
|
|
|
531551 |
+ sys_fw_dmi_tables);
|
|
|
531551 |
+}
|
|
|
531551 |
+
|
|
|
531551 |
/*
|
|
|
531551 |
* Probe for EFI interface
|
|
|
531551 |
*/
|
|
|
531551 |
@@ -242,6 +254,10 @@ int read_hypervisor_dmi(void)
|
|
|
531551 |
|| '\0' != 0)
|
|
|
531551 |
return rc;
|
|
|
531551 |
|
|
|
531551 |
+ rc = hypervisor_decode_sysfw();
|
|
|
531551 |
+ if (rc >= 0)
|
|
|
531551 |
+ return rc;
|
|
|
531551 |
+
|
|
|
531551 |
/* First try EFI (ia64, Intel-based Mac) */
|
|
|
531551 |
switch (address_from_efi(&fp)) {
|
|
|
531551 |
case EFI_NOT_FOUND:
|
|
|
531551 |
--
|
|
|
531551 |
2.9.4
|
|
|
531551 |
|