public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Remove hack from movsx/movzx decoding
@ 2012-01-16 13:08 Avi Kivity
  2012-01-16 13:08 ` [PATCH 1/2] KVM: x86 emulator: add 8-bit memory operands Avi Kivity
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Avi Kivity @ 2012-01-16 13:08 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: kvm, namit

movsx/movzx destination operands currently have a hack for the operand size.
Add OpMem8 and use it to remove the hack.

I'll wait with this until Nadav's more direct fix is in.

Avi Kivity (2):
  KVM: x86 emulator: add 8-bit memory operands
  KVM: x86 emulator: Remove byte-sized MOVSX/MOVZX hack

 arch/x86/kvm/emulate.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

-- 
1.7.7.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] KVM: x86 emulator: add 8-bit memory operands
  2012-01-16 13:08 [PATCH 0/2] Remove hack from movsx/movzx decoding Avi Kivity
@ 2012-01-16 13:08 ` Avi Kivity
  2012-01-16 13:08 ` [PATCH 2/2] KVM: x86 emulator: Remove byte-sized MOVSX/MOVZX hack Avi Kivity
  2012-01-17 12:03 ` [PATCH 0/2] Remove hack from movsx/movzx decoding Marcelo Tosatti
  2 siblings, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2012-01-16 13:08 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: kvm, namit

Useful for MOVSX/MOVZX.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 arch/x86/kvm/emulate.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 05a562b..92a45dd 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -57,6 +57,7 @@
 #define OpDS              23ull  /* DS */
 #define OpFS              24ull  /* FS */
 #define OpGS              25ull  /* GS */
+#define OpMem8            26ull  /* 8-bit zero extended memory operand */
 
 #define OpBits             5  /* Width of operand field */
 #define OpMask             ((1ull << OpBits) - 1)
@@ -101,6 +102,7 @@
 #define SrcAcc      (OpAcc << SrcShift)
 #define SrcImmU16   (OpImmU16 << SrcShift)
 #define SrcDX       (OpDX << SrcShift)
+#define SrcMem8     (OpMem8 << SrcShift)
 #define SrcMask     (OpMask << SrcShift)
 #define BitOp       (1<<11)
 #define MemAbs      (1<<12)      /* Memory operand is absolute displacement */
@@ -3605,6 +3607,9 @@ static int decode_operand(struct x86_emulate_ctxt *ctxt, struct operand *op,
 	case OpImm:
 		rc = decode_imm(ctxt, op, imm_size(ctxt), true);
 		break;
+	case OpMem8:
+		ctxt->memop.bytes = 1;
+		goto mem_common;
 	case OpMem16:
 		ctxt->memop.bytes = 2;
 		goto mem_common;
-- 
1.7.7.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] KVM: x86 emulator: Remove byte-sized MOVSX/MOVZX hack
  2012-01-16 13:08 [PATCH 0/2] Remove hack from movsx/movzx decoding Avi Kivity
  2012-01-16 13:08 ` [PATCH 1/2] KVM: x86 emulator: add 8-bit memory operands Avi Kivity
@ 2012-01-16 13:08 ` Avi Kivity
  2012-01-17 12:03 ` [PATCH 0/2] Remove hack from movsx/movzx decoding Marcelo Tosatti
  2 siblings, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2012-01-16 13:08 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: kvm, namit

Currently we treat MOVSX/MOVZX with a byte source as a byte instruction,
and change the destination operand size with a hack.  Change it to be
a word instruction, so the destination receives its natural size, and
change the source to be SrcMem8.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 arch/x86/kvm/emulate.c |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 92a45dd..1b4edb3 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -860,8 +860,7 @@ static void write_sse_reg(struct x86_emulate_ctxt *ctxt, sse128_t *data,
 }
 
 static void decode_register_operand(struct x86_emulate_ctxt *ctxt,
-				    struct operand *op,
-				    int inhibit_bytereg)
+				    struct operand *op)
 {
 	unsigned reg = ctxt->modrm_reg;
 	int highbyte_regs = ctxt->rex_prefix == 0;
@@ -878,7 +877,7 @@ static void decode_register_operand(struct x86_emulate_ctxt *ctxt,
 	}
 
 	op->type = OP_REG;
-	if ((ctxt->d & ByteOp) && !inhibit_bytereg) {
+	if (ctxt->d & ByteOp) {
 		op->addr.reg = decode_register(reg, ctxt->regs, highbyte_regs);
 		op->bytes = 1;
 	} else {
@@ -3465,13 +3464,13 @@ static int check_perm_out(struct x86_emulate_ctxt *ctxt)
 	I(DstMem | SrcReg | ModRM | BitOp | Lock, em_btr),
 	I(DstReg | SrcMemFAddr | ModRM | Src2FS, em_lseg),
 	I(DstReg | SrcMemFAddr | ModRM | Src2GS, em_lseg),
-	D(ByteOp | DstReg | SrcMem | ModRM | Mov), D(DstReg | SrcMem16 | ModRM | Mov),
+	D(DstReg | SrcMem8 | ModRM | Mov), D(DstReg | SrcMem16 | ModRM | Mov),
 	/* 0xB8 - 0xBF */
 	N, N,
 	G(BitOp, group8),
 	I(DstMem | SrcReg | ModRM | BitOp | Lock | PageTable, em_btc),
 	I(DstReg | SrcMem | ModRM, em_bsf), I(DstReg | SrcMem | ModRM, em_bsr),
-	D(ByteOp | DstReg | SrcMem | ModRM | Mov), D(DstReg | SrcMem16 | ModRM | Mov),
+	D(DstReg | SrcMem8 | ModRM | Mov), D(DstReg | SrcMem16 | ModRM | Mov),
 	/* 0xC0 - 0xCF */
 	D2bv(DstMem | SrcReg | ModRM | Lock),
 	N, D(DstMem | SrcReg | ModRM | Mov),
@@ -3553,9 +3552,7 @@ static int decode_operand(struct x86_emulate_ctxt *ctxt, struct operand *op,
 
 	switch (d) {
 	case OpReg:
-		decode_register_operand(ctxt, op,
-			 op == &ctxt->dst &&
-			 ctxt->twobyte && (ctxt->b == 0xb6 || ctxt->b == 0xb7));
+		decode_register_operand(ctxt, op);
 		break;
 	case OpImmUByte:
 		rc = decode_imm(ctxt, op, 1, false);
-- 
1.7.7.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] Remove hack from movsx/movzx decoding
  2012-01-16 13:08 [PATCH 0/2] Remove hack from movsx/movzx decoding Avi Kivity
  2012-01-16 13:08 ` [PATCH 1/2] KVM: x86 emulator: add 8-bit memory operands Avi Kivity
  2012-01-16 13:08 ` [PATCH 2/2] KVM: x86 emulator: Remove byte-sized MOVSX/MOVZX hack Avi Kivity
@ 2012-01-17 12:03 ` Marcelo Tosatti
  2 siblings, 0 replies; 4+ messages in thread
From: Marcelo Tosatti @ 2012-01-17 12:03 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm, namit

On Mon, Jan 16, 2012 at 03:08:43PM +0200, Avi Kivity wrote:
> movsx/movzx destination operands currently have a hack for the operand size.
> Add OpMem8 and use it to remove the hack.
> 
> I'll wait with this until Nadav's more direct fix is in.
> 
> Avi Kivity (2):
>   KVM: x86 emulator: add 8-bit memory operands
>   KVM: x86 emulator: Remove byte-sized MOVSX/MOVZX hack
> 
>  arch/x86/kvm/emulate.c |   18 ++++++++++--------
>  1 files changed, 10 insertions(+), 8 deletions(-)

Applied, thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-01-17 12:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-16 13:08 [PATCH 0/2] Remove hack from movsx/movzx decoding Avi Kivity
2012-01-16 13:08 ` [PATCH 1/2] KVM: x86 emulator: add 8-bit memory operands Avi Kivity
2012-01-16 13:08 ` [PATCH 2/2] KVM: x86 emulator: Remove byte-sized MOVSX/MOVZX hack Avi Kivity
2012-01-17 12:03 ` [PATCH 0/2] Remove hack from movsx/movzx decoding Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox