Commit fd60754e authored by Avi Kivity's avatar Avi Kivity

KVM: x86 emulator: Group decoding for groups 4 and 5

Add group decoding support for opcode 0xfe (group 4) and 0xff (group 5).
Signed-off-by: default avatarAvi Kivity <avi@qumranet.com>
parent 7d858a19
...@@ -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, Group3_Byte, Group3, Group1A, Group3_Byte, Group3, Group4, Group5,
}; };
static u16 opcode_table[256] = { static u16 opcode_table[256] = {
...@@ -174,7 +174,7 @@ static u16 opcode_table[256] = { ...@@ -174,7 +174,7 @@ static u16 opcode_table[256] = {
ImplicitOps, ImplicitOps, Group | Group3_Byte, Group | Group3, ImplicitOps, ImplicitOps, Group | Group3_Byte, Group | Group3,
/* 0xF8 - 0xFF */ /* 0xF8 - 0xFF */
ImplicitOps, 0, ImplicitOps, ImplicitOps, ImplicitOps, 0, ImplicitOps, ImplicitOps,
0, 0, ByteOp | DstMem | SrcNone | ModRM, DstMem | SrcNone | ModRM 0, 0, Group | Group4, Group | Group5,
}; };
static u16 twobyte_table[256] = { static u16 twobyte_table[256] = {
...@@ -246,6 +246,12 @@ static u16 group_table[] = { ...@@ -246,6 +246,12 @@ static u16 group_table[] = {
DstMem | SrcImm | ModRM | SrcImm, 0, DstMem | SrcImm | ModRM | SrcImm, 0,
DstMem | SrcNone | ModRM, ByteOp | DstMem | SrcNone | ModRM, DstMem | SrcNone | ModRM, ByteOp | DstMem | SrcNone | ModRM,
0, 0, 0, 0, 0, 0, 0, 0,
[Group4*8] =
ByteOp | DstMem | SrcNone | ModRM, ByteOp | DstMem | SrcNone | ModRM,
0, 0, 0, 0, 0, 0,
[Group5*8] =
DstMem | SrcNone | ModRM, DstMem | SrcNone | ModRM, 0, 0,
SrcMem | ModRM, 0, SrcMem | ModRM | Stack, 0,
}; };
static u16 group2_table[] = { static u16 group2_table[] = {
...@@ -1097,7 +1103,6 @@ static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt, ...@@ -1097,7 +1103,6 @@ static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt,
struct x86_emulate_ops *ops) struct x86_emulate_ops *ops)
{ {
struct decode_cache *c = &ctxt->decode; struct decode_cache *c = &ctxt->decode;
int rc;
switch (c->modrm_reg) { switch (c->modrm_reg) {
case 0: /* inc */ case 0: /* inc */
...@@ -1107,36 +1112,11 @@ static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt, ...@@ -1107,36 +1112,11 @@ static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt,
emulate_1op("dec", c->dst, ctxt->eflags); emulate_1op("dec", c->dst, ctxt->eflags);
break; break;
case 4: /* jmp abs */ case 4: /* jmp abs */
if (c->b == 0xff) c->eip = c->src.val;
c->eip = c->dst.val;
else {
DPRINTF("Cannot emulate %02x\n", c->b);
return X86EMUL_UNHANDLEABLE;
}
break; break;
case 6: /* push */ case 6: /* push */
emulate_push(ctxt);
/* 64-bit mode: PUSH always pushes a 64-bit operand. */
if (ctxt->mode == X86EMUL_MODE_PROT64) {
c->dst.bytes = 8;
rc = ops->read_std((unsigned long)c->dst.ptr,
&c->dst.val, 8, ctxt->vcpu);
if (rc != 0)
return rc;
}
register_address_increment(c->regs[VCPU_REGS_RSP],
-c->dst.bytes);
rc = ops->write_emulated(register_address(ctxt->ss_base,
c->regs[VCPU_REGS_RSP]), &c->dst.val,
c->dst.bytes, ctxt->vcpu);
if (rc != 0)
return rc;
c->dst.type = OP_NONE;
break; break;
default:
DPRINTF("Cannot emulate %02x\n", c->b);
return X86EMUL_UNHANDLEABLE;
} }
return 0; return 0;
} }
......
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