* [PATCH] x86 emulator: Add 'push es' instruction (opcode 0x06)
@ 2009-08-16 0:53 Mohammed Gamal
0 siblings, 0 replies; 7+ messages in thread
From: Mohammed Gamal @ 2009-08-16 0:53 UTC (permalink / raw)
To: avi; +Cc: kvm
Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
---
arch/x86/kvm/emulate.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 2eb807a..6305a12 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -92,7 +92,7 @@ static u32 opcode_table[256] = {
/* 0x00 - 0x07 */
ByteOp | DstMem | SrcReg | ModRM, DstMem | SrcReg | ModRM,
ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM,
- ByteOp | DstAcc | SrcImm, DstAcc | SrcImm, 0, 0,
+ ByteOp | DstAcc | SrcImm, DstAcc | SrcImm, ImplicitOps | Stack, 0,
/* 0x08 - 0x0F */
ByteOp | DstMem | SrcReg | ModRM, DstMem | SrcReg | ModRM,
ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM,
@@ -1186,6 +1186,14 @@ static int emulate_pop(struct x86_emulate_ctxt *ctxt,
return rc;
}
+static void emulate_push_sreg(struct x86_emulate_ctxt *ctxt, int seg)
+{
+ struct decode_cache *c = &ctxt->decode;
+ struct kvm_segment segment;
+ c->src.ptr = (unsigned long *) &c->regs[seg];
+ emulate_push(ctxt);
+}
+
static inline int emulate_grp1a(struct x86_emulate_ctxt *ctxt,
struct x86_emulate_ops *ops)
{
@@ -1707,6 +1715,9 @@ special_insn:
add: /* add */
emulate_2op_SrcV("add", c->src, c->dst, ctxt->eflags);
break;
+ case 0x06: /* push es */
+ emulate_push_sreg(ctxt, VCPU_SREG_ES);
+ break;
case 0x08 ... 0x0d:
or: /* or */
emulate_2op_SrcV("or", c->src, c->dst, ctxt->eflags);
--
1.6.0.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] x86 emulator: Add 'push es' instruction (opcode 0x06)
@ 2009-08-17 19:16 Mohammed Gamal
0 siblings, 0 replies; 7+ messages in thread
From: Mohammed Gamal @ 2009-08-17 19:16 UTC (permalink / raw)
To: avi; +Cc: kvm, Mohammed Gamal
Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
---
arch/x86/kvm/emulate.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 2eb807a..fc8a745 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -92,7 +92,7 @@ static u32 opcode_table[256] = {
/* 0x00 - 0x07 */
ByteOp | DstMem | SrcReg | ModRM, DstMem | SrcReg | ModRM,
ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM,
- ByteOp | DstAcc | SrcImm, DstAcc | SrcImm, 0, 0,
+ ByteOp | DstAcc | SrcImm, DstAcc | SrcImm, ImplicitOps | Stack, 0,
/* 0x08 - 0x0F */
ByteOp | DstMem | SrcReg | ModRM, DstMem | SrcReg | ModRM,
ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM,
@@ -1186,6 +1186,17 @@ static int emulate_pop(struct x86_emulate_ctxt *ctxt,
return rc;
}
+static void emulate_push_sreg(struct x86_emulate_ctxt *ctxt, int seg)
+{
+ struct decode_cache *c = &ctxt->decode;
+ struct kvm_segment segment;
+
+ kvm_x86_ops->get_segment(ctxt->vcpu, &segment, seg);
+
+ c->src.val = segment.selector;
+ emulate_push(ctxt);
+}
+
static inline int emulate_grp1a(struct x86_emulate_ctxt *ctxt,
struct x86_emulate_ops *ops)
{
@@ -1707,6 +1718,9 @@ special_insn:
add: /* add */
emulate_2op_SrcV("add", c->src, c->dst, ctxt->eflags);
break;
+ case 0x06: /* push es */
+ emulate_push_sreg(ctxt, VCPU_SREG_ES);
+ break;
case 0x08 ... 0x0d:
or: /* or */
emulate_2op_SrcV("or", c->src, c->dst, ctxt->eflags);
--
1.6.0.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] x86 emulator: Add 'push es' instruction (opcode 0x06)
2009-08-17 8:03 ` Avi Kivity
@ 2009-08-17 8:22 ` Mohammed Gamal
0 siblings, 0 replies; 7+ messages in thread
From: Mohammed Gamal @ 2009-08-17 8:22 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm
On Mon, Aug 17, 2009 at 11:03 AM, Avi Kivity<avi@redhat.com> wrote:
> On 08/16/2009 08:51 PM, Mohammed Gamal wrote:
>>
>> +static void emulate_push_sreg(struct x86_emulate_ctxt *ctxt, int seg)
>> +{
>> + struct decode_cache *c =&ctxt->decode;
>> + struct kvm_segment segment;
>> + kvm_x86_ops->get_segment(ctxt->vcpu,&segment, seg);
>> + c->src.ptr = (unsigned long *)&segment.selector;
>> + emulate_push(ctxt);
>> +}
>>
>
> This will pick up random junk from segment.type if used in 32-bit mode,
> since segment.selector is only 16 bits wide.
>
> btw, I see that emulate_push() uses src.val, not src.ptr. Have you tested
> this?
>
Hmmm, there are no test cases that test conventional push/pop
instructions. I'll write a test case and see if the function behaves
correctly.
>
> --
> error compiling committee.c: too many arguments to function
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86 emulator: Add 'push es' instruction (opcode 0x06)
2009-08-16 17:51 Mohammed Gamal
@ 2009-08-17 8:03 ` Avi Kivity
2009-08-17 8:22 ` Mohammed Gamal
0 siblings, 1 reply; 7+ messages in thread
From: Avi Kivity @ 2009-08-17 8:03 UTC (permalink / raw)
To: Mohammed Gamal; +Cc: kvm
On 08/16/2009 08:51 PM, Mohammed Gamal wrote:
>
> +static void emulate_push_sreg(struct x86_emulate_ctxt *ctxt, int seg)
> +{
> + struct decode_cache *c =&ctxt->decode;
> + struct kvm_segment segment;
> + kvm_x86_ops->get_segment(ctxt->vcpu,&segment, seg);
> + c->src.ptr = (unsigned long *)&segment.selector;
> + emulate_push(ctxt);
> +}
>
This will pick up random junk from segment.type if used in 32-bit mode,
since segment.selector is only 16 bits wide.
btw, I see that emulate_push() uses src.val, not src.ptr. Have you
tested this?
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] x86 emulator: Add 'push es' instruction (opcode 0x06)
@ 2009-08-16 17:51 Mohammed Gamal
2009-08-17 8:03 ` Avi Kivity
0 siblings, 1 reply; 7+ messages in thread
From: Mohammed Gamal @ 2009-08-16 17:51 UTC (permalink / raw)
To: avi; +Cc: kvm
Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
---
arch/x86/kvm/emulate.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 2eb807a..7688c0b 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -92,7 +92,7 @@ static u32 opcode_table[256] = {
/* 0x00 - 0x07 */
ByteOp | DstMem | SrcReg | ModRM, DstMem | SrcReg | ModRM,
ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM,
- ByteOp | DstAcc | SrcImm, DstAcc | SrcImm, 0, 0,
+ ByteOp | DstAcc | SrcImm, DstAcc | SrcImm, ImplicitOps | Stack, 0,
/* 0x08 - 0x0F */
ByteOp | DstMem | SrcReg | ModRM, DstMem | SrcReg | ModRM,
ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM,
@@ -1186,6 +1186,15 @@ static int emulate_pop(struct x86_emulate_ctxt *ctxt,
return rc;
}
+static void emulate_push_sreg(struct x86_emulate_ctxt *ctxt, int seg)
+{
+ struct decode_cache *c = &ctxt->decode;
+ struct kvm_segment segment;
+ kvm_x86_ops->get_segment(ctxt->vcpu, &segment, seg);
+ c->src.ptr = (unsigned long *) &segment.selector;
+ emulate_push(ctxt);
+}
+
static inline int emulate_grp1a(struct x86_emulate_ctxt *ctxt,
struct x86_emulate_ops *ops)
{
@@ -1707,6 +1716,9 @@ special_insn:
add: /* add */
emulate_2op_SrcV("add", c->src, c->dst, ctxt->eflags);
break;
+ case 0x06: /* push es */
+ emulate_push_sreg(ctxt, VCPU_SREG_ES);
+ break;
case 0x08 ... 0x0d:
or: /* or */
emulate_2op_SrcV("or", c->src, c->dst, ctxt->eflags);
--
1.6.0.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] x86 emulator: Add 'push es' instruction (opcode 0x06)
[not found] <20090816010921.GA22103@mohd-laptop>
@ 2009-08-16 8:42 ` Avi Kivity
0 siblings, 0 replies; 7+ messages in thread
From: Avi Kivity @ 2009-08-16 8:42 UTC (permalink / raw)
To: Mohammed Gamal; +Cc: KVM list
On 08/16/2009 04:09 AM, Mohammed Gamal wrote:
>
> +static void emulate_push_sreg(struct x86_emulate_ctxt *ctxt, int seg)
> +{
> + struct decode_cache *c =&ctxt->decode;
> + c->src.ptr = (unsigned long *)&c->regs[seg];
> + emulate_push(ctxt);
> +}
> +
>
This can't be right. c->regs[] is the general purpose register array,
not the segment registers.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] x86 emulator: Add 'push es' instruction (opcode 0x06)
@ 2009-08-16 1:07 Mohammed Gamal
0 siblings, 0 replies; 7+ messages in thread
From: Mohammed Gamal @ 2009-08-16 1:07 UTC (permalink / raw)
To: avi; +Cc: kvm
[Removed an unused variable]
Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
---
arch/x86/kvm/emulate.c | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 2eb807a..065131e 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -92,7 +92,7 @@ static u32 opcode_table[256] = {
/* 0x00 - 0x07 */
ByteOp | DstMem | SrcReg | ModRM, DstMem | SrcReg | ModRM,
ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM,
- ByteOp | DstAcc | SrcImm, DstAcc | SrcImm, 0, 0,
+ ByteOp | DstAcc | SrcImm, DstAcc | SrcImm, ImplicitOps | Stack, 0,
/* 0x08 - 0x0F */
ByteOp | DstMem | SrcReg | ModRM, DstMem | SrcReg | ModRM,
ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM,
@@ -1186,6 +1186,13 @@ static int emulate_pop(struct x86_emulate_ctxt *ctxt,
return rc;
}
+static void emulate_push_sreg(struct x86_emulate_ctxt *ctxt, int seg)
+{
+ struct decode_cache *c = &ctxt->decode;
+ c->src.ptr = (unsigned long *) &c->regs[seg];
+ emulate_push(ctxt);
+}
+
static inline int emulate_grp1a(struct x86_emulate_ctxt *ctxt,
struct x86_emulate_ops *ops)
{
@@ -1707,6 +1714,9 @@ special_insn:
add: /* add */
emulate_2op_SrcV("add", c->src, c->dst, ctxt->eflags);
break;
+ case 0x06: /* push es */
+ emulate_push_sreg(ctxt, VCPU_SREG_ES);
+ break;
case 0x08 ... 0x0d:
or: /* or */
emulate_2op_SrcV("or", c->src, c->dst, ctxt->eflags);
--
1.6.0.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-08-17 19:16 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-16 0:53 [PATCH] x86 emulator: Add 'push es' instruction (opcode 0x06) Mohammed Gamal
2009-08-16 1:07 Mohammed Gamal
[not found] <20090816010921.GA22103@mohd-laptop>
2009-08-16 8:42 ` Avi Kivity
2009-08-16 17:51 Mohammed Gamal
2009-08-17 8:03 ` Avi Kivity
2009-08-17 8:22 ` Mohammed Gamal
2009-08-17 19:16 Mohammed Gamal
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.