aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2025-09-03 11:46:35 +0200
committerKarel Zak <kzak@redhat.com>2025-09-03 11:46:35 +0200
commit90c0b7658c08ba01abfd12a189b17535ceb067bd (patch)
treebc595de0f1c93cc6cacf4fb786111aaf36ff20ba
parent0c57a76da61e5ab1f15eada0553b2ef85026269c (diff)
parent523faa741835e86aadc5183a61598937ac5290d9 (diff)
downloadutil-linux-90c0b7658c08ba01abfd12a189b17535ceb067bd.tar.gz
Merge branch 'feat/lscpu_add_microcode_column' of https://github.com/cgoesche/util-linux-fork
* 'feat/lscpu_add_microcode_column' of https://github.com/cgoesche/util-linux-fork: bash-completion: add MICROCODE to $OPTS_ALL lscpu: add MICROCODE output column
-rw-r--r--bash-completion/lscpu2
-rw-r--r--sys-utils/lscpu.c6
2 files changed, 7 insertions, 1 deletions
diff --git a/bash-completion/lscpu b/bash-completion/lscpu
index 9cae8953b0..b26086afb1 100644
--- a/bash-completion/lscpu
+++ b/bash-completion/lscpu
@@ -12,7 +12,7 @@ _lscpu_module()
prefix="${cur%$realcur}"
OPTS_ALL="CPU CORE SOCKET NODE
BOOK DRAWER CACHE POLARIZATION ADDRESS
- CONFIGURED ONLINE MAXMHZ MINMHZ"
+ CONFIGURED ONLINE MICROCODE MAXMHZ MINMHZ"
for WORD in $OPTS_ALL; do
if ! [[ $prefix == *"$WORD"* ]]; then
OPTS="$WORD ${OPTS:-""}"
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index fe996ebf93..f144b1d655 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -100,6 +100,7 @@ enum {
COL_CPU_ADDRESS,
COL_CPU_CONFIGURED,
COL_CPU_ONLINE,
+ COL_CPU_MICROCODE,
COL_CPU_MHZ,
COL_CPU_SCALMHZ,
COL_CPU_MAXMHZ,
@@ -148,6 +149,7 @@ static struct lscpu_coldesc coldescs_cpu[] =
[COL_CPU_ADDRESS] = { "ADDRESS", N_("physical address of a CPU") },
[COL_CPU_CONFIGURED] = { "CONFIGURED", N_("shows if the hypervisor has allocated the CPU"), 0, 0, SCOLS_JSON_BOOLEAN_OPTIONAL },
[COL_CPU_ONLINE] = { "ONLINE", N_("shows if Linux currently makes use of the CPU"), SCOLS_FL_RIGHT, 0, SCOLS_JSON_BOOLEAN_OPTIONAL },
+ [COL_CPU_MICROCODE] = { "MICROCODE", N_("shows the loaded CPU microcode version"), 0, 0, SCOLS_JSON_STRING },
[COL_CPU_MHZ] = { "MHZ", N_("shows the current MHz of the CPU"), SCOLS_FL_RIGHT, 0, SCOLS_JSON_NUMBER },
[COL_CPU_SCALMHZ] = { "SCALMHZ%", N_("shows scaling percentage of the CPU frequency"), SCOLS_FL_RIGHT, SCOLS_JSON_NUMBER },
[COL_CPU_MAXMHZ] = { "MAXMHZ", N_("shows the maximum MHz of the CPU"), SCOLS_FL_RIGHT, 0, SCOLS_JSON_NUMBER },
@@ -434,6 +436,10 @@ static char *get_cell_data(
case COL_CPU_ONLINE:
get_cell_boolean(cxt, !!cxt->online, is_cpu_online(cxt, cpu), buf, bufsz);
break;
+ case COL_CPU_MICROCODE:
+ if (cpu->type && cpu->type->microcode)
+ xstrncpy(buf, cpu->type->microcode, bufsz);
+ break;
case COL_CPU_MHZ:
if (cpu->mhz_cur_freq)
snprintf(buf, bufsz, "%.4f", cpu->mhz_cur_freq);