* [PATCH 1/2] KVM: x86 emulator: Add decoding of 16bit second in memory argument
@ 2010-02-24 10:28 Gleb Natapov
2010-02-25 13:40 ` Avi Kivity
0 siblings, 1 reply; 5+ messages in thread
From: Gleb Natapov @ 2010-02-24 10:28 UTC (permalink / raw)
To: avi, mtosatti; +Cc: kvm
Add decoding of Ep type of argument used by callf/jmpf.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
arch/x86/kvm/emulate.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index c9f604b..d288107 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -85,6 +85,7 @@
#define Src2ImmByte (2<<29)
#define Src2One (3<<29)
#define Src2Imm16 (4<<29)
+#define Src2Mem16 (5<<29)
#define Src2Mask (7<<29)
enum {
@@ -1163,6 +1164,10 @@ done_prefixes:
c->src2.bytes = 1;
c->src2.val = 1;
break;
+ case Src2Mem16:
+ c->src2.bytes = 2;
+ c->src2.type = OP_MEM;
+ break;
}
/* Decode and fetch the destination operand: register or memory. */
@@ -1881,6 +1886,17 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
c->src.orig_val = c->src.val;
}
+ if (c->src2.type == OP_MEM) {
+ c->src2.ptr = (unsigned long *)(memop + c->src.bytes);
+ c->src2.val = 0;
+ rc = ops->read_emulated((unsigned long)c->src2.ptr,
+ &c->src2.val,
+ c->src2.bytes,
+ ctxt->vcpu);
+ if (rc != X86EMUL_CONTINUE)
+ goto done;
+ }
+
if ((c->d & DstMask) == ImplicitOps)
goto special_insn;
--
1.6.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] KVM: x86 emulator: Add decoding of 16bit second in memory argument
2010-02-24 10:28 Gleb Natapov
@ 2010-02-25 13:40 ` Avi Kivity
0 siblings, 0 replies; 5+ messages in thread
From: Avi Kivity @ 2010-02-25 13:40 UTC (permalink / raw)
To: Gleb Natapov; +Cc: mtosatti, kvm
On 02/24/2010 12:28 PM, Gleb Natapov wrote:
> Add decoding of Ep type of argument used by callf/jmpf.
>
> Signed-off-by: Gleb Natapov<gleb@redhat.com>
> ---
> arch/x86/kvm/emulate.c | 16 ++++++++++++++++
> 1 files changed, 16 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index c9f604b..d288107 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -85,6 +85,7 @@
> #define Src2ImmByte (2<<29)
> #define Src2One (3<<29)
> #define Src2Imm16 (4<<29)
> +#define Src2Mem16 (5<<29)
> #define Src2Mask (7<<29)
>
> enum {
> @@ -1163,6 +1164,10 @@ done_prefixes:
> c->src2.bytes = 1;
> c->src2.val = 1;
> break;
> + case Src2Mem16:
> + c->src2.bytes = 2;
> + c->src2.type = OP_MEM;
> + break;
> }
>
> /* Decode and fetch the destination operand: register or memory. */
> @@ -1881,6 +1886,17 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
> c->src.orig_val = c->src.val;
> }
>
> + if (c->src2.type == OP_MEM) {
> + c->src2.ptr = (unsigned long *)(memop + c->src.bytes);
> + c->src2.val = 0;
> + rc = ops->read_emulated((unsigned long)c->src2.ptr,
> + &c->src2.val,
> + c->src2.bytes,
> + ctxt->vcpu);
> + if (rc != X86EMUL_CONTINUE)
> + goto done;
> + }
> +
>
This introduces a dependency between src and src2. The alternative is
to have an offset+segment operand type, but that introduces all types of
complications, so I guess the dependency is worth it. But at least
document it when you define Src2Mem16.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] KVM: x86 emulator: Add decoding of 16bit second in memory argument
@ 2010-02-25 14:36 Gleb Natapov
2010-02-25 14:36 ` [PATCH 2/2] KVM: x86 emulator: Implement jmp far opcode ff/5 Gleb Natapov
2010-02-25 14:38 ` [PATCH 1/2] KVM: x86 emulator: Add decoding of 16bit second in memory argument Avi Kivity
0 siblings, 2 replies; 5+ messages in thread
From: Gleb Natapov @ 2010-02-25 14:36 UTC (permalink / raw)
To: avi, mtosatti; +Cc: kvm
Add decoding of Ep type of argument used by callf/jmpf.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
arch/x86/kvm/emulate.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index c9f604b..97a7403 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -85,6 +85,9 @@
#define Src2ImmByte (2<<29)
#define Src2One (3<<29)
#define Src2Imm16 (4<<29)
+#define Src2Mem16 (5<<29) /* Used for Ep encoding. First argument has to be
+ in memory and second argument is located
+ immediately after the first one in memory. */
#define Src2Mask (7<<29)
enum {
@@ -1163,6 +1166,10 @@ done_prefixes:
c->src2.bytes = 1;
c->src2.val = 1;
break;
+ case Src2Mem16:
+ c->src2.bytes = 2;
+ c->src2.type = OP_MEM;
+ break;
}
/* Decode and fetch the destination operand: register or memory. */
@@ -1881,6 +1888,17 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
c->src.orig_val = c->src.val;
}
+ if (c->src2.type == OP_MEM) {
+ c->src2.ptr = (unsigned long *)(memop + c->src.bytes);
+ c->src2.val = 0;
+ rc = ops->read_emulated((unsigned long)c->src2.ptr,
+ &c->src2.val,
+ c->src2.bytes,
+ ctxt->vcpu);
+ if (rc != X86EMUL_CONTINUE)
+ goto done;
+ }
+
if ((c->d & DstMask) == ImplicitOps)
goto special_insn;
--
1.6.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] KVM: x86 emulator: Implement jmp far opcode ff/5
2010-02-25 14:36 [PATCH 1/2] KVM: x86 emulator: Add decoding of 16bit second in memory argument Gleb Natapov
@ 2010-02-25 14:36 ` Gleb Natapov
2010-02-25 14:38 ` [PATCH 1/2] KVM: x86 emulator: Add decoding of 16bit second in memory argument Avi Kivity
1 sibling, 0 replies; 5+ messages in thread
From: Gleb Natapov @ 2010-02-25 14:36 UTC (permalink / raw)
To: avi, mtosatti; +Cc: kvm
Implement jmp far opcode ff/5. It is used by multiboot loader.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
arch/x86/kvm/emulate.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 97a7403..5b6794a 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -346,7 +346,8 @@ static u32 group_table[] = {
[Group5*8] =
DstMem | SrcNone | ModRM, DstMem | SrcNone | ModRM,
SrcMem | ModRM | Stack, 0,
- SrcMem | ModRM | Stack, 0, SrcMem | ModRM | Stack, 0,
+ SrcMem | ModRM | Stack, SrcMem | ModRM | Src2Mem16 | ImplicitOps,
+ SrcMem | ModRM | Stack, 0,
[Group7*8] =
0, 0, ModRM | SrcMem | Priv, ModRM | SrcMem | Priv,
SrcNone | ModRM | DstMem | Mov, 0,
@@ -2322,6 +2323,7 @@ special_insn:
case 0xe9: /* jmp rel */
goto jmp;
case 0xea: /* jmp far */
+ jump_far:
if (kvm_load_segment_descriptor(ctxt->vcpu, c->src2.val,
VCPU_SREG_CS))
goto done;
@@ -2397,11 +2399,16 @@ special_insn:
ctxt->eflags |= EFLG_DF;
c->dst.type = OP_NONE; /* Disable writeback. */
break;
- case 0xfe ... 0xff: /* Grp4/Grp5 */
+ case 0xfe: /* Grp4 */
+ grp45:
rc = emulate_grp45(ctxt, ops);
if (rc != X86EMUL_CONTINUE)
goto done;
break;
+ case 0xff: /* Grp5 */
+ if (c->modrm_reg == 5)
+ goto jump_far;
+ goto grp45;
}
writeback:
--
1.6.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] KVM: x86 emulator: Add decoding of 16bit second in memory argument
2010-02-25 14:36 [PATCH 1/2] KVM: x86 emulator: Add decoding of 16bit second in memory argument Gleb Natapov
2010-02-25 14:36 ` [PATCH 2/2] KVM: x86 emulator: Implement jmp far opcode ff/5 Gleb Natapov
@ 2010-02-25 14:38 ` Avi Kivity
1 sibling, 0 replies; 5+ messages in thread
From: Avi Kivity @ 2010-02-25 14:38 UTC (permalink / raw)
To: Gleb Natapov; +Cc: mtosatti, kvm
On 02/25/2010 04:36 PM, Gleb Natapov wrote:
> Add decoding of Ep type of argument used by callf/jmpf.
>
>
Applied both, thanks.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-02-25 14:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-25 14:36 [PATCH 1/2] KVM: x86 emulator: Add decoding of 16bit second in memory argument Gleb Natapov
2010-02-25 14:36 ` [PATCH 2/2] KVM: x86 emulator: Implement jmp far opcode ff/5 Gleb Natapov
2010-02-25 14:38 ` [PATCH 1/2] KVM: x86 emulator: Add decoding of 16bit second in memory argument Avi Kivity
-- strict thread matches above, loose matches on Subject: below --
2010-02-24 10:28 Gleb Natapov
2010-02-25 13:40 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox