lscpu: use sysfs for table access if available

On ARM systems, accessing SMBIOS tables via /dev/mem using read()
calls is not supported. The reason is that such tables are usually
located in EFI_RUNTIME_SERVICE_DATA memory, which is not covered
by the linear mapping on those systems, and so read() calls will
fail.

So instead, use the /sys/firmware/dmi/tables/DMI sysfs file, which
contains the entire structure table array, and will be available
on any recent Linux system, even on ones that only export the rev3
SMBIOS entry point, which is currently ignored by lscpu.

Note that the max 'num' value is inferred from the size. This is not
a limitation of the sysfs interface, but a limitation of the rev3
entry point, which no longer carries a number of array elements.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Alexander Graf <agraf@suse.de>
1 file changed