From 0150d1bfbedf29d7473ae458815781488f62d11d Mon Sep 17 00:00:00 2001 From: "Borislav Petkov (AMD)" Date: Wed, 26 Apr 2023 11:41:07 +0200 Subject: tools/x86/kcpuid: Dump the correct CPUID function in error The tool uses the 16 least significant bits of the CPUID leaf as an index into its array of CPUID function field descriptions. However, when that index is non-existent, it uses the same, truncated index to report it, which is wrong: $ kcpuid -l 0x80000034 ERR: invalid input index (0x34) Use the original index number in the error message. Signed-off-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/20230426094107.27348-1-bp@alien8.de --- tools/arch/x86/kcpuid/kcpuid.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/arch/x86/kcpuid/kcpuid.c b/tools/arch/x86/kcpuid/kcpuid.c index 416f5b35dd8f..24b7d017ec2c 100644 --- a/tools/arch/x86/kcpuid/kcpuid.c +++ b/tools/arch/x86/kcpuid/kcpuid.c @@ -517,15 +517,16 @@ static void show_range(struct cpuid_range *range) static inline struct cpuid_func *index_to_func(u32 index) { struct cpuid_range *range; + u32 func_idx; range = (index & 0x80000000) ? leafs_ext : leafs_basic; - index &= 0x7FFFFFFF; + func_idx = index & 0xffff; - if (((index & 0xFFFF) + 1) > (u32)range->nr) { + if ((func_idx + 1) > (u32)range->nr) { printf("ERR: invalid input index (0x%x)\n", index); return NULL; } - return &range->funcs[index]; + return &range->funcs[func_idx]; } static void show_info(void) -- cgit v1.2.3 From b2ad431f6469b58914ee7254302c6dc97f688e54 Mon Sep 17 00:00:00 2001 From: Rong Tao Date: Fri, 28 Apr 2023 15:55:49 +0800 Subject: tools/x86/kcpuid: Add .gitignore Ignore kcpuid ELF file. [ bp: Drop the '/' before the name. ] Signed-off-by: Rong Tao Signed-off-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/tencent_F0318BF0724705EC156C341E11DE4040E805@qq.com --- tools/arch/x86/kcpuid/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 tools/arch/x86/kcpuid/.gitignore (limited to 'tools') diff --git a/tools/arch/x86/kcpuid/.gitignore b/tools/arch/x86/kcpuid/.gitignore new file mode 100644 index 000000000000..1b8541bc8dd0 --- /dev/null +++ b/tools/arch/x86/kcpuid/.gitignore @@ -0,0 +1 @@ +kcpuid -- cgit v1.2.3