aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/tools/distill.awk
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@redhat.com>2009-08-13 16:34:21 -0400
committerFrederic Weisbecker <fweisbec@gmail.com>2009-08-26 18:35:56 -0400
commitca0e9badd1a39fecdd235f4bf1481b9da756e27b (patch)
treee7d7f9a398bf50cb1bd327b38a29d756b54b7b95 /arch/x86/tools/distill.awk
parenteb13296cfaf6c699566473669a96a38a90562384 (diff)
x86: X86 instruction decoder build-time selftest
Add a user-space selftest of x86 instruction decoder at kernel build time. When CONFIG_X86_DECODER_SELFTEST=y, Kbuild builds a test harness of x86 instruction decoder and performs it after building vmlinux. The test compares the results of objdump and x86 instruction decoder code and check there are no differences. Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com> Signed-off-by: Jim Keniston <jkenisto@us.ibm.com> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Cc: Avi Kivity <avi@redhat.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Christoph Hellwig <hch@infradead.org> Cc: Frank Ch. Eigler <fche@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Jason Baron <jbaron@redhat.com> Cc: K.Prasad <prasad@linux.vnet.ibm.com> Cc: Lai Jiangshan <laijs@cn.fujitsu.com> Cc: Li Zefan <lizf@cn.fujitsu.com> Cc: Przemysław Pawełczyk <przemyslaw@pawelczyk.it> Cc: Roland McGrath <roland@redhat.com> Cc: Sam Ravnborg <sam@ravnborg.org> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Tom Zanussi <tzanussi@gmail.com> Cc: Vegard Nossum <vegard.nossum@gmail.com> LKML-Reference: <20090813203421.31965.29006.stgit@localhost.localdomain> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Diffstat (limited to 'arch/x86/tools/distill.awk')
-rw-r--r--arch/x86/tools/distill.awk42
1 files changed, 42 insertions, 0 deletions
diff --git a/arch/x86/tools/distill.awk b/arch/x86/tools/distill.awk
new file mode 100644
index 000000000000..d433619bb866
--- /dev/null
+++ b/arch/x86/tools/distill.awk
@@ -0,0 +1,42 @@
1#!/bin/awk -f
2# Usage: objdump -d a.out | awk -f distill.awk | ./test_get_len
3# Distills the disassembly as follows:
4# - Removes all lines except the disassembled instructions.
5# - For instructions that exceed 1 line (7 bytes), crams all the hex bytes
6# into a single line.
7# - Remove bad(or prefix only) instructions
8
9BEGIN {
10 prev_addr = ""
11 prev_hex = ""
12 prev_mnemonic = ""
13 bad_expr = "(\\(bad\\)|^rex|^.byte|^rep(z|nz)$|^lock$|^es$|^cs$|^ss$|^ds$|^fs$|^gs$|^data(16|32)$|^addr(16|32|64))"
14 fwait_expr = "^9b "
15 fwait_str="9b\tfwait"
16}
17
18/^ *[0-9a-f]+:/ {
19 if (split($0, field, "\t") < 3) {
20 # This is a continuation of the same insn.
21 prev_hex = prev_hex field[2]
22 } else {
23 # Skip bad instructions
24 if (match(prev_mnemonic, bad_expr))
25 prev_addr = ""
26 # Split fwait from other f* instructions
27 if (match(prev_hex, fwait_expr) && prev_mnemonic != "fwait") {
28 printf "%s\t%s\n", prev_addr, fwait_str
29 sub(fwait_expr, "", prev_hex)
30 }
31 if (prev_addr != "")
32 printf "%s\t%s\t%s\n", prev_addr, prev_hex, prev_mnemonic
33 prev_addr = field[1]
34 prev_hex = field[2]
35 prev_mnemonic = field[3]
36 }
37}
38
39END {
40 if (prev_addr != "")
41 printf "%s\t%s\t%s\n", prev_addr, prev_hex, prev_mnemonic
42}