Skip to contentSkip to conversation

x86/tools: objdump_reformat.awk: Skip bad instructions from llvm-objdump

PATCH In review Nathan Chancellor 2 participants 8 messages Dec 5, 2023 – Jan 4, 2024 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/tools: objdump_reformat.awk: Skip bad instructions from llvm-objdump

When running the instruction decoder selftest with LLVM=1 + CONFIG_PVH=y, there is a series of warnings:

arch/x86/tools/insn_decoder_test: warning: Found an x86 instruction decoder bug, please report this.
arch/x86/tools/insn_decoder_test: warning: ffffffff81000050 ea <unknown>
arch/x86/tools/insn_decoder_test: warning: objdump says 1 bytes, but insn_get_length() says 7 arch/x86/tools/insn_decoder_test: warning: Decoded and checked 7214721 instructions with 1 failures

GNU objdump outputs "(bad)" instead of "<unknown>", which is already handled in the bad_expr regex, so there is no warning.

  $ objdump -d arch/x86/platform/pvh/head.o | grep -E '50:\s+ea'
  50:   ea                      (bad)
  $ llvm-objdump -d arch/x86/platform/pvh/head.o | grep -E '50:\s+ea'
        50: ea                            <unknown>

Add "<unknown>" to the bad_expr regex to clear up the warning, allowing the instruction decoder selftest to fully pass with llvm-objdump.

---
 arch/x86/tools/objdump_reformat.awk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/tools/objdump_reformat.awk +1 -1
index a4120d907277..20b08a6c4d33 100644
@@ -11,7 +11,7 @@ BEGIN {
 	prev_addr = ""
 	prev_hex = ""
 	prev_mnemonic = ""
-	bad_expr = "(\\(bad\\)|^rex|^.byte|^rep(z|nz)$|^lock$|^es$|^cs$|^ss$|^ds$|^fs$|^gs$|^data(16|32)$|^addr(16|32|64))"
+	bad_expr = "(\\(bad\\)|<unknown>|^rex|^.byte|^rep(z|nz)$|^lock$|^es$|^cs$|^ss$|^ds$|^fs$|^gs$|^data(16|32)$|^addr(16|32|64))"
 	fwait_expr = "^9b[ \t]*fwait"
 	fwait_str="9b\tfwait"
 }

---
base-commit: 5225952d74d43e4c054731c74b8afd700b23a94a
change-id: 20231205-objdump_reformat-awk-handle-llvm-objdump-bad_expr-9e74cd2a08b5

Best regards,

Signature · 1 line
Nathan Chancellor <[email protected]>
#1 lore raw

Ping? I am still seeing this issue.

Quoted 48 lines · Nathan Chancellor

When running the instruction decoder selftest with LLVM=1 + CONFIG_PVH=y, there is a series of warnings:

arch/x86/tools/insn_decoder_test: warning: Found an x86 instruction decoder bug, please report this.
arch/x86/tools/insn_decoder_test: warning: ffffffff81000050 ea <unknown>
arch/x86/tools/insn_decoder_test: warning: objdump says 1 bytes, but insn_get_length() says 7 arch/x86/tools/insn_decoder_test: warning: Decoded and checked 7214721 instructions with 1 failures

GNU objdump outputs "(bad)" instead of "<unknown>", which is already handled in the bad_expr regex, so there is no warning.

  $ objdump -d arch/x86/platform/pvh/head.o | grep -E '50:\s+ea'
  50:   ea                      (bad)
  $ llvm-objdump -d arch/x86/platform/pvh/head.o | grep -E '50:\s+ea'
        50: ea                            <unknown>

Add "<unknown>" to the bad_expr regex to clear up the warning, allowing the instruction decoder selftest to fully pass with llvm-objdump.

---
 arch/x86/tools/objdump_reformat.awk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/tools/objdump_reformat.awk +1 -2
index a4120d907277..20b08a6c4d33 100644
@@ -11,7 +11,7 @@ BEGIN {
 	prev_addr = ""
 	prev_hex = ""
 	prev_mnemonic = ""
-	bad_expr = "(\\(bad\\)|^rex|^.byte|^rep(z|nz)$|^lock$|^es$|^cs$|^ss$|^ds$|^fs$|^gs$|^data(16|32)$|^addr(16|32|64))"
+	bad_expr = "(\\(bad\\)|<unknown>|^rex|^.byte|^rep(z|nz)$|^lock$|^es$|^cs$|^ss$|^ds$|^fs$|^gs$|^data(16|32)$|^addr(16|32|64))"
 	fwait_expr = "^9b[ \t]*fwait"
 	fwait_str="9b\tfwait"
 }
 
---

base-commit: 5225952d74d43e4c054731c74b8afd700b23a94a
change-id: 20231205-objdump_reformat-awk-handle-llvm-objdump-bad_expr-9e74cd2a08b5

Best regards,

Signature · 1 line
Nathan Chancellor <[email protected]>
maintainer
#2 lore raw
Quoted 1 line · Nathan Chancellor

Ping? I am still seeing this issue.

Does this need a Fixes tag and needs to go to Linus now or are you fine with 6.8-rc0?

I.e., the answer probably depends on what kernels you're running the llvm tests...

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#3 lore raw
Quoted 5 lines · Borislav Petkov
Quoted 1 line · Nathan Chancellor

Ping? I am still seeing this issue.

Does this need a Fixes tag and needs to go to Linus now or are you fine with 6.8-rc0?

This is only needed due to the recent changes from Sam and myself in x86/build, so no need to rush it to Linus. I just wanted to make sure it was not lost before the chaos of the merge window.

Cheers,
Nathan

maintainer
#4 lore raw
Quoted 9 lines · Nathan Chancellor
Quoted 5 lines · Borislav Petkov
Quoted 1 line · Nathan Chancellor

Ping? I am still seeing this issue.

Does this need a Fixes tag and needs to go to Linus now or are you fine with 6.8-rc0?

This is only needed due to the recent changes from Sam and myself in x86/build

I don't understand: those three commits seem unrelated to LLVM objdump outputting "<unknown>".

Or are you saying that you've *started* running the insn decoder selftest with llvm's objdump and those three commits are addressing differences in the output and this outstanding commit is needed too for the bad opcode case?

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#5 lore raw
Quoted 11 lines · Borislav Petkov
Quoted 9 lines · Nathan Chancellor
Quoted 5 lines · Borislav Petkov
Quoted 1 line · Nathan Chancellor

Ping? I am still seeing this issue.

Does this need a Fixes tag and needs to go to Linus now or are you fine with 6.8-rc0?

This is only needed due to the recent changes from Sam and myself in x86/build

Quoted 7 lines

I don't understand: those three commits seem unrelated to LLVM objdump outputting "<unknown>".

Or are you saying that you've *started* running the insn decoder selftest with llvm's objdump and those three commits are addressing differences in the output and this outstanding commit is needed too for the bad opcode case?

Prior to commit 5225952d74d4 ("x86/tools: Remove chkobjdump.awk"), the insn decoder selftest would not actually run with llvm-objdump altogether because chkobjdump.awk would fail (because it was only written for GNU objdump). The two commits prior to 5225952d74d4 were cleaning up differences between the output of each objdump implementations and this change should have been a part of that work as well, I just did not build enough configurations to see it. Hopefully that clears things up.

Cheers,
Nathan

#6 lore raw
Quoted 20 lines · Nathan Chancellor
Quoted 11 lines · Borislav Petkov
Quoted 9 lines · Nathan Chancellor
Quoted 5 lines · Borislav Petkov
Quoted 1 line · Nathan Chancellor

Ping? I am still seeing this issue.

Does this need a Fixes tag and needs to go to Linus now or are you fine with 6.8-rc0?

This is only needed due to the recent changes from Sam and myself in x86/build

Quoted 7 lines

I don't understand: those three commits seem unrelated to LLVM objdump outputting "<unknown>".

Or are you saying that you've *started* running the insn decoder selftest with llvm's objdump and those three commits are addressing differences in the output and this outstanding commit is needed too for the bad opcode case?

Quoted 8 lines

Prior to commit 5225952d74d4 ("x86/tools: Remove chkobjdump.awk"), the insn decoder selftest would not actually run with llvm-objdump altogether because chkobjdump.awk would fail (because it was only written for GNU objdump). The two commits prior to 5225952d74d4 were cleaning up differences between the output of each objdump implementations and this change should have been a part of that work as well, I just did not build enough configurations to see it. Hopefully that clears things up.

For the record, this explanation really should have been in the commit message of 5225952d74d4 but I guess I was not thinking at the time.

Cheers,
Nathan

maintainer
#7 lore raw
Quoted 2 lines · Nathan Chancellor

For the record, this explanation really should have been in the commit message of 5225952d74d4 but I guess I was not thinking at the time.

That's fine - we have the Link tag. Lemme refer to that thread and we're good.

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette