Commit 2adb5ad9 authored by Avi Kivity's avatar Avi Kivity

KVM: x86 emulator: Remove byte-sized MOVSX/MOVZX hack

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: default avatarAvi Kivity <avi@redhat.com>
Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
parent 28867cee
...@@ -860,8 +860,7 @@ static void write_sse_reg(struct x86_emulate_ctxt *ctxt, sse128_t *data, ...@@ -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, static void decode_register_operand(struct x86_emulate_ctxt *ctxt,
struct operand *op, struct operand *op)
int inhibit_bytereg)
{ {
unsigned reg = ctxt->modrm_reg; unsigned reg = ctxt->modrm_reg;
int highbyte_regs = ctxt->rex_prefix == 0; int highbyte_regs = ctxt->rex_prefix == 0;
...@@ -878,7 +877,7 @@ static void decode_register_operand(struct x86_emulate_ctxt *ctxt, ...@@ -878,7 +877,7 @@ static void decode_register_operand(struct x86_emulate_ctxt *ctxt,
} }
op->type = OP_REG; 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->addr.reg = decode_register(reg, ctxt->regs, highbyte_regs);
op->bytes = 1; op->bytes = 1;
} else { } else {
...@@ -3516,13 +3515,13 @@ static struct opcode twobyte_table[256] = { ...@@ -3516,13 +3515,13 @@ static struct opcode twobyte_table[256] = {
I(DstMem | SrcReg | ModRM | BitOp | Lock, em_btr), I(DstMem | SrcReg | ModRM | BitOp | Lock, em_btr),
I(DstReg | SrcMemFAddr | ModRM | Src2FS, em_lseg), I(DstReg | SrcMemFAddr | ModRM | Src2FS, em_lseg),
I(DstReg | SrcMemFAddr | ModRM | Src2GS, 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 */ /* 0xB8 - 0xBF */
N, N, N, N,
G(BitOp, group8), G(BitOp, group8),
I(DstMem | SrcReg | ModRM | BitOp | Lock | PageTable, em_btc), I(DstMem | SrcReg | ModRM | BitOp | Lock | PageTable, em_btc),
I(DstReg | SrcMem | ModRM, em_bsf), I(DstReg | SrcMem | ModRM, em_bsr), 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 */ /* 0xC0 - 0xCF */
D2bv(DstMem | SrcReg | ModRM | Lock), D2bv(DstMem | SrcReg | ModRM | Lock),
N, D(DstMem | SrcReg | ModRM | Mov), N, D(DstMem | SrcReg | ModRM | Mov),
...@@ -3604,9 +3603,7 @@ static int decode_operand(struct x86_emulate_ctxt *ctxt, struct operand *op, ...@@ -3604,9 +3603,7 @@ static int decode_operand(struct x86_emulate_ctxt *ctxt, struct operand *op,
switch (d) { switch (d) {
case OpReg: case OpReg:
decode_register_operand(ctxt, op, decode_register_operand(ctxt, op);
op == &ctxt->dst &&
ctxt->twobyte && (ctxt->b == 0xb6 || ctxt->b == 0xb7));
break; break;
case OpImmUByte: case OpImmUByte:
rc = decode_imm(ctxt, op, 1, false); rc = decode_imm(ctxt, op, 1, false);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment