From patchwork Tue Mar 15 21:50:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 87109 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 7B22AB70E9 for ; Wed, 16 Mar 2011 09:31:28 +1100 (EST) Received: from localhost ([127.0.0.1]:33988 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pzclx-00058R-10 for incoming@patchwork.ozlabs.org; Tue, 15 Mar 2011 18:31:25 -0400 Received: from [140.186.70.92] (port=35181 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PzcLV-0002KZ-B2 for qemu-devel@nongnu.org; Tue, 15 Mar 2011 18:04:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PzcLS-0004xo-UA for qemu-devel@nongnu.org; Tue, 15 Mar 2011 18:04:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31552) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PzcLS-0004xM-L1 for qemu-devel@nongnu.org; Tue, 15 Mar 2011 18:04:02 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2FM41bb017919 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 15 Mar 2011 18:04:02 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p2FM41a6010055; Tue, 15 Mar 2011 18:04:01 -0400 Received: from amt.cnet (vpn1-5-191.ams2.redhat.com [10.36.5.191]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p2FM3xgq024385; Tue, 15 Mar 2011 18:04:00 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 4EADF68A03E; Tue, 15 Mar 2011 18:53:28 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.4/8.14.4/Submit) id p2FLrOld002180; Tue, 15 Mar 2011 18:53:24 -0300 From: Marcelo Tosatti To: Anthony Liguori Date: Tue, 15 Mar 2011 18:50:46 -0300 Message-Id: <4894310eaf6daa9c80f98a19caebd20b14080ad2.1300225848.git.mtosatti@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Jan Kiszka , Marcelo Tosatti , qemu-devel@nongnu.org, kvm@vger.kernel.org, Alexander Graf Subject: [Qemu-devel] [PATCH 32/35] kvm: Align kvm_arch_handle_exit to kvm_cpu_exec changes 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 From: Jan Kiszka Make the return code of kvm_arch_handle_exit directly usable for kvm_cpu_exec. This is straightforward for x86 and ppc, just s390 would require more work. Avoid this for now by pushing the return code translation logic into s390's kvm_arch_handle_exit. Signed-off-by: Jan Kiszka CC: Alexander Graf Signed-off-by: Marcelo Tosatti --- kvm-all.c | 5 ----- target-i386/kvm.c | 8 ++++---- target-ppc/kvm.c | 8 ++++---- target-s390x/kvm.c | 5 +++++ 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index 271e361..f34cb69 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -989,11 +989,6 @@ int kvm_cpu_exec(CPUState *env) default: DPRINTF("kvm_arch_handle_exit\n"); ret = kvm_arch_handle_exit(env, run); - if (ret == 0) { - ret = EXCP_INTERRUPT; - } else if (ret > 0) { - ret = 0; - } break; } } while (ret == 0); diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 032bc3e..6f84610 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -1618,10 +1618,10 @@ static int kvm_handle_halt(CPUState *env) (env->eflags & IF_MASK)) && !(env->interrupt_request & CPU_INTERRUPT_NMI)) { env->halted = 1; - return 0; + return EXCP_HLT; } - return 1; + return 0; } static bool host_supports_vmx(void) @@ -1637,7 +1637,7 @@ static bool host_supports_vmx(void) int kvm_arch_handle_exit(CPUState *env, struct kvm_run *run) { uint64_t code; - int ret = 0; + int ret; switch (run->exit_reason) { case KVM_EXIT_HLT: @@ -1645,7 +1645,7 @@ int kvm_arch_handle_exit(CPUState *env, struct kvm_run *run) ret = kvm_handle_halt(env); break; case KVM_EXIT_SET_TPR: - ret = 1; + ret = 0; break; case KVM_EXIT_FAIL_ENTRY: code = run->fail_entry.hardware_entry_failure_reason; diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index 6c99a16..593eb98 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -271,7 +271,7 @@ static int kvmppc_handle_halt(CPUState *env) env->exception_index = EXCP_HLT; } - return 1; + return 0; } /* map dcr access to existing qemu dcr emulation */ @@ -280,7 +280,7 @@ static int kvmppc_handle_dcr_read(CPUState *env, uint32_t dcrn, uint32_t *data) if (ppc_dcr_read(env->dcr_env, dcrn, data) < 0) fprintf(stderr, "Read to unhandled DCR (0x%x)\n", dcrn); - return 1; + return 0; } static int kvmppc_handle_dcr_write(CPUState *env, uint32_t dcrn, uint32_t data) @@ -288,12 +288,12 @@ static int kvmppc_handle_dcr_write(CPUState *env, uint32_t dcrn, uint32_t data) if (ppc_dcr_write(env->dcr_env, dcrn, data) < 0) fprintf(stderr, "Write to unhandled DCR (0x%x)\n", dcrn); - return 1; + return 0; } int kvm_arch_handle_exit(CPUState *env, struct kvm_run *run) { - int ret = 0; + int ret; switch (run->exit_reason) { case KVM_EXIT_DCR: diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index a85ae0f..9123203 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -497,6 +497,11 @@ int kvm_arch_handle_exit(CPUState *env, struct kvm_run *run) break; } + if (ret == 0) { + ret = EXCP_INTERRUPT; + } else if (ret > 0) { + ret = 0; + } return ret; }