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: 1657801 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 97D0EDFABE for ; Sun, 28 Oct 2012 15:04:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752169Ab2J1PEX (ORCPT ); Sun, 28 Oct 2012 11:04:23 -0400 Received: from mail-la0-f46.google.com ([209.85.215.46]:50763 "EHLO mail-la0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751614Ab2J1PEW (ORCPT ); Sun, 28 Oct 2012 11:04:22 -0400 Received: by mail-la0-f46.google.com with SMTP id h6so3253512lag.19 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 Cc: blauwirbel@gmail.com, Avi Kivity , Marcelo Tosatti , kvm@vger.kernel.org Subject: [PATCH 2/5] kvm: avoid using cpu_single_env 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: Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.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);