mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 08:14:15 +08:00
bcf7ef56da
When running the instruction decoder selftest with LLVM=1 and 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. Signed-off-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/r/20231205-objdump_reformat-awk-handle-llvm-objdump-bad_expr-v1-1-b4a74f39396f@kernel.org
49 lines
1.3 KiB
Awk
49 lines
1.3 KiB
Awk
#!/bin/awk -f
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
# Usage: objdump -d a.out | awk -f objdump_reformat.awk | ./insn_decoder_test
|
|
# Reformats the disassembly as follows:
|
|
# - Removes all lines except the disassembled instructions.
|
|
# - For instructions that exceed 1 line (7 bytes), crams all the hex bytes
|
|
# into a single line.
|
|
# - Remove bad(or prefix only) instructions
|
|
|
|
BEGIN {
|
|
prev_addr = ""
|
|
prev_hex = ""
|
|
prev_mnemonic = ""
|
|
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"
|
|
}
|
|
|
|
/^ *[0-9a-f]+ <[^>]*>:/ {
|
|
# Symbol entry
|
|
printf("%s%s\n", $2, $1)
|
|
}
|
|
|
|
/^ *[0-9a-f]+:/ {
|
|
if (split($0, field, /: |\t/) < 3) {
|
|
# This is a continuation of the same insn.
|
|
prev_hex = prev_hex field[2]
|
|
} else {
|
|
# Skip bad instructions
|
|
if (match(prev_mnemonic, bad_expr))
|
|
prev_addr = ""
|
|
# Split fwait from other f* instructions
|
|
if (match(prev_hex, fwait_expr) && prev_mnemonic != "fwait") {
|
|
printf "%s\t%s\n", prev_addr, fwait_str
|
|
sub(fwait_expr, "", prev_hex)
|
|
}
|
|
if (prev_addr != "")
|
|
printf "%s\t%s\t%s\n", prev_addr, prev_hex, prev_mnemonic
|
|
prev_addr = field[1]
|
|
prev_hex = field[2]
|
|
prev_mnemonic = field[3]
|
|
}
|
|
}
|
|
|
|
END {
|
|
if (prev_addr != "")
|
|
printf "%s\t%s\t%s\n", prev_addr, prev_hex, prev_mnemonic
|
|
}
|