* [PATCH v2] x86/tools: fix line number reported for malformed lines
@ 2024-02-23 13:10 Valentin Obst
2024-02-23 13:19 ` kernel test robot
2024-02-23 15:00 ` Miguel Ojeda
0 siblings, 2 replies; 3+ messages in thread
From: Valentin Obst @ 2024-02-23 13:10 UTC (permalink / raw)
To: Borislav Petkov, Dave Hansen, H. Peter Anvin, Ingo Molnar,
Ingo Molnar, Thomas Gleixner
Cc: Andreas Hindborg, Greg Kroah-Hartman, John Baublitz,
Masami Hiramatsu, Miguel Ojeda, Peter Zijlstra,
Sergio González Collado, linux-kernel, stable, x86,
Valentin Obst
While debugging the `X86_DECODER_SELFTEST` failure first reported in [1],
we noticed that the line numbers reported by the `insn_decoder_test` tool
do not correspond to the line in the output of `objdump_reformat.awk` that
was causing the failure:
# TEST posttest
llvm-objdump -d -j .text ./vmlinux | \
awk -f ./arch/x86/tools/objdump_reformat.awk | \
arch/x86/tools/insn_decoder_test -y -v
arch/x86/tools/insn_decoder_test: error: malformed line 1657116:
68db0
$ llvm-objdump -d -j .text ./vmlinux | \
awk -f ./arch/x86/tools/objdump_reformat.awk > objdump_reformat.txt
$ head -n `echo 1657116+2 | bc` objdump_reformat.txt | tail -n 5
ffffffff815430b1 41 8b 47 1c movl
ffffffff815430b5 89 c1 movl
ffffffff815430b7 81 c9 00 40 00 00 orl
ffffffff815430bd 41 89 4e 18 movl
ffffffff815430c1 a8 40 testb
These lines are perfectly fine. The reason is that the line count reported
by the tool only includes instruction lines, i.e., it does not count symbol
lines. This behavior was introduced in Commit 35039eb6b199 ("x86: Show
symbol name if insn decoder test failed"), which included symbol lines
in the output of the awk script. This broke the `instuction lines == total
lines` property without accounting for it in `insn_decoder_test.c`.
Add a new variable to count the combined (insn+symbol) line count and
report this in the error message. With this patch, the line reported by the
tool is the line causing the failure (long line wrapped at 75 chars):
# TEST posttest
llvm-objdump -d -j .text ./vmlinux | \
awk -f ./arch/x86/tools/objdump_reformat.awk | \
arch/x86/tools/insn_decoder_test -y -v
arch/x86/tools/insn_decoder_test: error: malformed line 1699686:
68db0
$ head -n ` echo 1699686+2 | bc` objdump_reformat.txt | tail -n 5
ffffffff81568dac c3 retq
<_RNvXsP_NtCs7qddEHlz8fK_4core3fmtRINtNtNtNtB7_4iter8adapters5chain5Chain
INtNtBA_7flatten7FlattenINtNtB7_6option8IntoIterNtNtB7_4char11EscapeDebug
EEINtB1a_7FlatMapNtNtNtB7_3str4iter5CharsB1T_NtB2D_23CharEscapeDebugConti
nueEENtB5_5Debug3fmtB7_>:ffffffff81568db0
ffffffff81568dad 0f 1f 00 nopl
ffffffff81568db0 f3 0f 1e fa endbr64
ffffffff81568db4 41 56 pushq
[In this case the line causing the failure is interpreted as two lines by
the tool (due to its length, but this is fixed by [1, 2]), and the second
line is reported. Still the spatial closeness between the reported line and
the line causing the failure would have made debugging a lot easier.]
Link: https://lore.kernel.org/lkml/Y9ES4UKl%2F+DtvAVS@gmail.com/T/ [1]
Link: https://lore.kernel.org/rust-for-linux/20231119180145.157455-1-sergio.collado@gmail.com/ [2]
Fixes: 35039eb6b199 ("x86: Show symbol name if insn decoder test failed")
Reviewed-by: Miguel Ojeda <ojeda@kernel.org>
Tested-by: Miguel Ojeda <ojeda@kernel.org>
Reported-by: John Baublitz <john.m.baublitz@gmail.com>
Debugged-by: John Baublitz <john.m.baublitz@gmail.com>
Signed-off-by: Valentin Obst <kernel@valentinobst.de>
---
Changes in v2:
- Added tags 'Reviewed-by', 'Tested-by', 'Reported-by', 'Debugged-by',
'Link', and 'Fixes'.
- Explain why this patch fixes the commit mentioned in the 'Fixes' tag.
- CCed the stable list and sent to all x86 maintainers.
- Link to v1: https://lore.kernel.org/r/20240221-x86-insn-decoder-line-fix-v1-1-47cd5a1718c6@valentinobst.de
---
arch/x86/tools/insn_decoder_test.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/x86/tools/insn_decoder_test.c b/arch/x86/tools/insn_decoder_test.c
index 472540aeabc2..727017a3c3c7 100644
--- a/arch/x86/tools/insn_decoder_test.c
+++ b/arch/x86/tools/insn_decoder_test.c
@@ -114,6 +114,7 @@ int main(int argc, char **argv)
unsigned char insn_buff[16];
struct insn insn;
int insns = 0;
+ int lines = 0;
int warnings = 0;
parse_args(argc, argv);
@@ -123,6 +124,8 @@ int main(int argc, char **argv)
int nb = 0, ret;
unsigned int b;
+ lines++;
+
if (line[0] == '<') {
/* Symbol line */
strcpy(sym, line);
@@ -134,12 +137,12 @@ int main(int argc, char **argv)
strcpy(copy, line);
tab1 = strchr(copy, '\t');
if (!tab1)
- malformed_line(line, insns);
+ malformed_line(line, lines);
s = tab1 + 1;
s += strspn(s, " ");
tab2 = strchr(s, '\t');
if (!tab2)
- malformed_line(line, insns);
+ malformed_line(line, lines);
*tab2 = '\0'; /* Characters beyond tab2 aren't examined */
while (s < tab2) {
if (sscanf(s, "%x", &b) == 1) {
---
base-commit: b401b621758e46812da61fa58a67c3fd8d91de0d
change-id: 20240221-x86-insn-decoder-line-fix-7b1f2e1732ff
Best regards,
--
Valentin Obst <kernel@valentinobst.de>
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] x86/tools: fix line number reported for malformed lines
2024-02-23 13:10 [PATCH v2] x86/tools: fix line number reported for malformed lines Valentin Obst
@ 2024-02-23 13:19 ` kernel test robot
2024-02-23 15:00 ` Miguel Ojeda
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2024-02-23 13:19 UTC (permalink / raw)
To: Valentin Obst; +Cc: stable, oe-kbuild-all
Hi,
Thanks for your patch.
FYI: kernel test robot notices the stable kernel rule is not satisfied.
The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1
Rule: add the tag "Cc: stable@vger.kernel.org" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH v2] x86/tools: fix line number reported for malformed lines
Link: https://lore.kernel.org/stable/20240223-x86-insn-decoder-line-fix-v2-1-cde49c69f402%40valentinobst.de
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] x86/tools: fix line number reported for malformed lines
2024-02-23 13:10 [PATCH v2] x86/tools: fix line number reported for malformed lines Valentin Obst
2024-02-23 13:19 ` kernel test robot
@ 2024-02-23 15:00 ` Miguel Ojeda
1 sibling, 0 replies; 3+ messages in thread
From: Miguel Ojeda @ 2024-02-23 15:00 UTC (permalink / raw)
To: Valentin Obst
Cc: Borislav Petkov, Dave Hansen, H. Peter Anvin, Ingo Molnar,
Ingo Molnar, Thomas Gleixner, Andreas Hindborg,
Greg Kroah-Hartman, John Baublitz, Masami Hiramatsu, Miguel Ojeda,
Peter Zijlstra, Sergio González Collado, linux-kernel,
stable, x86
On Fri, Feb 23, 2024 at 2:17 PM Valentin Obst <kernel@valentinobst.de> wrote:
>
> - Explain why this patch fixes the commit mentioned in the 'Fixes' tag.
Thanks for this!
> - CCed the stable list and sent to all x86 maintainers.
Sorry if I was not clear -- the "Cc: stable@vger.kernel.org" needs to
be in the commit message itself, see:
https://docs.kernel.org/process/submitting-patches.html#select-the-recipients-for-your-patch
But I would wait a few days for a v3 to see if x86 says something
meanwhile -- patches to stable need to arrive in mainline anyway :)
Cheers,
Miguel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-23 15:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-23 13:10 [PATCH v2] x86/tools: fix line number reported for malformed lines Valentin Obst
2024-02-23 13:19 ` kernel test robot
2024-02-23 15:00 ` Miguel Ojeda
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.