]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lscpu: add 'microcode' information to the CPU summary
authorcgoesche <cgoesc2@wgu.edu>
Sun, 24 Aug 2025 00:25:36 +0000 (20:25 -0400)
committercgoesche <cgoesc2@wgu.edu>
Mon, 25 Aug 2025 14:02:55 +0000 (10:02 -0400)
The procfs provides microcode revision information on
supported platforms (probably only x86 for now).
It can be useful to show this in the output of lscpu
for various use cases, e.g. applications that wish to
make sure that a specific microcode version has been
loaded.

Addresses: #3050
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
sys-utils/lscpu-cputype.c
sys-utils/lscpu.1.adoc
sys-utils/lscpu.c
sys-utils/lscpu.h
tests/expected/lscpu/lscpu-vbox-win
tests/expected/lscpu/lscpu-vmware_fpe
tests/expected/lscpu/lscpu-x86_64-64cpu-linux6.2
tests/expected/lscpu/lscpu-x86_64-epyc_7451

index c3a4cbaa2f9fb643366fe092840e481df49200af..eda6bd1004b0899c9b8ceb03abd0803571c09d20 100644 (file)
@@ -91,6 +91,7 @@ void lscpu_unref_cputype(struct lscpu_cputype *ct)
                free(ct->bios_vendor);
                free(ct->machinetype);  /* s390 */
                free(ct->family);
+               free(ct->microcode);
                free(ct->model);
                free(ct->modelname);
                free(ct->bios_modelname);
@@ -140,6 +141,8 @@ static void fprintf_cputypes(FILE *f, struct lscpu_cxt *cxt)
                        fprintf(f, " machinetype: %s\n", ct->machinetype);
                if (ct->family)
                        fprintf(f, " family: %s\n", ct->family);
+               if (ct->microcode)
+                       fprintf(f, " microcode: %s\n", ct->microcode);
                if (ct->model)
                        fprintf(f, " model: %s\n", ct->model);
                if (ct->modelname)
@@ -183,6 +186,7 @@ enum {
        PAT_FLAGS,
        PAT_IMPLEMENTER,
        PAT_MAX_THREAD_ID,
+       PAT_MICROCODE,
        PAT_MHZ,
        PAT_MHZ_DYNAMIC,
        PAT_MHZ_STATIC,
@@ -236,6 +240,7 @@ static const struct cpuinfo_pattern type_patterns[] =
        DEF_PAT_CPUTYPE( "isa",                 PAT_ISA,        isa),           /* riscv */
        DEF_PAT_CPUTYPE( "marchid",             PAT_FAMILY,     family),        /* riscv */
        DEF_PAT_CPUTYPE( "max thread id",       PAT_MAX_THREAD_ID, mtid),       /* s390 */
+       DEF_PAT_CPUTYPE( "microcode",           PAT_MICROCODE, microcode),
        DEF_PAT_CPUTYPE( "mimpid",              PAT_MODEL,      model),         /* riscv */
        DEF_PAT_CPUTYPE( "model",               PAT_MODEL,      model),
        DEF_PAT_CPUTYPE( "model name",          PAT_MODEL_NAME, modelname),
index 795c3938b6d92519116cfb5aecd890b3f293744d..c8694e767abbfe78e0a278a3a55541500ab3eb77 100644 (file)
@@ -16,7 +16,7 @@ lscpu - display information about the CPU architecture
 
 == DESCRIPTION
 
-*lscpu* gathers CPU architecture information from _sysfs_, _/proc/cpuinfo_ and any applicable architecture-specific libraries (e.g. *librtas* on Powerpc). The command output can be optimized for parsing or for easy readability by humans. The information includes, for example, the number of CPUs, threads, cores, sockets, and Non-Uniform Memory Access (NUMA) nodes. There is also information about the CPU caches and cache sharing, family, model, bogoMIPS, byte order, and stepping.
+*lscpu* gathers CPU architecture information from _sysfs_, _/proc/cpuinfo_ and any applicable architecture-specific libraries (e.g. *librtas* on Powerpc). The command output can be optimized for parsing or for easy readability by humans. The information includes, for example, the number of CPUs, threads, cores, sockets, and Non-Uniform Memory Access (NUMA) nodes. There is also information about the CPU caches and cache sharing, family, model, bogoMIPS, byte order, stepping and microcode.
 
 The default output formatting on a terminal is subject to change and may be optimized for better readability. The output for non-terminals (e.g., pipes) is never affected by this optimization and it is always in "Field: data\n" format. Use for example "*lscpu | less*" to see the default output without optimizations.
 
@@ -106,6 +106,10 @@ The CPU logical numbers are not affected by this option.
 
 include::man-common/help-version.adoc[]
 
+== COLUMNS
+
+A list of valid column labels can be viewed with the *--help* option. 
+
 == BUGS
 
 The basic overview of CPU models is based on heuristics, taking into account differences such as
index 117fd57e1fa74f503d2c5f87191e7e454e965d23..99799594e7e8810aaad6b033dbde4a2462597528 100644 (file)
@@ -924,6 +924,8 @@ print_summary_cputype(struct lscpu_cxt *cxt,
 
        if (ct->stepping)
                add_summary_s(tb, sec, _("Stepping:"), ct->stepping);
+       if (ct->microcode)
+               add_summary_s(tb, sec, _("Microcode version:"), ct->microcode);
        if (ct->freqboost >= 0)
                add_summary_s(tb, sec, _("Frequency boost:"), ct->freqboost ?
                                _("enabled") : _("disabled"));
@@ -1042,7 +1044,7 @@ static void print_summary(struct lscpu_cxt *cxt)
                 */
                set = cpuset_alloc(cxt->maxcpus, NULL, NULL);
                if (!set)
-                       err(EXIT_FAILURE, _("failed to callocate cpu set"));
+                       err(EXIT_FAILURE, _("failed to allocate cpu set"));
                CPU_ZERO_S(cxt->setsize, set);
                for (i = 0; i < cxt->npossibles; i++) {
                        struct lscpu_cpu *cpu = cxt->cpus[i];
@@ -1067,7 +1069,7 @@ static void print_summary(struct lscpu_cxt *cxt)
                print_summary_cputype(cxt, cxt->cputypes[i], tb, sec);
        sec = NULL;
 
-       /* Section: vitualiazation */
+       /* Section: virtualization */
        if (cxt->virt) {
                sec = add_summary_e(tb, NULL, _("Virtualization features:"));
                if (cxt->virt->cpuflag && !strcmp(cxt->virt->cpuflag, "svm"))
index bd7b64cc57c7d247d9a09414ccf6579680b568f4..e1d86cbcd1cab2d16c4eae29e32d01c555a5450e 100644 (file)
@@ -74,6 +74,7 @@ struct lscpu_cputype {
        char    *bios_vendor;   /* aarch64 */
        char    *machinetype;   /* s390 */
        char    *family;
+       char    *microcode;
        char    *model;
        char    *modelname;
        char    *bios_modelname; /* aarch64 */
index bc0ed4cb605190279d174cba7f8882507910ddb6..75cc7f3f6ced4ca910ad92d32709745d35e763dd 100644 (file)
@@ -10,6 +10,7 @@ Thread(s) per core:  1
 Core(s) per socket:  2
 Socket(s):           1
 Stepping:            9
+Microcode version:   0x19
 CPU(s) scaling MHz:  42%
 CPU max MHz:         3800.0000
 CPU min MHz:         1600.0000
index 8fa54d2eeffcf8da7cc0a5652923e9b64084cbe2..808eb8c06c541a8c19e7be9d3f5b73b0af126cee 100644 (file)
@@ -10,6 +10,7 @@ Thread(s) per core:              2
 Core(s) per socket:              4
 Socket(s):                       2
 Stepping:                        0
+Microcode version:               0x6000852
 Frequency boost:                 enabled
 CPU(s) scaling MHz:              52%
 CPU max MHz:                     3200.0000
index 58ea109d9fe552982af2e6c74554dea5785449f1..935134bc7603a139af02e9d97d11f888ca600bf2 100644 (file)
@@ -11,6 +11,7 @@ Thread(s) per core:              2
 Core(s) per socket:              4
 Socket(s):                       1
 Stepping:                        1
+Microcode version:               0xa6
 CPU(s) scaling MHz:              45%
 CPU max MHz:                     4700.0000
 CPU min MHz:                     400.0000
index c0548f97d28dcd29064bb7a642dda1d2ac4999a8..c24a0df27d6fe982e2e7d296f6a3efd7e8867369 100644 (file)
@@ -10,6 +10,7 @@ Thread(s) per core:              2
 Core(s) per socket:              24
 Socket(s):                       2
 Stepping:                        2
+Microcode version:               0x8001227
 Frequency boost:                 enabled
 CPU(s) scaling MHz:              126%
 CPU max MHz:                     2300.0000