From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGT2T-0006k3-Sg for qemu-devel@nongnu.org; Fri, 24 Jun 2016 11:29:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bGT2O-0007E6-LF for qemu-devel@nongnu.org; Fri, 24 Jun 2016 11:29:00 -0400 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]:34765) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGT2O-0007DX-DT for qemu-devel@nongnu.org; Fri, 24 Jun 2016 11:28:56 -0400 Received: by mail-lf0-x242.google.com with SMTP id l184so21988218lfl.1 for ; Fri, 24 Jun 2016 08:28:56 -0700 (PDT) References: <1464986428-6739-1-git-send-email-alex.bennee@linaro.org> <1464986428-6739-6-git-send-email-alex.bennee@linaro.org> From: Sergey Fedorov Message-ID: <576D51B4.1090102@gmail.com> Date: Fri, 24 Jun 2016 18:28:52 +0300 MIME-Version: 1.0 In-Reply-To: <1464986428-6739-6-git-send-email-alex.bennee@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [RFC v3 05/19] exec: add assert_debug_safe and notes on debug structures List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?Q?Alex_Benn=c3=a9e?= , mttcg@listserver.greensocs.com, qemu-devel@nongnu.org, fred.konrad@greensocs.com, a.rigo@virtualopensystems.com, cota@braap.org, bobby.prani@gmail.com Cc: mark.burton@greensocs.com, pbonzini@redhat.com, jan.kiszka@siemens.com, rth@twiddle.net, peter.maydell@linaro.org, claudio.fontana@huawei.com, Peter Crosthwaite On 03/06/16 23:40, Alex Bennée wrote: > diff --git a/exec.c b/exec.c > index a3a93ae..b225282 100644 > --- a/exec.c > +++ b/exec.c > @@ -25,6 +25,7 @@ > #include "qemu/cutils.h" > #include "cpu.h" > #include "exec/exec-all.h" > +#include "qom/cpu.h" > #include "tcg.h" > #include "hw/qdev-core.h" > #if !defined(CONFIG_USER_ONLY) > @@ -62,7 +63,46 @@ > #include "qemu/mmap-alloc.h" > #endif > > -//#define DEBUG_SUBPAGE > +/* #define DEBUG_SUBPAGE */ > +/* #define DEBUG_DEBUG */ > + > +#ifdef DEBUG_DEBUG > +#define CHECK_DEBUG_SAFE 1 > +#else > +#define CHECK_DEBUG_SAFE 0 > +#endif > + > +/* > + * Safe access to debugging structures. > + * > + * Breakpoints and Watchpoints are kept in the vCPU structures. There > + * are two ways they are manipulated: > + * > + * - Outside of the context of the vCPU thread (e.g. gdbstub) > + * - Inside the context of the vCPU (architectural debug registers) > + * > + * In system emulation mode the chance of corruption is usually > + * mitigated by the fact the vCPUs is usually suspended whenever these > + * changes are made. > + * > + * In user emulation mode it is less clear (XXX: work this out) > + */ > + > +#ifdef CONFIG_SOFTMMU > +#define assert_debug_safe(cpu) do { \ > + if (CHECK_DEBUG_SAFE) { \ > + g_assert(!cpu->created || \ > + (cpu_is_stopped(cpu) || cpu == current_cpu)); \ There's no need in parentheses around "cpu_is_stopped(cpu) || cpu == current_cpu". > + } \ > + } while (0) > +#else > +#define assert_debug_safe(cpu) do { \ > + if (CHECK_DEBUG_SAFE) { \ > + g_assert(false); \ > + } \ Can be simply: #define assert_debug_safe(cpu) Kind regards, Sergey > + } while (0) > +#endif > + > > #if !defined(CONFIG_USER_ONLY) > /* ram_list is read under rcu_read_lock()/rcu_read_unlock(). Writes >