aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorWei Yongjun <yjwei@cn.fujitsu.com>2010-07-07 05:43:35 -0400
committerAvi Kivity <avi@redhat.com>2010-08-01 23:40:27 -0400
commit5d55f299f97769130c6cc67896414c988db309ab (patch)
tree4b18d7721ff788e8bda93e57086037e1d6ac195b /arch/x86/kvm
parent07cbc6c185aee2c0479776845988242a040c7c93 (diff)
KVM: x86 emulator: re-implementing 'mov AL,moffs' instruction decoding
This patch change to use DstAcc for decoding 'mov AL, moffs' and introduced SrcAcc for decoding 'mov moffs, AL'. Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/emulate.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 286572a5675b..255473f974ab 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -70,6 +70,7 @@
70#define SrcSI (0xa<<4) /* Source is in the DS:RSI */ 70#define SrcSI (0xa<<4) /* Source is in the DS:RSI */
71#define SrcImmFAddr (0xb<<4) /* Source is immediate far address */ 71#define SrcImmFAddr (0xb<<4) /* Source is immediate far address */
72#define SrcMemFAddr (0xc<<4) /* Source is far address in memory */ 72#define SrcMemFAddr (0xc<<4) /* Source is far address in memory */
73#define SrcAcc (0xd<<4) /* Source Accumulator */
73#define SrcMask (0xf<<4) 74#define SrcMask (0xf<<4)
74/* Generic ModRM decode. */ 75/* Generic ModRM decode. */
75#define ModRM (1<<8) 76#define ModRM (1<<8)
@@ -177,8 +178,8 @@ static u32 opcode_table[256] = {
177 0, 0, SrcImmFAddr | No64, 0, 178 0, 0, SrcImmFAddr | No64, 0,
178 ImplicitOps | Stack, ImplicitOps | Stack, 0, 0, 179 ImplicitOps | Stack, ImplicitOps | Stack, 0, 0,
179 /* 0xA0 - 0xA7 */ 180 /* 0xA0 - 0xA7 */
180 ByteOp | DstReg | SrcMem | Mov | MemAbs, DstReg | SrcMem | Mov | MemAbs, 181 ByteOp | DstAcc | SrcMem | Mov | MemAbs, DstAcc | SrcMem | Mov | MemAbs,
181 ByteOp | DstMem | SrcReg | Mov | MemAbs, DstMem | SrcReg | Mov | MemAbs, 182 ByteOp | DstMem | SrcAcc | Mov | MemAbs, DstMem | SrcAcc | Mov | MemAbs,
182 ByteOp | SrcSI | DstDI | Mov | String, SrcSI | DstDI | Mov | String, 183 ByteOp | SrcSI | DstDI | Mov | String, SrcSI | DstDI | Mov | String,
183 ByteOp | SrcSI | DstDI | String, SrcSI | DstDI | String, 184 ByteOp | SrcSI | DstDI | String, SrcSI | DstDI | String,
184 /* 0xA8 - 0xAF */ 185 /* 0xA8 - 0xAF */
@@ -1186,6 +1187,25 @@ done_prefixes:
1186 else 1187 else
1187 c->src.val = insn_fetch(u8, 1, c->eip); 1188 c->src.val = insn_fetch(u8, 1, c->eip);
1188 break; 1189 break;
1190 case SrcAcc:
1191 c->src.type = OP_REG;
1192 c->src.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
1193 c->src.ptr = &c->regs[VCPU_REGS_RAX];
1194 switch (c->src.bytes) {
1195 case 1:
1196 c->src.val = *(u8 *)c->src.ptr;
1197 break;
1198 case 2:
1199 c->src.val = *(u16 *)c->src.ptr;
1200 break;
1201 case 4:
1202 c->src.val = *(u32 *)c->src.ptr;
1203 break;
1204 case 8:
1205 c->src.val = *(u64 *)c->src.ptr;
1206 break;
1207 }
1208 break;
1189 case SrcOne: 1209 case SrcOne:
1190 c->src.bytes = 1; 1210 c->src.bytes = 1;
1191 c->src.val = 1; 1211 c->src.val = 1;
@@ -2854,13 +2874,7 @@ special_insn:
2854 if (rc != X86EMUL_CONTINUE) 2874 if (rc != X86EMUL_CONTINUE)
2855 goto done; 2875 goto done;
2856 break; 2876 break;
2857 case 0xa0 ... 0xa1: /* mov */ 2877 case 0xa0 ... 0xa3: /* mov */
2858 c->dst.ptr = (unsigned long *)&c->regs[VCPU_REGS_RAX];
2859 c->dst.val = c->src.val;
2860 break;
2861 case 0xa2 ... 0xa3: /* mov */
2862 c->dst.val = (unsigned long)c->regs[VCPU_REGS_RAX];
2863 break;
2864 case 0xa4 ... 0xa5: /* movs */ 2878 case 0xa4 ... 0xa5: /* movs */
2865 goto mov; 2879 goto mov;
2866 case 0xa6 ... 0xa7: /* cmps */ 2880 case 0xa6 ... 0xa7: /* cmps */