If emulation fails due to the instruction being unemulated. Return immediately
instead of restarting the instruction and infinitely trying to execute it.

Signed-off-by: Mohammed Gamal <m.gamal...@gmail.com>
---
 arch/x86/kvm/x86.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 416aa0e..a31db44 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4036,6 +4036,9 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
                }
 
                ++vcpu->stat.insn_emulation;
+               if (r == X86EMUL_UNHANDLEABLE)
+                       return handle_emulation_failure(vcpu);
+
                if (r)  {
                        if (reexecute_instruction(vcpu, cr2))
                                return EMULATE_DONE;
@@ -4057,6 +4060,9 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
 restart:
        r = x86_emulate_insn(&vcpu->arch.emulate_ctxt);
 
+       if (r == X86EMUL_UNHANDLEABLE)
+               return handle_emulation_failure(vcpu);
+
        if (r) { /* emulation failed */
                if (reexecute_instruction(vcpu, cr2))
                        return EMULATE_DONE;
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to