public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Paul Benoit <paul@os.amperecomputing.com>
To: util-linux@vger.kernel.org
Cc: Paul Benoit <paul@os.amperecomputing.com>
Subject: [PATCH v2 1/2] lscpu-arm: Include the ARM SMC CC SOC_ID name.
Date: Wed, 11 Feb 2026 13:23:08 -0800	[thread overview]
Message-ID: <20260211212309.126190-1-paul@os.amperecomputing.com> (raw)
In-Reply-To: <a758edc3-2d4f-4e5d-8951-8aad0c3a546a@os.amperecomputing.com>

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 <paul@os.amperecomputing.com>
---
 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


  reply	other threads:[~2026-02-11 21:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-11 21:16 [PATCH 1/2] lscpu-arm: Allow externally sourced model name Paul Benoit
2025-07-11 21:16 ` [PATCH 2/2] lscpu-arm: Remove the "Ampere-1a" part Paul Benoit
2025-07-14 12:16   ` Karel Zak
2025-07-14 20:48     ` Jeremy Linton
2025-07-14 22:22       ` Paul Benoit
2025-07-15  9:19       ` Karel Zak
2025-11-07 21:26         ` Paul Benoit
2025-11-07 20:48       ` Paul Benoit
2026-02-11 21:23         ` Paul Benoit [this message]
2026-02-11 21:23         ` [PATCH v2 2/2] lscpu-arm: Correct Ampere part name strings Paul Benoit
2025-07-11 22:22 ` [PATCH 1/2] lscpu-arm: Allow externally sourced model name Jeremy Linton
2025-11-07 21:45   ` Paul Benoit
2025-07-14 12:11 ` Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260211212309.126190-1-paul@os.amperecomputing.com \
    --to=paul@os.amperecomputing.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox