[PATCH 1/2]KVM: x86_emulator: Decode the memory operand for 'mov'

Yang, Sheng
2007-10-26T06:15:18Z

[-- Attachment #1: Type: text/plain, Size: 1807 bytes --]

>From ebfc23b71051e5ab19d22fb3f9c3d57721566ea9 Mon Sep 17 00:00:00 2001
From: Sheng Yang <sheng.yang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Date: Fri, 26 Oct 2007 13:41:28 +0800
Subject: [PATCH] KVM: x86_emulator: Decode the memory operand for 'mov'

For the following TPR patch, we must get gva for executing instructions.
Most
memory operands are decoded in ModR/M part, except some kinds of 'mov'.
This
patch decoded the memory operand for these 'mov' instructions, instead
of using
CR2.

Signed-off-by: Sheng Yang <sheng.yang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
drivers/kvm/x86_emulate.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c
index f858c01..f75f75a 100644
--- a/drivers/kvm/x86_emulate.c
+++ b/drivers/kvm/x86_emulate.c
@@ -837,6 +837,11 @@ modrm_done:
&& c->modrm_reg == 7)
break;
srcmem_common:
+ /* Decode memory operand for mov(0xa0 ... 0xa1)*/
+ if ((c->b == 0xa0) || (c->b == 0xa1)) {
+ ctxt->cr2 = insn_fetch(u32, c->src.bytes,
c->eip);
+ c->eip -= c->src.bytes;
+ }
/*
* For instructions with a ModR/M byte, switch to
register
* access if Mod = 3.
@@ -906,6 +911,7 @@ modrm_done:
}
break;
case DstMem:
+ c->dst.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
/*
* For instructions with a ModR/M byte, switch to
register
* access if Mod = 3.
@@ -914,6 +920,11 @@ modrm_done:
c->dst.type = OP_REG;
else
c->dst.type = OP_MEM;
+ /* Decode memory operand for mov(0xa2 ... 0xa3)*/
+ if ((c->b == 0xa2) || (c->b == 0xa3)) {
+ ctxt->cr2 = insn_fetch(u32, c->dst.bytes,
c->eip);
+ c->eip -= c->dst.bytes;
+ }
break;
}

--
1.5.2

Thanks
Yang, Sheng

[-- Attachment #2: 0001-KVM-x86_emulator-Decode-the-memory-operand-for-mo.patch --]
[-- Type: application/octet-stream, Size: 1662 bytes --]

From ebfc23b71051e5ab19d22fb3f9c3d57721566ea9 Mon Sep 17 00:00:00 2001
From: Sheng Yang <sheng.yang@intel.com>
Date: Fri, 26 Oct 2007 13:41:28 +0800
Subject: [PATCH] KVM: x86_emulator: Decode the memory operand for 'mov'

For the following TPR patch, we must get gva for executing instructions. Most
memory operands are decoded in ModR/M part, except some kinds of 'mov'. This
patch decoded the memory operand for these 'mov' instructions, instead of using
CR2.

Signed-off-by: Sheng Yang <sheng.yang@intel.com>
---
drivers/kvm/x86_emulate.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c
index f858c01..f75f75a 100644
--- a/drivers/kvm/x86_emulate.c
+++ b/drivers/kvm/x86_emulate.c
@@ -837,6 +837,11 @@ modrm_done:
&& c->modrm_reg == 7)
break;
srcmem_common:
+ /* Decode memory operand for mov(0xa0 ... 0xa1)*/
+ if ((c->b == 0xa0) || (c->b == 0xa1)) {
+ ctxt->cr2 = insn_fetch(u32, c->src.bytes, c->eip);
+ c->eip -= c->src.bytes;
+ }
/*
* For instructions with a ModR/M byte, switch to register
* access if Mod = 3.
@@ -906,6 +911,7 @@ modrm_done:
}
break;
case DstMem:
+ c->dst.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
/*
* For instructions with a ModR/M byte, switch to register
* access if Mod = 3.
@@ -914,6 +920,11 @@ modrm_done:
c->dst.type = OP_REG;
else
c->dst.type = OP_MEM;
+ /* Decode memory operand for mov(0xa2 ... 0xa3)*/
+ if ((c->b == 0xa2) || (c->b == 0xa3)) {
+ ctxt->cr2 = insn_fetch(u32, c->dst.bytes, c->eip);
+ c->eip -= c->dst.bytes;
+ }
break;
}

--
1.5.2

[-- Attachment #3: Type: text/plain, Size: 314 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

[-- Attachment #4: Type: text/plain, Size: 186 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org