* [PATCH 1/2]KVM: x86_emulator: Decode the memory operand for 'mov'
@ 2007-10-26 6:15 Yang, Sheng
[not found] ` <DB3BD37E3533EE46BED2FBA80995557F9BED4A-wq7ZOvIWXbM/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Yang, Sheng @ 2007-10-26 6:15 UTC (permalink / raw)
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
[-- 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
https://lists.sourceforge.net/lists/listinfo/kvm-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2]KVM: x86_emulator: Decode the memory operand for 'mov'
[not found] ` <DB3BD37E3533EE46BED2FBA80995557F9BED4A-wq7ZOvIWXbM/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2007-10-26 9:02 ` Avi Kivity
[not found] ` <4721AD2E.3050307-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Avi Kivity @ 2007-10-26 9:02 UTC (permalink / raw)
To: Yang, Sheng; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Yang, Sheng wrote:
> >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;
> + }
>
We're moving eip backwards here, then forwards in x86_emulate_insn()...
I'm getting dizzy.
How about add a MemAbs bitflag in decode it outside, similar to the
ModRM flag and decoding?
--
error compiling committee.c: too many arguments to function
-------------------------------------------------------------------------
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/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2]KVM: x86_emulator: Decode the memory operand for 'mov'
[not found] ` <4721AD2E.3050307-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2007-10-26 9:11 ` Yang, Sheng
2007-10-26 9:28 ` Yang, Sheng
1 sibling, 0 replies; 6+ messages in thread
From: Yang, Sheng @ 2007-10-26 9:11 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Avi Kivity wrote:
> Yang, Sheng wrote:
>>> 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;
>> + }
>>
>
> We're moving eip backwards here, then forwards in
x86_emulate_insn()...
> I'm getting dizzy.
>
> How about add a MemAbs bitflag in decode it outside, similar to the
> ModRM flag and decoding?
Oops...
In current condition, no eip move required. I will remove these
movement...
Thanks
Yang, Sheng
-------------------------------------------------------------------------
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/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2]KVM: x86_emulator: Decode the memory operand for 'mov'
[not found] ` <4721AD2E.3050307-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-26 9:11 ` Yang, Sheng
@ 2007-10-26 9:28 ` Yang, Sheng
[not found] ` <DB3BD37E3533EE46BED2FBA80995557F9BEE42-wq7ZOvIWXbM/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
1 sibling, 1 reply; 6+ messages in thread
From: Yang, Sheng @ 2007-10-26 9:28 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
[-- Attachment #1: Type: text/plain, Size: 2212 bytes --]
>From 3ceb677ffee889880020d8ccb6b9f2c5bfb05644 Mon Sep 17 00:00:00 2001
From: Sheng Yang <sheng.yang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Date: Fri, 26 Oct 2007 17:15:36 +0800
Subject: [PATCH 1/2] 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, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c
index f858c01..5f6a40c 100644
--- a/drivers/kvm/x86_emulate.c
+++ b/drivers/kvm/x86_emulate.c
@@ -837,6 +837,9 @@ 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);
/*
* For instructions with a ModR/M byte, switch to
register
* access if Mod = 3.
@@ -906,6 +909,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 +918,9 @@ 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);
break;
}
@@ -1337,13 +1344,9 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt,
struct x86_emulate_ops *ops)
case 0xa0 ... 0xa1: /* mov */
c->dst.ptr = (unsigned long *)&c->regs[VCPU_REGS_RAX];
c->dst.val = c->src.val;
- /* skip src displacement */
- c->eip += c->ad_bytes;
break;
case 0xa2 ... 0xa3: /* mov */
c->dst.val = (unsigned long)c->regs[VCPU_REGS_RAX];
- /* skip c->dst displacement */
- c->eip += c->ad_bytes;
break;
case 0xc0 ... 0xc1:
emulate_grp2(ctxt);
--
1.5.2
[-- Attachment #2: 0001-KVM-x86_emulator-Decode-the-memory-operand-for-mo.patch --]
[-- Type: application/octet-stream, Size: 2080 bytes --]
From 3ceb677ffee889880020d8ccb6b9f2c5bfb05644 Mon Sep 17 00:00:00 2001
From: Sheng Yang <sheng.yang@intel.com>
Date: Fri, 26 Oct 2007 17:15:36 +0800
Subject: [PATCH 1/2] 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, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c
index f858c01..5f6a40c 100644
--- a/drivers/kvm/x86_emulate.c
+++ b/drivers/kvm/x86_emulate.c
@@ -837,6 +837,9 @@ 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);
/*
* For instructions with a ModR/M byte, switch to register
* access if Mod = 3.
@@ -906,6 +909,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 +918,9 @@ 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);
break;
}
@@ -1337,13 +1344,9 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
case 0xa0 ... 0xa1: /* mov */
c->dst.ptr = (unsigned long *)&c->regs[VCPU_REGS_RAX];
c->dst.val = c->src.val;
- /* skip src displacement */
- c->eip += c->ad_bytes;
break;
case 0xa2 ... 0xa3: /* mov */
c->dst.val = (unsigned long)c->regs[VCPU_REGS_RAX];
- /* skip c->dst displacement */
- c->eip += c->ad_bytes;
break;
case 0xc0 ... 0xc1:
emulate_grp2(ctxt);
--
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
https://lists.sourceforge.net/lists/listinfo/kvm-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2]KVM: x86_emulator: Decode the memory operand for 'mov'
[not found] ` <DB3BD37E3533EE46BED2FBA80995557F9BEE42-wq7ZOvIWXbM/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2007-10-28 16:43 ` Avi Kivity
[not found] ` <4724BC38.3050701-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Avi Kivity @ 2007-10-28 16:43 UTC (permalink / raw)
To: Yang, Sheng; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Yang, Sheng wrote:
> From 3ceb677ffee889880020d8ccb6b9f2c5bfb05644 Mon Sep 17 00:00:00 2001
> From: Sheng Yang <sheng.yang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Date: Fri, 26 Oct 2007 17:15:36 +0800
> Subject: [PATCH 1/2] 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.
>
>
I committed a patch which moves abs address generation to the decode
stage using a MovAbs flag in the decode table.
--
error compiling committee.c: too many arguments to function
-------------------------------------------------------------------------
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/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2]KVM: x86_emulator: Decode the memory operand for 'mov'
[not found] ` <4724BC38.3050701-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2007-10-29 4:53 ` Yang, Sheng
0 siblings, 0 replies; 6+ messages in thread
From: Yang, Sheng @ 2007-10-29 4:53 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Avi Kivity wrote:
> Yang, Sheng wrote:
>> From 3ceb677ffee889880020d8ccb6b9f2c5bfb05644 Mon Sep 17 00:00:00
2001
>> From: Sheng Yang <sheng.yang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>> Date: Fri, 26 Oct 2007 17:15:36 +0800
>> Subject: [PATCH 1/2] 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.
>>
>>
>
> I committed a patch which moves abs address generation to the decode
> stage using a MovAbs flag in the decode table.
OK. I will resend the TPR patch alone later.
Thanks
Yang, Sheng
-------------------------------------------------------------------------
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/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-10-29 4:53 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-26 6:15 [PATCH 1/2]KVM: x86_emulator: Decode the memory operand for 'mov' Yang, Sheng
[not found] ` <DB3BD37E3533EE46BED2FBA80995557F9BED4A-wq7ZOvIWXbM/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-10-26 9:02 ` Avi Kivity
[not found] ` <4721AD2E.3050307-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-26 9:11 ` Yang, Sheng
2007-10-26 9:28 ` Yang, Sheng
[not found] ` <DB3BD37E3533EE46BED2FBA80995557F9BEE42-wq7ZOvIWXbM/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-10-28 16:43 ` Avi Kivity
[not found] ` <4724BC38.3050701-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-29 4:53 ` Yang, Sheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox