From patchwork Sun Jun 9 19:13:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 250103 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 72CD42C02A8 for ; Mon, 10 Jun 2013 05:28:04 +1000 (EST) Received: from localhost ([::1]:39423 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UllHW-0005Dp-Dc for incoming@patchwork.ozlabs.org; Sun, 09 Jun 2013 15:28:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ull4N-0000Z1-Kg for qemu-devel@nongnu.org; Sun, 09 Jun 2013 15:14:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ull4M-0000k0-9f for qemu-devel@nongnu.org; Sun, 09 Jun 2013 15:14:27 -0400 Received: from cantor2.suse.de ([195.135.220.15]:44437 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ull4M-0000jo-3E for qemu-devel@nongnu.org; Sun, 09 Jun 2013 15:14:26 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id AC2B1A41E0; Sun, 9 Jun 2013 21:14:25 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Sun, 9 Jun 2013 21:13:00 +0200 Message-Id: <1370805206-26574-34-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1370805206-26574-1-git-send-email-afaerber@suse.de> References: <1370805206-26574-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: Marcelo Tosatti , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Gleb Natapov , "open list:Overall" Subject: [Qemu-devel] [PATCH qom-cpu 33/59] kvm: Simplify kvm_remove_all_breakpoints() further 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 Use new qemu_for_each_cpu(). Signed-off-by: Andreas Färber --- kvm-all.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index d5ed831..312106d 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1986,24 +1986,36 @@ int kvm_remove_breakpoint(CPUArchState *current_env, target_ulong addr, return 0; } +typedef struct KVMRemoveBreakpointData { + struct kvm_sw_breakpoint *bp; + bool removed; +} KVMRemoveBreakpointData; + +static void kvm_remove_all_breakpoints_one(CPUState *cpu, void *data) +{ + KVMRemoveBreakpointData *s = data; + + if (s->removed) { + return; + } + s->removed = kvm_arch_remove_sw_breakpoint(cpu, s->bp) == 0; +} + void kvm_remove_all_breakpoints(CPUArchState *current_env) { CPUState *current_cpu = ENV_GET_CPU(current_env); struct kvm_sw_breakpoint *bp, *next; KVMState *s = current_cpu->kvm_state; - CPUArchState *env; - CPUState *cpu; int err; QTAILQ_FOREACH_SAFE(bp, &s->kvm_sw_breakpoints, entry, next) { if (kvm_arch_remove_sw_breakpoint(current_cpu, bp) != 0) { /* Try harder to find a CPU that currently sees the breakpoint. */ - for (env = first_cpu; env != NULL; env = env->next_cpu) { - cpu = ENV_GET_CPU(env); - if (kvm_arch_remove_sw_breakpoint(cpu, bp) == 0) { - break; - } - } + KVMRemoveBreakpointData data = { + .bp = bp, + .removed = false, + }; + qemu_for_each_cpu(kvm_remove_all_breakpoints_one, &data); } QTAILQ_REMOVE(&s->kvm_sw_breakpoints, bp, entry); g_free(bp);