aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kvm/emulate.c42
1 files changed, 18 insertions, 24 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 8bfa3e3aa71d..c0715ae05a54 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -2378,6 +2378,13 @@ static int em_rdtsc(struct x86_emulate_ctxt *ctxt)
2378 return X86EMUL_CONTINUE; 2378 return X86EMUL_CONTINUE;
2379} 2379}
2380 2380
2381static int em_mov(struct x86_emulate_ctxt *ctxt)
2382{
2383 struct decode_cache *c = &ctxt->decode;
2384 c->dst.val = c->src.val;
2385 return X86EMUL_CONTINUE;
2386}
2387
2381#define D(_y) { .flags = (_y) } 2388#define D(_y) { .flags = (_y) }
2382#define N D(0) 2389#define N D(0)
2383#define G(_f, _g) { .flags = ((_f) | Group), .u.group = (_g) } 2390#define G(_f, _g) { .flags = ((_f) | Group), .u.group = (_g) }
@@ -2489,8 +2496,8 @@ static struct opcode opcode_table[256] = {
2489 G(DstMem | SrcImmByte | ModRM | Group, group1), 2496 G(DstMem | SrcImmByte | ModRM | Group, group1),
2490 D2bv(DstMem | SrcReg | ModRM), D2bv(DstMem | SrcReg | ModRM | Lock), 2497 D2bv(DstMem | SrcReg | ModRM), D2bv(DstMem | SrcReg | ModRM | Lock),
2491 /* 0x88 - 0x8F */ 2498 /* 0x88 - 0x8F */
2492 D2bv(DstMem | SrcReg | ModRM | Mov), 2499 I2bv(DstMem | SrcReg | ModRM | Mov, em_mov),
2493 D2bv(DstReg | SrcMem | ModRM | Mov), 2500 I2bv(DstReg | SrcMem | ModRM | Mov, em_mov),
2494 D(DstMem | SrcNone | ModRM | Mov), D(ModRM | SrcMem | NoAccess | DstReg), 2501 D(DstMem | SrcNone | ModRM | Mov), D(ModRM | SrcMem | NoAccess | DstReg),
2495 D(ImplicitOps | SrcMem16 | ModRM), G(0, group1A), 2502 D(ImplicitOps | SrcMem16 | ModRM), G(0, group1A),
2496 /* 0x90 - 0x97 */ 2503 /* 0x90 - 0x97 */
@@ -2500,24 +2507,25 @@ static struct opcode opcode_table[256] = {
2500 I(SrcImmFAddr | No64, em_call_far), N, 2507 I(SrcImmFAddr | No64, em_call_far), N,
2501 D(ImplicitOps | Stack), D(ImplicitOps | Stack), N, N, 2508 D(ImplicitOps | Stack), D(ImplicitOps | Stack), N, N,
2502 /* 0xA0 - 0xA7 */ 2509 /* 0xA0 - 0xA7 */
2503 D2bv(DstAcc | SrcMem | Mov | MemAbs), 2510 I2bv(DstAcc | SrcMem | Mov | MemAbs, em_mov),
2504 D2bv(DstMem | SrcAcc | Mov | MemAbs), 2511 I2bv(DstMem | SrcAcc | Mov | MemAbs, em_mov),
2505 D2bv(SrcSI | DstDI | Mov | String), D2bv(SrcSI | DstDI | String), 2512 I2bv(SrcSI | DstDI | Mov | String, em_mov),
2513 D2bv(SrcSI | DstDI | String),
2506 /* 0xA8 - 0xAF */ 2514 /* 0xA8 - 0xAF */
2507 D2bv(DstAcc | SrcImm), 2515 D2bv(DstAcc | SrcImm),
2508 D2bv(SrcAcc | DstDI | Mov | String), 2516 I2bv(SrcAcc | DstDI | Mov | String, em_mov),
2509 D2bv(SrcSI | DstAcc | Mov | String), 2517 I2bv(SrcSI | DstAcc | Mov | String, em_mov),
2510 D2bv(SrcAcc | DstDI | String), 2518 D2bv(SrcAcc | DstDI | String),
2511 /* 0xB0 - 0xB7 */ 2519 /* 0xB0 - 0xB7 */
2512 X8(D(ByteOp | DstReg | SrcImm | Mov)), 2520 X8(I(ByteOp | DstReg | SrcImm | Mov, em_mov)),
2513 /* 0xB8 - 0xBF */ 2521 /* 0xB8 - 0xBF */
2514 X8(D(DstReg | SrcImm | Mov)), 2522 X8(I(DstReg | SrcImm | Mov, em_mov)),
2515 /* 0xC0 - 0xC7 */ 2523 /* 0xC0 - 0xC7 */
2516 D2bv(DstMem | SrcImmByte | ModRM), 2524 D2bv(DstMem | SrcImmByte | ModRM),
2517 I(ImplicitOps | Stack | SrcImmU16, em_ret_near_imm), 2525 I(ImplicitOps | Stack | SrcImmU16, em_ret_near_imm),
2518 D(ImplicitOps | Stack), 2526 D(ImplicitOps | Stack),
2519 D(DstReg | SrcMemFAddr | ModRM | No64), D(DstReg | SrcMemFAddr | ModRM | No64), 2527 D(DstReg | SrcMemFAddr | ModRM | No64), D(DstReg | SrcMemFAddr | ModRM | No64),
2520 D2bv(DstMem | SrcImm | ModRM | Mov), 2528 I2bv(DstMem | SrcImm | ModRM | Mov, em_mov),
2521 /* 0xC8 - 0xCF */ 2529 /* 0xC8 - 0xCF */
2522 N, N, N, D(ImplicitOps | Stack), 2530 N, N, N, D(ImplicitOps | Stack),
2523 D(ImplicitOps), D(SrcImmByte), D(ImplicitOps | No64), D(ImplicitOps), 2531 D(ImplicitOps), D(SrcImmByte), D(ImplicitOps | No64), D(ImplicitOps),
@@ -3212,8 +3220,6 @@ special_insn:
3212 c->dst.val = c->src.orig_val; 3220 c->dst.val = c->src.orig_val;
3213 c->lock_prefix = 1; 3221 c->lock_prefix = 1;
3214 break; 3222 break;
3215 case 0x88 ... 0x8b: /* mov */
3216 goto mov;
3217 case 0x8c: /* mov r/m, sreg */ 3223 case 0x8c: /* mov r/m, sreg */
3218 if (c->modrm_reg > VCPU_SREG_GS) { 3224 if (c->modrm_reg > VCPU_SREG_GS) {
3219 emulate_ud(ctxt); 3225 emulate_ud(ctxt);
@@ -3271,22 +3277,14 @@ special_insn:
3271 if (rc != X86EMUL_CONTINUE) 3277 if (rc != X86EMUL_CONTINUE)
3272 goto done; 3278 goto done;
3273 break; 3279 break;
3274 case 0xa0 ... 0xa3: /* mov */
3275 case 0xa4 ... 0xa5: /* movs */
3276 goto mov;
3277 case 0xa6 ... 0xa7: /* cmps */ 3280 case 0xa6 ... 0xa7: /* cmps */
3278 c->dst.type = OP_NONE; /* Disable writeback. */ 3281 c->dst.type = OP_NONE; /* Disable writeback. */
3279 DPRINTF("cmps: mem1=0x%p mem2=0x%p\n", c->src.addr.mem, c->dst.addr.mem); 3282 DPRINTF("cmps: mem1=0x%p mem2=0x%p\n", c->src.addr.mem, c->dst.addr.mem);
3280 goto cmp; 3283 goto cmp;
3281 case 0xa8 ... 0xa9: /* test ax, imm */ 3284 case 0xa8 ... 0xa9: /* test ax, imm */
3282 goto test; 3285 goto test;
3283 case 0xaa ... 0xab: /* stos */
3284 case 0xac ... 0xad: /* lods */
3285 goto mov;
3286 case 0xae ... 0xaf: /* scas */ 3286 case 0xae ... 0xaf: /* scas */
3287 goto cmp; 3287 goto cmp;
3288 case 0xb0 ... 0xbf: /* mov r, imm */
3289 goto mov;
3290 case 0xc0 ... 0xc1: 3288 case 0xc0 ... 0xc1:
3291 emulate_grp2(ctxt); 3289 emulate_grp2(ctxt);
3292 break; 3290 break;
@@ -3305,10 +3303,6 @@ special_insn:
3305 if (rc != X86EMUL_CONTINUE) 3303 if (rc != X86EMUL_CONTINUE)
3306 goto done; 3304 goto done;
3307 break; 3305 break;
3308 case 0xc6 ... 0xc7: /* mov (sole member of Grp11) */
3309 mov:
3310 c->dst.val = c->src.val;
3311 break;
3312 case 0xcb: /* ret far */ 3306 case 0xcb: /* ret far */
3313 rc = emulate_ret_far(ctxt, ops); 3307 rc = emulate_ret_far(ctxt, ops);
3314 if (rc != X86EMUL_CONTINUE) 3308 if (rc != X86EMUL_CONTINUE)