aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGleb Natapov <gleb@redhat.com>2010-03-18 09:20:15 -0400
committerAvi Kivity <avi@redhat.com>2010-05-17 05:16:12 -0400
commitaca06a83071e4e4c9150751db7ea6a46240734fc (patch)
tree9346ba8604f6b09e72595288a8d2c4c3feb3d48b
parenta41ffb7540cb37426759e688083502d6463421b2 (diff)
KVM: x86 emulator: cleanup grp3 return value
When x86_emulate_insn() does not know how to emulate instruction it exits via cannot_emulate label in all cases except when emulating grp3. Fix that. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
-rw-r--r--arch/x86/kvm/emulate.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 46a7ee3040a0..d696cbd6ff7a 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -1397,7 +1397,6 @@ static inline int emulate_grp3(struct x86_emulate_ctxt *ctxt,
1397 struct x86_emulate_ops *ops) 1397 struct x86_emulate_ops *ops)
1398{ 1398{
1399 struct decode_cache *c = &ctxt->decode; 1399 struct decode_cache *c = &ctxt->decode;
1400 int rc = X86EMUL_CONTINUE;
1401 1400
1402 switch (c->modrm_reg) { 1401 switch (c->modrm_reg) {
1403 case 0 ... 1: /* test */ 1402 case 0 ... 1: /* test */
@@ -1410,11 +1409,9 @@ static inline int emulate_grp3(struct x86_emulate_ctxt *ctxt,
1410 emulate_1op("neg", c->dst, ctxt->eflags); 1409 emulate_1op("neg", c->dst, ctxt->eflags);
1411 break; 1410 break;
1412 default: 1411 default:
1413 DPRINTF("Cannot emulate %02x\n", c->b); 1412 return 0;
1414 rc = X86EMUL_UNHANDLEABLE;
1415 break;
1416 } 1413 }
1417 return rc; 1414 return 1;
1418} 1415}
1419 1416
1420static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt, 1417static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt,
@@ -2374,9 +2371,8 @@ special_insn:
2374 c->dst.type = OP_NONE; /* Disable writeback. */ 2371 c->dst.type = OP_NONE; /* Disable writeback. */
2375 break; 2372 break;
2376 case 0xf6 ... 0xf7: /* Grp3 */ 2373 case 0xf6 ... 0xf7: /* Grp3 */
2377 rc = emulate_grp3(ctxt, ops); 2374 if (!emulate_grp3(ctxt, ops))
2378 if (rc != X86EMUL_CONTINUE) 2375 goto cannot_emulate;
2379 goto done;
2380 break; 2376 break;
2381 case 0xf8: /* clc */ 2377 case 0xf8: /* clc */
2382 ctxt->eflags &= ~EFLG_CF; 2378 ctxt->eflags &= ~EFLG_CF;