[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120401160315.4502.55715.stgit@shimauta>
Date: Mon, 02 Apr 2012 01:03:15 +0900
From: Masami Hiramatsu <masami.hiramatsu@...il.com>
To: linux-kernel@...r.kernel.org
Cc: Huang Ying <ying.huang@...el.com>,
Ananth N Mavinakayanahalli <ananth@...ibm.com>,
Frederic Weisbecker <fweisbec@...il.com>,
"H. Peter Anvin" <hpa@...or.com>, Ingo Molnar <mingo@...hat.com>,
Jason Wessel <jason.wessel@...driver.com>,
Thomas Gleixner <tglx@...utronix.de>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>
Subject: [RFC PATCH -tip 05/16] x86: Disassemble x86-64 only instructions
Support x86-64 only instructions on disassembler.
For example, syscall and sysret.
Signed-off-by: Masami Hiramatsu <masami.hiramatsu@...il.com>
---
arch/x86/lib/mnemonic.c | 23 +++++++++++++++++++++--
arch/x86/tools/gen-insn-mnemonic-x86.awk | 11 +++++++++--
2 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/arch/x86/lib/mnemonic.c b/arch/x86/lib/mnemonic.c
index 0c375fb..dfd1aab 100644
--- a/arch/x86/lib/mnemonic.c
+++ b/arch/x86/lib/mnemonic.c
@@ -1,10 +1,29 @@
#include <linux/kernel.h>
+#include <linux/string.h>
#include <asm/insn.h>
#include <asm/disasm.h>
/* Define mnemonic lookup table */
#include "mnemonic-tables.c"
+static const char *get_variant(const char *fmt, struct insn *insn)
+{
+ const char *p;
+
+ if (!fmt)
+ goto out;
+
+ if (insn->x86_64) {
+ p = strstr(fmt, "%6");
+ if (!p)
+ goto out;
+ fmt = strchr(p, ':') + 1;
+ } else if (strstr(fmt, "%6") == fmt)
+ fmt = NULL;
+out:
+ return fmt;
+}
+
const char *get_mnemonic_format(struct insn *insn, const char **grp)
{
insn_attr_t attr;
@@ -39,7 +58,7 @@ const char *get_mnemonic_format(struct insn *insn, const char **grp)
table = mnemonic_escape_tables[n][0];
}
if (table)
- ret = table[idx];
+ ret = get_variant(table[idx], insn);
/* Solve groups */
if (grp && inat_is_group(attr)) {
@@ -51,7 +70,7 @@ const char *get_mnemonic_format(struct insn *insn, const char **grp)
else
table = mnemonic_group_tables[n][0];
idx = X86_MODRM_REG(idx);
- *grp = table[idx];
+ *grp = get_variant(table[idx], insn);
}
}
return ret;
diff --git a/arch/x86/tools/gen-insn-mnemonic-x86.awk b/arch/x86/tools/gen-insn-mnemonic-x86.awk
index 2714f2f..14fca68 100644
--- a/arch/x86/tools/gen-insn-mnemonic-x86.awk
+++ b/arch/x86/tools/gen-insn-mnemonic-x86.awk
@@ -49,6 +49,7 @@ BEGIN {
regs_expr = "^[ABCDESR][0-9A-Z]"
vregs_expr = "^[re][0-9A-Z]"
+ only64_expr = "\\(o64\\)"
lprefix1_expr = "\\(66\\)"
lprefix2_expr = "\\(F3\\)"
lprefix3_expr = "\\(F2\\)"
@@ -254,6 +255,7 @@ function get_operand(opnd, i,count,f8,opnds) {
ext = null
flags = null
opnd = null
+ pfx = ""
# parse one opcode
if (match($i, opnd_expr))
opnd = get_operand($(i++))
@@ -283,10 +285,15 @@ function get_operand(opnd, i,count,f8,opnds) {
opcode = "call"
if (match(opcode, "^ret.*"))
opcode = "ret"
+
+ # additional flags
+ if (match(ext, only64_expr))
+ pfx = "%6:"
+
if (length(opnd) != 0)
- flags = "\"" opcode " " opnd "\""
+ flags = "\"" pfx opcode " " opnd "\""
else
- flags = "\"" opcode "\""
+ flags = "\"" pfx opcode "\""
if (length(flags) == 0)
continue
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists