From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mohammed Gamal Subject: [PATCH 2/2] x86: Bail out on unemulated instructions Date: Sat, 14 Aug 2010 18:51:34 +0300 Message-ID: <1281801094-4515-2-git-send-email-m.gamal005@gmail.com> References: <1281801094-4515-1-git-send-email-m.gamal005@gmail.com> Cc: mtosatti@redhat.com, kvm@vger.kernel.org, Mohammed Gamal To: avi@redhat.com Return-path: Received: from mail-ww0-f44.google.com ([74.125.82.44]:33946 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755994Ab0HNPv5 (ORCPT ); Sat, 14 Aug 2010 11:51:57 -0400 Received: by mail-ww0-f44.google.com with SMTP id 40so4351140wwj.1 for ; Sat, 14 Aug 2010 08:51:56 -0700 (PDT) In-Reply-To: <1281801094-4515-1-git-send-email-m.gamal005@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: 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 --- 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