[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <167822889002.5837.2464794663329420874.tip-bot2@tip-bot2>
Date: Tue, 07 Mar 2023 22:41:30 -0000
From: "tip-bot2 for Borislav Petkov (AMD)" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: "Borislav Petkov (AMD)" <bp@...en8.de>,
Terry Bowman <terry.bowman@....com>,
Feng Tang <feng.tang@...el.com>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: x86/misc] tools/x86/kcpuid: Dump the CPUID function in detailed view
The following commit has been merged into the x86/misc branch of tip:
Commit-ID: cd3ad6619517cda3a055d864a85cebbd434dba9a
Gitweb: https://git.kernel.org/tip/cd3ad6619517cda3a055d864a85cebbd434dba9a
Author: Borislav Petkov (AMD) <bp@...en8.de>
AuthorDate: Mon, 06 Feb 2023 08:18:32 -06:00
Committer: Borislav Petkov (AMD) <bp@...en8.de>
CommitterDate: Tue, 07 Mar 2023 23:35:44 +01:00
tools/x86/kcpuid: Dump the CPUID function in detailed view
Sometimes it is useful to know which CPUID leaf contains the fields so
add it to -d output so that it looks like this:
CPUID_0x8000001e_ECX[0x0]:
extended_apic_id : 0x8 - Extended APIC ID
core_id : 0x4 - Identifies the logical core ID
threads_per_core : 0x1 - The number of threads per core is threads_per_core + 1
node_id : 0x0 - Node ID
nodes_per_processor : 0x0 - Nodes per processor { 0: 1 node, else reserved }
CPUID_0x8000001f_ECX[0x0]:
sme - Secure Memory Encryption
...
Signed-off-by: Borislav Petkov (AMD) <bp@...en8.de>
Signed-off-by: Terry Bowman <terry.bowman@....com>
Reviewed-by: Feng Tang <feng.tang@...el.com>
Link: https://lore.kernel.org/r/20230206141832.4162264-4-terry.bowman@amd.com
---
tools/arch/x86/kcpuid/kcpuid.c | 32 +++++++++++++++++++++++++-------
1 file changed, 25 insertions(+), 7 deletions(-)
diff --git a/tools/arch/x86/kcpuid/kcpuid.c b/tools/arch/x86/kcpuid/kcpuid.c
index dae7551..416f5b3 100644
--- a/tools/arch/x86/kcpuid/kcpuid.c
+++ b/tools/arch/x86/kcpuid/kcpuid.c
@@ -33,7 +33,7 @@ struct reg_desc {
struct bits_desc descs[32];
};
-enum {
+enum cpuid_reg {
R_EAX = 0,
R_EBX,
R_ECX,
@@ -41,6 +41,10 @@ enum {
NR_REGS
};
+static const char * const reg_names[] = {
+ "EAX", "EBX", "ECX", "EDX",
+};
+
struct subleaf {
u32 index;
u32 sub;
@@ -428,12 +432,18 @@ static void parse_text(void)
/* Decode every eax/ebx/ecx/edx */
-static void decode_bits(u32 value, struct reg_desc *rdesc)
+static void decode_bits(u32 value, struct reg_desc *rdesc, enum cpuid_reg reg)
{
struct bits_desc *bdesc;
int start, end, i;
u32 mask;
+ if (!rdesc->nr) {
+ if (show_details)
+ printf("\t %s: 0x%08x\n", reg_names[reg], value);
+ return;
+ }
+
for (i = 0; i < rdesc->nr; i++) {
bdesc = &rdesc->descs[i];
@@ -468,13 +478,21 @@ static void show_leaf(struct subleaf *leaf)
if (!leaf)
return;
- if (show_raw)
+ if (show_raw) {
leaf_print_raw(leaf);
+ } else {
+ if (show_details)
+ printf("CPUID_0x%x_ECX[0x%x]:\n",
+ leaf->index, leaf->sub);
+ }
+
+ decode_bits(leaf->eax, &leaf->info[R_EAX], R_EAX);
+ decode_bits(leaf->ebx, &leaf->info[R_EBX], R_EBX);
+ decode_bits(leaf->ecx, &leaf->info[R_ECX], R_ECX);
+ decode_bits(leaf->edx, &leaf->info[R_EDX], R_EDX);
- decode_bits(leaf->eax, &leaf->info[R_EAX]);
- decode_bits(leaf->ebx, &leaf->info[R_EBX]);
- decode_bits(leaf->ecx, &leaf->info[R_ECX]);
- decode_bits(leaf->edx, &leaf->info[R_EDX]);
+ if (!show_raw && show_details)
+ printf("\n");
}
static void show_func(struct cpuid_func *func)
Powered by blists - more mailing lists