From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41209) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cC8Bi-0006pT-HF for qemu-devel@nongnu.org; Wed, 30 Nov 2016 11:56:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cC8Be-0005g3-Ih for qemu-devel@nongnu.org; Wed, 30 Nov 2016 11:56:54 -0500 Received: from mail-wj0-f169.google.com ([209.85.210.169]:34263) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cC8Be-0005fb-Bq for qemu-devel@nongnu.org; Wed, 30 Nov 2016 11:56:50 -0500 Received: by mail-wj0-f169.google.com with SMTP id mp19so181243657wjc.1 for ; Wed, 30 Nov 2016 08:56:49 -0800 (PST) References: <87twapmozq.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: <87twapmozq.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me> Date: Wed, 30 Nov 2016 16:55:47 +0000 Message-ID: <871sxsucto.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] Confusion regarding temporaries with branch conditional List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Nikunj A Dadhania Cc: rth@twiddle.net, qemu-devel@nongnu.org Nikunj A Dadhania writes: > Hi, > > I was writing one instruction and hit following issue: > > [snip]/qemu/tcg/tcg.c:2039: tcg fatal error > qemu-ppc64le: [snip]/qemu/translate-all.c:175: tb_lock: Assertion `!have_tb_lock' failed. > Segmentation fault (core dumped) This is confusing because something is trying to take the tb_lock while you are in code generation. tb_lock is held for code generation to ensure serialisation of generation. > > Debugging deeper found that its something to do with the variable type: > > TCGv nb = tcg_temp_new(); > tcg_gen_andi_tl(nb, cpu_gpr[rB(ctx->opcode)], 0xFF); > tcg_gen_brcondi_tl(TCG_COND_EQ, nb, 0, l1); > [ Do something here] > gen_set_label(l1); > tcg_temp_free(nb); > > If I change the variable as "local temporary", the code works fine: > > TCGv nb = tcg_temp_local_new(); > tcg_gen_andi_tl(nb, cpu_gpr[rB(ctx->opcode)], 0xFF); > tcg_gen_brcondi_tl(TCG_COND_EQ, nb, 0, l1); > [ Do something here] > gen_set_label(l1); > tcg_temp_free(nb); > > I see lot of code that is using temporaries for similar operations, > example target-ppc/translate.c:gen_check_align(). How is that working, > is this a bug there as well? Well that is odd. Are you sure there is no side effect that is attempting to modify run state during generation? I'm thinking of changing memory maps or other such stuff. A back trace at the assert would make things clearer. > > Regards, > Nikunj -- Alex Bennée