From patchwork Sun Jun 9 19:12:59 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: 2694821 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 BB2E3E033C for ; Sun, 9 Jun 2013 19:14:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752108Ab3FITO2 (ORCPT ); Sun, 9 Jun 2013 15:14:28 -0400 Received: from cantor2.suse.de ([195.135.220.15]:44432 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751960Ab3FITOZ (ORCPT ); Sun, 9 Jun 2013 15:14:25 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 61625A51CB; Sun, 9 Jun 2013 21:14:24 +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 32/59] kvm: Simplify kvm_{insert, remove, remove_all}_breakpoint[s]() Date: Sun, 9 Jun 2013 21:12:59 +0200 Message-Id: <1370805206-26574-33-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 | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index 90b89cd..d5ed831 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1891,12 +1891,22 @@ int kvm_update_guest_debug(CPUArchState *env, unsigned long reinject_trap) return data.err; } +static void kvm_update_guest_debug_one(CPUState *cpu, void *data) +{ + int *perr = data; + CPUArchState *env = cpu->env_ptr; + + if (*perr) { + return; + } + *perr = kvm_update_guest_debug(env, 0); +} + int kvm_insert_breakpoint(CPUArchState *current_env, target_ulong addr, target_ulong len, int type) { CPUState *current_cpu = ENV_GET_CPU(current_env); struct kvm_sw_breakpoint *bp; - CPUArchState *env; int err; if (type == GDB_BREAKPOINT_SW) { @@ -1928,11 +1938,10 @@ int kvm_insert_breakpoint(CPUArchState *current_env, target_ulong addr, } } - for (env = first_cpu; env != NULL; env = env->next_cpu) { - err = kvm_update_guest_debug(env, 0); - if (err) { - return err; - } + err = 0; + qemu_for_each_cpu(kvm_update_guest_debug_one, &err); + if (err) { + return err; } return 0; } @@ -1942,7 +1951,6 @@ int kvm_remove_breakpoint(CPUArchState *current_env, target_ulong addr, { CPUState *current_cpu = ENV_GET_CPU(current_env); struct kvm_sw_breakpoint *bp; - CPUArchState *env; int err; if (type == GDB_BREAKPOINT_SW) { @@ -1970,11 +1978,10 @@ int kvm_remove_breakpoint(CPUArchState *current_env, target_ulong addr, } } - for (env = first_cpu; env != NULL; env = env->next_cpu) { - err = kvm_update_guest_debug(env, 0); - if (err) { - return err; - } + err = 0; + qemu_for_each_cpu(kvm_update_guest_debug_one, &err); + if (err) { + return err; } return 0; } @@ -1986,6 +1993,7 @@ void kvm_remove_all_breakpoints(CPUArchState *current_env) 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) { @@ -2002,9 +2010,8 @@ void kvm_remove_all_breakpoints(CPUArchState *current_env) } kvm_arch_remove_all_hw_breakpoints(); - for (env = first_cpu; env != NULL; env = env->next_cpu) { - kvm_update_guest_debug(env, 0); - } + err = 0; + qemu_for_each_cpu(kvm_update_guest_debug_one, &err); } #else /* !KVM_CAP_SET_GUEST_DEBUG */