Commit 7d858a19 authored by Avi Kivity's avatar Avi Kivity

KVM: x86 emulator: Group decoding for group 3

This adds group decoding support for opcodes 0xf6, 0xf7 (group 3).
Signed-off-by: default avatarAvi Kivity <avi@qumranet.com>
parent 43bb19cd
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
#define GroupMask 0xff /* Group number stored in bits 0:7 */ #define GroupMask 0xff /* Group number stored in bits 0:7 */
enum { enum {
Group1A, Group1A, Group3_Byte, Group3,
}; };
static u16 opcode_table[256] = { static u16 opcode_table[256] = {
...@@ -171,8 +171,7 @@ static u16 opcode_table[256] = { ...@@ -171,8 +171,7 @@ static u16 opcode_table[256] = {
0, 0, 0, 0, 0, 0, 0, 0,
/* 0xF0 - 0xF7 */ /* 0xF0 - 0xF7 */
0, 0, 0, 0, 0, 0, 0, 0,
ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps, Group | Group3_Byte, Group | Group3,
ByteOp | DstMem | SrcNone | ModRM, DstMem | SrcNone | ModRM,
/* 0xF8 - 0xFF */ /* 0xF8 - 0xFF */
ImplicitOps, 0, ImplicitOps, ImplicitOps, ImplicitOps, 0, ImplicitOps, ImplicitOps,
0, 0, ByteOp | DstMem | SrcNone | ModRM, DstMem | SrcNone | ModRM 0, 0, ByteOp | DstMem | SrcNone | ModRM, DstMem | SrcNone | ModRM
...@@ -239,6 +238,14 @@ static u16 twobyte_table[256] = { ...@@ -239,6 +238,14 @@ static u16 twobyte_table[256] = {
static u16 group_table[] = { static u16 group_table[] = {
[Group1A*8] = [Group1A*8] =
DstMem | SrcNone | ModRM | Mov | Stack, 0, 0, 0, 0, 0, 0, 0, DstMem | SrcNone | ModRM | Mov | Stack, 0, 0, 0, 0, 0, 0, 0,
[Group3_Byte*8] =
ByteOp | SrcImm | DstMem | ModRM, 0,
ByteOp | DstMem | SrcNone | ModRM, ByteOp | DstMem | SrcNone | ModRM,
0, 0, 0, 0,
[Group3*8] =
DstMem | SrcImm | ModRM | SrcImm, 0,
DstMem | SrcNone | ModRM, ByteOp | DstMem | SrcNone | ModRM,
0, 0, 0, 0,
}; };
static u16 group2_table[] = { static u16 group2_table[] = {
...@@ -1070,26 +1077,6 @@ static inline int emulate_grp3(struct x86_emulate_ctxt *ctxt, ...@@ -1070,26 +1077,6 @@ static inline int emulate_grp3(struct x86_emulate_ctxt *ctxt,
switch (c->modrm_reg) { switch (c->modrm_reg) {
case 0 ... 1: /* test */ case 0 ... 1: /* test */
/*
* Special case in Grp3: test has an immediate
* source operand.
*/
c->src.type = OP_IMM;
c->src.ptr = (unsigned long *)c->eip;
c->src.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
if (c->src.bytes == 8)
c->src.bytes = 4;
switch (c->src.bytes) {
case 1:
c->src.val = insn_fetch(s8, 1, c->eip);
break;
case 2:
c->src.val = insn_fetch(s16, 2, c->eip);
break;
case 4:
c->src.val = insn_fetch(s32, 4, c->eip);
break;
}
emulate_2op_SrcV("test", c->src, c->dst, ctxt->eflags); emulate_2op_SrcV("test", c->src, c->dst, ctxt->eflags);
break; break;
case 2: /* not */ case 2: /* not */
...@@ -1103,7 +1090,6 @@ static inline int emulate_grp3(struct x86_emulate_ctxt *ctxt, ...@@ -1103,7 +1090,6 @@ static inline int emulate_grp3(struct x86_emulate_ctxt *ctxt,
rc = X86EMUL_UNHANDLEABLE; rc = X86EMUL_UNHANDLEABLE;
break; break;
} }
done:
return rc; return rc;
} }
......
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