From: "tip-bot2 for Borislav Petkov (AMD)" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: "Borislav Petkov (AMD)" <bp@alien8.de>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: x86/misc] tools/x86/kcpuid: Dump the correct CPUID function in error
Date: Mon, 08 May 2023 14:04:35 -0000 [thread overview]
Message-ID: <168355467536.404.8937977023899677332.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20230426094107.27348-1-bp@alien8.de>
The following commit has been merged into the x86/misc branch of tip:
Commit-ID: 0150d1bfbedf29d7473ae458815781488f62d11d
Gitweb: https://git.kernel.org/tip/0150d1bfbedf29d7473ae458815781488f62d11d
Author: Borislav Petkov (AMD) <bp@alien8.de>
AuthorDate: Wed, 26 Apr 2023 11:41:07 +02:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Mon, 08 May 2023 15:50:27 +02:00
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) <bp@alien8.de>
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(-)
diff --git a/tools/arch/x86/kcpuid/kcpuid.c b/tools/arch/x86/kcpuid/kcpuid.c
index 416f5b3..24b7d01 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)
prev parent reply other threads:[~2023-05-08 14:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-26 9:41 [PATCH] " Borislav Petkov
2023-05-08 14:04 ` tip-bot2 for Borislav Petkov (AMD) [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=168355467536.404.8937977023899677332.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=bp@alien8.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®