Skip to content

Commit bdae8ef

Browse files
lifeixacrnsi
authored andcommitted
hv: instr_emul: fix movzx return memory opsize wrong
There're some instructions which not support bit 0(w bit) flag but which memory opcode size is fixed and the memory opcode size is not equal to the register opcode size. In our code, there is movzx (which opcode is 0F B7) which memory opcode size is fixed to 16 bits. So add a flag VIE_OP_F_WORD_OP to indicate a instruction which memory opcode size is fixed to 16 bits. Tracked-On: #1337 Signed-off-by: Li, Fei1 <fei1.li@intel.com> Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
1 parent 795d6de commit bdae8ef

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

hypervisor/arch/x86/guest/instr_emul.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
* FOR NON-64-BIT MODES, Vol 2, Intel SDM.
9797
*/
9898
#define VIE_OP_F_BYTE_OP (1U << 5U) /* 8-bit operands. */
99+
#define VIE_OP_F_WORD_OP (1U << 6U) /* 16-bit operands. */
99100

100101
static const struct instr_emul_vie_op two_byte_opcodes[256] = {
101102
[0xB6] = {
@@ -104,6 +105,7 @@ static const struct instr_emul_vie_op two_byte_opcodes[256] = {
104105
},
105106
[0xB7] = {
106107
.op_type = VIE_OP_TYPE_MOVZX,
108+
.op_flags = VIE_OP_F_WORD_OP,
107109
},
108110
[0xBA] = {
109111
.op_type = VIE_OP_TYPE_BITTEST,
@@ -2398,8 +2400,13 @@ int32_t decode_instruction(struct acrn_vcpu *vcpu)
23982400

23992401
if (retval >= 0) {
24002402
/* return the Memory Operand byte size */
2401-
retval = ((emul_ctxt->vie.op.op_flags & VIE_OP_F_BYTE_OP) != 0U) ?
2402-
1 : (int32_t)emul_ctxt->vie.opsize;
2403+
if ((emul_ctxt->vie.op.op_flags & VIE_OP_F_BYTE_OP) != 0U) {
2404+
retval = 1;
2405+
} else if ((emul_ctxt->vie.op.op_flags & VIE_OP_F_WORD_OP) != 0U) {
2406+
retval = 2;
2407+
} else {
2408+
retval = (int32_t)emul_ctxt->vie.opsize;
2409+
}
24032410
}
24042411
}
24052412
}

0 commit comments

Comments
 (0)