From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8Tl7-0002ql-El for qemu-devel@nongnu.org; Thu, 02 Jun 2016 10:38:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8Tl1-0004ec-OD for qemu-devel@nongnu.org; Thu, 02 Jun 2016 10:38:04 -0400 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]:36842) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8Tl0-0004eG-OK for qemu-devel@nongnu.org; Thu, 02 Jun 2016 10:37:59 -0400 Received: by mail-lf0-x241.google.com with SMTP id h68so5334404lfh.3 for ; Thu, 02 Jun 2016 07:37:58 -0700 (PDT) References: <1459870344-16773-1-git-send-email-alex.bennee@linaro.org> <1459870344-16773-6-git-send-email-alex.bennee@linaro.org> <5733295B.8090401@gmail.com> <87shwx6w10.fsf@linaro.org> From: Sergey Fedorov Message-ID: <575044C3.5000501@gmail.com> Date: Thu, 2 Jun 2016 17:37:55 +0300 MIME-Version: 1.0 In-Reply-To: <87shwx6w10.fsf@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [RFC v2 05/11] tcg: protect TBContext with tb_lock. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?Q?Alex_Benn=c3=a9e?= Cc: mttcg@listserver.greensocs.com, fred.konrad@greensocs.com, a.rigo@virtualopensystems.com, cota@braap.org, qemu-devel@nongnu.org, mark.burton@greensocs.com, pbonzini@redhat.com, jan.kiszka@siemens.com, rth@twiddle.net, peter.maydell@linaro.org, claudio.fontana@huawei.com, Peter Crosthwaite , "Michael S. Tsirkin" , Eduardo Habkost On 01/06/16 13:30, Alex Bennée wrote: > Sergey Fedorov writes: > >> On 05/04/16 18:32, Alex Bennée wrote: >> (snip) >>> diff --git a/exec.c b/exec.c >>> index 17f390e..c46c123 100644 >>> --- a/exec.c >>> +++ b/exec.c >>> @@ -2111,6 +2111,9 @@ static void check_watchpoint(int offset, int len, MemTxAttrs attrs, int flags) >>> continue; >>> } >>> cpu->watchpoint_hit = wp; >>> + >>> + /* Unlocked by cpu_loop_exit or cpu_resume_from_signal. */ >> In fact, neither cpu_resume_from_signal() nor cpu_loop_exit() unlocks >> the lock by itself, it gets unlocked after sigsetjmp() returns via >> siglongjmp() back to cpu_exec(). So maybe it would be more clear to say >> something like "'tb_lock' gets unlocked after siglongjmp()"? > > "Locks are reset when we longjmp back to the main cpu_exec loop"? Yes, it this looks fine. > Looking at where the patch is though I think I need to bring that bit > forward from the main series. > >>> + tb_lock(); >>> tb_check_watchpoint(cpu); >>> if (wp->flags & BP_STOP_BEFORE_ACCESS) { >>> cpu->exception_index = EXCP_DEBUG; >> (snip) >>> diff --git a/translate-all.c b/translate-all.c >>> index a7ff5e7..935d24c 100644 >>> --- a/translate-all.c >>> +++ b/translate-all.c >>> @@ -834,7 +834,9 @@ static void page_flush_tb(void) >>> } >>> >>> /* flush all the translation blocks */ >>> -/* XXX: tb_flush is currently not thread safe */ >>> +/* XXX: tb_flush is currently not thread safe. System emulation calls it only >>> + * with tb_lock taken or from safe_work, so no need to take tb_lock here. >>> + */ >> "System emulation"? What about user-mode emulation? > It's still not thread safe ;-) > > It's a harder problem to solve because we can't just suspend all > threads to reset the translation buffer. I'm not sure we want to try and > fix it in this series. I think it could be possible to do something like start_exclusive() to achieve this in user-only emulation. >>> void tb_flush(CPUState *cpu) >>> { >>> #if defined(DEBUG_FLUSH) Kind regards, Sergey