From patchwork Mon May 10 08:21:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 98089 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 o4A8LcdO004039 for ; Mon, 10 May 2010 08:21:38 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755472Ab0EJIVg (ORCPT ); Mon, 10 May 2010 04:21:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33222 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751311Ab0EJIVf (ORCPT ); Mon, 10 May 2010 04:21:35 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4A8LZMU006799 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 10 May 2010 04:21:35 -0400 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4A8LYrV031072; Mon, 10 May 2010 04:21:34 -0400 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id 0922318D450; Mon, 10 May 2010 11:21:34 +0300 (IDT) Date: Mon, 10 May 2010 11:21:34 +0300 From: Gleb Natapov To: avi@redhat.com, mtosatti@redhat.com Cc: kvm@vger.kernel.org Subject: [PATCH] Do not stop VM if emulation failed in userspace. Message-ID: <20100510082133.GK24787@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 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]); Mon, 10 May 2010 08:21:38 +0000 (UTC) diff --git a/kvm-all.c b/kvm-all.c index 9ac35aa..db28d94 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -786,6 +786,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 67c0392..79e59f5 100644 --- a/kvm.h +++ b/kvm.h @@ -187,4 +187,5 @@ int kvm_set_irqfd(int gsi, int fd, bool assigned) #endif int kvm_set_ioeventfd_pio_word(int fd, uint16_t adr, uint16_t val, bool assign); +bool kvm_arch_stop_on_emulation_error(CPUState *env); #endif diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 76c1adb..c333f86 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -1287,4 +1287,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); +} + #include "qemu-kvm-x86.c" diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index aa3d432..7b246a1 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -321,3 +321,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 72e77b0..14f723b 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -480,3 +480,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; +}