From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZQAW2-0000wi-G0 for qemu-devel@nongnu.org; Fri, 14 Aug 2015 04:39:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZQAVw-00069h-RH for qemu-devel@nongnu.org; Fri, 14 Aug 2015 04:39:06 -0400 Received: from greensocs.com ([193.104.36.180]:43476) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZQAVw-00069D-D4 for qemu-devel@nongnu.org; Fri, 14 Aug 2015 04:39:00 -0400 Message-ID: <55CDA920.7060204@greensocs.com> Date: Fri, 14 Aug 2015 10:38:56 +0200 From: Frederic Konrad MIME-Version: 1.0 References: <1439220437-23957-1-git-send-email-fred.konrad@greensocs.com> <1439220437-23957-8-git-send-email-fred.konrad@greensocs.com> <55CB862E.2090507@greensocs.com> <87zj1wfjx0.fsf@linaro.org> In-Reply-To: <87zj1wfjx0.fsf@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC PATCH V7 07/19] protect TBContext with tb_lock. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?QWxleCBCZW5uw6ll?= Cc: mttcg@listserver.greensocs.com, mark.burton@greensocs.com, qemu-devel@nongnu.org, a.rigo@virtualopensystems.com, guillaume.delbergue@greensocs.com, pbonzini@redhat.com On 12/08/2015 20:20, Alex Benn=C3=A9e wrote: > Frederic Konrad writes: > >> On 10/08/2015 17:27, fred.konrad@greensocs.com wrote: >>> From: KONRAD Frederic >>> >>> This protects TBContext with tb_lock to make tb_* thread safe. >>> >>> We can still have issue with tb_flush in case of multithread TCG: >>> An other CPU can be executing code during a flush. >>> >>> This can be fixed later by making all other TCG thread exiting before= calling >>> tb_flush(). >>> >>> tb_find_slow is separated into tb_find_slow and tb_find_physical as t= he whole >>> tb_find_slow doesn't require to lock the tb. >>> >>> Signed-off-by: KONRAD Frederic >>> >>> Changes: >> [...] >>> =20 >>> @@ -675,6 +710,7 @@ static inline void code_gen_alloc(size_t tb_size) >>> CODE_GEN_AVG_BLOCK_SIZE; >>> tcg_ctx.tb_ctx.tbs =3D >>> g_malloc(tcg_ctx.code_gen_max_blocks * sizeof(Translat= ionBlock)); >>> + qemu_mutex_init(&tcg_ctx.tb_ctx.tb_lock); >>> } >>> =20 >>> /* Must be called before using the QEMU cpus. 'tb_size' is the siz= e >>> @@ -699,16 +735,22 @@ bool tcg_enabled(void) >>> return tcg_ctx.code_gen_buffer !=3D NULL; >>> } >>> =20 >>> -/* Allocate a new translation block. Flush the translation buffer if >>> - too many translation blocks or too much generated code. */ >>> +/* >>> + * Allocate a new translation block. Flush the translation buffer if >>> + * too many translation blocks or too much generated code. >>> + * tb_alloc is not thread safe but tb_gen_code is protected by a mut= ex so this >>> + * function is called only by one thread. >>> + */ >>> static TranslationBlock *tb_alloc(target_ulong pc) >>> { >>> - TranslationBlock *tb; >>> + TranslationBlock *tb =3D NULL; >>> =20 >>> if (tcg_ctx.tb_ctx.nb_tbs >=3D tcg_ctx.code_gen_max_blocks || >>> (tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer) >=3D >>> tcg_ctx.code_gen_buffer_max_size) { >>> - return NULL; >>> + tb =3D &tcg_ctx.tb_ctx.tbs[tcg_ctx.tb_ctx.nb_tbs++]; >>> + tb->pc =3D pc; >>> + tb->cflags =3D 0; >> Missed this wrong unreverted part which in the end doesn't do a tb_flu= sh >> when required and crashes! >> Fixing that allows me to boot with jessie and virt. > \o/ > > Do you see crashes while it is running? > > It's interesting that I've not had a problem booting jessie with virt > though - just crashes while hanging. > > Are you likely to push a v8 this week (or a temp branch?) with this and > any other obvious fixes? I appreciate Paolo has given you a not-so-smal= l > pile of review comments as well so I wasn't looking for a complete new > patch set! here is something I did yesterday: multi_tcg_v7_bugfixed The patch-set is a mess and not re-based on the patch-set sent by Paolo. Fred > >> Fred