From patchwork Wed May 12 21:25:05 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 99118 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4CLRaht029431 for ; Wed, 12 May 2010 21:27:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757971Ab0ELV1e (ORCPT ); Wed, 12 May 2010 17:27:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51088 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757866Ab0ELV1L (ORCPT ); Wed, 12 May 2010 17:27:11 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4CLR6Q2011653 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 12 May 2010 17:27:06 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4CLR5Ke025574; Wed, 12 May 2010 17:27:05 -0400 Received: from amt.cnet (vpn2-10-158.ams2.redhat.com [10.36.10.158]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o4CLR3DL021868; Wed, 12 May 2010 17:27:04 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 0883E656080; Wed, 12 May 2010 18:26:28 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id o4CLQNb9028662; Wed, 12 May 2010 18:26:23 -0300 From: Marcelo Tosatti To: Anthony Liguori Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Gleb Natapov , Marcelo Tosatti Subject: [PATCH 11/12] Do not stop VM if emulation failed in userspace. Date: Wed, 12 May 2010 18:25:05 -0300 Message-Id: <4513d9232badcc5039d69dae946054ba2682c258.1273699506.git.mtosatti@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 12 May 2010 21:27:37 +0000 (UTC) diff --git a/kvm-all.c b/kvm-all.c index d06980c..c238f54 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -764,6 +764,8 @@ static void kvm_handle_internal_error(CPUState *env, struct kvm_run *run) cpu_dump_state(env, stderr, fprintf, 0); if (run->internal.suberror == KVM_INTERNAL_ERROR_EMULATION) { fprintf(stderr, "emulation failure\n"); + if (!kvm_arch_stop_on_emulation_error(env)) + return; } /* FIXME: Should trigger a qmp message to let management know * something went wrong. diff --git a/kvm.h b/kvm.h index 5071a31..a28e7aa 100644 --- a/kvm.h +++ b/kvm.h @@ -140,6 +140,8 @@ void kvm_arch_remove_all_hw_breakpoints(void); void kvm_arch_update_guest_debug(CPUState *env, struct kvm_guest_debug *dbg); +bool kvm_arch_stop_on_emulation_error(CPUState *env); + int kvm_check_extension(KVMState *s, unsigned int extension); uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function, diff --git a/target-i386/kvm.c b/target-i386/kvm.c index bd7a190..676aa60 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -1289,3 +1289,10 @@ void kvm_arch_update_guest_debug(CPUState *env, struct kvm_guest_debug *dbg) } } #endif /* KVM_CAP_SET_GUEST_DEBUG */ + +bool kvm_arch_stop_on_emulation_error(CPUState *env) +{ + return !(env->cr[0] & CR0_PE_MASK) || + ((env->segs[R_CS].selector & 3) != 3); +} + diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index 91c0963..2625cb8 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -326,3 +326,8 @@ uint32_t kvmppc_get_tbfreq(void) retval = atoi(ns); return retval; } + +bool kvm_arch_stop_on_emulation_error(CPUState *env) +{ + return true; +} diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index a2c00ac..a2d7741 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -485,3 +485,8 @@ int kvm_arch_handle_exit(CPUState *env, struct kvm_run *run) return ret; } + +bool kvm_arch_stop_on_emulation_error(CPUState *env) +{ + return true; +}