From: tip-bot for Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
masami.hiramatsu.pt@hitachi.com, tglx@linutronix.de,
mingo@elte.hu
Subject: [tip:perf/core] x86: Fix instruction decoder to handle grouped AVX instructions
Date: Mon, 5 Dec 2011 09:42:01 -0800 [thread overview]
Message-ID: <tip-130b78b2bf16d5d89091db38374faef896360cf9@git.kernel.org> (raw)
In-Reply-To: <20111205120539.15475.91428.stgit@cloud>
Commit-ID: 130b78b2bf16d5d89091db38374faef896360cf9
Gitweb: http://git.kernel.org/tip/130b78b2bf16d5d89091db38374faef896360cf9
Author: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
AuthorDate: Mon, 5 Dec 2011 21:05:39 +0900
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Mon, 5 Dec 2011 14:53:15 +0100
x86: Fix instruction decoder to handle grouped AVX instructions
For reducing memory usage of attribute table, x86 instruction
decoder puts "Group" attribute only on "no-last-prefix"
attribute table (same as vex_p == 0 case).
Thus, the decoder should look no-last-prefix table first, and
then only if it is not a group, move on to "with-last-prefix"
table (vex_p != 0).
However, current implementation, inat_get_avx_attribute()
looks with-last-prefix directly. So, when decoding
a grouped AVX instruction, the decoder fails to find correct
group because there is no "Group" attribute on the table.
This ends up with the mis-decoding of instructions, as Ingo
reported in http://thread.gmane.org/gmane.linux.kernel/1214103
This patch fixes it to check no-last-prefix table first
even if that is an AVX instruction, and get an attribute from
"with last-prefix" table only if that is not a group.
Reported-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: yrl.pp-manager.tt@hitachi.com
Link: http://lkml.kernel.org/r/20111205120539.15475.91428.stgit@cloud
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86/lib/inat.c | 9 ++++++++-
arch/x86/lib/insn.c | 4 +++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/arch/x86/lib/inat.c b/arch/x86/lib/inat.c
index 46fc4ee..88ad5fb 100644
--- a/arch/x86/lib/inat.c
+++ b/arch/x86/lib/inat.c
@@ -82,9 +82,16 @@ insn_attr_t inat_get_avx_attribute(insn_byte_t opcode, insn_byte_t vex_m,
const insn_attr_t *table;
if (vex_m > X86_VEX_M_MAX || vex_p > INAT_LSTPFX_MAX)
return 0;
- table = inat_avx_tables[vex_m][vex_p];
+ /* At first, this checks the master table */
+ table = inat_avx_tables[vex_m][0];
if (!table)
return 0;
+ if (!inat_is_group(table[opcode]) && vex_p) {
+ /* If this is not a group, get attribute directly */
+ table = inat_avx_tables[vex_m][vex_p];
+ if (!table)
+ return 0;
+ }
return table[opcode];
}
diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
index 374562e..5a1f9f3 100644
--- a/arch/x86/lib/insn.c
+++ b/arch/x86/lib/insn.c
@@ -202,7 +202,7 @@ void insn_get_opcode(struct insn *insn)
m = insn_vex_m_bits(insn);
p = insn_vex_p_bits(insn);
insn->attr = inat_get_avx_attribute(op, m, p);
- if (!inat_accept_vex(insn->attr))
+ if (!inat_accept_vex(insn->attr) && !inat_is_group(insn->attr))
insn->attr = 0; /* This instruction is bad */
goto end; /* VEX has only 1 byte for opcode */
}
@@ -249,6 +249,8 @@ void insn_get_modrm(struct insn *insn)
pfx = insn_last_prefix(insn);
insn->attr = inat_get_group_attribute(mod, pfx,
insn->attr);
+ if (insn_is_avx(insn) && !inat_accept_vex(insn->attr))
+ insn->attr = 0; /* This is bad */
}
}
next prev parent reply other threads:[~2011-12-05 17:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-05 12:05 [PATCH 0/6]x86: decoder bugfixes/updates Masami Hiramatsu
2011-12-05 12:05 ` [PATCH 1/6] [RESEND][BUGFIX] x86/tools: Fix Makefile to build all test tools Masami Hiramatsu
2011-12-05 17:41 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2011-12-05 12:05 ` [PATCH 2/6] [RESEND][BUGFIX] x86: Fix instruction decoder to handle grouped AVX instructions Masami Hiramatsu
2011-12-05 17:42 ` tip-bot for Masami Hiramatsu [this message]
2011-12-05 12:05 ` [PATCH 3/6] [RESEND][BUGFIX] x86/tools: Fix instruction decoder message output Masami Hiramatsu
2011-12-05 17:42 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2011-12-05 12:05 ` [PATCH 4/6] [RESEND][BUGFIX] x86/tools: Fix insn_sanity message outputs Masami Hiramatsu
2011-12-05 17:43 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2011-12-05 12:05 ` [PATCH 5/6] x86: Update instruction decoder to support new AVX formats Masami Hiramatsu
2011-12-05 17:44 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2011-12-05 12:06 ` [PATCH 6/6] x86/tools: Add decoded instruction dump mode Masami Hiramatsu
2011-12-05 17:45 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-130b78b2bf16d5d89091db38374faef896360cf9@git.kernel.org \
--to=masami.hiramatsu.pt@hitachi.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).