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: 2694811 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 A1A24E033B for ; Sun, 9 Jun 2013 19:14:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752096Ab3FITO1 (ORCPT ); Sun, 9 Jun 2013 15:14:27 -0400 Received: from cantor2.suse.de ([195.135.220.15]:44436 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751968Ab3FITO0 (ORCPT ); Sun, 9 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 Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , Gleb Natapov , Marcelo Tosatti , kvm@vger.kernel.org (open list:Overall) Subject: [PATCH qom-cpu 33/59] kvm: Simplify kvm_remove_all_breakpoints() further 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 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.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);