From: Gleb Natapov <gleb@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>, kvm@vger.kernel.org
Subject: Re: [PATCH 7/8] KVM: x86 emulator: simplify instruction decode flags for opcodes E0-FF
Date: Mon, 23 Aug 2010 16:33:03 +0300 [thread overview]
Message-ID: <20100823133303.GQ10499@redhat.com> (raw)
In-Reply-To: <1282561577-24491-8-git-send-email-avi@redhat.com>
On Mon, Aug 23, 2010 at 02:06:16PM +0300, Avi Kivity wrote:
> Use the new byte/word dual opcode decode.
>
> Signed-off-by: Avi Kivity <avi@redhat.com>
> ---
> arch/x86/kvm/emulate.c | 6 ++----
> 1 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index c61f73d..6cb5663 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -2464,13 +2464,11 @@ static struct opcode opcode_table[256] = {
> N, N, N, N, N, N, N, N,
> /* 0xE0 - 0xE7 */
> X3(D(SrcImmByte)), N,
> - D(ByteOp | SrcImmUByte | DstAcc), D(SrcImmUByte | DstAcc),
> - D(ByteOp | SrcAcc | DstImmUByte), D(SrcAcc | DstImmUByte),
> + D2bv(SrcImmUByte | DstAcc), D2bv(SrcAcc | DstImmUByte),
> /* 0xE8 - 0xEF */
> D(SrcImm | Stack), D(SrcImm | ImplicitOps),
> D(SrcImmFAddr | No64), D(SrcImmByte | ImplicitOps),
> - D(SrcNone | ByteOp | DstAcc), D(SrcNone | DstAcc),
> - D(ByteOp | SrcAcc | ImplicitOps), D(SrcAcc | ImplicitOps),
> + D2bv(SrcNone | DstAcc), D2bv(SrcAcc | ImplicitOps),
> /* 0xF0 - 0xF7 */
> N, N, N, N,
> D(ImplicitOps | Priv), D(ImplicitOps), G(ByteOp, group3), G(0, group3),
Hmm. I actually have a patch that makes encoding of those to be different.
===
Some instructions has 32 bit operand even in long mode.
Decode this through decode table instead of during instruction
emulation.
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 3b35e13..b4361fa 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -84,6 +84,7 @@
#define Group (1<<14) /* Bits 3:5 of modrm byte extend opcode */
#define GroupDual (1<<15) /* Alternate decoding of mod == 3 */
/* Misc flags */
+#define Op32in64 (1<<22) /* Operand is 32b even in long mode */
#define NoAccess (1<<23) /* Don't access memory (lea/invlpg/verr etc) */
#define Op3264 (1<<24) /* Operand is 64b in long mode, 32b otherwise */
#define Undefined (1<<25) /* No Such Instruction */
@@ -2472,13 +2473,13 @@ static struct opcode opcode_table[256] = {
N, N, N, N, N, N, N, N,
/* 0xE0 - 0xE7 */
X3(D(SrcImmByte)), N,
- D(ByteOp | SrcImmUByte | DstAcc), D(SrcImmUByte | DstAcc),
- D(ByteOp | SrcAcc | DstImmUByte), D(SrcAcc | DstImmUByte),
+ D(ByteOp | SrcImmUByte | DstAcc), D(SrcImmUByte | DstAcc | Op32in64),
+ D(ByteOp | SrcAcc | DstImmUByte), D(SrcAcc | DstImmUByte | Op32in64),
/* 0xE8 - 0xEF */
D(SrcImm | Stack), D(SrcImm | ImplicitOps),
D(SrcImmFAddr | No64), D(SrcImmByte | ImplicitOps),
- D(SrcNone | ByteOp | DstAcc), D(SrcNone | DstAcc),
- D(ByteOp | SrcAcc | ImplicitOps), D(SrcAcc | ImplicitOps),
+ D(SrcNone | ByteOp | DstAcc), D(SrcNone | DstAcc | Op32in64),
+ D(ByteOp | SrcAcc | ImplicitOps), D(SrcAcc | ImplicitOps | Op32in64),
/* 0xF0 - 0xF7 */
N, N, N, N,
D(ImplicitOps | Priv), D(ImplicitOps), G(ByteOp, group3), G(0, group3),
@@ -2750,6 +2751,9 @@ done_prefixes:
c->op_bytes = 4;
}
+ if (mode == X86EMUL_MODE_PROT64 && (c->d & Op32in64))
+ c->op_bytes = 4;
+
/* ModRM and SIB bytes. */
if (c->d & ModRM) {
rc = decode_modrm(ctxt, ops, &memop);
@@ -3295,7 +3299,6 @@ special_insn:
case 0xed: /* in (e/r)ax,dx */
c->src.val = c->regs[VCPU_REGS_RDX];
do_io_in:
- c->dst.bytes = min(c->dst.bytes, 4u);
if (!emulator_io_permited(ctxt, ops, c->src.val, c->dst.bytes)) {
emulate_gp(ctxt, 0);
goto done;
@@ -3308,7 +3311,6 @@ special_insn:
case 0xef: /* out dx,(e/r)ax */
c->dst.val = c->regs[VCPU_REGS_RDX];
do_io_out:
- c->src.bytes = min(c->src.bytes, 4u);
if (!emulator_io_permited(ctxt, ops, c->dst.val,
c->src.bytes)) {
emulate_gp(ctxt, 0);
--
Gleb.
next prev parent reply other threads:[~2010-08-23 13:33 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-23 11:06 [PATCH 0/8] Simplify byte/word opcode pair decode Avi Kivity
2010-08-23 11:06 ` [PATCH 1/8] KVM: x86 emulator: support byte/word opcode pairs Avi Kivity
2010-08-23 11:06 ` [PATCH 2/8] KVM: x86 emulator: simplify ALU block (opcodes 00-3F) decode flags Avi Kivity
2010-08-25 19:39 ` Marcelo Tosatti
2010-08-26 8:26 ` Avi Kivity
2010-08-23 11:06 ` [PATCH 3/8] KVM: x86 emulator: simplify string instruction " Avi Kivity
2010-08-23 11:06 ` [PATCH 4/8] KVM: x86 emulator: simplify instruction decode flags for opcodes 80-8F Avi Kivity
2010-08-23 11:06 ` [PATCH 5/8] KVM: x86 emulator: simplify instruction decode flags for opcodes A0-AF Avi Kivity
2010-08-23 11:06 ` [PATCH 6/8] KVM: x86 emulator: simplify instruction decode flags for opcodes C0-DF Avi Kivity
2010-08-23 11:06 ` [PATCH 7/8] KVM: x86 emulator: simplify instruction decode flags for opcodes E0-FF Avi Kivity
2010-08-23 13:33 ` Gleb Natapov [this message]
2010-08-23 13:46 ` Avi Kivity
2010-08-23 13:56 ` Gleb Natapov
2010-08-23 11:06 ` [PATCH 8/8] KVM: x86 emulator: simplify instruction decode flags for opcodes 0F 00-FF Avi Kivity
2010-08-23 13:29 ` [PATCH 0/8] Simplify byte/word opcode pair decode Paolo Bonzini
2010-08-23 13:48 ` Avi Kivity
2010-08-23 14:04 ` Paolo Bonzini
2010-08-23 14:13 ` Avi Kivity
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=20100823133303.GQ10499@redhat.com \
--to=gleb@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
/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