From patchwork Sun Oct 28 15:03:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Blue Swirl X-Patchwork-Id: 194709 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id F34B52C008D for ; Mon, 29 Oct 2012 02:10:06 +1100 (EST) Received: from localhost ([::1]:48293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TSUQ3-0005ly-Nt for incoming@patchwork.ozlabs.org; Sun, 28 Oct 2012 11:04:55 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60333) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TSUPX-0004OF-5R for qemu-devel@nongnu.org; Sun, 28 Oct 2012 11:04:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TSUPV-0005Oz-Ei for qemu-devel@nongnu.org; Sun, 28 Oct 2012 11:04:23 -0400 Received: from mail-la0-f45.google.com ([209.85.215.45]:43678) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TSUPV-00056x-7f for qemu-devel@nongnu.org; Sun, 28 Oct 2012 11:04:21 -0400 Received: by mail-la0-f45.google.com with SMTP id m13so3208095lah.4 for ; Sun, 28 Oct 2012 08:04:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :in-reply-to:references; bh=61nolsp/K5xVNnCHIpjlCs4Mg/uyfgtNZd4psZl5N3I=; b=lq51YZfXpPc/iAOBVPr7rSwN9Vwn8YCC6vUj14O3K8UHpxRlBoz9FZwcFhjKiRRNEp wnjvJqDmeh4g2hz039/l5R+5eg3rk2aqna0wL3DhD7CB1T2gaaM3jrhUhLZwJ2a+0WiE nVTEWZskNkF7DcFWw1JzvMTd5/sPVIVj1F3E9DpxtNppX8j2qapjwJrKo3TXK7hDSuk3 jobDIY6oER0CfVx305ZzQR1AVnWuSu242bYL3aw2sE5iK38x0WPimNIXIBVIkIUlps7V bgal1/yyTlm9Dp5VpJWBXeeCnRwpH3E8lkc67dMkTHI7BmaU+b6oxFh8zsBD7Lo83Fzv koCw== Received: by 10.112.43.34 with SMTP id t2mr10791208lbl.109.1351436660795; Sun, 28 Oct 2012 08:04:20 -0700 (PDT) Received: from localhost.localdomain (blueswirl.broker.freenet6.net. [2001:5c0:1000:b::b867]) by mx.google.com with ESMTPS id ew2sm2251421lbb.2.2012.10.28.08.04.16 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 28 Oct 2012 08:04:20 -0700 (PDT) From: Blue Swirl To: qemu-devel@nongnu.org Date: Sun, 28 Oct 2012 15:03:49 +0000 Message-Id: X-Mailer: git-send-email 1.7.2.5 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.215.45 Cc: blauwirbel@gmail.com, Marcelo Tosatti , Avi Kivity , kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH 2/5] kvm: avoid using cpu_single_env X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Pass around CPUState instead of using global cpu_single_env. Signed-off-by: Blue Swirl Reviewed-by: Andreas Färber --- target-i386/kvm.c | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-) diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 3aa62b2..3329d5e 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -1909,14 +1909,15 @@ void kvm_arch_remove_all_hw_breakpoints(void) static CPUWatchpoint hw_watchpoint; -static int kvm_handle_debug(struct kvm_debug_exit_arch *arch_info) +static int kvm_handle_debug(CPUX86State *env, + struct kvm_debug_exit_arch *arch_info) { int ret = 0; int n; if (arch_info->exception == 1) { if (arch_info->dr6 & (1 << 14)) { - if (cpu_single_env->singlestep_enabled) { + if (env->singlestep_enabled) { ret = EXCP_DEBUG; } } else { @@ -1928,13 +1929,13 @@ static int kvm_handle_debug(struct kvm_debug_exit_arch *arch_info) break; case 0x1: ret = EXCP_DEBUG; - cpu_single_env->watchpoint_hit = &hw_watchpoint; + env->watchpoint_hit = &hw_watchpoint; hw_watchpoint.vaddr = hw_breakpoint[n].addr; hw_watchpoint.flags = BP_MEM_WRITE; break; case 0x3: ret = EXCP_DEBUG; - cpu_single_env->watchpoint_hit = &hw_watchpoint; + env->watchpoint_hit = &hw_watchpoint; hw_watchpoint.vaddr = hw_breakpoint[n].addr; hw_watchpoint.flags = BP_MEM_ACCESS; break; @@ -1942,16 +1943,16 @@ static int kvm_handle_debug(struct kvm_debug_exit_arch *arch_info) } } } - } else if (kvm_find_sw_breakpoint(cpu_single_env, arch_info->pc)) { + } else if (kvm_find_sw_breakpoint(env, arch_info->pc)) { ret = EXCP_DEBUG; } if (ret == 0) { - cpu_synchronize_state(cpu_single_env); - assert(cpu_single_env->exception_injected == -1); + cpu_synchronize_state(env); + assert(env->exception_injected == -1); /* pass to guest */ - cpu_single_env->exception_injected = arch_info->exception; - cpu_single_env->has_error_code = 0; + env->exception_injected = arch_info->exception; + env->has_error_code = 0; } return ret; @@ -2034,7 +2035,7 @@ int kvm_arch_handle_exit(CPUX86State *env, struct kvm_run *run) break; case KVM_EXIT_DEBUG: DPRINTF("kvm_exit_debug\n"); - ret = kvm_handle_debug(&run->debug.arch); + ret = kvm_handle_debug(env, &run->debug.arch); break; default: fprintf(stderr, "KVM: unknown exit reason %d\n", run->exit_reason);