From patchwork Thu Nov 29 03:32:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liguang X-Patchwork-Id: 202652 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 7DDDF2C0087 for ; Thu, 29 Nov 2012 14:35:34 +1100 (EST) Received: from localhost ([::1]:47756 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TduuS-0005zP-FI for incoming@patchwork.ozlabs.org; Wed, 28 Nov 2012 22:35:32 -0500 Received: from eggs.gnu.org ([208.118.235.92]:57001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TduuA-0005qh-E7 for qemu-devel@nongnu.org; Wed, 28 Nov 2012 22:35:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tduu9-0001A7-F1 for qemu-devel@nongnu.org; Wed, 28 Nov 2012 22:35:14 -0500 Received: from [222.73.24.84] (port=29128 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tduu9-00018F-62 for qemu-devel@nongnu.org; Wed, 28 Nov 2012 22:35:13 -0500 X-IronPort-AV: E=Sophos;i="4.83,338,1352044800"; d="scan'208";a="6296346" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 29 Nov 2012 11:33:27 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id qAT3ZCWd021833; Thu, 29 Nov 2012 11:35:12 +0800 Received: from liguang.fnst.cn.fujitsu.com ([10.167.225.128]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2012112911344422-148996 ; Thu, 29 Nov 2012 11:34:44 +0800 From: liguang To: ehabkost@redhat.com, imammedo@redhat.com, afaerber@suse.de, qemu-devel@nongnu.org Date: Thu, 29 Nov 2012 11:32:51 +0800 Message-Id: <1354159971-6720-3-git-send-email-lig.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1354159971-6720-1-git-send-email-lig.fnst@cn.fujitsu.com> References: <1354159971-6720-1-git-send-email-lig.fnst@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/11/29 11:34:44, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/11/29 11:34:44, Serialize complete at 2012/11/29 11:34:44 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 222.73.24.84 Cc: liguang Subject: [Qemu-devel] [PATCH 3/3] target-i386:refactor check_hw_breakpoints function 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 Signed-off-by: liguang --- target-i386/helper.c | 28 ++++++++++++++++++++-------- 1 files changed, 20 insertions(+), 8 deletions(-) diff --git a/target-i386/helper.c b/target-i386/helper.c index 9ca52a7..a506df0 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -1012,22 +1012,34 @@ void hw_breakpoint_remove(CPUX86State *env, int index) int check_hw_breakpoints(CPUX86State *env, int force_dr6_update) { target_ulong dr6; - int reg, type; + int index; int hit_enabled = 0; dr6 = env->dr[6] & ~0xf; - for (reg = 0; reg < MAX_BP; reg++) { - type = hw_breakpoint_type(env->dr[7], reg); - if ((type == 0 && env->dr[reg] == env->eip) || - ((type & 1) && env->cpu_watchpoint[reg] && - (env->cpu_watchpoint[reg]->flags & BP_WATCHPOINT_HIT))) { - dr6 |= 1 << reg; - if (hw_breakpoint_enabled(env->dr[7], reg)) + for (index = 0; index < MAX_BP; index++) { + switch (hw_breakpoint_type(env->dr[7], index)){ + case BP_INST: + if (env->dr[index] != env->eip) + break; + goto enable_hit; + case BP_DATA_WR: + case BP_DATA_RW: + if (!env->cpu_watchpoint[index]) + break; + if (!(env->cpu_watchpoint[index]->flags & BP_WATCHPOINT_HIT)) + break; + enable_hit: + dr6 |= 1 << index; + if (hw_breakpoint_enabled(env->dr[7], index)) hit_enabled = 1; + break; + case BP_IO_RW: + break; } } if (hit_enabled || force_dr6_update) env->dr[6] = dr6; + return hit_enabled; }