[PATCH v2 1/2] lscpu-arm: Include the ARM SMC CC SOC_ID name.
Paul Benoit <[email protected]> Wed, 11 Feb 2026 13:23:08 -0800
| Newsgroups | org.kernel.vger.util-linux |
|---|---|
| Message-ID | <[email protected]> |
On ARM SMC CC 1.6 compliant systems, output the optional SMC CC SOC_ID
name if available.
Vendor ID: Ampere
BIOS Vendor ID: Ampere (R)
Model name: Ampere-1a
SMCCC SOC_ID name: AmpereOne (R) A192-32X
BIOS Model name: AmpereOne (R) A192-32X CPU @ 3.2GH
Signed-off-by: Paul Benoit <[email protected]>
---
sys-utils/lscpu-arm.c | 38 ++++++++++++++++++++++++++++++++++++++
sys-utils/lscpu.c | 2 ++
sys-utils/lscpu.h | 4 ++++
3 files changed, 44 insertions(+)
diff --git a/sys-utils/lscpu-arm.c b/sys-utils/lscpu-arm.c
index ed255a3c7..f388080ad 100644
--- a/sys-utils/lscpu-arm.c
+++ b/sys-utils/lscpu-arm.c
@@ -11,6 +11,7 @@
* The information here is gathered from
* - ARM manuals
* - Linux kernel: arch/armX/include/asm/cputype.h
+ * - Linux kernel: Documentation/ABI/testing/sysfs-devices-soc
* - GCC sources: config/arch/arch-cores.def
* - Ancient wisdom
* - SMBIOS tables (if applicable)
@@ -460,6 +461,41 @@ static int arm_rXpY_decode(struct lscpu_cputype *ct)
return 0;
}
+static void on_smc_platform_get_socidname(struct lscpu_cputype *ct)
+{
+ char *machinename = NULL;
+ char *soc_id_jep106_id_str = NULL;
+
+ /* On systems that support SMC CC (Secure Monitor Call Calling
+ * Convention, get the SOC_ID name. The Linux kernel obtains it from
+ * Trusted Firmware via an SMC CC call, and sets
+ * /sys/bus/soc/devices/soc0/machine _PATH_SOC_ID to this value. lscpu
+ * will obtain the value from there.
+ *
+ * Documentation/ABI/testing/sysfs-devices-soc, in the Linux kernel
+ * source tree, gives insight into detecting a SMC CC compliant system
+ * by checking that start of the _PATH_SOC_ID value for "jep106:".
+ */
+ ul_path_read_string(NULL, &soc_id_jep106_id_str, _PATH_SOC_ID);
+
+ if (soc_id_jep106_id_str) {
+ if (strncmp(soc_id_jep106_id_str, "jep106:", 7) == 0) {
+ ul_path_read_string(NULL, &machinename,
+ _PATH_SOC_MACHINENAME);
+ if (machinename) {
+ if (strnlen(machinename, sizeof(machinename))) {
+ free(ct->socid_name);
+ ct->socid_name = xstrdup(machinename);
+ }
+
+ free(machinename);
+ }
+ }
+
+ free(soc_id_jep106_id_str);
+ }
+}
+
static void arm_decode(struct lscpu_cxt *cxt, struct lscpu_cputype *ct)
{
if (is_live(cxt) && access(_PATH_SYS_DMI, R_OK) == 0)
@@ -468,6 +504,8 @@ static void arm_decode(struct lscpu_cxt *cxt, struct lscpu_cputype *ct)
arm_ids_decode(ct);
arm_rXpY_decode(ct);
+ on_smc_platform_get_socidname(ct);
+
if (is_live(cxt) && cxt->is_cluster)
ct->nr_socket_on_cluster = get_number_of_physical_sockets_from_dmi();
}
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 4556aa6df..cd2d00312 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -895,6 +895,8 @@ print_summary_cputype(struct lscpu_cxt *cxt,
struct libscols_line *sec)
{
sec = add_summary_s(tb, sec, _("Model name:"), ct->modelname ? ct->modelname : "-");
+ if (ct->socid_name)
+ add_summary_s(tb, sec, _("SMCCC SOC_ID name:"), ct->socid_name);
if (ct->bios_modelname)
add_summary_s(tb, sec, _("BIOS Model name:"), ct->bios_modelname);
if (ct->bios_family)
diff --git a/sys-utils/lscpu.h b/sys-utils/lscpu.h
index 0fae5d29e..b8011bc55 100644
--- a/sys-utils/lscpu.h
+++ b/sys-utils/lscpu.h
@@ -46,6 +46,8 @@ UL_DEBUG_DECLARE_MASK(lscpu);
#define _PATH_SYS_NODE _PATH_SYS_SYSTEM "/node"
#define _PATH_SYS_DMI "/sys/firmware/dmi/tables/DMI"
#define _PATH_ACPI_PPTT "/sys/firmware/acpi/tables/PPTT"
+#define _PATH_SOC_ID "/sys/devices/soc0/soc_id"
+#define _PATH_SOC_MACHINENAME "/sys/devices/soc0/machine"
struct lscpu_cache {
int id; /* unique identifier */
@@ -119,6 +121,8 @@ struct lscpu_cputype {
size_t nr_socket_on_cluster; /* the number of sockets if the is_cluster is 1 */
char *isa; /* loongarch */
+
+ char *socid_name; /* aarch64 */
};
/* dispatching modes */
--
2.48.1