KVM: fix emulator_task_switch() return value.
authorGleb Natapov <gleb@redhat.com>
Thu, 15 Apr 2010 09:29:50 +0000 (12:29 +0300)
committerAvi Kivity <avi@redhat.com>
Mon, 17 May 2010 09:17:49 +0000 (12:17 +0300)
emulator_task_switch() should return -1 for failure and 0 for success to
the caller, just like x86_emulate_insn() does.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/x86/kvm/emulate.c
arch/x86/kvm/x86.c

index 585d0ef4a5f6edea21409932f8f04da3aa9a1e14..5ac0bb465ed67fd725881ccacfeb22e44597f4cf 100644 (file)
@@ -2453,7 +2453,7 @@ int emulator_task_switch(struct x86_emulate_ctxt *ctxt,
                rc = writeback(ctxt, ops);
        }
 
-       return rc;
+       return (rc == X86EMUL_UNHANDLEABLE) ? -1 : 0;
 }
 
 static void string_addr_inc(struct x86_emulate_ctxt *ctxt, unsigned long base,
index 58a295c6bf62e85789ebeee1f379cd9680660c2f..30efeead4511f6bda8b8f4466bbe76cb14d39333 100644 (file)
@@ -4800,10 +4800,11 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason,
                                   tss_selector, reason, has_error_code,
                                   error_code);
 
-       if (ret == X86EMUL_CONTINUE)
-               kvm_x86_ops->set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags);
+       if (ret)
+               return EMULATE_FAIL;
 
-       return (ret != X86EMUL_CONTINUE);
+       kvm_x86_ops->set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags);
+       return EMULATE_DONE;
 }
 EXPORT_SYMBOL_GPL(kvm_task_switch);