* [PATCH 1/2] lscpu-arm: Allow externally sourced model name.
@ 2025-07-11 21:16 Paul Benoit
2025-07-11 21:16 ` [PATCH 2/2] lscpu-arm: Remove the "Ampere-1a" part Paul Benoit
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: Paul Benoit @ 2025-07-11 21:16 UTC (permalink / raw)
To: util-linux; +Cc: Paul Benoit
When there isn't an entry for the model name in the id_part table(s),
attempt to get the machine name from /sys/bus/soc/devices/soc0/machine
to use as the model name. This mechanism allows lscpu to use the
model/machine name provided via the ARM SMC support code rather than via
hard-coded lscpu tables.
This code was tested by removing the "Ampere-1a" entry from the
ampere-part table and verifying that lscpu displayed the correct machine
name obtained via the ARM SMC interface to Trusted Firmware. The
"Ampere-1a" entry will be permanently removed by a separate patch.
Signed-off-by: Paul Benoit <paul@os.amperecomputing.com>
---
sys-utils/lscpu-arm.c | 35 ++++++++++++++++++++++++++++++++---
sys-utils/lscpu.h | 1 +
2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/sys-utils/lscpu-arm.c b/sys-utils/lscpu-arm.c
index 8745599d4..a46106bcb 100644
--- a/sys-utils/lscpu-arm.c
+++ b/sys-utils/lscpu-arm.c
@@ -388,7 +388,10 @@ int is_arm(struct lscpu_cxt *cxt)
static int arm_ids_decode(struct lscpu_cputype *ct)
{
int impl, part, j;
+ unsigned int i;
const struct id_part *parts = NULL;
+ FILE *fd;
+ char machinename[BUFSIZ] = "";
impl = parse_implementer_id(ct);
if (impl <= 0)
@@ -406,11 +409,11 @@ static int arm_ids_decode(struct lscpu_cputype *ct)
/* decode model */
if (!parts)
- goto done;
+ goto try_machinename;
part = parse_model_id(ct);
if (part <= 0)
- goto done;
+ goto try_machinename;
for (j = 0; parts[j].id != -1; j++) {
if (parts[j].id == part) {
@@ -419,7 +422,33 @@ static int arm_ids_decode(struct lscpu_cputype *ct)
break;
}
}
-done:
+
+try_machinename:
+
+ /*
+ * If the Model name was not found in the lscpu 'id_part' tables, see
+ * if there is a Machine name associated with the SOC. This name may
+ * have been set via either SOC specific support code, or obtained
+ * via an ARM SMC CC call into Trusted Firmware.
+ */
+ if (!ct->modelname) {
+ fd = ul_path_fopen(NULL, "r", _PATH_SOC_MACHINENAME);
+ if (fd) {
+ if (!fgets(machinename, sizeof(machinename), fd))
+ machinename[0] = '\0';
+ fclose(fd);
+
+ /* Replace newline with string terminator */
+ for (i = 0; i < strlen(machinename); i++) {
+ if (machinename[i] == '\n')
+ machinename[i] = '\0';
+ }
+
+ if (strnlen(machinename, sizeof(machinename)))
+ ct->modelname = xstrdup(machinename);
+ }
+ }
+
return 0;
}
diff --git a/sys-utils/lscpu.h b/sys-utils/lscpu.h
index bd7b64cc5..581602f70 100644
--- a/sys-utils/lscpu.h
+++ b/sys-utils/lscpu.h
@@ -46,6 +46,7 @@ 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_MACHINENAME "/sys/bus/soc/devices/soc0/machine"
struct lscpu_cache {
int id; /* unique identifier */
--
2.48.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 2/2] lscpu-arm: Remove the "Ampere-1a" part. 2025-07-11 21:16 [PATCH 1/2] lscpu-arm: Allow externally sourced model name Paul Benoit @ 2025-07-11 21:16 ` Paul Benoit 2025-07-14 12:16 ` Karel Zak 2025-07-11 22:22 ` [PATCH 1/2] lscpu-arm: Allow externally sourced model name Jeremy Linton 2025-07-14 12:11 ` Karel Zak 2 siblings, 1 reply; 13+ messages in thread From: Paul Benoit @ 2025-07-11 21:16 UTC (permalink / raw) To: util-linux; +Cc: Paul Benoit Remove the "Ampere-1a" part. On newer Ampere Computing systems, the system/model name will be obtained from /sys/bus/soc/devices/soc0/machine, that is populated with the ARM SMC CC SOC_ID Name. Signed-off-by: Paul Benoit <paul@os.amperecomputing.com> --- sys-utils/lscpu-arm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sys-utils/lscpu-arm.c b/sys-utils/lscpu-arm.c index 8745599d4..4ea555d86 100644 --- a/sys-utils/lscpu-arm.c +++ b/sys-utils/lscpu-arm.c @@ -268,7 +268,6 @@ static const struct id_part hisi_part[] = { static const struct id_part ampere_part[] = { { 0xac3, "Ampere-1" }, - { 0xac4, "Ampere-1a" }, { -1, "unknown" }, }; -- 2.48.1 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2] lscpu-arm: Remove the "Ampere-1a" part. 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 0 siblings, 1 reply; 13+ messages in thread From: Karel Zak @ 2025-07-14 12:16 UTC (permalink / raw) To: Paul Benoit; +Cc: util-linux On Fri, Jul 11, 2025 at 02:16:48PM -0700, Paul Benoit wrote: > Remove the "Ampere-1a" part. On newer Ampere Computing systems, the > system/model name will be obtained from /sys/bus/soc/devices/soc0/machine, > that is populated with the ARM SMC CC SOC_ID Name. If I understand correctly, there are old systems without /sys/.../soc0/machine, right? The change will remove Ampere-1a from the lscpu output. This sounds backward incompatible. Karel -- Karel Zak <kzak@redhat.com> http://karelzak.blogspot.com ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2] lscpu-arm: Remove the "Ampere-1a" part. 2025-07-14 12:16 ` Karel Zak @ 2025-07-14 20:48 ` Jeremy Linton 2025-07-14 22:22 ` Paul Benoit ` (2 more replies) 0 siblings, 3 replies; 13+ messages in thread From: Jeremy Linton @ 2025-07-14 20:48 UTC (permalink / raw) To: Karel Zak, Paul Benoit; +Cc: util-linux On 7/14/25 7:16 AM, Karel Zak wrote: > On Fri, Jul 11, 2025 at 02:16:48PM -0700, Paul Benoit wrote: >> Remove the "Ampere-1a" part. On newer Ampere Computing systems, the >> system/model name will be obtained from /sys/bus/soc/devices/soc0/machine, >> that is populated with the ARM SMC CC SOC_ID Name. > > If I understand correctly, there are old systems without > /sys/.../soc0/machine, right? The change will remove Ampere-1a from > the lscpu output. This sounds backward incompatible. Thats a good point, but as I understand it, Ampere hasn't been happy with the string that is there. If its OK to break whatever scripts/etc might depend on it at the moment, why not just update the string. Then invert the check so that the /sys/bus entry is preferred? ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2] lscpu-arm: Remove the "Ampere-1a" part. 2025-07-14 20:48 ` Jeremy Linton @ 2025-07-14 22:22 ` Paul Benoit 2025-07-15 9:19 ` Karel Zak 2025-11-07 20:48 ` Paul Benoit 2 siblings, 0 replies; 13+ messages in thread From: Paul Benoit @ 2025-07-14 22:22 UTC (permalink / raw) To: Jeremy Linton, Karel Zak; +Cc: util-linux On 7/14/2025 4:48 PM, Jeremy Linton wrote: > On 7/14/25 7:16 AM, Karel Zak wrote: >> On Fri, Jul 11, 2025 at 02:16:48PM -0700, Paul Benoit wrote: >>> Remove the "Ampere-1a" part. On newer Ampere Computing systems, the >>> system/model name will be obtained from /sys/bus/soc/devices/soc0/ >>> machine, >>> that is populated with the ARM SMC CC SOC_ID Name. >> >> If I understand correctly, there are old systems without >> /sys/.../soc0/machine, right? The change will remove Ampere-1a from >> the lscpu output. This sounds backward incompatible. > > Thats a good point, but as I understand it, Ampere hasn't been happy > with the string that is there. > Hi Jeremy and Karel, While I haven't personally been part of those discussions, that's also my understanding of the situation. > If its OK to break whatever scripts/etc might depend on it at the > moment, why not just update the string. > That's becoming even more tempting given the valid issues that you and Karel have identified with my patch. Though, the nice thing about lscpu picking up the Model name, from somewhere like /sys/bus/soc/devices/soc0/, is that lscpu will be able to output the model name of newly released processors without/before them needing to be added to the lscpu part(s) table. That assumes a kernel where either the ARM SMC CC SOC_ID (Name) handling code, or the support code for a specific SOC, set the Model name from which /sys/bus/soc/devices/soc0/ gets set. > Then invert the check so that the /sys/bus entry is preferred? > That's the way I had originally coded things, but I was concerned about the change in behavior of having the /sys/bus/soc/devices/soc0/ value override the established part(s) table names for non-Ampere processors. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2] lscpu-arm: Remove the "Ampere-1a" part. 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 2 siblings, 1 reply; 13+ messages in thread From: Karel Zak @ 2025-07-15 9:19 UTC (permalink / raw) To: Jeremy Linton; +Cc: Paul Benoit, util-linux On Mon, Jul 14, 2025 at 03:48:50PM -0500, Jeremy Linton wrote: > On 7/14/25 7:16 AM, Karel Zak wrote: > > On Fri, Jul 11, 2025 at 02:16:48PM -0700, Paul Benoit wrote: > > > Remove the "Ampere-1a" part. On newer Ampere Computing systems, the > > > system/model name will be obtained from /sys/bus/soc/devices/soc0/machine, > > > that is populated with the ARM SMC CC SOC_ID Name. > > > > If I understand correctly, there are old systems without > > /sys/.../soc0/machine, right? The change will remove Ampere-1a from > > the lscpu output. This sounds backward incompatible. > > Thats a good point, but as I understand it, Ampere hasn't been happy with > the string that is there. We can update the string to make them happy. > If its OK to break whatever scripts/etc might depend on it at the moment, > why not just update the string. > > Then invert the check so that the /sys/bus entry is preferred? I still do not understand how a per-CPU identifier can be replaced by one soc0 path. What if there is soc1, soc2, etc.? Anyway, using /sys/bus as the primary source and the hardcoded id_part[] array as a fallback seems better than removing anything from id_part[] and relying on /sys/bus only. Karel -- Karel Zak <kzak@redhat.com> http://karelzak.blogspot.com ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2] lscpu-arm: Remove the "Ampere-1a" part. 2025-07-15 9:19 ` Karel Zak @ 2025-11-07 21:26 ` Paul Benoit 0 siblings, 0 replies; 13+ messages in thread From: Paul Benoit @ 2025-11-07 21:26 UTC (permalink / raw) To: Karel Zak, Jeremy Linton; +Cc: util-linux On 7/15/2025 5:19 AM, Karel Zak wrote: > On Mon, Jul 14, 2025 at 03:48:50PM -0500, Jeremy Linton wrote: >> On 7/14/25 7:16 AM, Karel Zak wrote: >>> On Fri, Jul 11, 2025 at 02:16:48PM -0700, Paul Benoit wrote: >>>> Remove the "Ampere-1a" part. On newer Ampere Computing systems, the >>>> system/model name will be obtained from /sys/bus/soc/devices/soc0/machine, >>>> that is populated with the ARM SMC CC SOC_ID Name. >>> >>> If I understand correctly, there are old systems without >>> /sys/.../soc0/machine, right? The change will remove Ampere-1a from >>> the lscpu output. This sounds backward incompatible. >> >> Thats a good point, but as I understand it, Ampere hasn't been happy with >> the string that is there. > > We can update the string to make them happy. > >> If its OK to break whatever scripts/etc might depend on it at the moment, >> why not just update the string. >> >> Then invert the check so that the /sys/bus entry is preferred? > > I still do not understand how a per-CPU identifier can be replaced by > one soc0 path. What if there is soc1, soc2, etc.? Yes, I agree that /sys/bus/soc/devices/soc0/machine shouldn't be used for processors/cpus in soc1..socn unless all physical SOCs are mapped by soc0. My recollection is that I only saw the one /sys/bus/devices/soc0 on an SMC compliant system with 2 SOCs. The smccc_soc_init routine is what calls soc_device_register once. The support code for other ARM SOCs call soc_device_register from a *_probe routine (run once per SOC?). As per my other reply in this thread today, /sys/bus/soc/devices/soc0/machine will only be used for a SMC CC compliant SOC. > > Anyway, using /sys/bus as the primary source and the hardcoded id_part[] > array as a fallback seems better than removing anything from id_part[] > and relying on /sys/bus only. > > Karel > ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2] lscpu-arm: Remove the "Ampere-1a" part. 2025-07-14 20:48 ` Jeremy Linton 2025-07-14 22:22 ` Paul Benoit 2025-07-15 9:19 ` Karel Zak @ 2025-11-07 20:48 ` Paul Benoit 2026-02-11 21:23 ` [PATCH v2 1/2] lscpu-arm: Include the ARM SMC CC SOC_ID name Paul Benoit 2026-02-11 21:23 ` [PATCH v2 2/2] lscpu-arm: Correct Ampere part name strings Paul Benoit 2 siblings, 2 replies; 13+ messages in thread From: Paul Benoit @ 2025-11-07 20:48 UTC (permalink / raw) To: Jeremy Linton, Karel Zak; +Cc: util-linux Thanks for your input Jeremy and Karel. I apologize for taking so long to get back to this project. On 7/14/2025 4:48 PM, Jeremy Linton wrote: > On 7/14/25 7:16 AM, Karel Zak wrote: >> On Fri, Jul 11, 2025 at 02:16:48PM -0700, Paul Benoit wrote: >>> Remove the "Ampere-1a" part. On newer Ampere Computing systems, the >>> system/model name will be obtained from /sys/bus/soc/devices/soc0/ >>> machine, >>> that is populated with the ARM SMC CC SOC_ID Name. >> >> If I understand correctly, there are old systems without >> /sys/.../soc0/machine, right? The change will remove Ampere-1a from >> the lscpu output. This sounds backward incompatible. > > Thats a good point, but as I understand it, Ampere hasn't been happy > with the string that is there. > > If its OK to break whatever scripts/etc might depend on it at the > moment, why not just update the string. For SOCs using SMC CC compliant firmware, I do like that having lscpu use /sys/bus/soc/devices/soc0/machine means that the name for a new SMC SOC would be displayed without needing to update the lscpu part(s) table. Though, I'm concerned that the SMC CC SOC_ID Name won't always be a direct mapping to a processor/cpu name. Especially for a SOC that contains a mix of BIG/little, performance/efficiency, and/or special purpose cores. When all the cores of a SOC are the same, then it is probably ok to equate the SMC CC SOC_ID Name with the processor/cpu part name. For SMC CC compliant SOCs, perhaps it makes more sense to have lscpu display the /sys/bus/soc/devices/soc0/machine value as a new "SOC_ID Name" value in a manner similar to the "BIOS Model name"? Would changes be required to lscpu to select such a "SOC_ID Name" field from the lscpu command line, or would it be sufficient to only display this SOC_ID Name field in lscpu modes where the detailed/complete cpu/processor information is displayed? If lscpu were to display the /sys/bus/soc/devices/soc0/machines value as "SOC_ID Name", then the Ampere cpus/processor names would need to continue to come from the lscpu part(s) table. Though, The existing names in the "ampere_part" table would still need to change. > > Then invert the check so that the /sys/bus entry is preferred? Prior to my V1 lscpu patch, when I first made some lscpu changes as a way to test the SMC CC SOC_ID Name kernel changes, I had originally been checking for /sys/bus/soc/devices/soc0/machine before looking for an entry in the part(s) table. My concern with that was for the non-SMC SOCs, for which there was both a part(s) table entry and /sys/bus/soc/devices/soc0/machine was set. If the string in the part(s) table was not the same as the /sys/bus/soc/devices/soc0/machine string, lscpu would then be displaying a different string than it had in the past. That is why my V1 patch switched to using the /sys/bus/soc/devices/soc0/machine value only if there wasn't an entry in the part(s) table. A way to reduce the risk, of now using /sys/bus/soc/devices/soc0/machine instead of the part(s) table entry for a non-SMC SOC, would be for lscpu to only use the /sys/bus/soc/devices/soc0/machine value if the value of /sys/devices/soc0/soc_id starts with "jep106:". Documentation/ABI/testing/sysfs-devices-soc in the Linux kernel tree says "On many of ARM based silicon with SMCCC v1.2+ compliant firmware this will contain the SOC ID appended to the family attribute to ensure there is no conflict in this namespace across various vendors. The format is "jep106:XXYY:ZZZZ" where XX is identity code, YY is continuation code and ZZZZ is the SOC ID." A search of the Linux kernel code confirms that only drivers/firmware/smccc/soc_id.c is generating/using the "jep106:" string. ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 1/2] lscpu-arm: Include the ARM SMC CC SOC_ID name. 2025-11-07 20:48 ` Paul Benoit @ 2026-02-11 21:23 ` Paul Benoit 2026-02-11 21:23 ` [PATCH v2 2/2] lscpu-arm: Correct Ampere part name strings Paul Benoit 1 sibling, 0 replies; 13+ messages in thread From: Paul Benoit @ 2026-02-11 21:23 UTC (permalink / raw) To: util-linux; +Cc: Paul Benoit 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 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 2/2] lscpu-arm: Correct Ampere part name strings. 2025-11-07 20:48 ` Paul Benoit 2026-02-11 21:23 ` [PATCH v2 1/2] lscpu-arm: Include the ARM SMC CC SOC_ID name Paul Benoit @ 2026-02-11 21:23 ` Paul Benoit 1 sibling, 0 replies; 13+ messages in thread From: Paul Benoit @ 2026-02-11 21:23 UTC (permalink / raw) To: util-linux; +Cc: Paul Benoit Change "Ampere-1" to "Ampere1", and "Ampere-1a" to "Ampere1a" in the ampere_part table. Signed-off-by: Paul Benoit <paul@os.amperecomputing.com> --- sys-utils/lscpu-arm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys-utils/lscpu-arm.c b/sys-utils/lscpu-arm.c index f388080ad..0b0935402 100644 --- a/sys-utils/lscpu-arm.c +++ b/sys-utils/lscpu-arm.c @@ -276,8 +276,8 @@ static const struct id_part hisi_part[] = { }; static const struct id_part ampere_part[] = { - { 0xac3, "Ampere-1" }, - { 0xac4, "Ampere-1a" }, + { 0xac3, "Ampere1" }, + { 0xac4, "Ampere1a" }, { -1, "unknown" }, }; -- 2.48.1 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 1/2] lscpu-arm: Allow externally sourced model name. 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-11 22:22 ` Jeremy Linton 2025-11-07 21:45 ` Paul Benoit 2025-07-14 12:11 ` Karel Zak 2 siblings, 1 reply; 13+ messages in thread From: Jeremy Linton @ 2025-07-11 22:22 UTC (permalink / raw) To: Paul Benoit, util-linux Hi, On 7/11/25 4:16 PM, Paul Benoit wrote: > When there isn't an entry for the model name in the id_part table(s), > attempt to get the machine name from /sys/bus/soc/devices/soc0/machine > to use as the model name. This mechanism allows lscpu to use the > model/machine name provided via the ARM SMC support code rather than via > hard-coded lscpu tables. Since this is suppose to be synced with the DMI data, and is sourced from the firmware would it make more sense to replace the BIOS name with it? > > This code was tested by removing the "Ampere-1a" entry from the > ampere-part table and verifying that lscpu displayed the correct machine > name obtained via the ARM SMC interface to Trusted Firmware. The > "Ampere-1a" entry will be permanently removed by a separate patch. > > Signed-off-by: Paul Benoit <paul@os.amperecomputing.com> > --- > sys-utils/lscpu-arm.c | 35 ++++++++++++++++++++++++++++++++--- > sys-utils/lscpu.h | 1 + > 2 files changed, 33 insertions(+), 3 deletions(-) > > diff --git a/sys-utils/lscpu-arm.c b/sys-utils/lscpu-arm.c > index 8745599d4..a46106bcb 100644 > --- a/sys-utils/lscpu-arm.c > +++ b/sys-utils/lscpu-arm.c > @@ -388,7 +388,10 @@ int is_arm(struct lscpu_cxt *cxt) > static int arm_ids_decode(struct lscpu_cputype *ct) > { > int impl, part, j; > + unsigned int i; > const struct id_part *parts = NULL; > + FILE *fd; > + char machinename[BUFSIZ] = ""; > > impl = parse_implementer_id(ct); > if (impl <= 0) > @@ -406,11 +409,11 @@ static int arm_ids_decode(struct lscpu_cputype *ct) > > /* decode model */ > if (!parts) > - goto done; > + goto try_machinename; > > part = parse_model_id(ct); > if (part <= 0) > - goto done; > + goto try_machinename; > > for (j = 0; parts[j].id != -1; j++) { > if (parts[j].id == part) { > @@ -419,7 +422,33 @@ static int arm_ids_decode(struct lscpu_cputype *ct) > break; > } > } > -done: > + > +try_machinename: > + > + /* > + * If the Model name was not found in the lscpu 'id_part' tables, see > + * if there is a Machine name associated with the SOC. This name may > + * have been set via either SOC specific support code, or obtained > + * via an ARM SMC CC call into Trusted Firmware. > + */ > + if (!ct->modelname) { > + fd = ul_path_fopen(NULL, "r", _PATH_SOC_MACHINENAME); > + if (fd) { > + if (!fgets(machinename, sizeof(machinename), fd)) > + machinename[0] = '\0'; > + fclose(fd); > + > + /* Replace newline with string terminator */ > + for (i = 0; i < strlen(machinename); i++) { > + if (machinename[i] == '\n') > + machinename[i] = '\0'; > + } > + > + if (strnlen(machinename, sizeof(machinename))) > + ct->modelname = xstrdup(machinename); > + } > + } > + > return 0; > } > > diff --git a/sys-utils/lscpu.h b/sys-utils/lscpu.h > index bd7b64cc5..581602f70 100644 > --- a/sys-utils/lscpu.h > +++ b/sys-utils/lscpu.h > @@ -46,6 +46,7 @@ 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_MACHINENAME "/sys/bus/soc/devices/soc0/machine" > > struct lscpu_cache { > int id; /* unique identifier */ ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/2] lscpu-arm: Allow externally sourced model name. 2025-07-11 22:22 ` [PATCH 1/2] lscpu-arm: Allow externally sourced model name Jeremy Linton @ 2025-11-07 21:45 ` Paul Benoit 0 siblings, 0 replies; 13+ messages in thread From: Paul Benoit @ 2025-11-07 21:45 UTC (permalink / raw) To: Jeremy Linton, util-linux On 7/11/2025 6:22 PM, Jeremy Linton wrote: > Hi, > > On 7/11/25 4:16 PM, Paul Benoit wrote: >> When there isn't an entry for the model name in the id_part table(s), >> attempt to get the machine name from /sys/bus/soc/devices/soc0/machine >> to use as the model name. This mechanism allows lscpu to use the >> model/machine name provided via the ARM SMC support code rather than via >> hard-coded lscpu tables. > > Since this is suppose to be synced with the DMI data, and is sourced > from the firmware would it make more sense to replace the BIOS name with > it? I was recently reminded that the SMC CC SOC_ID Name (/sys/bus/soc/devices/soc0/machine) and BIOS name could be from 2 different organizations, and may not always resemble each other. > > >> >> This code was tested by removing the "Ampere-1a" entry from the >> ampere-part table and verifying that lscpu displayed the correct machine >> name obtained via the ARM SMC interface to Trusted Firmware. The >> "Ampere-1a" entry will be permanently removed by a separate patch. >> >> Signed-off-by: Paul Benoit <paul@os.amperecomputing.com> >> --- >> sys-utils/lscpu-arm.c | 35 ++++++++++++++++++++++++++++++++--- >> sys-utils/lscpu.h | 1 + >> 2 files changed, 33 insertions(+), 3 deletions(-) >> >> diff --git a/sys-utils/lscpu-arm.c b/sys-utils/lscpu-arm.c >> index 8745599d4..a46106bcb 100644 >> --- a/sys-utils/lscpu-arm.c >> +++ b/sys-utils/lscpu-arm.c >> @@ -388,7 +388,10 @@ int is_arm(struct lscpu_cxt *cxt) >> static int arm_ids_decode(struct lscpu_cputype *ct) >> { >> int impl, part, j; >> + unsigned int i; >> const struct id_part *parts = NULL; >> + FILE *fd; >> + char machinename[BUFSIZ] = ""; >> impl = parse_implementer_id(ct); >> if (impl <= 0) >> @@ -406,11 +409,11 @@ static int arm_ids_decode(struct lscpu_cputype *ct) >> /* decode model */ >> if (!parts) >> - goto done; >> + goto try_machinename; >> part = parse_model_id(ct); >> if (part <= 0) >> - goto done; >> + goto try_machinename; >> for (j = 0; parts[j].id != -1; j++) { >> if (parts[j].id == part) { >> @@ -419,7 +422,33 @@ static int arm_ids_decode(struct lscpu_cputype *ct) >> break; >> } >> } >> -done: >> + >> +try_machinename: >> + >> + /* >> + * If the Model name was not found in the lscpu 'id_part' tables, >> see >> + * if there is a Machine name associated with the SOC. This name >> may >> + * have been set via either SOC specific support code, or obtained >> + * via an ARM SMC CC call into Trusted Firmware. >> + */ >> + if (!ct->modelname) { >> + fd = ul_path_fopen(NULL, "r", _PATH_SOC_MACHINENAME); >> + if (fd) { >> + if (!fgets(machinename, sizeof(machinename), fd)) >> + machinename[0] = '\0'; >> + fclose(fd); >> + >> + /* Replace newline with string terminator */ >> + for (i = 0; i < strlen(machinename); i++) { >> + if (machinename[i] == '\n') >> + machinename[i] = '\0'; >> + } >> + >> + if (strnlen(machinename, sizeof(machinename))) >> + ct->modelname = xstrdup(machinename); >> + } >> + } >> + >> return 0; >> } >> diff --git a/sys-utils/lscpu.h b/sys-utils/lscpu.h >> index bd7b64cc5..581602f70 100644 >> --- a/sys-utils/lscpu.h >> +++ b/sys-utils/lscpu.h >> @@ -46,6 +46,7 @@ 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_MACHINENAME "/sys/bus/soc/devices/soc0/machine" >> struct lscpu_cache { >> int id; /* unique identifier */ > ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/2] lscpu-arm: Allow externally sourced model name. 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-11 22:22 ` [PATCH 1/2] lscpu-arm: Allow externally sourced model name Jeremy Linton @ 2025-07-14 12:11 ` Karel Zak 2 siblings, 0 replies; 13+ messages in thread From: Karel Zak @ 2025-07-14 12:11 UTC (permalink / raw) To: Paul Benoit; +Cc: util-linux Hi Paul, On Fri, Jul 11, 2025 at 02:16:47PM -0700, Paul Benoit wrote: > When there isn't an entry for the model name in the id_part table(s), > attempt to get the machine name from /sys/bus/soc/devices/soc0/machine How is it supposed to work on a system with multiple CPU types (more CPU models) if it reads all from the same path? > + /* > + * If the Model name was not found in the lscpu 'id_part' tables, see > + * if there is a Machine name associated with the SOC. This name may > + * have been set via either SOC specific support code, or obtained > + * via an ARM SMC CC call into Trusted Firmware. > + */ > + if (!ct->modelname) { > + fd = ul_path_fopen(NULL, "r", _PATH_SOC_MACHINENAME); > + if (fd) { > + if (!fgets(machinename, sizeof(machinename), fd)) > + machinename[0] = '\0'; > + fclose(fd); > + > + /* Replace newline with string terminator */ > + for (i = 0; i < strlen(machinename); i++) { > + if (machinename[i] == '\n') > + machinename[i] = '\0'; > + } > + > + if (strnlen(machinename, sizeof(machinename))) > + ct->modelname = xstrdup(machinename); if (!ct->modelname) ul_path_read_string(NULL, &ct->modelname, _PATH_SOC_MACHINENAME); This should be enough, it reads the string, removes \n and strdup() the result. Karel -- Karel Zak <kzak@redhat.com> http://karelzak.blogspot.com ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2026-02-11 21:23 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 ` [PATCH v2 1/2] lscpu-arm: Include the ARM SMC CC SOC_ID name Paul Benoit 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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox