From patchwork Fri Mar 4 10:20:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 85407 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 147A8B70E6 for ; Fri, 4 Mar 2011 21:38:08 +1100 (EST) Received: from localhost ([127.0.0.1]:44930 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PvSOb-0000id-4Z for incoming@patchwork.ozlabs.org; Fri, 04 Mar 2011 05:38:05 -0500 Received: from [140.186.70.92] (port=50849 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PvS7c-00028q-Tk for qemu-devel@nongnu.org; Fri, 04 Mar 2011 05:22:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PvS7N-0005FB-TL for qemu-devel@nongnu.org; Fri, 04 Mar 2011 05:20:22 -0500 Received: from david.siemens.de ([192.35.17.14]:26881) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PvS7N-0005D9-77 for qemu-devel@nongnu.org; Fri, 04 Mar 2011 05:20:17 -0500 Received: from mail1.siemens.de (localhost [127.0.0.1]) by david.siemens.de (8.13.6/8.13.6) with ESMTP id p24AKF70012910; Fri, 4 Mar 2011 11:20:15 +0100 Received: from mchn199C.mchp.siemens.de ([139.25.109.49]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id p24AKCXR008671; Fri, 4 Mar 2011 11:20:15 +0100 From: Jan Kiszka To: Avi Kivity , Marcelo Tosatti Date: Fri, 4 Mar 2011 11:20:09 +0100 Message-Id: <42c13eb02928b113fd6f4b5c013648d266e1ff4c.1299233998.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 192.35.17.14 Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Alexander Graf Subject: [Qemu-devel] [PATCH 12/15] 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 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 --- 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 cc652cf..d643dc7 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1007,11 +1007,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 bfc8d66..b43a85c 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 5673a95..4761d5d 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -496,6 +496,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; }