From: Takuya Yoshikawa <takuya.yoshikawa@gmail.com>
To: avi@redhat.com, mtosatti@redhat.com
Cc: kvm@vger.kernel.org, yoshikawa.takuya@oss.ntt.co.jp, gleb@redhat.com
Subject: [PATCH 05/10] KVM: x86 emulator: Use opcode::execute for XCHG(86/87)
Date: Sun, 29 May 2011 21:59:09 +0900 [thread overview]
Message-ID: <20110529215909.047f6a2a.takuya.yoshikawa@gmail.com> (raw)
In-Reply-To: <20110529215200.17be7761.takuya.yoshikawa@gmail.com>
From: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
In addition, replace one "goto xchg" with an em_xchg() call.
Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
---
arch/x86/kvm/emulate.c | 31 +++++++++++++++++--------------
1 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 2e2e87f..16c7507 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -2611,6 +2611,20 @@ static int em_test(struct x86_emulate_ctxt *ctxt)
return X86EMUL_CONTINUE;
}
+static int em_xchg(struct x86_emulate_ctxt *ctxt)
+{
+ struct decode_cache *c = &ctxt->decode;
+
+ /* Write back the register source. */
+ c->src.val = c->dst.val;
+ write_register_operand(&c->src);
+
+ /* Write back the memory destination with implicit LOCK prefix. */
+ c->dst.val = c->src.orig_val;
+ c->lock_prefix = 1;
+ return X86EMUL_CONTINUE;
+}
+
static int em_imul(struct x86_emulate_ctxt *ctxt)
{
struct decode_cache *c = &ctxt->decode;
@@ -3142,7 +3156,7 @@ static struct opcode opcode_table[256] = {
G(ByteOp | DstMem | SrcImm | ModRM | No64 | Group, group1),
G(DstMem | SrcImmByte | ModRM | Group, group1),
I2bv(DstMem | SrcReg | ModRM, em_test),
- D2bv(DstMem | SrcReg | ModRM | Lock),
+ I2bv(DstMem | SrcReg | ModRM | Lock, em_xchg),
/* 0x88 - 0x8F */
I2bv(DstMem | SrcReg | ModRM | Mov, em_mov),
I2bv(DstReg | SrcMem | ModRM | Mov, em_mov),
@@ -3866,18 +3880,6 @@ special_insn:
if (test_cc(c->b, ctxt->eflags))
jmp_rel(c, c->src.val);
break;
- case 0x86 ... 0x87: /* xchg */
- xchg:
- /* Write back the register source. */
- c->src.val = c->dst.val;
- write_register_operand(&c->src);
- /*
- * Write back the memory destination with implicit LOCK
- * prefix.
- */
- c->dst.val = c->src.orig_val;
- c->lock_prefix = 1;
- break;
case 0x8c: /* mov r/m, sreg */
if (c->modrm_reg > VCPU_SREG_GS) {
rc = emulate_ud(ctxt);
@@ -3913,7 +3915,8 @@ special_insn:
case 0x90 ... 0x97: /* nop / xchg reg, rax */
if (c->dst.addr.reg == &c->regs[VCPU_REGS_RAX])
break;
- goto xchg;
+ rc = em_xchg(ctxt);
+ break;
case 0x98: /* cbw/cwde/cdqe */
switch (c->op_bytes) {
case 2: c->dst.val = (s8)c->dst.val; break;
--
1.7.4.1
next prev parent reply other threads:[~2011-05-29 12:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-29 12:52 [PATCH 00/10] KVM: x86 emulator: Some cleanups and conversion to opcode::execute Takuya Yoshikawa
2011-05-29 12:53 ` [PATCH 01/10] KVM: x86 emulator: Use the pointers ctxt and c consistently Takuya Yoshikawa
2011-05-29 12:55 ` [PATCH 02/10] KVM: x86 emulator: Rename emulate_xxx() to em_xxx() Takuya Yoshikawa
2011-05-29 12:56 ` [PATCH 03/10] KVM: x86 emulator: Use opcode::execute for some instructions Takuya Yoshikawa
2011-05-29 12:57 ` [PATCH 04/10] KVM: x86 emulator: Use opcode::execute for TEST(84/85, A8/A9) Takuya Yoshikawa
2011-05-29 12:59 ` Takuya Yoshikawa [this message]
2011-05-29 13:00 ` [PATCH 06/10] KVM: x86 emulator: Use opcode::execute for RET(C3) Takuya Yoshikawa
2011-05-29 13:01 ` [PATCH 07/10] KVM: x86 emulator: Use opcode::execute for MOV(8C/8E) Takuya Yoshikawa
2011-05-29 13:02 ` [PATCH 08/10] KVM: x86 emulator: Clean up INT n/INTO/INT 3(CC/CD/CE) Takuya Yoshikawa
2011-05-29 13:04 ` [PATCH 09/10] KVM: x86 emulator: Use opcode::execute for LOOP/JCXZ Takuya Yoshikawa
2011-05-29 13:05 ` [PATCH 10/10] KVM: x86 emulator: Use opcode::execute for CLI/STI(FA/FB) Takuya Yoshikawa
2011-05-31 18:33 ` [PATCH 00/10] KVM: x86 emulator: Some cleanups and conversion to opcode::execute Marcelo Tosatti
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=20110529215909.047f6a2a.takuya.yoshikawa@gmail.com \
--to=takuya.yoshikawa@gmail.com \
--cc=avi@redhat.com \
--cc=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=yoshikawa.takuya@oss.ntt.co.jp \
/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