From patchwork Tue Mar 9 01:53:45 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 47145 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1291AB7D1B for ; Tue, 9 Mar 2010 13:00:59 +1100 (EST) Received: from localhost ([127.0.0.1]:54163 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nooki-0005A1-7l for incoming@patchwork.ozlabs.org; Mon, 08 Mar 2010 21:00:56 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NooiI-00049c-WC for qemu-devel@nongnu.org; Mon, 08 Mar 2010 20:58:27 -0500 Received: from [199.232.76.173] (port=57792 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NooiI-00048x-10 for qemu-devel@nongnu.org; Mon, 08 Mar 2010 20:58:26 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NooiF-0005vs-VY for qemu-devel@nongnu.org; Mon, 08 Mar 2010 20:58:25 -0500 Received: from mx20.gnu.org ([199.232.41.8]:61403) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NooiF-0005vd-BZ for qemu-devel@nongnu.org; Mon, 08 Mar 2010 20:58:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NooiE-00005O-7e for qemu-devel@nongnu.org; Mon, 08 Mar 2010 20:58:22 -0500 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o291wJn6029883 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 8 Mar 2010 20:58:19 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o291wJa9003476; Mon, 8 Mar 2010 20:58:19 -0500 Received: from amt.cnet (vpn-10-246.rdu.redhat.com [10.11.10.246]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o291wHYt007790; Mon, 8 Mar 2010 20:58:18 -0500 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id BAC1E68A7D6; Mon, 8 Mar 2010 22:57:17 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id o291vHkT025645; Mon, 8 Mar 2010 22:57:17 -0300 Message-Id: <20100309015644.207517219@redhat.com> User-Agent: quilt/0.47-1 Date: Mon, 08 Mar 2010 22:53:45 -0300 From: Marcelo Tosatti To: kvm@vger.kernel.org, qemu-devel@nongnu.org References: <20100309015343.901738854@redhat.com> Content-Disposition: inline; filename=kvm_handle_internal_error X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by mx20.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: Marcelo Tosatti Subject: [Qemu-devel] [patch 2/3] kvm: handle internal error X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Port qemu-kvm's KVM_EXIT_INTERNAL_ERROR handling to upstream. Signed-off-by: Marcelo Tosatti Index: qemu-kvm/kvm-all.c =================================================================== --- qemu-kvm.orig/kvm-all.c +++ qemu-kvm/kvm-all.c @@ -721,6 +721,28 @@ static int kvm_handle_io(uint16_t port, return 1; } +#ifdef KVM_CAP_INTERNAL_ERROR_DATA +static void kvm_handle_internal_error(CPUState *env, struct kvm_run *run) +{ + + if (kvm_check_extension(kvm_state, KVM_CAP_INTERNAL_ERROR_DATA)) { + int i; + + fprintf(stderr, "KVM internal error. Suberror: %d\n", + run->internal.suberror); + + for (i = 0; i < run->internal.ndata; ++i) { + fprintf(stderr, "extra data[%d]: %"PRIx64"\n", + i, (uint64_t)run->internal.data[i]); + } + } + cpu_dump_state(env, stderr, fprintf, 0); + if (run->internal.suberror == KVM_INTERNAL_ERROR_EMULATION) + fprintf(stderr, "emulation failure\n"); + vm_stop(0); +} +#endif + void kvm_flush_coalesced_mmio_buffer(void) { #ifdef KVM_CAP_COALESCED_MMIO @@ -836,6 +858,11 @@ int kvm_cpu_exec(CPUState *env) case KVM_EXIT_EXCEPTION: dprintf("kvm_exit_exception\n"); break; +#ifdef KVM_CAP_INTERNAL_ERROR_DATA + case KVM_EXIT_INTERNAL_ERROR: + kvm_handle_internal_error(env, run); + break; +#endif case KVM_EXIT_DEBUG: dprintf("kvm_exit_debug\n"); #ifdef KVM_CAP_SET_GUEST_DEBUG